:root {
    --bg: #eef2f7;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --text: #172033;
    --muted: #65748b;
    --line: #d9e2ec;
    --primary: #1668dc;
    --primary-dark: #0f4fa7;
    --success: #15945f;
    --warning: #b76e00;
    --danger: #b42318;
    --sidebar: #132238;
    --sidebar-soft: #1b304d;
    --sidebar-text: #dce7f5;
    --sidebar-width: 240px;
    --sidebar-collapsed-width: 78px;
    --shadow: 0 18px 45px rgba(20, 32, 51, .10);
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--text);
    background: var(--bg);
}

a {
    color: inherit;
}

.xpdc-shell {
    min-height: 100vh;
    display: flex;
}

.xpdc-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: var(--sidebar-width);
    color: var(--sidebar-text);
    background: var(--sidebar);
    padding: 18px 14px;
    transition: width .22s ease, transform .22s ease;
    overflow-x: hidden;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 54px;
    padding: 8px 8px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .10);
}

.brand-logo {
    display: block;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    object-fit: contain;
    border-radius: 8px;
    background: #fff;
    padding: 4px;
}

.brand-copy {
    min-width: 0;
}

.brand-copy strong,
.brand-copy span {
    display: block;
    white-space: nowrap;
}

.brand-copy span {
    margin-top: 2px;
    color: #a9bad0;
    font-size: 12px;
}

.sidebar-nav {
    display: grid;
    gap: 8px;
    margin-top: 18px;
}

.nav-section,
.nav-link {
    width: 100%;
    border: 0;
    border-radius: 8px;
    color: var(--sidebar-text);
    background: transparent;
    text-decoration: none;
    font: inherit;
    outline: 0;
}

.nav-section {
    display: grid;
    grid-template-columns: 30px 1fr 22px;
    align-items: center;
    gap: 8px;
    padding: 11px 10px;
    cursor: pointer;
    text-align: left;
}

.nav-section:hover,
.nav-section.is-open,
.nav-section:focus-visible,
.nav-link:focus-visible {
    background: var(--sidebar-soft);
}

.nav-icon {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 7px;
    background: rgba(255, 255, 255, .12);
    font-weight: 700;
}

.nav-icon svg,
.nav-link-icon svg {
    display: block;
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.nav-label {
    line-height: 1.25;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-chevron {
    justify-self: end;
    font-size: 22px;
    transition: transform .18s ease;
}

.nav-section.is-open .nav-chevron {
    transform: rotate(90deg);
}

.nav-items {
    display: grid;
    gap: 4px;
    max-height: 0;
    overflow: hidden;
    padding-left: 38px;
    transition: max-height .22s ease;
}

.nav-items.is-open {
    max-height: 360px;
    padding-bottom: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    color: #bfd0e5;
    font-size: 14px;
}

.nav-link-icon {
    display: inline-grid;
    place-items: center;
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
}

.nav-link:hover,
.nav-link.is-active {
    color: #fff;
    background: rgba(255, 255, 255, .12);
}

.nav-logout {
    margin-top: 12px;
    color: #ffd7d7;
}

.xpdc-main {
    width: 100%;
    min-width: 0;
    margin-left: var(--sidebar-width);
    transition: margin-left .22s ease;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 84px;
    padding: 16px 28px;
    background: rgba(238, 242, 247, .92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(217, 226, 236, .85);
}

.topbar h1 {
    margin: 2px 0 0;
    font-size: 24px;
    line-height: 1.2;
}

.eyebrow,
.page-subtitle {
    margin: 0;
    color: var(--muted);
}

.eyebrow {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.page-subtitle {
    margin-top: 4px;
    font-size: 14px;
}

.icon-button {
    display: inline-grid;
    gap: 4px;
    place-content: center;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    cursor: pointer;
}

.icon-button span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text);
}

.content-area {
    padding: 24px 28px 42px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat-card,
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.stat-card {
    padding: 16px;
}

.stat-label {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 13px;
}

.stat-value {
    margin: 0;
    font-size: 26px;
    font-weight: 800;
}

.panel {
    padding: 20px;
}

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.compact-header {
    margin-bottom: 10px;
}

.panel-title {
    margin: 0;
    font-size: 18px;
}

.panel-note {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.field {
    display: grid;
    gap: 7px;
}

.field.full {
    grid-column: 1 / -1;
}

label {
    color: #314158;
    font-size: 13px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text);
    background: #fff;
    font-size: 15px;
}

textarea {
    min-height: 92px;
    resize: vertical;
    font-family: inherit;
    line-height: 1.45;
}

input[readonly] {
    background: var(--panel-soft);
    color: #47566b;
}

.check-line {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
}

.check-line input {
    width: 18px;
    min-height: 18px;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 9px 14px;
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;
    cursor: pointer;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-warning {
    background: var(--warning);
    color: #fff;
}

.btn-muted {
    background: #e7edf4;
    color: #26364c;
}

.btn-outline {
    border-color: var(--line);
    background: #fff;
    color: var(--text);
}

.filter-bar {
    display: grid;
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    gap: 12px;
    align-items: end;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 12px;
    text-align: left;
    vertical-align: middle;
}

th {
    background: #edf4fb;
    color: #314158;
    font-size: 13px;
}

td {
    font-size: 14px;
}

tr:last-child td {
    border-bottom: 0;
}

.table-actions {
    display: flex;
    gap: 8px;
    white-space: nowrap;
}

.inline-status-form {
    margin: 0;
}

.inline-status-form select {
    min-width: 150px;
    min-height: 34px;
    padding: 6px 9px;
}

.claim-items {
    display: grid;
    gap: 8px;
}

.claim-item-row {
    display: grid;
    grid-template-columns: minmax(130px, .8fr) minmax(220px, 1.6fr) minmax(90px, .45fr) auto;
    gap: 8px;
    align-items: center;
}

.claim-item-row .btn {
    min-height: 38px;
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 9px;
    background: #e8f3ff;
    color: #0f4fa7;
    font-size: 12px;
    font-weight: 700;
}

.badge-warning {
    background: #fff4df;
    color: #8a5200;
}

.badge-success {
    background: #e7f7ef;
    color: #0f6c43;
}

.alert {
    margin-bottom: 14px;
    border-radius: 8px;
    padding: 11px 12px;
    background: #fff1f0;
    color: var(--danger);
    font-size: 14px;
}

.notice-success {
    margin-bottom: 14px;
    border-radius: 8px;
    padding: 11px 12px;
    background: #e7f7ef;
    color: #0f6c43;
    font-size: 14px;
}

.photo-preview {
    display: none;
    width: 100%;
    max-height: 220px;
    border: 1px solid var(--line);
    border-radius: 8px;
    object-fit: cover;
    background: var(--panel-soft);
}

.photo-preview.is-visible {
    display: block;
}

.activity-report-table {
    min-width: 1500px;
}

.muted-cell {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.activity-photo-link {
    display: grid;
    gap: 4px;
    width: 88px;
    margin-bottom: 8px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
}

.activity-photo-link img {
    width: 88px;
    height: 62px;
    border: 1px solid var(--line);
    border-radius: 8px;
    object-fit: cover;
    background: var(--panel-soft);
}

.lookup-info {
    min-height: 22px;
    margin-top: 12px;
    color: var(--muted);
    font-size: 14px;
}

.lookup-info.is-ok {
    color: var(--success);
}

.lookup-info.is-warn {
    color: var(--danger);
}

.bakery-panel {
    max-width: 760px;
}

.bakery-form-grid {
    grid-template-columns: minmax(0, 1.5fr) minmax(120px, .7fr);
}

.bakery-report-page {
    margin: -18px -12px 0;
}

.po-report-page {
    margin: -18px -12px 0;
}

.bakery-report-page .panel {
    padding: 18px 24px;
}

.po-report-page .panel {
    padding: 16px 22px;
}

.bakery-report-page .filter-bar {
    grid-template-columns: repeat(5, minmax(150px, 1fr));
}

.po-report-page .filter-bar {
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    align-items: start;
}

.po-filter-actions {
    grid-column: 1 / -1;
    margin-top: 0;
    align-items: center;
}

.po-filter-actions .btn {
    min-width: 86px;
}

.bakery-report-page table {
    min-width: 1100px;
}

.po-report-page table {
    min-width: 980px;
}

.bakery-report-page th,
.bakery-report-page td {
    padding: 14px 16px;
}

.po-report-page th,
.po-report-page td {
    padding: 14px 16px;
}

.warehouse-print-header,
.warehouse-print-filters,
.print-status-text {
    display: none;
}

.warehouse-sj-report-table td:nth-child(4),
.warehouse-sj-report-table td:nth-child(5),
.warehouse-sj-report-table td:nth-child(6),
.warehouse-sj-report-table td:nth-child(10) {
    text-align: right;
}

.qty-edit-form {
    margin: 0;
}

.qty-edit-input {
    width: 88px;
    min-height: 36px;
    padding: 7px 9px;
    text-align: right;
}

#ui-datepicker-div,
.ui-datepicker {
    z-index: 1000 !important;
    width: 306px;
    padding: 10px;
    border: 1px solid var(--line) !important;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 24px 60px rgba(20, 32, 51, .18);
    font-family: Arial, Helvetica, sans-serif;
}

.ui-datepicker .ui-datepicker-header {
    display: grid;
    grid-template-columns: 34px 1fr 34px;
    align-items: center;
    min-height: 42px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: var(--panel-soft);
}

.ui-datepicker .ui-datepicker-title {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin: 0 38px;
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
}

.ui-datepicker .ui-datepicker-title select {
    min-height: 34px;
    padding: 6px 24px 6px 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    background: #fff;
    font: inherit;
    outline: none;
}

.ui-datepicker .ui-datepicker-prev,
.ui-datepicker .ui-datepicker-next {
    top: 5px;
    width: 32px;
    height: 32px;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
}

.ui-datepicker .ui-datepicker-prev {
    left: 6px;
}

.ui-datepicker .ui-datepicker-next {
    right: 6px;
}

.ui-datepicker .ui-datepicker-prev:hover,
.ui-datepicker .ui-datepicker-next:hover {
    border-color: var(--line);
    background: #fff;
}

.ui-datepicker .ui-datepicker-prev span,
.ui-datepicker .ui-datepicker-next span {
    display: none;
}

.ui-datepicker .ui-datepicker-prev::before,
.ui-datepicker .ui-datepicker-next::before {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--text);
    font-size: 22px;
    line-height: 1;
}

.ui-datepicker .ui-datepicker-prev::before {
    content: "<";
}

.ui-datepicker .ui-datepicker-next::before {
    content: ">";
}

.ui-datepicker table {
    width: 100%;
    margin: 10px 0 0;
    border-collapse: separate;
    border-spacing: 3px;
    table-layout: fixed;
    font-size: 13px;
}

.ui-datepicker th {
    padding: 6px 0;
    border: 0;
    color: var(--muted);
    background: transparent;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.ui-datepicker td {
    padding: 0;
    border: 0;
    background: transparent;
}

.ui-datepicker td span,
.ui-datepicker td a {
    display: grid;
    place-items: center;
    width: 100%;
    min-height: 34px;
    padding: 0;
    border: 1px solid transparent !important;
    border-radius: 8px;
    color: var(--text) !important;
    background: transparent !important;
    text-align: center;
    text-decoration: none;
}

.ui-datepicker .ui-datepicker-other-month a,
.ui-datepicker .ui-datepicker-other-month span {
    color: #a7b2c2 !important;
}

.ui-datepicker td a:hover {
    border-color: #b9cff1 !important;
    background: #edf5ff !important;
    color: var(--primary-dark) !important;
}

.ui-datepicker .ui-datepicker-today a,
.ui-datepicker .ui-datepicker-today span {
    border-color: rgba(22, 104, 220, .35) !important;
    background: #edf5ff !important;
    color: var(--primary-dark) !important;
    font-weight: 700;
}

.ui-datepicker .ui-datepicker-current-day a {
    border-color: var(--primary) !important;
    background: var(--primary) !important;
    color: #fff !important;
    font-weight: 700;
}

.ui-datepicker .ui-datepicker-buttonpane {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin: 10px 0 0;
    padding: 10px 0 0;
    border: 0;
    border-top: 1px solid var(--line);
    background: transparent;
}

.ui-datepicker .ui-datepicker-buttonpane button {
    min-height: 34px;
    margin: 0;
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    background: #fff;
    font-weight: 700;
    opacity: 1;
    cursor: pointer;
}

.ui-datepicker .ui-datepicker-buttonpane button:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #edf5ff;
}

body.sidebar-collapsed .xpdc-sidebar {
    width: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .xpdc-main {
    margin-left: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .brand-copy,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .nav-chevron,
body.sidebar-collapsed .nav-items {
    display: none;
}

body.sidebar-collapsed .nav-section {
    grid-template-columns: 1fr;
    justify-items: center;
}

@media (max-width: 980px) {
    .xpdc-sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }

    .xpdc-main {
        margin-left: 0;
    }

    body.sidebar-collapsed .xpdc-sidebar {
        width: var(--sidebar-width);
    }

    body.sidebar-collapsed .xpdc-main {
        margin-left: 0;
    }

    body.sidebar-collapsed .brand-copy,
    body.sidebar-collapsed .nav-label,
    body.sidebar-collapsed .nav-chevron {
        display: block;
    }

    body.sidebar-collapsed .nav-items {
        display: grid;
    }

    body.sidebar-open .xpdc-sidebar {
        transform: translateX(0);
    }

    .xpdc-overlay {
        position: fixed;
        inset: 0;
        z-index: 25;
        display: none;
        background: rgba(12, 20, 33, .45);
    }

    body.sidebar-open .xpdc-overlay {
        display: block;
    }

    .dashboard-grid,
    .filter-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .topbar,
    .content-area {
        padding-left: 16px;
        padding-right: 16px;
    }

    .topbar h1 {
        font-size: 20px;
    }

    .dashboard-grid,
    .form-grid,
    .filter-bar,
    .claim-item-row {
        grid-template-columns: 1fr;
    }

    .panel {
        padding: 16px;
    }

    .bakery-panel {
        max-width: none;
    }

    .bakery-report-page {
        margin: 0;
    }

    .po-report-page {
        margin: 0;
    }

    .bakery-report-page .panel {
        padding: 16px;
    }

    .po-report-page .panel {
        padding: 16px;
    }

    .bakery-table {
        border: 0;
        background: transparent;
    }

    .bakery-table table,
    .bakery-table thead,
    .bakery-table tbody,
    .bakery-table th,
    .bakery-table td,
    .bakery-table tr {
        display: block;
        min-width: 0;
    }

    .bakery-table thead {
        display: none;
    }

    .bakery-table tr {
        margin-bottom: 12px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #fff;
        overflow: hidden;
    }

    .bakery-table td {
        display: grid;
        grid-template-columns: 96px 1fr;
        gap: 10px;
        border-bottom: 1px solid var(--line);
        padding: 10px 12px;
        text-align: left;
        word-break: break-word;
    }

    .bakery-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 12px;
        font-weight: 700;
    }

    .bakery-table td:last-child {
        border-bottom: 0;
    }

    .qty-edit-input {
        width: 100%;
        max-width: 150px;
    }
}

@media print {
    @page {
        size: A4 landscape;
        margin: 9mm;
    }

    * {
        box-shadow: none !important;
        text-shadow: none !important;
    }

    html,
    body {
        width: 297mm;
        min-height: 210mm;
        margin: 0;
        background: #fff !important;
        color: #111827 !important;
        font-size: 10px;
    }

    .xpdc-sidebar,
    .xpdc-overlay,
    .topbar,
    .po-report-page > .panel:first-child,
    .panel-note,
    .inline-status-form,
    script {
        display: none !important;
    }

    .xpdc-shell,
    .xpdc-main,
    .content-area,
    .po-report-page {
        display: block !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
    }

    .po-report-page .panel {
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        background: #fff !important;
    }

    .panel-header {
        margin-bottom: 7px;
        padding-bottom: 6px;
        border-bottom: 1px solid #cbd5e1;
    }

    .panel-title {
        margin: 0;
        color: #111827 !important;
        font-size: 14px;
        line-height: 1.2;
    }

    .warehouse-print-header {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 14px;
        margin-bottom: 8px;
        padding-bottom: 8px;
        border-bottom: 2px solid #111827;
    }

    .warehouse-print-header h2 {
        margin: 1px 0 3px;
        color: #111827;
        font-size: 18px;
        line-height: 1.15;
    }

    .warehouse-print-header p {
        margin: 0;
        color: #475569;
        font-size: 10px;
    }

    .warehouse-print-kicker {
        color: #0f766e !important;
        font-weight: 700;
        letter-spacing: .06em;
        text-transform: uppercase;
    }

    .warehouse-print-summary {
        display: grid;
        grid-template-columns: repeat(2, minmax(90px, 1fr));
        gap: 5px 10px;
        min-width: 250px;
        color: #111827;
        font-size: 10px;
        text-align: right;
    }

    .warehouse-print-filters {
        display: flex;
        flex-wrap: wrap;
        gap: 5px 14px;
        margin-bottom: 8px;
        padding-bottom: 7px;
        border-bottom: 1px solid #d1d5db;
        color: #334155;
        font-size: 9.5px;
    }

    .table-wrap {
        overflow: visible !important;
        border: 0 !important;
        background: #fff !important;
    }

    .po-report-page table,
    .warehouse-sj-report-table {
        width: 100% !important;
        min-width: 0 !important;
        border-collapse: collapse !important;
        table-layout: fixed;
        background: #fff !important;
    }

    .warehouse-sj-report-table th,
    .warehouse-sj-report-table td {
        padding: 4px 5px !important;
        border: 1px solid #cbd5e1 !important;
        color: #111827 !important;
        font-size: 8.5px;
        line-height: 1.25;
        vertical-align: top;
        word-break: break-word;
    }

    .warehouse-sj-report-table th {
        background: #e5e7eb !important;
        font-size: 8px;
        font-weight: 700;
        text-align: center;
        text-transform: uppercase;
    }

    .warehouse-sj-report-table th:nth-child(1) { width: 8%; }
    .warehouse-sj-report-table th:nth-child(2) { width: 12%; }
    .warehouse-sj-report-table th:nth-child(3) { width: 8%; }
    .warehouse-sj-report-table th:nth-child(4),
    .warehouse-sj-report-table th:nth-child(5),
    .warehouse-sj-report-table th:nth-child(6) { width: 6%; }
    .warehouse-sj-report-table th:nth-child(7) { width: 6%; }
    .warehouse-sj-report-table th:nth-child(8) { width: 10%; }
    .warehouse-sj-report-table th:nth-child(9) { width: 22%; }
    .warehouse-sj-report-table th:nth-child(10) { width: 6%; }
    .warehouse-sj-report-table th:nth-child(11) { width: 10%; }

    .badge {
        display: inline-block;
        min-width: 38px;
        border: 1px solid #94a3b8 !important;
        background: #fff !important;
        color: #111827 !important;
        text-align: center;
    }

    .print-status-text {
        display: inline !important;
        font-weight: 700;
    }

    thead {
        display: table-header-group;
    }

    tr,
    td,
    th {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}
