/* Rawasi supply demo — Saudi corporate look: deep green, sand, dark slate. RTL-first. */
:root {
  --green-900: #0B3B2E;
  --green-800: #0C4A39;
  --green-700: #0E5A43;
  --green-600: #13704F;
  --green-100: #E3F0EA;
  --green-50: #F1F8F4;
  --sand-50: #FAF7F1;
  --sand-100: #F4EDE0;
  --sand-200: #EADFC9;
  --sand-300: #DCC9A3;
  --sand-500: #C2A46D;
  --sand-700: #8C6F38;
  --slate-900: #16202B;
  --slate-800: #1E2A36;
  --slate-700: #2B3A48;
  --slate-500: #5B6B7A;
  --slate-300: #A9B4BF;
  --line: #E7E0D2;
  --text: #1B2733;
  --bg: #F6F2EA;
  --card: #FFFFFF;
  --danger: #B42318;
  --danger-bg: #FDECEA;
  --st-new: #2563EB; --st-new-bg: #E8EFFE;
  --st-confirmed: #7C3AED; --st-confirmed-bg: #F1EAFE;
  --st-progress: #D9700B; --st-progress-bg: #FFF1E2;
  --st-done: #15803D; --st-done-bg: #E5F4EA;
  --st-cancel: #6B7280; --st-cancel-bg: #F0F1F3;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(22, 32, 43, .04), 0 4px 16px rgba(22, 32, 43, .05);
  --sidebar-w: 264px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'IBM Plex Sans Arabic', Tahoma, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--green-700); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.35; }
p { margin: .25rem 0; }
code { background: var(--sand-100); padding: 1px 6px; border-radius: 5px; font-size: .9em; }
.muted { color: var(--slate-500); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.pad { padding: 16px; }
.w100 { width: 100%; }
.num, td.num, th.num { text-align: left; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.ic { width: 18px; height: 18px; flex: none; vertical-align: -4px; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--slate-900), var(--slate-800));
  color: #D7DEE5; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 14px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 20px; border-bottom: 1px solid rgba(255,255,255,.07); margin-bottom: 14px; }
.brand-mark svg { width: 44px; height: 44px; display: block; }
.brand-text strong { display: block; color: #fff; font-size: 17px; }
.brand-text span { font-size: 11.5px; color: var(--sand-300); }
.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; color: #C4CED8; font-weight: 500; position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(14, 90, 67, .55); color: #fff; }
.nav-item.active::before { content: ''; position: absolute; right: -14px; top: 8px; bottom: 8px; width: 4px; border-radius: 4px 0 0 4px; background: var(--sand-500); }
.nav-item .ic { width: 19px; height: 19px; opacity: .9; }
.nav-badge { margin-inline-start: auto; font-style: normal; background: var(--sand-500); color: var(--slate-900); font-size: 11.5px; font-weight: 700; padding: 0 8px; border-radius: 20px; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.07); padding-top: 14px; display: grid; gap: 10px; }
.demo-badge { font-size: 11.5px; color: var(--sand-300); text-align: center; }
.btn-sidebar { background: rgba(255,255,255,.06); color: #E3E8ED; border: 1px solid rgba(255,255,255,.1); }
.btn-sidebar:hover { background: rgba(255,255,255,.12); }
.sidebar-backdrop { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding: 10px 24px; min-height: 66px;
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 18px; color: var(--slate-900); }
.today { font-size: 12.5px; color: var(--slate-500); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.menu-btn { display: none; }
.role-switch { display: inline-flex; background: var(--sand-100); border-radius: 10px; padding: 3px; border: 1px solid var(--line); }
.role-switch button { white-space: nowrap; border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font: inherit; font-size: 13px; font-weight: 600; color: var(--slate-700); cursor: pointer; }
.role-switch button.active { background: var(--green-700); color: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.customer-switch { max-width: 230px; }
.bell-wrap { position: relative; }
.bell { position: relative; }
.bell .badge { position: absolute; top: -3px; left: -3px; background: #D92D20; color: #fff; font-size: 10.5px; font-weight: 700; min-width: 19px; height: 19px; border-radius: 10px; display: grid; place-items: center; padding: 0 4px; border: 2px solid #fff; }
.user-chip { display: flex; align-items: center; gap: 9px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--sand-200); color: var(--sand-700); display: grid; place-items: center; font-weight: 700; }
.user-meta b { white-space: nowrap; display: block; font-size: 13px; line-height: 1.3; }
.user-meta small { color: var(--slate-500); font-size: 11.5px; }

.view { padding: 22px 24px 48px; max-width: 1480px; width: 100%; margin: 0 auto; }
.print-header, #print-area { display: none; }

/* ---------- generic ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card-title { font-size: 15.5px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; color: var(--slate-900); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h3 { font-size: 15.5px; display: flex; align-items: center; gap: 8px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h2 { font-size: 22px; color: var(--slate-900); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.grid-2 > .card, .grid-2-1 > .card { margin-bottom: 0; }
.grid-2, .grid-2-1 { margin-bottom: 16px; }
.grid-2-1 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; }
.grid-main-side { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.sticky { position: sticky; top: 84px; }
.spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 8px 14px; font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s;
  text-decoration: none !important;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--green-700); color: #fff; }
.btn-primary:hover { background: var(--green-800); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--slate-800); }
.btn-ghost:hover { background: var(--sand-50); border-color: var(--sand-300); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #912018; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-bg); border-color: #F5C2BE; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-sm .ic { width: 15px; height: 15px; }
.btn-block { width: 100%; padding: 11px; margin-top: 12px; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: #fff; display: inline-grid; place-items: center; cursor: pointer; color: var(--slate-700); }
.icon-btn:hover { background: var(--sand-50); }
.icon-btn.danger { color: var(--danger); border-color: transparent; background: transparent; }
.link-btn { background: none; border: 0; color: var(--green-700); font: inherit; font-weight: 600; cursor: pointer; padding: 0; display: inline-flex; align-items: center; gap: 6px; }
.row-actions { display: flex; gap: 5px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- forms ---------- */
input, select, textarea {
  font: inherit; font-size: 14px; color: var(--text); background: #fff; border: 1px solid #DDD5C5; border-radius: var(--radius-sm); padding: 8px 11px; width: 100%; min-height: 38px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green-600); box-shadow: 0 0 0 3px rgba(19, 112, 79, .14); }
input:disabled, select:disabled, textarea:disabled { background: #F3F1EC; color: var(--slate-500); cursor: not-allowed; }
input[type=date], input[type=time] { direction: ltr; text-align: right; }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; accent-color: var(--green-700); }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field > label { font-weight: 600; font-size: 13px; color: var(--slate-700); }
.field.inline { flex-direction: row; align-items: center; gap: 12px; }
.field.inline > label { min-width: 150px; }
.req { color: var(--danger); }
.hint { color: var(--slate-500); font-size: 12px; }
.err { color: var(--danger); font-size: 12px; min-height: 0; }
.err:empty { display: none; }
.field.invalid input, .field.invalid select, .field.invalid textarea, tr.invalid input, tr.invalid select { border-color: var(--danger); background: #FFFAFA; }
#lines-err { margin-top: 6px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid.tight { gap: 0 10px; }
.col-full { grid-column: 1 / -1; }
.form-section { font-size: 14px; color: var(--green-700); border-top: 1px dashed var(--line); padding-top: 12px; margin: 4px 0 10px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.input-row { display: flex; gap: 8px; }
.input-row select { flex: 1; }
.input-affix { display: flex; align-items: center; gap: 8px; flex: 1; }
.input-affix span { white-space: nowrap; color: var(--slate-500); font-size: 13px; }
.radio-row { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.radio { display: inline-flex; align-items: center; gap: 7px; font-weight: 500; cursor: pointer; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 40px; height: 22px; background: #D3D7DC; border-radius: 22px; position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 3px; right: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: right .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--green-700); }
.switch input:checked + .track::after { right: 21px; }
.switch input:disabled + .track { opacity: .55; }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px rgba(19,112,79,.25); }
.switch-mini { display: inline-block; width: 30px; height: 17px; border-radius: 17px; background: #D3D7DC; position: relative; vertical-align: middle; }
.switch-mini::after { content: ''; position: absolute; top: 2px; right: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; transition: right .2s; }
.switch-mini.on { background: var(--green-700); }
.switch-mini.on::after { right: 15px; }
.plate-input { display: grid; grid-template-columns: repeat(3, 70px) 1fr; gap: 6px; }
.plate-input select { text-align: center; font-weight: 700; padding-inline: 4px; }
.w-num { width: 84px; }

/* ---------- chips, tags, progress ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip-new { color: var(--st-new); background: var(--st-new-bg); }
.chip-confirmed { color: var(--st-confirmed); background: var(--st-confirmed-bg); }
.chip-in_progress { color: var(--st-progress); background: var(--st-progress-bg); }
.chip-completed { color: var(--st-done); background: var(--st-done-bg); }
.chip-cancelled { color: var(--st-cancel); background: var(--st-cancel-bg); }
.chip-d-scheduled { color: var(--st-confirmed); background: var(--st-confirmed-bg); }
.chip-d-delivered { color: var(--st-done); background: var(--st-done-bg); }
.chip-d-cancelled { color: var(--st-cancel); background: var(--st-cancel-bg); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; background: var(--sand-100); color: var(--sand-700); white-space: nowrap; }
.tag-urgent { background: #FEE4E2; color: #B42318; }
.tag-late { background: #FFF1E2; color: #B45309; }
.tag-new { background: var(--st-new-bg); color: var(--st-new); }
.tag-ok { background: var(--st-done-bg); color: var(--st-done); }
.tag-weekend { background: #EEF0F3; color: var(--slate-500); }
.progress-wrap { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.progress { flex: 1; height: 8px; background: #EEE8DC; border-radius: 8px; overflow: hidden; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--sand-500), var(--green-600)); border-radius: 8px; transition: width .4s; }
.progress.done span { background: var(--st-done); }
.progress-label { font-size: 12px; font-weight: 600; color: var(--slate-700); min-width: 36px; font-variant-numeric: tabular-nums; }
.qty b { display: block; font-variant-numeric: tabular-nums; }
.qty small { color: var(--slate-500); font-size: 12px; }
.mat-pill { display: inline-block; background: var(--sand-50); border: 1px solid var(--sand-200); border-radius: 7px; padding: 0 8px; font-size: 12px; margin: 2px 0 2px 4px; white-space: nowrap; }
.pills { max-width: 260px; }
.sum-chip { display: inline-block; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; margin: 0 0 8px 8px; font-size: 13px; }
.chips-row { margin-bottom: 8px; }

/* ---------- plate (Saudi style) ---------- */
.plate { display: inline-flex; align-items: stretch; border: 1.5px solid var(--slate-800); border-radius: 5px; background: #fff; font-weight: 700; font-size: 12.5px; line-height: 1; overflow: hidden; white-space: nowrap; vertical-align: middle; }
.plate span { padding: 4px 6px; display: flex; align-items: center; }
.plate-l { border-inline-start: 1px solid var(--slate-800); letter-spacing: 2px; }
.plate-ksa { background: var(--green-700); color: #fff; font-size: 8px; padding: 4px 3px !important; writing-mode: vertical-rl; letter-spacing: 1px; }

/* ---------- phone / map ---------- */
.phone-cell { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.phone-cell a[dir=ltr] { color: var(--text); font-variant-numeric: tabular-nums; }
.wa-btn { width: 24px; height: 24px; border-radius: 50%; background: #25D366; color: #fff !important; display: inline-grid; place-items: center; }
.wa-btn .ic { width: 14px; height: 14px; }
.map-link { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; font-size: 13px; }

/* ---------- KPIs ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.kpi-grid.five { grid-template-columns: repeat(5, 1fr); }
.kpi-grid.three { grid-template-columns: repeat(3, 1fr); }
.kpi {
  display: flex; gap: 12px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  font: inherit; text-align: right; color: inherit; position: relative; overflow: hidden;
}
button.kpi { cursor: pointer; transition: transform .12s, box-shadow .12s; }
button.kpi:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(22,32,43,.08); }
.kpi::after { content: ''; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 4px; background: var(--tone); }
.kpi-ic { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--tone-bg); color: var(--tone); flex: none; }
.kpi-label { display: block; font-size: 12.5px; color: var(--slate-500); font-weight: 500; }
.kpi-value { display: block; font-size: 22px; color: var(--slate-900); font-variant-numeric: tabular-nums; line-height: 1.3; }
.kpi-sub { display: block; font-size: 12px; color: var(--slate-500); }
.progress-kpi .progress { margin: 6px 0 2px; height: 10px; }
.tone-green { --tone: var(--green-700); --tone-bg: var(--green-100); }
.tone-blue { --tone: var(--st-new); --tone-bg: var(--st-new-bg); }
.tone-orange { --tone: var(--st-progress); --tone-bg: var(--st-progress-bg); }
.tone-sand { --tone: var(--sand-700); --tone-bg: var(--sand-100); }
.tone-slate { --tone: var(--slate-700); --tone-bg: #E9EDF1; }
.tone-purple { --tone: var(--st-confirmed); --tone-bg: var(--st-confirmed-bg); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -2px; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: right; font-weight: 600; color: var(--slate-500); font-size: 12px; background: var(--sand-50); padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid #F0EBE1; vertical-align: middle; white-space: nowrap; }
.table td.changes, .table td.wrap { white-space: normal; }
.dl-table.hide-project .c-project, .dl-table.hide-material .c-material, .dl-table.hide-truck .c-truck { display: none; }
.table tbody tr:hover { background: #FCFAF6; }
.table tfoot td { font-weight: 700; background: var(--sand-50); border-top: 2px solid var(--sand-300); }
.table.compact td, .table.compact th { padding: 6px 8px; }
.table td.changes { min-width: 220px; }
.row-new { background: #F7F9FF; }
.row-late td:first-child { box-shadow: inset -3px 0 0 #E0893A; }
.row-muted { opacity: .55; }
.row-edit { background: #FFFBEF !important; }
.row-edit select, .row-edit input { min-height: 34px; padding: 5px 8px; font-size: 13px; }
.dcell { display: inline-flex; flex-direction: column; line-height: 1.35; white-space: nowrap; }
.dcell small { color: var(--slate-500); font-size: 11.5px; }
.ord-link { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chg { display: block; font-size: 12.5px; }
.chg del { color: var(--slate-500); }

/* ---------- empty / notes ---------- */
.empty { text-align: center; padding: 30px 16px; color: var(--slate-500); }
.empty-ic { width: 54px; height: 54px; border-radius: 16px; background: var(--sand-100); color: var(--sand-700); display: grid; place-items: center; margin: 0 auto 10px; }
.empty-ic .ic { width: 26px; height: 26px; }
.empty strong { display: block; color: var(--slate-800); font-size: 15px; margin-bottom: 2px; }
.note { background: var(--sand-50); border: 1px solid var(--sand-200); border-radius: 10px; padding: 10px 14px; margin: 10px 0; font-size: 13px; }
.note .ic { margin-inline-end: 4px; }
.note-info { background: #EFF6FF; border-color: #CFE0FB; color: #1E3A8A; }
.note-warn { background: #FFF7EC; border-color: #F7D9AE; color: #92400E; }
.note-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

/* ---------- tabs & filters ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tab { padding: 10px 14px; color: var(--slate-500); font-weight: 600; border-bottom: 2.5px solid transparent; white-space: nowrap; margin-bottom: -1px; }
.tab:hover { color: var(--slate-900); text-decoration: none; }
.tab.active { color: var(--green-700); border-bottom-color: var(--green-700); }
.filters { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; padding: 14px 16px; }
.filters .f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--slate-500); min-width: 150px; flex: 0 1 180px; }
.filters .f.grow { flex: 1 1 240px; }
.filters .f input, .filters .f select { min-height: 36px; padding: 6px 10px; font-size: 13.5px; }
.filters .f .hint { font-weight: 400; min-height: 18px; }
.filter-actions { display: flex; gap: 8px; margin-inline-start: auto; }
.status-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; width: 100%; }
.filters .status-tabs { margin-bottom: 0; }
.stab { border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 5px 12px; font: inherit; font-size: 13px; font-weight: 600; color: var(--slate-700); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.stab em { font-style: normal; background: var(--sand-100); border-radius: 10px; padding: 0 7px; font-size: 11.5px; }
.stab.active { background: var(--slate-800); color: #fff; border-color: var(--slate-800); }
.stab.active em { background: rgba(255,255,255,.18); }
.stab.s-new.active { background: var(--st-new); border-color: var(--st-new); }
.stab.s-confirmed.active { background: var(--st-confirmed); border-color: var(--st-confirmed); }
.stab.s-in_progress.active { background: var(--st-progress); border-color: var(--st-progress); }
.stab.s-completed.active { background: var(--st-done); border-color: var(--st-done); }
.stab.s-cancelled.active { background: var(--st-cancel); border-color: var(--st-cancel); }
.segmented { display: inline-flex; background: var(--sand-100); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.segmented button { border: 0; background: none; font: inherit; font-size: 13px; font-weight: 600; padding: 5px 12px; border-radius: 8px; cursor: pointer; color: var(--slate-700); }
.segmented button.active { background: #fff; color: var(--green-700); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* ---------- order screens ---------- */
.order-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.order-card { display: flex; flex-direction: column; gap: 9px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); color: inherit; border-top: 4px solid var(--sand-300); transition: transform .12s, box-shadow .12s; }
.order-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 10px 26px rgba(22,32,43,.08); }
.order-card.s-new { border-top-color: var(--st-new); }
.order-card.s-confirmed { border-top-color: var(--st-confirmed); }
.order-card.s-in_progress { border-top-color: var(--st-progress); }
.order-card.s-completed { border-top-color: var(--st-done); }
.order-card.s-cancelled { border-top-color: var(--st-cancel); opacity: .8; }
.oc-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.oc-head strong { font-size: 15.5px; }
.oc-proj, .oc-foot { font-size: 13px; color: var(--slate-500); display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.oc-nums { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--slate-500); }
.oc-nums b { color: var(--slate-900); }
.order-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 22px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; margin-bottom: 4px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed #EEE7DA; font-size: 13.5px; }
.kv:last-child { border-bottom: 0; }
.kv > span { color: var(--slate-500); white-space: nowrap; }
.kv > b { text-align: left; font-weight: 600; }
.kv.total { border-top: 2px solid var(--sand-300); border-bottom: 0; margin-top: 4px; padding-top: 10px; font-size: 14.5px; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ''; position: absolute; right: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.timeline li { position: relative; padding: 0 28px 16px 0; }
.timeline li:last-child { padding-bottom: 0; }
.tl-dot { position: absolute; right: 1px; top: 5px; width: 14px; height: 14px; border-radius: 50%; border: 3px solid #fff; background: var(--slate-300); box-shadow: 0 0 0 1px var(--line); }
.tl-new .tl-dot { background: var(--st-new); }
.tl-confirmed .tl-dot { background: var(--st-confirmed); }
.tl-in_progress .tl-dot { background: var(--st-progress); }
.tl-completed .tl-dot { background: var(--st-done); }
.tl-cancelled .tl-dot { background: var(--st-cancel); }
.tl-delivery .tl-dot { background: var(--sand-500); }
.timeline b { font-size: 13.5px; }
.timeline p { font-size: 12.5px; color: var(--slate-700); }
.timeline small { color: var(--slate-500); font-size: 11.5px; line-height: 1.5; display: block; }
details summary { cursor: pointer; padding: 2px 0; }
details[open] summary { margin-bottom: 12px; }
.mini-info { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; background: var(--green-50); border: 1px solid #D4E8DD; border-radius: 10px; padding: 9px 12px; margin-top: 8px; font-size: 13px; }
.lines-table td { padding: 6px; }
.lines-table td:last-child { width: 44px; }
.sum-lines { margin: 4px 0; }
.review .table { margin: 8px 0; }
.confirm-msg { font-size: 14px; }

/* ---------- action lists (dashboard) ---------- */
.action-list { list-style: none; margin: 0; padding: 0; }
.action-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #F0EBE1; }
.action-list li:last-child { border-bottom: 0; }
.al-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: left; white-space: nowrap; }
.al-side small { color: var(--slate-500); }
.chart-box { position: relative; height: 290px; }

/* ---------- deliveries ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 14px; }
.date-nav { display: flex; align-items: center; gap: 6px; }
.date-nav input { width: 160px; }
.date-label { font-size: 13.5px; }
.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin-bottom: 16px; }
.wday { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 9px 6px; font: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 1px; color: var(--slate-700); transition: border-color .15s; }
.wday:hover { border-color: var(--sand-500); }
.wday .wd-name { font-weight: 700; font-size: 13px; }
.wday .wd-g { font-size: 12px; }
.wday .wd-h { font-size: 11px; color: var(--slate-500); }
.wday .wd-c { font-size: 12px; font-weight: 600; color: var(--green-700); margin-top: 3px; display: flex; flex-direction: column; align-items: center; }
.wday .wd-c em { font-style: normal; color: var(--st-confirmed); font-weight: 500; font-size: 11px; }
.wday.weekend { background: repeating-linear-gradient(135deg, #F7F5F0, #F7F5F0 6px, #F1EEE7 6px, #F1EEE7 12px); color: var(--slate-500); }
.wday.weekend .wd-c { color: var(--slate-500); }
.wday.is-today { border-color: var(--sand-500); }
.wday.active { background: var(--green-700); border-color: var(--green-700); color: #fff; }
.wday.active .wd-h, .wday.active .wd-c, .wday.active .wd-c em { color: #E6F2EC; }
.dl-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.dl-form-card { position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow-y: auto; }
.dl-group { padding: 0; overflow: hidden; }
.dl-group .table-wrap { margin: 0; }
.dl-group-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; background: linear-gradient(90deg, var(--sand-50), #fff); border-bottom: 1px solid var(--line); }
.dl-gh-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dl-gh-title small { color: var(--slate-500); width: 100%; padding-inline-start: 26px; margin-top: -4px; }
.dl-gh-tot { display: flex; gap: 12px; align-items: center; white-space: nowrap; font-variant-numeric: tabular-nums; }
.dl-gh-tot b { color: var(--green-700); font-size: 15px; }
.remaining-box { display: grid; grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); gap: 6px; margin: -4px 0 12px; }
.remaining-box:empty { display: none; }
.remaining-box > div { background: var(--sand-50); border: 1px solid var(--sand-200); border-radius: 9px; padding: 6px 8px; text-align: center; }
.remaining-box span { display: block; font-size: 11px; color: var(--slate-500); }
.remaining-box b { font-size: 13px; font-variant-numeric: tabular-nums; }
.remaining-box .rem { background: #FFF5EA; border-color: #F5D8B3; }
.remaining-box .ok { background: var(--st-done-bg); border-color: #BFE3CB; }

/* ---------- settings ---------- */
.days-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day-check { border: 1px solid var(--line); border-radius: 10px; padding: 10px 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; font-size: 12.5px; font-weight: 600; }
.day-check.weekend { background: #F7F5F0; }
.future-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.disabled-card { background: #FCFBF8; }
.danger-zone { border-color: #F5C2BE; }

/* ---------- notifications ---------- */
.dropdown { position: absolute; top: calc(100% + 8px); left: 0; width: 380px; max-width: calc(100vw - 24px); background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 16px 48px rgba(22,32,43,.18); z-index: 50; overflow: hidden; }
.dd-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.dd-list { max-height: 420px; overflow-y: auto; }
.dd-foot { display: block; width: 100%; border: 0; border-top: 1px solid var(--line); background: var(--sand-50); padding: 10px; font: inherit; font-weight: 600; color: var(--green-700); cursor: pointer; }
.notif { display: flex; gap: 10px; width: 100%; text-align: right; border: 0; border-bottom: 1px solid #F2EEE6; background: #fff; padding: 12px 14px; font: inherit; cursor: pointer; color: inherit; }
.notif:hover { background: var(--sand-50); }
.notif.unread { background: #F5FAF7; }
.notif.unread strong::after { content: ''; display: inline-block; width: 7px; height: 7px; background: #D92D20; border-radius: 50%; margin-inline-start: 6px; vertical-align: middle; }
.notif-ic { width: 34px; height: 34px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--sand-100); color: var(--sand-700); }
.notif-ic.t-order_created { background: var(--st-new-bg); color: var(--st-new); }
.notif-ic.t-order_confirmed { background: var(--st-confirmed-bg); color: var(--st-confirmed); }
.notif-ic.t-delivery { background: var(--st-progress-bg); color: var(--st-progress); }
.notif-ic.t-order_completed { background: var(--st-done-bg); color: var(--st-done); }
.notif-ic.t-order_cancelled { background: var(--st-cancel-bg); color: var(--st-cancel); }
.notif-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.notif-body strong { font-size: 13.5px; }
.notif-body span { font-size: 13px; color: var(--slate-700); }
.notif-body small { color: var(--slate-500); font-size: 11.5px; }
.notif-page { padding: 0; overflow: hidden; }

/* ---------- toasts & modal ---------- */
.toasts { position: fixed; bottom: 20px; left: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 40px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; background: var(--slate-900); color: #fff; padding: 12px 14px; border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.25); font-size: 13.5px; animation: toastIn .25s ease-out; transition: opacity .35s, transform .35s; }
.toast.out { opacity: 0; transform: translateY(8px); }
.toast strong { display: block; color: var(--sand-300); }
.toast-ic { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; flex: none; background: rgba(255,255,255,.1); }
.toast-success .toast-ic { background: var(--green-600); }
.toast-error { background: #7A1A12; }
.toast-info { background: var(--green-900); }
.toast-info .toast-ic { background: var(--sand-500); color: var(--slate-900); }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } }
.modal-backdrop { position: fixed; inset: 0; background: rgba(22,32,43,.5); z-index: 100; display: grid; place-items: center; padding: 16px; animation: fadeIn .15s; }
@keyframes fadeIn { from { opacity: 0; } }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 24px 64px rgba(0,0,0,.3); animation: modalIn .18s ease-out; }
.modal.sm { max-width: 480px; }
.modal.md { max-width: 520px; }
.modal.lg { max-width: 760px; }
@keyframes modalIn { from { transform: translateY(10px) scale(.98); opacity: 0; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 16.5px; }
.modal-head .icon-btn { width: 34px; height: 34px; border: 0; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-start; gap: 8px; flex-direction: row-reverse; background: var(--sand-50); border-radius: 0 0 16px 16px; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .kpi-grid.five { grid-template-columns: repeat(3, 1fr); }
  .grid-main-side, .dl-layout { grid-template-columns: minmax(0, 1fr) 320px; }
}
@media (max-width: 1080px) {
  .grid-main-side, .dl-layout, .grid-2-1 { grid-template-columns: minmax(0, 1fr); }
  .sticky, .dl-form-card { position: static; max-height: none; }
  .dl-form-card { order: -1; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .user-meta { display: none; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; right: 0; top: 0; bottom: 0; width: 280px; z-index: 80; transform: translateX(100%); transition: transform .25s; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 70; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 8px 12px; gap: 8px; flex-wrap: wrap; }
  .topbar-title h1 { font-size: 16px; }
  .topbar-actions { width: 100%; order: 3; }
  .role-switch { flex: 1; }
  .role-switch button { flex: 1; padding: 6px 6px; }
  .customer-switch { flex: 1; max-width: none; }
  .view { padding: 14px 12px 40px; }
  .grid-2, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .week-strip { grid-template-columns: repeat(7, minmax(84px, 1fr)); overflow-x: auto; }
  .days-grid { grid-template-columns: repeat(4, 1fr); }
  .filters .f { flex: 1 1 140px; }
  .filter-actions { width: 100%; margin: 0; }
  .page-head h2 { font-size: 19px; }
  .order-cards { grid-template-columns: 1fr; }
  .modal-backdrop { place-items: end center; padding: 0; }
  .modal { max-height: 92vh; border-radius: 16px 16px 0 0; }
}
@media (max-width: 520px) {
  .kpi-grid, .kpi-grid.five, .kpi-grid.three { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px; }
  .kpi-ic { display: none; }
  .kpi-value { font-size: 18px; }
  .user-chip { display: none; }
  .toolbar .segmented { width: 100%; }
  .toolbar .segmented button { flex: 1; padding: 5px 4px; }
  .plate-input { grid-template-columns: repeat(3, 1fr) 1.4fr; }
  .field.inline { flex-direction: column; align-items: stretch; }
}

/* ---------- print ---------- */
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 11.5px; }
  .sidebar, .topbar, .no-print, .toasts, #modal-root, .tabs, .filters, .row-actions, .menu-btn { display: none !important; }
  .app { display: block; }
  .view { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; padding: 10px; margin-bottom: 10px; }
  .chart-box { height: 220px; }
  .table th { background: #f2f2f2 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-header { display: flex !important; justify-content: space-between; align-items: center; gap: 16px; border-bottom: 2px solid var(--green-700); padding-bottom: 10px; margin-bottom: 14px; }
  .ph-company { display: flex; gap: 10px; align-items: center; }
  .ph-company svg { width: 40px; height: 40px; }
  .ph-company strong { display: block; font-size: 14px; }
  .ph-company span { display: block; font-size: 10.5px; color: #444; }
  .ph-title { text-align: center; }
  .ph-title h2 { font-size: 16px; }
  .ph-title p { font-size: 10.5px; color: #444; }
  .ph-date { text-align: left; font-size: 10.5px; }
  .grid-main-side, .grid-2, .grid-2-1 { display: block; }
  .kpi-grid { grid-template-columns: repeat(4, 1fr) !important; }
  .kpi { box-shadow: none; padding: 8px; }
  .kpi-ic { display: none; }
  a { color: inherit; }
  details > *:not(summary) { display: none; }

  body.printing-note #app { display: none !important; }
  body.printing-note #print-area { display: block !important; }
}
.dn { font-size: 12.5px; color: #111; }
.dn-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 3px double var(--green-700); padding-bottom: 12px; margin-bottom: 14px; }
.dn-co { display: flex; gap: 12px; align-items: center; }
.dn-logo svg { width: 56px; height: 56px; }
.dn-co h2 { font-size: 16px; }
.dn-co p { font-size: 11px; color: #444; margin: 1px 0; }
.dn-title { text-align: center; }
.dn-title h1 { font-size: 24px; color: var(--green-800); }
.dn-title span { display: block; font-size: 11px; letter-spacing: 2px; color: #666; }
.dn-no { margin-top: 6px; border: 1.5px solid #111; padding: 3px 12px; font-weight: 700; font-size: 15px; display: inline-block; }
.dn h3 { font-size: 13px; background: #f1f1f1; padding: 5px 10px; margin: 12px 0 6px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.dn-meta, .dn-items { width: 100%; border-collapse: collapse; }
.dn-meta th, .dn-meta td, .dn-items th, .dn-items td { border: 1px solid #bbb; padding: 6px 8px; text-align: right; vertical-align: top; }
.dn-meta th { background: #fafafa; width: 16%; font-weight: 600; white-space: nowrap; }
.dn-items th { background: #eef4f1; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.dn-items td { font-size: 13px; }
.dn-notes { margin: 10px 0; }
.dn-sign { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 26px; }
.dn-sign div { border: 1px solid #bbb; border-radius: 6px; padding: 10px; min-height: 120px; display: flex; flex-direction: column; gap: 10px; }
.dn-sign b { border-bottom: 1px solid #ddd; padding-bottom: 4px; }
.dn-foot { margin-top: 18px; font-size: 10.5px; color: #555; border-top: 1px solid #ddd; padding-top: 6px; text-align: center; }
.edit-cell select { display: block; margin-bottom: 6px; min-width: 260px; }
