:root {
  --bg: #f3f5f1;
  --surface: #ffffff;
  --surface-2: #f8faf7;
  --ink: #17221f;
  --muted: #68756f;
  --line: #dce3df;
  --brand: #175c4d;
  --brand-dark: #0f2f2a;
  --brand-soft: #e4f1ec;
  --accent: #e1a742;
  --danger: #b8392e;
  --warn: #a56318;
  --success: #277553;
  --info: #2d5e9c;
  --shadow: 0 16px 44px rgba(15, 47, 42, .08);
  --radius: 16px;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--ink); font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(225, 167, 66, .35); outline-offset: 2px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; overflow: auto; display: flex; flex-direction: column; padding: 18px 14px; color: #d7e4df; background: linear-gradient(180deg, #0f2f2a 0%, #143a32 62%, #0b2722 100%); z-index: 30; }
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 7px 22px; color: #fff; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; color: #18322c; background: var(--accent); font-size: 19px; font-weight: 900; box-shadow: inset 0 -3px 0 rgba(0,0,0,.12); }
.brand strong, .brand small { display: block; }
.brand strong { letter-spacing: .02em; }
.brand small { margin-top: 1px; color: #98b4aa; font-size: 11px; }
.nav-label { margin: 16px 10px 5px; color: #7ea197; font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.nav-item { position: relative; display: flex; width: 100%; align-items: center; gap: 10px; margin: 2px 0; padding: 10px 11px; border: 0; border-radius: 10px; color: #c1d2cc; background: transparent; text-align: left; cursor: pointer; }
.nav-item span { width: 19px; text-align: center; font-size: 16px; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { color: #fff; background: rgba(225,167,66,.17); box-shadow: inset 3px 0 var(--accent); }
.nav-count { margin-left: auto; min-width: 21px; padding: 1px 6px; border-radius: 999px; color: #16352e; background: var(--accent); font-size: 10px; text-align: center; }
.sidebar-footer { margin-top: auto; padding: 14px 10px 3px; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-footer b { font-size: 12px; }
.sidebar-footer small { display: block; margin: 4px 0 0 16px; color: #7ea197; font-size: 10px; }
.status-dot { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: #52d393; box-shadow: 0 0 0 4px rgba(82,211,147,.12); }
.offline .status-dot { background: #f3b85d; box-shadow: 0 0 0 4px rgba(243,184,93,.12); }

.main-shell { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 22px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); backdrop-filter: blur(14px); }
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-left strong, .topbar-left small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-left small { color: var(--muted); font-size: 11px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.mobile-only { display: none !important; }
.icon-btn, .btn, .text-btn, .tabs button, .segmented button { border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.icon-btn { display: inline-grid; width: 38px; height: 38px; place-items: center; border-radius: 10px; font-size: 18px; }
.icon-btn:hover, .btn:hover { border-color: #aebbb5; background: #fafcfb; }
.btn { min-height: 38px; padding: 8px 13px; border-radius: 10px; font-weight: 750; white-space: nowrap; }
.btn.primary { color: #fff; border-color: var(--brand); background: var(--brand); box-shadow: 0 5px 14px rgba(23,92,77,.16); }
.btn.primary:hover { background: #104c3f; }
.btn.danger { color: var(--danger); border-color: #ecc9c5; background: #fff7f6; }
.btn:disabled { opacity: .48; cursor: not-allowed; }
.text-btn { border: 0; color: var(--brand); background: transparent; font-weight: 800; cursor: pointer; }
.search-trigger { width: min(360px, 30vw); display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: var(--surface-2); text-align: left; cursor: pointer; }
.search-trigger .search-copy { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.search-trigger kbd { margin-left: auto; padding: 1px 6px; border: 1px solid var(--line); border-radius: 5px; color: #7b8782; background: #fff; font-size: 10px; }
.select, .input, textarea { min-height: 40px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: #fff; }
.select.compact { max-width: 180px; }

.content { width: min(1580px, 100%); margin: 0 auto; padding: 24px; }
.page { display: none; animation: page-in .18s ease-out; }
.page.active { display: block; }
@keyframes page-in { from { opacity: .3; transform: translateY(4px); } }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.page-heading h1 { margin: 1px 0 3px; font-size: clamp(23px, 3vw, 31px); line-height: 1.18; letter-spacing: -.025em; }
.page-heading p { margin: 0; color: var(--muted); }
.eyebrow, .section-kicker { margin: 0 !important; color: var(--brand) !important; font-size: 10px !important; font-weight: 900; letter-spacing: .13em; text-transform: uppercase; }
.date-pill, .role-pill { padding: 7px 11px; border: 1px solid #cddbd5; border-radius: 999px; color: var(--brand); background: #edf5f1; font-size: 12px; font-weight: 800; }

.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 2px 7px rgba(15,47,42,.025); overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 17px; border-bottom: 1px solid var(--line); }
.card-head h2 { margin: 2px 0 0; font-size: 17px; }
.card-body { padding: 16px 17px; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { position: relative; min-height: 116px; padding: 16px; overflow: hidden; }
.kpi::after { content: ""; position: absolute; right: -25px; bottom: -37px; width: 95px; height: 95px; border-radius: 50%; background: var(--tone, #e8f1ed); }
.kpi .kpi-icon { display: grid; width: 31px; height: 31px; place-items: center; margin-bottom: 9px; border-radius: 9px; color: var(--brand); background: var(--tone, #e8f1ed); font-weight: 900; }
.kpi small { color: var(--muted); }
.kpi strong { display: block; margin-top: 1px; font-size: 24px; line-height: 1.2; }
.kpi em { color: var(--success); font-size: 11px; font-style: normal; }
.compact-kpis { grid-template-columns: repeat(3, minmax(0,1fr)); }
.compact-kpis .kpi { min-height: 95px; }
.dashboard-grid { display: grid; grid-template-columns: 1.12fr .88fr; gap: 14px; margin-bottom: 14px; }
.focus-card { min-height: 340px; }
.task-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 14px 17px; border-bottom: 1px solid var(--line); cursor: pointer; }
.task-row:last-child { border-bottom: 0; }
.task-row:hover { background: var(--surface-2); }
.task-icon { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 11px; color: var(--brand); background: var(--brand-soft); font-weight: 900; }
.task-copy b, .task-copy small { display: block; }
.task-copy small { margin-top: 2px; color: var(--muted); }
.task-age { color: var(--warn); font-size: 11px; font-weight: 800; }
.flow-track { padding: 15px 17px; }
.flow-step { display: grid; grid-template-columns: 33px 1fr auto; align-items: center; gap: 10px; position: relative; min-height: 50px; }
.flow-step:not(:last-child)::after { content: ""; position: absolute; left: 16px; top: 38px; width: 1px; height: 25px; background: #cdd9d4; }
.flow-step .step-num { display: grid; width: 33px; height: 33px; place-items: center; border: 1px solid #c5d4ce; border-radius: 50%; color: var(--brand); background: #eef5f2; font-weight: 900; z-index: 1; }
.flow-step b, .flow-step small { display: block; }
.flow-step small { color: var(--muted); font-size: 11px; }
.flow-step .step-count { min-width: 26px; padding: 3px 8px; border-radius: 999px; background: #edf2ef; text-align: center; font-weight: 900; }

.table-card { overflow: hidden; }
.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 12px 13px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; white-space: nowrap; }
th { color: #75817c; background: #f8faf8; font-size: 10px; font-weight: 850; letter-spacing: .05em; text-transform: uppercase; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #fafcfb; }
tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; }
td small { color: var(--muted); }
.status { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 999px; color: #59655f; background: #edf1ef; font-size: 10px; font-weight: 900; letter-spacing: .02em; }
.status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status.APPROVED, .status.POSTED, .status.COMPLETED, .status.ON_TRACK, .status.ISSUED { color: var(--success); background: #e9f6ef; }
.status.IN_APPROVAL, .status.SUBMITTED, .status.IN_TRANSIT, .status.PARTIAL, .status.REVIEW { color: var(--info); background: #eaf2fb; }
.status.CRITICAL, .status.REJECTED, .status.DISQUALIFIED, .status.OVERDUE { color: var(--danger); background: #fff0ee; }
.status.HIGH, .status.WATCH, .status.ACTION_REQUIRED, .status.WAITING_GRN, .status.WAITING { color: var(--warn); background: #fff4e4; }
.status.DRAFT, .status.WAITING, .status.NOT_STARTED { color: #68756f; background: #edf1ef; }
.status.AWARDED, .status.READY_FOR_RFQ { color: #654aa5; background: #f1edfb; }
.risk-date { color: var(--danger); font-weight: 850; }
.progress-mini { width: 94px; height: 6px; margin-bottom: 3px; border-radius: 999px; background: #e3e8e5; overflow: hidden; }
.progress-mini i { display: block; height: 100%; border-radius: inherit; background: var(--brand); }

.tabs, .segmented { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 11px; background: #edf1ef; }
.tabs { margin-bottom: 14px; }
.tabs button, .segmented button { padding: 7px 11px; border-color: transparent; border-radius: 8px; color: var(--muted); background: transparent; font-weight: 750; cursor: pointer; }
.tabs button.active, .segmented button.active { color: var(--ink); background: #fff; box-shadow: 0 1px 4px rgba(15,47,42,.08); }
.task-list { display: grid; gap: 10px; }
.inbox-card { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 14px; align-items: center; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.inbox-card .doc-type { display: grid; width: 43px; height: 43px; place-items: center; border-radius: 12px; color: var(--brand); background: var(--brand-soft); font-size: 11px; font-weight: 900; }
.inbox-card h3 { margin: 0 0 2px; font-size: 15px; }
.inbox-card p { margin: 0; color: var(--muted); font-size: 12px; }
.inbox-card-actions { display: flex; gap: 7px; }
.filter-row, .search-panel { display: flex; align-items: center; gap: 9px; margin-bottom: 14px; }
.filter-row { justify-content: space-between; }
.filter-row .input { min-width: 260px; }
.search-panel { padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.search-field { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 180px; padding: 0 11px; border: 1px solid var(--line); border-radius: 10px; background: #f8faf8; }
.search-field input { width: 100%; min-height: 40px; border: 0; outline: 0; background: transparent; }
.result-summary { margin: 3px 0 10px; color: var(--muted); font-size: 12px; }
.product-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.product-card { display: flex; min-height: 230px; flex-direction: column; padding: 16px; border: 1px solid var(--line); border-radius: 15px; background: #fff; }
.product-card:hover { border-color: #a9beb5; box-shadow: var(--shadow); transform: translateY(-1px); }
.product-top { display: flex; justify-content: space-between; gap: 10px; }
.product-symbol { display: grid; width: 48px; height: 48px; place-items: center; border-radius: 13px; color: var(--brand); background: var(--brand-soft); font-weight: 900; }
.product-card h3 { margin: 14px 0 3px; font-size: 16px; }
.product-card p { margin: 0; color: var(--muted); font-size: 12px; }
.product-meta { display: flex; gap: 12px; margin-top: 11px; color: var(--muted); font-size: 11px; }
.product-bottom { display: flex; align-items: end; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.product-price small, .product-price b { display: block; }
.product-price small { color: var(--muted); }
.product-price b { font-size: 16px; }
.count-badge { display: inline-grid; min-width: 21px; height: 21px; place-items: center; margin-left: 5px; border-radius: 999px; color: #fff; background: var(--brand); font-size: 10px; }

.delivery-board { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.delivery-card { padding: 16px; border: 1px solid var(--line); border-radius: 15px; background: #fff; }
.delivery-card.critical { border-top: 4px solid var(--danger); }
.delivery-card.watch { border-top: 4px solid var(--accent); }
.delivery-card.ok { border-top: 4px solid var(--success); }
.delivery-card header { display: flex; justify-content: space-between; gap: 8px; }
.delivery-card h3 { margin: 10px 0 2px; }
.delivery-card p { margin: 0; color: var(--muted); font-size: 12px; }
.delivery-dates { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 13px 0; }
.delivery-dates div { padding: 9px; border-radius: 10px; background: var(--surface-2); }
.delivery-dates small, .delivery-dates b { display: block; }
.delivery-dates small { color: var(--muted); font-size: 10px; }
.timeline-mini { display: flex; gap: 4px; margin: 12px 0 4px; }
.timeline-mini i { flex: 1; height: 6px; border-radius: 999px; background: #dfe5e2; }
.timeline-mini i.done { background: var(--brand); }
.notice { margin-bottom: 14px; padding: 12px 14px; border: 1px solid #c8ddd4; border-radius: 12px; color: #2c5e50; background: #edf6f2; }
.document-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.document-card { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 11px; padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: #fff; cursor: pointer; }
.document-card:hover { border-color: #a8bbb3; box-shadow: 0 8px 24px rgba(15,47,42,.07); }
.doc-icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 11px; color: var(--brand); background: var(--brand-soft); font-size: 10px; font-weight: 900; }
.document-card b, .document-card small { display: block; }
.document-card small { color: var(--muted); font-size: 10px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.settings-list > div { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.settings-list > div:last-child { border-bottom: 0; }
.settings-list small { color: var(--muted); }
.settings-list .btn, .settings-list .status { grid-row: 1 / span 2; grid-column: 2; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid label { color: var(--muted); font-size: 11px; }
.form-grid .input, .form-grid .select { width: 100%; margin-top: 4px; color: var(--ink); }
.form-grid .full { grid-column: 1 / -1; }
.helper { color: var(--muted); font-size: 11px; }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; }
.file-btn { display: inline-flex; align-items: center; }

.drawer, .modal, .command { position: fixed; inset: 0; z-index: 80; display: none; }
.drawer.open, .modal.open, .command.open { display: block; }
.drawer-shade, .modal-shade { position: absolute; inset: 0; background: rgba(9,31,27,.52); backdrop-filter: blur(2px); }
.drawer-panel { position: absolute; top: 0; right: 0; width: min(760px, 96vw); height: 100%; display: flex; flex-direction: column; background: #fff; box-shadow: -20px 0 60px rgba(5,30,25,.18); animation: drawer-in .22s ease-out; }
@keyframes drawer-in { from { transform: translateX(30px); opacity: .3; } }
.drawer-panel > header, .modal-card > header { display: flex; align-items: start; justify-content: space-between; gap: 12px; padding: 17px 19px; border-bottom: 1px solid var(--line); }
.drawer-panel h2, .modal-card h2 { margin: 2px 0 0; font-size: 20px; }
.drawer-content { flex: 1; overflow: auto; padding: 18px 19px; }
.drawer-panel > footer, .modal-card > footer { display: flex; justify-content: flex-end; gap: 8px; min-height: 65px; padding: 13px 19px; border-top: 1px solid var(--line); background: #fafcfb; }
.detail-hero { margin: -18px -19px 16px; padding: 21px 19px; color: #fff; background: linear-gradient(135deg, var(--brand-dark), #246b5b); }
.detail-hero p { margin: 2px 0 0; color: #c8ded6; }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 15px; }
.detail-box { padding: 10px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); }
.detail-box small, .detail-box b { display: block; }
.detail-box small { color: var(--muted); font-size: 10px; }
.detail-section { margin-top: 18px; }
.detail-section h3 { margin: 0 0 9px; font-size: 14px; }
.approval-line { position: relative; display: grid; grid-template-columns: 29px 1fr auto; align-items: center; gap: 9px; min-height: 46px; }
.approval-line:not(:last-child)::after { content: ""; position: absolute; left: 14px; top: 34px; width: 1px; height: 20px; background: var(--line); }
.approval-line .check { display: grid; width: 29px; height: 29px; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: #fff; z-index: 1; }
.approval-line.approved .check { color: #fff; border-color: var(--success); background: var(--success); }
.approval-line.pending .check { color: var(--warn); border-color: #e4bd7c; background: #fff5e7; }
.approval-line.rejected .check { color: #fff; border-color: var(--danger); background: var(--danger); }
.approval-line small { color: var(--muted); }
.line-table { width: 100%; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.line-table table { font-size: 11px; }
.document-preview { padding: 26px; border: 1px solid #d7ddd9; background: #fff; box-shadow: 0 3px 15px rgba(0,0,0,.04); }
.document-preview .doc-head { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 17px; border-bottom: 2px solid var(--brand-dark); }
.document-preview h2 { margin: 0; }
.document-preview .doc-company { text-align: right; }
.document-preview .doc-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 20px; margin: 17px 0; }
.document-preview .doc-meta div { display: grid; grid-template-columns: 110px 1fr; gap: 7px; }
.document-preview .doc-total { margin-top: 12px; text-align: right; font-size: 18px; font-weight: 900; }
.audit-list { margin: 0; padding: 0; list-style: none; }
.audit-list li { position: relative; padding: 0 0 13px 20px; color: var(--muted); }
.audit-list li::before { content: ""; position: absolute; left: 1px; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--brand); }
.audit-list li::after { content: ""; position: absolute; left: 4px; top: 16px; bottom: 0; width: 1px; background: var(--line); }
.audit-list li:last-child::after { display: none; }

.modal.open { display: flex; align-items: center; justify-content: center; padding: 18px; }
.modal-card { position: relative; width: min(820px, 96vw); max-height: 92vh; display: flex; flex-direction: column; border-radius: 17px; background: #fff; box-shadow: 0 28px 90px rgba(0,0,0,.23); overflow: hidden; animation: modal-in .18s ease-out; }
@keyframes modal-in { from { transform: translateY(8px) scale(.99); opacity: .3; } }
.modal-content { overflow: auto; padding: 18px 19px; }
.modal-card > footer { min-height: 63px; }
.modal-line { display: grid; grid-template-columns: minmax(0,1fr) 90px 120px 36px; gap: 7px; align-items: end; padding: 9px 0; border-bottom: 1px solid var(--line); }
.modal-line:last-child { border-bottom: 0; }
.modal-line label { color: var(--muted); font-size: 10px; }
.modal-line .input, .modal-line .select { width: 100%; }
.modal-total { margin-top: 12px; text-align: right; font-size: 18px; font-weight: 900; }
.empty { padding: 35px 20px; color: var(--muted); text-align: center; }
.empty b { display: block; margin-bottom: 3px; color: var(--ink); }

.command.open { display: flex; align-items: flex-start; justify-content: center; padding: 11vh 18px 18px; background: rgba(9,31,27,.56); backdrop-filter: blur(3px); }
.command-card { width: min(690px, 96vw); max-height: 72vh; border: 1px solid #b8c7c1; border-radius: 16px; background: #fff; box-shadow: 0 28px 90px rgba(0,0,0,.25); overflow: hidden; }
.command-input { display: flex; align-items: center; gap: 9px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.command-input input { flex: 1; min-width: 0; border: 0; outline: 0; font-size: 16px; }
.key-hint { padding: 3px 7px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: #f5f7f6; font-size: 9px; }
.command-results { max-height: 56vh; overflow: auto; padding: 7px; }
.command-result { display: grid; grid-template-columns: 39px 1fr auto; gap: 10px; align-items: center; padding: 10px; border-radius: 10px; cursor: pointer; }
.command-result:hover { background: var(--surface-2); }
.command-result small { color: var(--muted); }
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 120; display: none; max-width: 420px; padding: 11px 14px; border-radius: 11px; color: #fff; background: #143a32; box-shadow: 0 18px 45px rgba(0,0,0,.2); }
.toast.show { display: block; animation: toast-in .2s ease-out; }
.toast.error { background: #802c24; }
@keyframes toast-in { from { transform: translateY(8px); opacity: .3; } }
.backdrop { display: none; }

@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .product-grid, .delivery-board, .document-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .search-trigger { width: 220px; }
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -265px; width: 248px; transition: left .2s ease-out; box-shadow: 18px 0 45px rgba(0,0,0,.18); }
  .sidebar.open { left: 0; }
  .backdrop.show { position: fixed; inset: 0; z-index: 25; display: block; background: rgba(9,31,27,.42); }
  .mobile-only { display: inline-grid !important; }
  .topbar { padding: 0 13px; }
  .search-trigger { width: 40px; justify-content: center; }
  .search-trigger .search-copy, .search-trigger kbd { display: none; }
  .select.compact { width: 43px; color: transparent; background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%); background-position: calc(50% - 3px) 50%, calc(50% + 3px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }
  .content { padding: 17px 13px 28px; }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .topbar-actions .primary { width: 40px; padding: 0; font-size: 0; }
  .topbar-actions .primary::before { content: "+"; font-size: 20px; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 10px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi { min-height: 105px; padding: 13px; }
  .kpi strong { font-size: 20px; }
  .product-grid, .delivery-board, .document-grid { grid-template-columns: 1fr; }
  .filter-row, .search-panel { align-items: stretch; flex-direction: column; }
  .filter-row .input, .search-panel .select { width: 100%; min-width: 0; }
  .segmented { width: 100%; overflow: auto; }
  .segmented button { flex: 0 0 auto; }
  .inbox-card { grid-template-columns: auto 1fr; }
  .inbox-card-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .form-grid, .detail-grid { grid-template-columns: 1fr; }
  .modal-line { grid-template-columns: minmax(0,1fr) 75px 100px 33px; }
  .drawer-panel { width: 100vw; }
  .document-preview { padding: 15px; }
  .document-preview .doc-head { flex-direction: column; }
  .document-preview .doc-company { text-align: left; }
  .document-preview .doc-meta { grid-template-columns: 1fr; }
}

@media print {
  body * { visibility: hidden; }
  .document-preview, .document-preview * { visibility: visible; }
  .document-preview { position: fixed; inset: 0; width: 100%; border: 0; box-shadow: none; }
}
