/* ============================================================
   Boland PVC — Order Management System
   Matches Figma design
   ============================================================ */

:root {
    --brand-blue:      #1B6CB5;
    --brand-blue-dk:   #135096;
    --brand-blue-lt:   #e8f1fb;
    --sidebar-bg:      #ffffff;
    --sidebar-border:  #e5e7eb;
    --sidebar-width:   210px;
    --stat-received:   #1B6CB5;
    --stat-picked:     #9ca3af;
    --stat-packed:     #22c0d3;
    --stat-shipped:    #8faa5b;
    --stat-delivered:  #b5c98a;
    --page-bg:         #f4f6f9;
}

/* ---- Reset / Base ---- */
* { box-sizing: border-box; }
body { margin: 0; background: var(--page-bg); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }

/* ---- App shell ---- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.app-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 20px 16px 16px;
    border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-logo-img {
    width: 100%;
    max-width: 160px;
    height: auto;
    display: block;
}

.sidebar-nav {
    list-style: none;
    padding: 12px 8px;
    margin: 0;
    flex: 1;
}
.sidebar-nav li { margin: 2px 0; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #374151;
    text-decoration: none;
    transition: background 0.12s, color 0.12s;
    cursor: pointer;
}
.sidebar-link i { font-size: 1rem; flex-shrink: 0; }
.sidebar-link:hover { background: var(--brand-blue-lt); color: var(--brand-blue); }
.sidebar-link.active { background: var(--brand-blue); color: #fff; }

.sidebar-group { margin-top: 4px; }
.sidebar-group-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    font-size: 0.9rem;
    color: #374151;
    font-weight: 500;
}
.sidebar-group-label i { font-size: 1rem; }
.sidebar-chevron {
    margin-left: auto; font-size: 0.7rem; color: #9ca3af;
    transition: transform 0.2s;
}
.sidebar-group.open .sidebar-chevron { transform: rotate(90deg); }

.sidebar-sub {
    list-style: none;
    padding: 0 0 0 8px;
    margin: 0;
    display: none;
}
.sidebar-group.open .sidebar-sub { display: block; }
.sidebar-sub-link {
    font-size: 0.85rem;
    padding: 7px 12px;
    color: #6b7280;
}
.sidebar-sub-link:hover, .sidebar-sub-link.active { color: var(--brand-blue); background: var(--brand-blue-lt); }

.sidebar-footer {
    padding: 12px 8px;
    border-top: 1px solid var(--sidebar-border);
}
.sidebar-logout { color: #6b7280 !important; font-size: 0.9rem; }
.sidebar-logout:hover { background: #fee2e2; color: #dc2626 !important; }

/* ---- Version / Changelog ---- */
.sidebar-version { margin-bottom: 8px; position: relative; }
.sidebar-version-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px; border-radius: 12px;
    background: var(--brand-blue-lt, #e7f1ff); color: var(--brand-blue, #0d6efd);
    font-size: 0.78rem; font-weight: 600; cursor: pointer;
    transition: background 0.15s;
}
.sidebar-version-badge:hover { background: #cfe2ff; }
.sidebar-version-badge i { font-size: 0.72rem; }
.sidebar-changelog-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4); z-index: 1099;
}
.sidebar-changelog {
    display: none; position: fixed; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 520px; max-width: 90vw; max-height: 70vh; background: #fff;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3); z-index: 1100;
    overflow: hidden;
}
.sidebar-changelog-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px; border-bottom: 1px solid #eee;
    font-weight: 700; font-size: 1rem; color: #1f2937;
}
.sidebar-changelog-header .btn-close { font-size: 0.7rem; }
.sidebar-changelog-body {
    overflow-y: auto; max-height: calc(70vh - 56px); padding: 12px 0;
}
.changelog-release { padding: 12px 20px; border-bottom: 1px solid #f3f4f6; }
.changelog-release:last-child { border-bottom: none; }
.changelog-latest { background: #f0fdf4; }
.changelog-release-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 6px;
}
.changelog-release-header strong { font-size: 0.92rem; color: #1f2937; }
.changelog-date { font-size: 0.78rem; color: #9ca3af; white-space: nowrap; }
.changelog-items {
    margin: 0; padding-left: 18px; list-style: disc;
}
.changelog-items li { font-size: 0.82rem; color: #4b5563; line-height: 1.6; }

/* ---- Main area ---- */
.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.app-main main {
    flex: 1;
    padding: 28px 32px;
}

/* ---- Page header ---- */
.page-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
}
.page-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #111827;
    margin: 0;
}
.page-header i { font-size: 1.4rem; color: #6b7280; }

/* ---- Status stat cards ---- */
.stat-cards {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.stat-card {
    flex: 1;
    min-width: 120px;
    border-radius: 10px;
    padding: 18px 20px;
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}
.stat-card-received  { background: var(--stat-received); }
.stat-card-picked    { background: var(--stat-picked); }
.stat-card-packed    { background: var(--stat-packed); }
.stat-card-shipped   { background: var(--stat-shipped); }
.stat-card-delivered { background: var(--stat-delivered); }

.stat-card-count { font-size: 1.5rem; font-weight: 700; line-height: 1; }
.stat-card-label { font-size: 0.8rem; margin-top: 4px; opacity: 0.9; }
.stat-card-icon  { font-size: 1.4rem; opacity: 0.6; }

/* ---- Filter bar ---- */
.filter-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.filter-bar .form-control,
.filter-bar .form-select {
    font-size: 0.875rem;
}
.filter-bar .btn-icon {
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    cursor: pointer;
    flex-shrink: 0;
}
.filter-bar .btn-icon:hover { background: var(--brand-blue-lt); border-color: var(--brand-blue); color: var(--brand-blue); }
.filter-bar .ms-auto { margin-left: auto !important; }

/* ---- Order group sections ---- */
.order-group { margin-bottom: 20px; }
.order-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.order-group-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #111827;
}
.order-group-actions { display: flex; gap: 6px; }

/* ---- Orders table ---- */
.orders-table {
    width: 100%;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
}
.orders-table th {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    font-weight: 600;
    padding: 12px 16px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}
.sortable-th { cursor: pointer; user-select: none; transition: color 0.15s; }
.sortable-th:hover { color: var(--brand-blue); }
.sortable-th.active-sort { color: var(--brand-blue); }
.sort-icon { font-size: 0.68rem; margin-left: 4px; opacity: 0.4; }
.sortable-th:hover .sort-icon { opacity: 0.7; }
.sortable-th.active-sort .sort-icon { opacity: 1; }
.orders-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.9rem;
    color: #374151;
    vertical-align: middle;
}
.orders-table tr:last-child td { border-bottom: none; }
.orders-table tbody tr:hover { background: #f9fafb; cursor: pointer; }

.order-expand-btn {
    background: none;
    border: none;
    padding: 0 4px;
    color: #9ca3af;
    cursor: pointer;
    font-size: 0.9rem;
    transition: transform 0.15s;
}
.order-expand-btn.expanded { transform: rotate(90deg); }

.order-number { font-weight: 600; color: #111827; }
.order-customer-name { color: var(--brand-blue); font-weight: 500; }
.order-date { color: #6b7280; font-size: 0.85rem; }
.order-contact { color: #374151; font-size: 0.85rem; }

/* Expandable detail row */
.order-detail-row { display: none; }
.order-detail-row.open { display: table-row; }
.order-detail-cell {
    padding: 0 16px 16px 40px !important;
    background: #f9fafb;
}
.order-detail-inner {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 12px 16px;
}

/* ---- Status badges ---- */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
}
.status-Received  { background: #dbeafe; color: #1e40af; }
.status-Confirmed { background: #cffafe; color: #0e7490; }
.status-Picked    { background: #f3f4f6; color: #374151; }
.status-Packed    { background: #e0f2fe; color: #0369a1; }
.status-Shipped   { background: #d1fae5; color: #065f46; }
.status-Delivered { background: #dcfce7; color: #166534; }

/* ---- Cards ---- */
.card { border: 1px solid #e5e7eb; border-radius: 8px; }

/* ---- Buttons ---- */
.btn-primary { background: var(--brand-blue); border-color: var(--brand-blue); }
.btn-primary:hover, .btn-primary:focus { background: var(--brand-blue-dk); border-color: var(--brand-blue-dk); }
.btn-outline-primary { color: var(--brand-blue); border-color: var(--brand-blue); }
.btn-outline-primary:hover { background: var(--brand-blue); color: #fff; }

/* ---- Tables (general) ---- */
.table th {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    font-weight: 600;
    border-top: none;
}
.table tbody tr:hover { background-color: var(--brand-blue-lt); }

/* ---- Modals ---- */
.modal-header { border-bottom: 1px solid #e5e7eb; }
.modal-footer { border-top: 1px solid #e5e7eb; }

/* ---- Forms ---- */
.form-label { font-size: 0.85rem; color: #374151; margin-bottom: 4px; }
.form-control:focus, .form-select:focus {
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 0.2rem rgba(27,108,181,0.15);
}

/* ---- Picking slip print ---- */
@media print {
    .no-print, .app-sidebar, nav { display: none !important; }
    body { background: #fff; }
}

/* ---- Portal navbar ---- */
.portal-navbar { background: var(--brand-blue); padding: 12px 0; }

/* ---- Empty state ---- */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: #9ca3af;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}
.empty-state i { font-size: 2.5rem; display: block; margin-bottom: 12px; }
.empty-state p { margin: 0; font-size: 0.95rem; }

/* ---- Pricing toolbar ---- */
.pricing-toolbar {
    margin-bottom: 12px;
    padding: 10px 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}

/* ---- Pricing bulk update panel ---- */
.pricing-bulk-panel {
    margin-bottom: 12px;
    padding: 10px 12px;
    background: #fff8e1;
    border: 1px solid #fbbf24;
    border-radius: 6px;
}

/* ---- PO Upload / Import wizard ---- */
.po-upload-zone {
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    color: #9ca3af;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.po-upload-zone:hover,
.po-upload-zone.dragover {
    border-color: var(--brand-blue);
    background: var(--brand-blue-lt);
}
.po-upload-zone i { font-size: 2rem; display: block; margin-bottom: 8px; }

.import-step { display: none; }
.import-step.active { display: block; }

.import-line-unmatched { background: #fffbea; }
.import-match-warning { color: #d97706; font-size: 0.8rem; }

/* ---- OMNI Export badge ---- */
.export-badge { font-size: 0.7rem; vertical-align: middle; }

/* ============================================================
   Orders Page — Teal Theme & Card Layout
   ============================================================ */

:root {
    --brand-teal:     #0d9488;
    --brand-teal-dk:  #0f766e;
    --brand-teal-lt:  #ccfbf1;
    --brand-teal-bg:  #f0fdfa;
}

/* ---- Dashboard / Orders page header ---- */
.orders-page-header {
    background: linear-gradient(135deg, #1a5276 0%, #154360 100%);
    border-radius: 10px;
    padding: 20px 28px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.orders-page-header h1 {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin: 0;
    color: #fff;
}
.orders-page-header .btn { color: #fff; border-color: rgba(255,255,255,0.5); }
.orders-page-header .btn:hover { background: rgba(255,255,255,0.15); border-color: #fff; }

/* ---- Order cards ---- */
.order-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-left: 4px solid var(--brand-teal);
    border-radius: 8px;
    margin-bottom: 10px;
    transition: box-shadow 0.15s, border-color 0.15s;
    overflow: hidden;
}
.order-card:hover {
    box-shadow: 0 2px 12px rgba(13,148,136,0.10);
    border-left-color: var(--brand-teal-dk);
}
.order-card.expanded {
    border-left-color: var(--brand-teal-dk);
    box-shadow: 0 4px 20px rgba(13,148,136,0.12);
}
.order-card.status-Received  { border-left-color: #1a5276; }
.order-card.status-Confirmed { border-left-color: #7AB648; }
.order-card.status-Picked    { border-left-color: #5B9A8B; }
.order-card.status-Packed    { border-left-color: #2E86AB; }
.order-card.status-Shipped   { border-left-color: #9AAB6B; }
.order-card.status-Delivered { border-left-color: #A8BF8A; }
.order-card.status-PendingReview { border-left-color: #f59e0b; }
.order-card.status-Cancelled { border-left-color: #dc2626; }

.order-card-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    cursor: pointer;
    user-select: none;
}
.order-card-header:hover { background: #f9fafb; }

.order-card-expand {
    background: none;
    border: none;
    padding: 0 4px;
    color: #9ca3af;
    cursor: pointer;
    font-size: 0.9rem;
    transition: transform 0.15s;
    flex-shrink: 0;
}
.order-card.expanded .order-card-expand { transform: rotate(90deg); }

.order-card-id {
    font-weight: 700;
    font-size: 0.95rem;
    color: #111827;
    min-width: 120px;
}
.order-card-customer {
    color: var(--brand-teal);
    font-weight: 500;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.order-card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.order-card-date {
    color: #6b7280;
    font-size: 0.85rem;
}
.order-card-items {
    color: #6b7280;
    font-size: 0.82rem;
}
.order-card-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}
.order-card-badge.badge-received  { background: #1a5276; color: #fff; }
.order-card-badge.badge-confirmed { background: #7AB648; color: #fff; }
.order-card-badge.badge-picked    { background: #5B9A8B; color: #fff; }
.order-card-badge.badge-packed    { background: #2E86AB; color: #fff; }
.order-card-badge.badge-shipped   { background: #9AAB6B; color: #fff; }
.order-card-badge.badge-delivered { background: #A8BF8A; color: #fff; }
.order-card-badge.badge-pending   { background: #fef3c7; color: #92400e; }
.order-card-badge.badge-cancelled { background: #fee2e2; color: #991b1b; }

.order-card-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* ---- Order card: PO thumbnail ---- */
.order-card-po-thumb {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border-radius: 6px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.order-card-po-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ---- Order card: info block ---- */
.order-card-info {
    flex: 1;
    min-width: 0;
}
.order-card-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 2px;
}
.order-card-summary {
    color: #6b7280;
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- Order card: right section ---- */
.order-card-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex-shrink: 0;
}
.order-card-actions-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.order-card-status-row {
    display: flex;
    align-items: center;
}

/* ---- Order detail panel ---- */
.order-detail-panel {
    display: none;
    padding: 0 20px 20px;
    border-top: 1px solid #f3f4f6;
    background: #fafbfc;
}
.order-card.expanded .order-detail-panel {
    display: block;
}
.order-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 16px;
}
@media (max-width: 992px) {
    .order-detail-grid { grid-template-columns: 1fr; }
}

/* Client details block */
.client-details {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
}
.client-details h6 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--brand-teal);
    font-weight: 700;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--brand-teal-lt);
}
.client-detail-row {
    display: flex;
    padding: 4px 0;
    font-size: 0.88rem;
}
.client-detail-label {
    font-weight: 600;
    color: #374151;
    min-width: 120px;
    flex-shrink: 0;
}
.client-detail-value {
    color: #6b7280;
}

/* ---- Order items table (in detail panel) ---- */
.order-items-table {
    width: 100%;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    margin-top: 16px;
}
.order-items-table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    font-weight: 600;
    padding: 10px 14px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}
.order-items-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.88rem;
    color: #374151;
    vertical-align: middle;
}
.order-items-table tr:last-child td { border-bottom: none; }
.order-items-table .item-total {
    font-weight: 600;
    color: #111827;
}

/* ---- Financial summary ---- */
.financial-summary {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    margin-top: 16px;
}
.financial-summary h6 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--brand-teal);
    font-weight: 700;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--brand-teal-lt);
}
.financial-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    font-size: 0.9rem;
    color: #374151;
}
.financial-row.total {
    border-top: 2px solid var(--brand-teal);
    margin-top: 6px;
    padding-top: 10px;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--brand-teal-dk);
}

/* ---- PO Preview pane ---- */
.po-preview {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}
.po-preview h6 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--brand-teal);
    font-weight: 700;
    padding: 12px 16px;
    margin: 0;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
}
.po-preview-body {
    padding: 0;
    min-height: 200px;
    background: #f5f5f5;
    display: flex;
    align-items: stretch;
    justify-content: center;
}
.po-preview-body iframe {
    width: 100%;
    min-height: 800px;
    height: 100%;
    border: none;
}
.po-preview-body img {
    max-width: 100%;
    height: auto;
}
/* In the review card, make the PO column sticky so it scrolls with the items */
.po-review-body .po-preview {
    position: sticky;
    top: 0;
}

/* ---- Missing items section ---- */
.missing-items-section {
    background: #fffbeb;
    border: 1px solid #fbbf24;
    border-radius: 8px;
    padding: 16px;
    margin-top: 12px;
}
.missing-items-section h6 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #92400e;
    font-weight: 700;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.missing-item-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    font-size: 0.88rem;
    border-bottom: 1px solid rgba(251,191,36,0.3);
}
.missing-item-row:last-child { border-bottom: none; }

/* ---- PO Review Card (upload review) ---- */
.po-review-card {
    background: #fff;
    border: 2px solid #f59e0b;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px rgba(245,158,11,0.12);
}
.po-review-header {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #fff;
    padding: 14px 20px;
    border-radius: 8px 8px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.po-review-header h5 { margin: 0; font-size: 1rem; font-weight: 600; }
.po-review-body {
    padding: 20px;
}
.po-review-footer {
    padding: 14px 20px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background: #fefce8;
    border-radius: 0 0 8px 8px;
}

/* ---- Full-page PO / Order Detail view ---- */
.po-fullpage {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 4px 24px rgba(0,0,0,0.06);
    overflow: hidden;
}
.po-fullpage-header {
    background: linear-gradient(135deg, #1a5276 0%, #154360 100%);
    padding: 14px 24px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.po-fullpage-header h5 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}
.po-fullpage-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}
.po-fullpage-po-num {
    font-size: 0.85rem;
    opacity: 0.85;
    background: rgba(255,255,255,0.15);
    padding: 2px 10px;
    border-radius: 12px;
}
.po-fullpage-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* ---- Client details strip (full-width, top) ---- */
.po-fullpage-client-strip {
    padding: 16px 24px;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
}
.client-strip-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px 20px;
}
.client-strip-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.client-strip-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b7280;
}
.client-strip-value {
    font-size: 0.88rem;
    font-weight: 500;
    color: #1f2937;
    word-break: break-word;
}
.client-strip-notes {
    margin-top: 10px;
}
/* Editable form row variant for PO review */
.client-strip-form-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 12px 16px;
    margin-bottom: 10px;
}
.client-strip-form-row:last-child { margin-bottom: 0; }
.client-strip-form-item { display: flex; flex-direction: column; gap: 3px; }
.client-strip-form-item .client-strip-label { margin-bottom: 2px; }
.client-strip-form-wide { }
@media (max-width: 992px) {
    .client-strip-grid { grid-template-columns: repeat(2, 1fr); }
    .client-strip-form-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 576px) {
    .client-strip-grid { grid-template-columns: 1fr; }
    .client-strip-form-row { grid-template-columns: 1fr; }
}

/* ---- Action bar ---- */
.po-fullpage-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 24px;
    border-top: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
}
.save-success-msg {
    transition: opacity 0.3s;
    font-size: 0.88rem;
}

/* ---- Two-column body grid: PO document left, items/financials right ---- */
.po-fullpage-body-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    flex: 1;
}
.po-fullpage-body-left {
    border-right: 1px solid #e5e7eb;
    padding: 16px 20px;
    min-height: 500px;
}
.po-fullpage-body-left .po-preview {
    height: 100%;
    display: flex;
    flex-direction: column;
}
.po-fullpage-body-left .po-preview-body {
    flex: 1;
    min-height: 480px;
}
.po-fullpage-body-right {
    padding: 16px 20px;
    overflow-y: auto;
}
.po-body-section {
    margin-bottom: 20px;
}
.po-body-section:last-child { margin-bottom: 0; }
@media (max-width: 992px) {
    .po-fullpage-body-grid { grid-template-columns: 1fr; }
    .po-fullpage-body-left { border-right: none; border-bottom: 1px solid #e5e7eb; min-height: 400px; }
}

/* Legacy section padding (keep for any remaining usage) */
.po-fullpage-section {
    padding: 0 24px 20px;
}
.po-fullpage-section:first-of-type {
    padding-top: 20px;
}

/* ---- Upload zone (inline) ---- */
.po-upload-inline {
    border: 2px dashed #d1d5db;
    border-radius: 10px;
    padding: 32px 20px;
    text-align: center;
    color: #9ca3af;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    margin-bottom: 16px;
    background: #fff;
}
.po-upload-inline:hover,
.po-upload-inline.dragover {
    border-color: var(--brand-teal);
    background: var(--brand-teal-lt);
    color: var(--brand-teal);
}
.po-upload-inline i { font-size: 2.2rem; display: block; margin-bottom: 8px; }

.po-processing-spinner {
    text-align: center;
    padding: 40px 20px;
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    margin-bottom: 16px;
}

/* ---- Dashboard stat cards (colored backgrounds) ---- */
.dash-stat-cards {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.dash-stat-card {
    flex: 1;
    min-width: 140px;
    border-radius: 12px;
    padding: 18px 20px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: opacity 0.15s, transform 0.15s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.dash-stat-card:hover { opacity: 0.9; transform: translateY(-2px); }
.dash-stat-card.active { box-shadow: 0 4px 16px rgba(0,0,0,0.20); transform: translateY(-2px); }
.dash-stat-card .stat-info { display: flex; flex-direction: column; }
.dash-stat-card .stat-number { font-size: 2.8rem; font-weight: 800; line-height: 1; }
.dash-stat-card .stat-label { font-size: 0.9rem; margin-top: 8px; opacity: 0.9; font-weight: 500; }
.dash-stat-card .stat-icon { font-size: 2.2rem; opacity: 0.35; }

/* Gradient strip: dark teal → teal → medium teal → olive → steel → light grey */
.dash-stat-received  { background: #1a5276; }
.dash-stat-confirmed { background: #7AB648; }
.dash-stat-picked    { background: #5B9A8B; }
.dash-stat-packed    { background: #2E86AB; }
.dash-stat-shipped   { background: #9AAB6B; }
.dash-stat-delivered { background: #A8BF8A; }

/* ---- Section header (status title + expand/collapse) ---- */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.section-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
}
.section-actions { display: flex; gap: 8px; }

/* ---- Dashboard orders table ---- */
.orders-table-wrap {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    overflow: hidden;
}
.orders-table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
}
.orders-table th {
    font-size: 0.85rem;
    font-weight: 600;
    color: #6b7280;
    padding: 14px 20px;
    border-bottom: 2px solid #e5e7eb;
    text-align: left;
    background: #fff;
}
.orders-table td {
    padding: 16px 20px;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.92rem;
    vertical-align: middle;
    color: #374151;
}
.orders-table tbody tr.order-row { cursor: pointer; transition: background 0.1s; }
.orders-table tbody tr.order-row:hover { background: #f8fafc; }
.orders-table tbody tr.order-row.expanded { background: #f0fdfa; }
.orders-table .row-chevron {
    color: #9ca3af;
    font-size: 0.9rem;
    transition: transform 0.15s;
    display: inline-block;
}
.orders-table tr.order-row.expanded .row-chevron { transform: rotate(90deg); }
.orders-table .order-detail-row td {
    padding: 0;
    background: #fafbfc;
    border-bottom: 2px solid #e5e7eb;
}
.orders-table .order-detail-row .detail-inner {
    padding: 20px;
}

/* Expand All / Collapse All buttons */
.dash-btn-expand {
    background: #1a5276;
    color: #fff;
    border: none;
    font-weight: 600;
}
.dash-btn-expand:hover {
    background: #154360;
    color: #fff;
}

/* ---- Dashboard expanded detail panel (Figma layout) ---- */
/* ============================================================
   Enterprise Layout: top-bar (160px) + split-view (remaining)
   ============================================================ */
.dash-detail-layout {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* -- Top bar: client info strip + action buttons ----------- */
.dash-detail-header-zone {
    height: 160px;
    min-height: 160px;
    max-height: 160px;
    padding: 16px 32px 12px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    overflow: hidden;
}

/* -- Split view: PO left, items right --------------------- */
.dash-detail-split-zone {
    height: calc(100vh - 160px);
    min-height: 740px;
    display: grid;
    grid-template-columns: 1.25fr 8px 1fr;
    gap: 0;
    padding: 24px 32px 32px;
    overflow: hidden;
}
.dash-detail-split-zone > .dash-detail-body {
    display: contents;
}

/* Left panel — PO preview card */
.dash-detail-split-zone .dash-detail-left {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin-right: 8px;
}

/* Right panel — stacked cards: items, totals */
.dash-detail-split-zone .dash-detail-right {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 16px;
    min-height: 0;
    min-width: 0;
    margin-left: 8px;
}

/* -- Client details: compact info strip ------------------- */
.dash-detail-client {
    flex: 1;
    min-width: 0;
}
.dash-detail-client h6 {
    font-size: 0.78rem;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 8px 0;
}
.dash-client-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px 16px;
}
.dash-client-field {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.dash-client-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b7280;
}
.dash-client-value {
    font-size: 0.82rem;
    color: #1f2937;
    word-break: break-word;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 5px 8px;
}

/* -- Action buttons: top-right in header zone ------------- */
.dash-detail-actions {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    flex-shrink: 0;
    padding-top: 2px;
}
.dash-btn-confirm {
    background: #1a5276;
    color: #fff;
    border: none;
    font-weight: 600;
}
.dash-btn-confirm:hover {
    background: #154360;
    color: #fff;
}

/* Two-column body: PO left, Items+Financial right */
.dash-detail-body {
    display: contents; /* children flow into parent .dash-detail-split-zone grid */
}
/* When no PO doc, override split-zone to single column */
.dash-detail-split-zone:has(.dash-detail-body-single) {
    grid-template-columns: 1fr;
}
.dash-detail-body-single {
    display: block; /* no PO — single column, no grid passthrough */
    height: 100%;
    overflow-y: auto;
}
.dash-split-handle {
    width: 8px;
    cursor: col-resize;
    background: #e5e7eb;
    position: relative;
    transition: background 0.15s;
    z-index: 5;
}
.dash-split-handle:hover,
.dash-split-handle:active {
    background: #3b82f6;
}
.dash-split-handle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 32px;
    border-left: 1px solid rgba(0,0,0,0.2);
    border-right: 1px solid rgba(0,0,0,0.2);
}
/* Utility classes for split-resize JS (no inline styles) */
body.split-resizing { cursor: col-resize; user-select: none; }
.no-pointer { pointer-events: none; }

/* PO Preview zoom toolbar */
.po-zoom-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: #f8f9fa;
    border-bottom: 1px solid #e5e7eb;
    border-radius: 14px 14px 0 0;
    flex-shrink: 0;
}
.po-zoom-bar .btn { padding: 2px 8px; font-size: 0.8rem; line-height: 1; }
.po-zoom-level {
    font-size: 0.8rem;
    font-weight: 600;
    color: #374151;
    min-width: 40px;
    text-align: center;
}

.dash-detail-left .po-preview {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.dash-detail-left .po-preview-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
}
.dash-detail-left .po-preview-body iframe,
.dash-detail-left .po-preview-body embed {
    width: 100%;
    height: 100%;
    min-height: 0;
    border: none;
}
.dash-detail-left .po-preview-body img {
    width: 100%;
    height: auto;
    display: block;
}
.dash-detail-items {
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
}
.dash-detail-items h6 {
    font-size: 0.9rem;
    font-weight: 700;
    color: #1f2937;
    padding: 16px 20px 0;
    margin: 0 0 12px 0;
}

/* Items list — scrollable within card */
.dash-items-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* Item card rows — Figma card-style layout */
.dash-item-header {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
}
.dash-item-card {
    border: 1px solid #e5e7eb;
    border-top: none;
    background: #fff;
    padding: 0;
}
.dash-item-card:last-of-type {
    border-radius: 0 0 8px 8px;
}
.dash-item-row {
    display: flex;
    align-items: center;
    padding: 14px 16px;
}
.dash-item-col.dash-item-code  { flex: 0 1 160px; min-width: 80px; font-weight: 500; color: #1f2937; font-size: 0.82rem; position: relative; }
.product-search-input { font-size: 0.82rem !important; }
.product-search-results {
    display: none;
    position: absolute; top: 100%; left: 0;
    width: 280px; max-height: 240px; overflow-y: auto;
    background: #fff; border: 1px solid #dee2e6; border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15); z-index: 1050;
}
.product-search-empty { padding: 8px 10px; font-size: 0.8rem; }
.product-search-item {
    padding: 8px 12px; cursor: pointer; border-bottom: 1px solid #f3f4f6;
}
.product-search-item:last-child { border-bottom: none; }
.product-search-item:hover { background: #f0f7ff; }
.dash-item-col.dash-item-desc  { flex: 1 1 100px; min-width: 0; color: #374151; overflow: hidden; }
.dash-item-col.dash-item-qty   { flex: 0 1 65px; min-width: 50px; text-align: center; }
.dash-item-col.dash-item-price { flex: 0 1 85px; min-width: 65px; text-align: right; }
.dash-item-col.dash-item-tax   { flex: 0 1 80px; min-width: 60px; text-align: right; color: #6b7280; }
.dash-item-col.dash-item-total { flex: 0 1 100px; min-width: 70px; text-align: right; font-weight: 700; color: #c0504d; font-size: 0.95rem; }
/* Inline editable inputs in item cards */
.dash-item-input {
    border: 1px solid transparent;
    background: transparent;
    padding: 4px 6px;
    font-size: 0.88rem;
    color: #374151;
    width: 100%;
    min-width: 0;
    border-radius: 4px;
    transition: border-color 0.15s, background 0.15s;
    font-family: inherit;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dash-item-input:hover {
    border-color: #d1d5db;
    background: #fff;
}
.dash-item-input:focus {
    border-color: #1a5276;
    background: #fff;
    outline: none;
    box-shadow: 0 0 0 2px rgba(26,82,118,0.15);
}
.dash-item-input-num {
    text-align: right;
}
/* Hide number input spinners for cleaner look */
.dash-item-input-num::-webkit-inner-spin-button,
.dash-item-input-num::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.dash-item-input-num { -moz-appearance: textfield; }

.dash-detail-financial {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    flex-shrink: 0;
}
.dash-detail-financial .financial-row {
    padding: 8px 0;
    font-size: 0.95rem;
}
.dash-detail-financial .financial-row.total {
    font-size: 1.1rem;
}

/* Responsive breakpoints for split view */
@media (min-width: 1440px) {
    .dash-detail-split-zone {
        grid-template-columns: 1.35fr 8px 1fr;
    }
}
@media (max-width: 1280px) {
    .dash-detail-split-zone {
        grid-template-columns: 1fr 8px 420px;
    }
}
@media (max-width: 1024px) {
    .dash-detail-split-zone {
        grid-template-columns: 1fr;
        height: auto;
        min-height: auto;
        overflow-y: auto;
    }
    .dash-detail-split-zone .dash-split-handle {
        display: none;
    }
    .dash-detail-split-zone .dash-detail-left {
        min-height: 400px;
    }
}

@media (max-width: 992px) {
    .dash-client-grid { grid-template-columns: repeat(2, 1fr); }
    .dash-detail-body { grid-template-columns: 1fr !important; }
    .dash-split-handle { display: none; }
}
/* Review header zone — taller for editable form fields */
.dash-detail-header-zone--review {
    height: 220px;
    min-height: 220px;
    max-height: 220px;
}
.dash-detail-header-zone--review + .dash-detail-split-zone {
    height: calc(100vh - 220px);
}

/* Items header bar with title + action button */
.dash-items-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px 8px;
}
.dash-items-header-bar h6 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 700;
    color: #1f2937;
}

/* Client title bar with order number + badge */
.dash-detail-client-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.dash-detail-client-title h6 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 700;
}

/* Section label for history/missing items */
.section-label {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    margin-bottom: 8px;
}

/* No-PO placeholder */
.po-no-document {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: #9ca3af;
}
.po-no-document i {
    font-size: 3rem;
    margin-bottom: 8px;
}

/* Form select auto width */
.form-select-auto { width: auto; }

/* Review items table column widths */
.order-items-table .col-extracted { width: 25%; }
.order-items-table .col-product { width: 30%; }
.order-items-table .col-qty { width: 8%; }
.order-items-table .col-price { width: 12%; }
.order-items-table .col-total { width: 12%; }
.order-items-table .col-action { width: 5%; }

/* Unmatched item row highlight */
.review-row-unmatched { background: #fffbea; }

/* ============================================================
   Order Search Dropdown
   ============================================================ */
.order-search-dropdown {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 1050;
    background: #fff; border: 1px solid #dee2e6; border-top: none;
    border-radius: 0 0 .375rem .375rem; box-shadow: 0 4px 12px rgba(0,0,0,.12);
    max-height: 340px; overflow-y: auto; display: none;
}
.order-search-item {
    padding: 10px 12px; cursor: pointer; border-bottom: 1px solid #f1f3f5;
}
.order-search-item:last-child { border-bottom: none; }
.order-search-item:hover, .order-search-item.active { background: #e7f5ff; }
.order-search-noresults { padding: 12px; text-align: center; color: #6c757d; font-size: 0.875rem; }

/* ============================================================
   Customer Autocomplete
   ============================================================ */
.customer-autocomplete { position: relative; }
.customer-autocomplete input { width: 100%; }
.customer-ac-dropdown {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 1050;
    background: #fff; border: 1px solid #dee2e6; border-top: none;
    border-radius: 0 0 .375rem .375rem; box-shadow: 0 4px 12px rgba(0,0,0,.12);
    max-height: 280px; overflow-y: auto; display: none;
}
.customer-ac-dropdown.show { display: block; }
.customer-ac-item {
    padding: 8px 12px; cursor: pointer; border-bottom: 1px solid #f1f3f5;
    font-size: 0.875rem;
}
.customer-ac-item:last-child { border-bottom: none; }
.customer-ac-item:hover, .customer-ac-item.active { background: #e7f5ff; }
.customer-ac-item .ac-code { color: #6c757d; font-size: 0.75rem; }
.customer-ac-item .ac-entity { color: #868e96; font-size: 0.7rem; float: right; }
.customer-ac-noresults { padding: 12px; text-align: center; color: #6c757d; font-size: 0.875rem; }
.dash-client-field-wide { grid-column: span 2; }

@media (max-width: 576px) {
    .dash-client-grid { grid-template-columns: 1fr; }
    .dash-client-field-wide { grid-column: span 1; }
}
