/* =========================================================================
   DataExpert Lab ERP — stylesheet
   ========================================================================= */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #0284c7;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --dark: #0f172a;
  --dark-2: #1e293b;
  --page: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #334155;
  --muted: #64748b;
  --radius: 12px;
  --shadow: 0 10px 25px -5px rgba(0,0,0,.05), 0 8px 10px -6px rgba(0,0,0,.01);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--page);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body.modal-open { overflow: hidden; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ------------------------------- Header --------------------------------- */
.navbar {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #fff;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-logo {
  height: 40px;
  background: #fff;
  padding: 4px 10px;
  border-radius: 8px;
  object-fit: contain;
}

.brand-title { font-size: 1.15rem; font-weight: 800; letter-spacing: -.4px; }
.sub-title { font-size: .75rem; color: #94a3b8; }

.nav-tabs {
  display: flex;
  gap: 6px;
  background: rgba(255,255,255,.06);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.1);
  flex-wrap: wrap;
}

.tab-btn {
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #94a3b8;
  font: inherit;
  font-size: .84rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, color .2s;
}

.tab-btn:hover { color: #fff; background: rgba(255,255,255,.1); }

.tab-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 4px 12px rgba(37,99,235,.4);
}

.nav-actions { display: flex; gap: 10px; align-items: center; }

/* ------------------------------- Buttons -------------------------------- */
.btn {
  padding: 9px 16px;
  border: none;
  border-radius: 8px;
  font: inherit;
  font-size: .86rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: transform .15s, box-shadow .15s, background .15s;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 4px 10px rgba(37,99,235,.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 15px rgba(37,99,235,.4); }

.btn-success { background: linear-gradient(135deg, var(--success), #059669); color: #fff; }
.btn-success:hover { transform: translateY(-1px); }

.btn-outline {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: #f8fafc; }
.btn-outline.danger { color: var(--danger); border-color: #fecaca; }
.btn-outline.danger:hover { background: #fef2f2; }

.btn-ghost {
  background: rgba(255,255,255,.08);
  border: 1px solid #475569;
  color: #e2e8f0;
}
.btn-ghost:hover { background: #334155; }
.btn-ghost.wa-set { border-color: #22c55e; color: #86efac; background: rgba(34,197,94,.12); }

.file-btn { position: relative; }

/* ------------------------------ Container ------------------------------- */
.app-container { padding: 22px; max-width: 1800px; margin: 0 auto; }

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn .25s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* -------------------------------- KPIs ---------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card {
  background: #fff;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: transform .2s;
}
.kpi-card:hover { transform: translateY(-3px); }
.kpi-card.kpi-alert { border-color: #fecaca; }

.kpi-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 1.35rem;
  flex-shrink: 0;
}
.kpi-blue   { background: #eff6ff; }
.kpi-green  { background: #ecfdf5; }
.kpi-amber  { background: #fffbeb; }
.kpi-purple { background: #faf5ff; }
.kpi-red    { background: #fef2f2; }

.kpi-label { font-size: .76rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .3px; }
.kpi-value { font-size: 1.7rem; font-weight: 800; color: var(--dark); line-height: 1.15; margin-top: 2px; }
.kpi-sub   { font-size: .74rem; color: var(--muted); font-weight: 600; margin-top: 3px; }

/* ------------------------------ Dashboard ------------------------------- */
.analytics-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
.analytics-grid.three { grid-template-columns: repeat(3, 1fr); }

.dashboard-card {
  background: #fff;
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.card-title small { font-size: .76rem; color: var(--muted); font-weight: 600; }

.stat-bar-group { display: flex; flex-direction: column; gap: 12px; }

.stat-label-flex {
  display: flex;
  justify-content: space-between;
  font-size: .82rem;
  font-weight: 600;
  margin-bottom: 4px;
  gap: 10px;
}

.progress-track { background: #e2e8f0; height: 9px; border-radius: 10px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 10px; transition: width .5s ease; }

.empty-note { font-size: .82rem; color: var(--muted); padding: 10px 0; }

/* ------------------------------ Mini lists ------------------------------ */
.mini-list { display: flex; flex-direction: column; }

.mini-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: .86rem;
}
.mini-row:last-child { border-bottom: none; }

.mini-sub { font-size: .74rem; color: var(--muted); font-weight: 500; margin-top: 2px; }
.mini-sub.overdue { color: var(--danger); font-weight: 700; }
.mini-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* -------------------------------- Chips --------------------------------- */
.chip {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
}
.chip-green   { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.chip-amber   { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.chip-red     { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.chip-slate   { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }
.chip-paid    { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.chip-partial { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.chip-unpaid  { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.chip-none    { background: #f1f5f9; color: #64748b; border-color: #cbd5e1; }

/* ------------------------------- Toolbar -------------------------------- */
.toolbar {
  background: #fff;
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.toolbar-left { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar-hint { font-size: .8rem; color: var(--muted); }

.search-input, .filter-select {
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: .88rem;
  background: #fff;
  color: var(--text);
}
.search-input { width: 300px; max-width: 100%; }

/* ------------------------------ Data bar -------------------------------- */
.data-bar {
  background: #fff;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: .86rem;
}
.data-bar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* -------------------------------- Kanban -------------------------------- */
.kanban-board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(272px, 1fr);
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 18px;
}

.kanban-column {
  background: #e6ebf2;
  border-radius: var(--radius);
  padding: 12px;
  min-height: 620px;
  display: flex;
  flex-direction: column;
  transition: background .15s, box-shadow .15s;
}
.kanban-column.drop-target {
  background: #dbeafe;
  box-shadow: inset 0 0 0 2px var(--primary);
}

.column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 2px solid #cbd5e1;
}
.column-title { font-size: .8rem; font-weight: 800; text-transform: uppercase; color: #475569; letter-spacing: .3px; }

.job-count {
  background: #fff;
  padding: 2px 9px;
  border-radius: 12px;
  font-size: .74rem;
  font-weight: 800;
  color: var(--dark);
}

.column-value { font-size: .74rem; color: #64748b; font-weight: 700; margin: 6px 0 10px; min-height: 14px; }

.cards-container { display: flex; flex-direction: column; gap: 12px; flex: 1; }

.column-empty {
  font-size: .78rem;
  color: #94a3b8;
  text-align: center;
  padding: 22px 8px;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
}

.kanban-card {
  background: #fff;
  border-radius: 10px;
  padding: 13px;
  box-shadow: 0 2px 4px rgba(0,0,0,.05);
  border-left: 5px solid var(--primary);
  cursor: grab;
  transition: transform .15s, box-shadow .15s, opacity .15s;
}
.kanban-card:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(0,0,0,.1); }
.kanban-card.dragging { opacity: .45; cursor: grabbing; }

.card-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.ticket-id { font-weight: 800; font-size: .86rem; color: var(--primary); }

.device-badge {
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: .7rem;
  font-weight: 700;
  color: #475569;
  white-space: nowrap;
}

.card-customer { font-weight: 700; font-size: .92rem; color: var(--dark); }
.card-sub { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.card-serial { font-size: .72rem; font-family: ui-monospace, 'Courier New', monospace; margin-top: 4px; color: #475569; }

.card-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }

.stage-select-label {
  display: block;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 10px;
  letter-spacing: .3px;
}
.stage-select {
  width: 100%;
  margin-top: 3px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  font-size: .8rem;
  background: #f8fafc;
  color: var(--text);
}

.card-actions { margin-top: 7px; display: flex; gap: 5px; flex-wrap: wrap; }

.action-btn {
  font: inherit;
  font-size: .73rem;
  padding: 5px 9px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  transition: background .15s;
}
.action-btn:hover { background: #e2e8f0; }
.action-btn.wa { color: #15803d; background: #f0fdf4; border-color: #bbf7d0; }
.action-btn.wa:hover { background: #dcfce7; }
.action-btn.danger { color: var(--danger); border-color: #fecaca; background: #fef2f2; }
.action-btn.danger:hover { background: #fee2e2; }

/* ------------------------------- Tables --------------------------------- */
.custom-table-container {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.data-table { width: 100%; border-collapse: collapse; min-width: 940px; }

.data-table th, .data-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: .87rem;
  vertical-align: top;
}

.data-table th {
  background: #f8fafc;
  font-weight: 800;
  color: #475569;
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .3px;
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table tr:hover td { background: #f8fafc; }
.data-table .num, .data-table th.num { text-align: right; }
.cell-id { font-weight: 800; color: var(--primary); white-space: nowrap; }
.mono { font-family: ui-monospace, 'Courier New', monospace; font-size: .8rem; }
.pcb { color: #be123c; font-weight: 700; }
.row-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.table-empty { text-align: center; color: var(--muted); padding: 34px 14px; font-size: .88rem; }

/* -------------------------------- Modals -------------------------------- */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.72);
  backdrop-filter: blur(5px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 18px;
}
.modal.active { display: flex; }

.modal-content {
  background: #fff;
  width: 820px;
  max-width: 100%;
  max-height: 94vh;
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,.35);
}
.modal-content.narrow { width: 520px; }
#inboxModal .modal-content { width: 800px; }
#inboxModal .modal-header h3 { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#inboxModal .modal-header .btn { flex: 0 0 auto; }
.inbox-tools { padding: 10px 16px; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.inbox-tools input, .inbox-tools select, .inbox-tools textarea { width: 100%; margin: 6px 0; }
.inbox-tabs, .inbox-actions, .inbox-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.inbox-tabs .btn { flex: 1; padding: 8px 6px; }
.inbox-auto { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.inbox-tools .inbox-auto input { width: 16px; height: 16px; margin: 0; }
.inbox-chips .btn, .inbox-actions .btn { font-size: 12px; padding: 7px 10px; }
#inboxReplyTools { max-height: 26dvh; overflow-y: auto; }
#inboxReplyTools details { margin-top: 8px; font-size: 13px; }
#inboxQuickManage > div { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin: 6px 0; }
#inboxTemplatePanel { max-height: 25dvh; overflow-y: auto; padding-top: 8px; }
#inboxForm .btn { width: auto; flex: 0 0 auto; }
.modal-content.wide { width: 950px; }

.modal-header {
  background: var(--dark);
  color: #fff;
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.modal-header h3 { font-size: 1.02rem; font-weight: 700; }
.modal-header.wa-header { background: #075e54; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-body.doc-body { background: #e2e8f0; padding: 18px; }

.modal-footer {
  padding: 14px 20px;
  background: #f8fafc;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* --------------------------------- Forms -------------------------------- */
.form-section {
  font-size: .74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  margin: 4px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.form-section:not(:first-child) { margin-top: 22px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }

label { font-size: .8rem; font-weight: 600; color: #475569; }

input, select, textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: .88rem;
  color: var(--text);
  background: #fff;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
textarea { resize: vertical; }
.mono-area { font-family: ui-monospace, 'Courier New', monospace; font-size: .82rem; background: #f8fafc; }

.field-hint { font-size: .74rem; color: var(--muted); }

#serialWarning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  padding: 10px 13px;
  border-radius: 8px;
  font-size: .82rem;
  line-height: 1.5;
}

.tax-preview {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px 15px;
}
.tax-row { display: flex; justify-content: space-between; gap: 12px; font-size: .86rem; padding: 4px 0; }
.tax-row.tax-total {
  border-top: 1px solid #cbd5e1;
  margin-top: 5px;
  padding-top: 8px;
  font-weight: 800;
  color: var(--dark);
  font-size: .95rem;
}
.tax-row.tax-warn { color: var(--danger); font-weight: 700; }
.tax-note { font-size: .74rem; color: var(--muted); margin-top: 8px; }

.info-box {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  color: #0c4a6e;
  border-radius: 10px;
  padding: 12px 15px;
  font-size: .82rem;
  line-height: 1.55;
  margin-top: 14px;
}
.info-box.amber { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.info-box strong { display: block; margin-bottom: 4px; }
.info-box p + p { margin-top: 7px; }

.recipient { font-size: .88rem; margin-bottom: 13px; }

/* -------------------------------- Toasts -------------------------------- */
.toast-host {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-width: min(360px, calc(100vw - 40px));
}

.toast {
  background: var(--dark);
  color: #fff;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: .85rem;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0,0,0,.25);
  border-left: 4px solid var(--primary);
  animation: toastIn .22s ease;
}
.toast-success { border-left-color: var(--success); }
.toast-error   { border-left-color: var(--danger); }
.toast-warn    { border-left-color: var(--warning); }
.toast-out { opacity: 0; transform: translateX(14px); transition: opacity .28s, transform .28s; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(18px); }
  to { opacity: 1; transform: none; }
}

/* ------------------------- A4 printable documents ----------------------- */
.document-a4 {
  background: #fff;
  width: 210mm;
  min-height: 297mm;
  padding: 14mm 15mm;
  margin: 0 auto;
  font-size: 12px;
  color: #000;
  line-height: 1.42;
  box-shadow: 0 0 20px rgba(0,0,0,.15);
}

.doc-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  border-bottom: 2px solid #000;
  padding-bottom: 10px;
  margin-bottom: 13px;
}
.doc-head-left { display: flex; align-items: flex-start; gap: 12px; }
.doc-logo { max-height: 56px; object-fit: contain; }
.doc-company { font-size: 10.5px; line-height: 1.45; }
.doc-company strong { font-size: 13px; }
.doc-head-right { text-align: right; flex-shrink: 0; }
.doc-head-right h2 { font-size: 19px; letter-spacing: 1px; margin-bottom: 4px; }
.doc-head-right p { font-size: 11px; }

.doc-party {
  border: 1px solid #000;
  padding: 9px 11px;
  margin-bottom: 13px;
  font-size: 11.5px;
  line-height: 1.5;
}

.doc-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.doc-table th, .doc-table td { border: 1px solid #000; padding: 6px 8px; text-align: left; font-size: 11px; }
.doc-table th { background: #f2f2f2; font-weight: 700; }
.doc-table .num, .doc-table th.num { text-align: right; }
.doc-table .doc-total-row td { background: #f2f2f2; font-size: 12.5px; }
.doc-table.doc-pay { width: 58%; margin-left: auto; }
.doc-small { font-size: 10px; color: #444; }
.doc-words { font-size: 11px; margin-bottom: 13px; }

.bank-details-box {
  border: 1px solid #000;
  padding: 9px 11px;
  margin-bottom: 13px;
  font-size: 11px;
  line-height: 1.6;
}
.bank-details-box strong:first-child { display: block; margin-bottom: 3px; text-decoration: underline; }

.notes-box { font-size: 10.5px; line-height: 1.5; margin-bottom: 18px; }
.notes-box strong { text-decoration: underline; }
.notes-box ol { margin: 5px 0 0 18px; }
.notes-box li { margin-bottom: 3px; }
.doc-declaration { margin-top: 8px; font-style: italic; }

.sign-area {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 34px;
  font-size: 10.5px;
}
.sign-right { text-align: right; }

/* --------------------------------- Print -------------------------------- */
@page { size: A4; margin: 0; }

@media print {
  body { background: #fff; }
  body > *:not(.modal) { display: none !important; }
  .modal { display: none !important; }

  body.printing #docModal {
    display: block !important;
    position: static;
    background: none;
    backdrop-filter: none;
    padding: 0;
    inset: auto;
  }
  body.printing #docModal .modal-header,
  body.printing #docModal .modal-footer { display: none !important; }

  body.printing #docModal .modal-content {
    display: block;
    width: auto;
    max-width: none;
    max-height: none;
    box-shadow: none;
    border-radius: 0;
    overflow: visible;
  }
  body.printing #docModal .modal-body {
    padding: 0;
    background: #fff;
    overflow: visible;
    max-height: none;
  }
  .document-a4 {
    box-shadow: none;
    margin: 0;
    width: 100%;
    min-height: 0;
    padding: 12mm 14mm;
  }
  .doc-table { page-break-inside: avoid; }
}

/* ------------------------------ Responsive ------------------------------ */
@media (max-width: 1200px) {
  .analytics-grid, .analytics-grid.three { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
  .navbar { padding: 12px 16px; }
  .nav-tabs { order: 3; width: 100%; overflow-x: auto; }
  .app-container { padding: 14px; }
  .analytics-grid, .analytics-grid.three { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-group.full { grid-column: 1; }
  .search-input { width: 100%; }
  .toolbar-left { width: 100%; }
  .kanban-board { grid-auto-columns: minmax(258px, 84vw); }
  .modal { padding: 0; align-items: stretch; }
  .modal-content, .modal-content.narrow, .modal-content.wide {
    width: 100%; max-width: 100%; max-height: 100vh; border-radius: 0;
  }
  .modal-footer { justify-content: stretch; }
  .modal-footer .btn { flex: 1; justify-content: center; }
  .data-bar-actions { width: 100%; }
  .data-bar-actions .btn { flex: 1; justify-content: center; }
}

@media (max-width: 600px) {
  .brand-title { font-size: 1rem; }
  .sub-title { display: none; }
  .kpi-value { font-size: 1.45rem; }
  .document-a4 { width: 100%; padding: 10mm; }
}

/* ===================== DATA EXPERT bill (Drive layout) =====================
   Rebuilt from the bill the owner had been filling in by hand in Google Docs,
   so the printed page a customer receives is unchanged — only the typing goes
   away. Kept apart from .doc-* so the older quotation/invoice still print as
   they did. Print rules live with the existing @media print block.          */
.de-bill { position: relative; overflow: hidden; padding: 0 34px 26px; font-family: "Times New Roman", Times, serif; color: #000; }
.de-ribbon { position: absolute; top: 0; right: 0; width: 0; height: 0; border-top: 62px solid #1b9ad6; border-left: 150px solid transparent; }
.de-watermark { position: absolute; top: 40%; left: 50%; width: 330px; transform: translate(-50%, -50%); opacity: .07; pointer-events: none; }

.de-top { display: flex; justify-content: space-between; align-items: flex-start; padding-top: 14px; }
.de-logo { width: 240px; height: auto; }
.de-top-right { text-align: right; font-size: 13px; padding-top: 46px; }
.de-invno { font-size: 11px; color: #555; margin-top: 3px; }

.de-to { margin: 26px 0 30px; font-size: 13.5px; line-height: 1.75; position: relative; }
.de-to-label { margin-bottom: 4px; }
.de-k { color: #444; }

.de-table { width: 100%; border-collapse: collapse; font-size: 12.5px; position: relative; }
.de-table th, .de-table td { border: 1px solid #000; padding: 6px 7px; vertical-align: middle; }
.de-table th { text-align: center; font-weight: 700; }
.de-table td { text-align: center; }
.de-table .num { text-align: right; }
.de-table th.num { text-align: center; }
.de-serial { line-height: 1.45; }
.de-grand td { border-top: 1px solid #000; }

.de-split { font-size: 11px; color: #444; margin: 7px 0 0; }
.de-words { font-size: 12px; margin: 10px 0 0; }

.de-bank { margin-top: 26px; font-size: 12.5px; line-height: 1.6; }
.de-note { margin-top: 16px; font-size: 12.5px; display: flex; gap: 10px; line-height: 1.6; }
.de-note-lbl { white-space: nowrap; }

.de-sign { margin-top: 54px; text-align: right; font-size: 13px; }
.de-foot { margin-top: 42px; font-size: 12.5px; line-height: 1.55; }

/* ---- serial barcode scanner ---- */
.serial-row { display: flex; gap: 8px; align-items: stretch; }
.serial-row input { flex: 1; }
.btn-scan { flex: 0 0 auto; width: 46px; font-size: 19px; line-height: 1; cursor: pointer;
  border: 1px solid var(--line, #d7dce5); border-radius: 8px; background: var(--surface, #f3f5f9); }
.btn-scan:hover { background: var(--surface-2, #e7ecf5); }

#scanOverlay { position: fixed; inset: 0; z-index: 4000; background: rgba(8,12,20,.94);
  display: grid; place-items: center; padding: 18px; }
#scanOverlay .scan-box { width: min(94vw, 460px); text-align: center; position: relative; }
#scanVideo { width: 100%; border-radius: 12px; background: #000; aspect-ratio: 3/4; object-fit: cover; }
#scanOverlay .scan-frame { position: absolute; left: 8%; right: 8%; top: 34%; height: 18%;
  border: 2px solid #38bdf8; border-radius: 8px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.28); }
#scanOverlay .scan-hint { color: #cbd5e1; font-size: 13px; margin: 12px 0 10px; }

/* NAV_ACTIONS_WRAP (2026-09-29): three header buttons sat in one non-wrapping row and the
   last of them — "New case", the one thing the shop presses all day — ended exactly at the
   screen edge on a phone, so on anything narrower it was clipped. Let the row wrap and give
   the primary action its own full-width line when space runs out. */
@media (max-width: 680px) {
  .nav-actions { flex-wrap: wrap; gap: 8px; }
  .nav-actions .btn-primary { flex: 1 1 100%; justify-content: center; }
}

/* ===================== Professional UI polish (2026-09-30) =====================
   Server-served CRM skin used by web and APK. Keeps workflows intact while making
   the interface calmer, denser, and less template-like. */
:root {
  --primary: #1f5eff;
  --primary-dark: #1746c7;
  --accent: #0f766e;
  --dark: #111827;
  --dark-2: #1f2937;
  --page: #f6f8fb;
  --border: #dde5f0;
  --text: #243044;
  --muted: #6b778c;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.06);
}

body { letter-spacing: 0; }

.navbar {
  background: #111827;
  padding: 12px 22px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  flex-wrap: nowrap;
  gap: 18px;
  box-shadow: 0 1px 0 rgba(255,255,255,.08), 0 10px 32px rgba(15,23,42,.18);
}

.brand-logo { height: 38px; padding: 5px 9px; border-radius: 6px; }
.brand-title { font-size: 1.06rem; letter-spacing: 0; }
.sub-title { color: #aab7cc; }

.nav-tabs {
  justify-self: center;
  max-width: 100%;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 4px;
  border-radius: 8px;
}

.tab-btn {
  padding: 8px 12px;
  border-radius: 6px;
  color: #b8c4d8;
  font-size: .82rem;
  font-weight: 700;
  white-space: nowrap;
}

.tab-btn.active {
  background: #fff;
  color: #111827;
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
}

.nav-actions { gap: 8px; justify-content: flex-end; }
.btn-utility { background: rgba(255,255,255,.06); color: #d9e4f5; }
.btn-utility.wa-set { color: #bbf7d0; border-color: rgba(34,197,94,.45); background: rgba(34,197,94,.11); }

.btn {
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: .84rem;
  font-weight: 700;
  justify-content: center;
  transition: box-shadow .15s, background .15s, border-color .15s, color .15s;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 8px 18px rgba(31,94,255,.22);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); transform: none; }
.btn-success { background: #059669; border-color: #059669; }
.btn-success:hover { background: #047857; transform: none; }
.btn-outline:hover { border-color: #cbd5e1; }

.app-container { max-width: 1480px; }

.kpi-grid { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.kpi-card { display: block; padding: 16px 17px; }
.kpi-card:hover { transform: none; box-shadow: 0 1px 2px rgba(15,23,42,.05), 0 12px 28px rgba(15,23,42,.08); }
.kpi-card.kpi-alert { border-color: #fecaca; box-shadow: inset 3px 0 0 #ef4444, var(--shadow); }
.kpi-icon { display: none; }
.kpi-label { font-size: .72rem; font-weight: 800; letter-spacing: .5px; }
.kpi-value { margin-top: 7px; font-size: 1.85rem; letter-spacing: 0; }

.dashboard-card { padding: 18px; }
.toolbar { padding: 12px 14px; }

.data-bar {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 12px 14px;
  font-size: .82rem;
  color: #475569;
  margin-top: 2px;
}
.data-bar strong { color: #334155; font-size: .82rem; }
.data-bar .btn { padding: 6px 10px; font-size: .78rem; box-shadow: none; }
.data-bar-actions { gap: 7px; }

.kanban-column { background: #eef2f7; }
.kanban-card {
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(15,23,42,.06);
  border: 1px solid #e5edf6;
  border-left: 4px solid var(--primary);
}
.kanban-card:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(15,23,42,.1); }

.action-btn { padding: 5px 8px; }
.modal-header { background: #111827; }

.btn-scan {
  width: auto;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 800;
  color: #334155;
}

@media (max-width: 900px) {
  .navbar { grid-template-columns: 1fr; padding: 12px 14px; gap: 10px; }
  .brand { justify-content: space-between; width: 100%; }
  .nav-tabs { width: 100%; justify-self: stretch; }
  .nav-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .nav-actions .btn-primary { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
  .brand-logo { height: 34px; }
  .tab-btn { padding: 7px 10px; font-size: .78rem; }
  .btn { min-height: 38px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-card { padding: 13px; }
  .kpi-value { font-size: 1.45rem; }
  .data-bar { align-items: stretch; }
  .data-bar > div:first-child { width: 100%; display: grid; gap: 7px; }
}

/* ===================== Super-app shell (2026-09-30) =====================
   Tabler-style icons (inline sprite, MIT) + phone bottom navigation,
   partner shops, reviews and a Settings screen. */
.ico { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.btn .ico { margin-right: 6px; }
.btn { display: inline-flex; align-items: center; }

.chip-partner { background: #eef2ff; color: #3730a3; }
.partner-tag { color: #4f46e5; font-weight: 600; }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.settings-grid .form-group { margin-bottom: 14px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: #f8fafc; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.danger-zone { margin-top: 16px; border-top: 1px dashed var(--border); padding-top: 12px; }
.danger-zone summary { cursor: pointer; font-size: .82rem; font-weight: 700; color: #b91c1c; }
.danger-zone p { margin-top: 8px; }
#saveStamp { display: block; margin-top: 2px; }

.bottom-nav { display: none; }
.more-sheet { display: none; }

@media (max-width: 680px) {
  .navbar { position: sticky; top: 0; z-index: 50; grid-template-columns: 1fr auto; padding: 10px 14px; gap: 10px; }
  .navbar .nav-tabs, .navbar .btn-utility { display: none; }
  .brand { width: auto; justify-content: flex-start; }
  .nav-actions { width: auto; display: flex; }
  .nav-actions .btn-primary { flex: 0 0 auto; padding: 8px 12px; }
  .app-container { padding: 12px 12px calc(84px + env(safe-area-inset-bottom)); }

  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: #fff; border-top: 1px solid var(--border); box-shadow: 0 -6px 20px rgba(15,23,42,.06);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bottom-nav button { display: flex; flex-direction: column; align-items: center; gap: 3px; background: none; border: 0;
    font: 600 .68rem Inter, system-ui, sans-serif; color: #64748b; padding: 6px 0; border-radius: 10px; cursor: pointer; }
  .bottom-nav button .ico { width: 22px; height: 22px; }
  .bottom-nav button.active { color: var(--primary); background: #eef3ff; }

  .more-sheet { position: fixed; inset: 0; z-index: 70; background: rgba(15,23,42,.35); align-items: flex-end; }
  .more-sheet.open { display: flex; }
  .more-panel { width: 100%; background: #fff; border-radius: 16px 16px 0 0; padding: 10px 10px calc(14px + env(safe-area-inset-bottom));
    display: grid; gap: 4px; }
  .more-panel button { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: none; border: 0;
    padding: 14px 12px; border-radius: 10px; font: 600 .95rem Inter, system-ui, sans-serif; color: var(--text); cursor: pointer; }
  .more-panel button:active { background: #f1f5f9; }
  .more-panel .ico { width: 22px; height: 22px; color: var(--primary); }

  .settings-grid { grid-template-columns: 1fr; }
  .toast-host { bottom: calc(80px + env(safe-area-inset-bottom)); }
}

@media (max-width: 680px) {
  .brand-title { white-space: nowrap; }
  .custom-table-container { overflow: visible; background: none; border: 0; box-shadow: none; }
  .data-table, .data-table tbody { display: block; width: 100%; min-width: 0; }
  .data-table tr:hover td { background: none; }
  .data-table thead { display: none; }
  .data-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; background: #fff; border: 1px solid var(--border);
    border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
  .data-table td { display: block; border: 0; padding: 0; min-width: 0; text-align: left; overflow-wrap: anywhere; }
  .data-table td.num { text-align: left; }
  .data-table td[data-label]::before { content: attr(data-label); display: block; font-size: .66rem; font-weight: 800;
    letter-spacing: .4px; text-transform: uppercase; color: #94a3b8; margin-bottom: 2px; }
  .data-table td:first-child { grid-column: 1 / -1; font-size: .95rem; }
  .data-table td:first-child::before { display: none; }
  .data-table td.row-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; padding-top: 8px; border-top: 1px solid #eef2f7; }
  .data-table td.row-actions::before { display: none; }
  .data-table td.table-empty { grid-column: 1 / -1; text-align: center; }
}
@media (max-width: 680px) {
  .navbar { grid-template-columns: minmax(0, 1fr) auto; }
  .brand { min-width: 0; overflow: hidden; }
  .brand > div { min-width: 0; }
  .brand-title { overflow: hidden; text-overflow: ellipsis; }
}
@media (max-width: 400px) { .brand-title { display: none; } }
/* WhatsApp number moved to Settings; keep the header to tabs + two actions. */
#waHeaderBadge { display: none; }
.nav-tabs { scrollbar-width: none; }
.nav-tabs::-webkit-scrollbar { display: none; }
@media (max-width: 1440px) { .navbar .sub-title { display: none; } }
@media (min-width: 681px) and (max-width: 1180px) {
  .navbar { grid-template-columns: minmax(0, 1fr) auto; }
  .navbar .nav-tabs { grid-column: 1 / -1; grid-row: 2; justify-self: start; }
  .nav-actions { width: auto; display: flex; }
}

/* Case QR label (2026-09-30): two 80×42 mm labels — one for the drive, one for the customer. */
.label-sheet { display: flex; flex-wrap: wrap; gap: 8mm; padding: 6mm; background: #fff; }
.case-label { width: 80mm; height: 42mm; border: 1px dashed #94a3b8; border-radius: 2mm; padding: 3mm;
  display: flex; gap: 3mm; align-items: center; font: 9pt/1.3 Inter, Arial, sans-serif; color: #000; overflow: hidden; }
.cl-qr { width: 30mm; height: 30mm; flex: 0 0 30mm; }
.cl-qr svg { width: 100%; height: 100%; display: block; }
.cl-text { min-width: 0; }
.cl-text > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cl-brand { font-size: 7pt; font-weight: 800; letter-spacing: .6px; color: #1f5eff; }
.cl-case { font-size: 14pt; font-weight: 900; }
.cl-mono { font-family: ui-monospace, Menlo, monospace; font-size: 8pt; }
.cl-copy { font-size: 6.5pt; color: #475569; margin-top: 1mm; }
@media print { .label-sheet { padding: 0; } .case-label { break-inside: avoid; } }

/* Intake evidence (2026-09-30) */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin-top: 10px; }
.photo-cell { position: relative; margin: 0; background: #f1f5f9; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.photo-cell img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; cursor: zoom-in; }
.photo-cell figcaption { font-size: .7rem; color: var(--muted); padding: 3px 6px; }
.photo-del { position: absolute; top: 5px; right: 5px; width: 26px; height: 26px; border-radius: 50%; border: 0;
  background: rgba(15,23,42,.7); color: #fff; cursor: pointer; font-size: 12px; }
.terms-box { background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px 12px 30px; font-size: .84rem; }
.terms-box li { margin: 3px 0; }
.sign-pad { width: 100%; height: auto; aspect-ratio: 3 / 1; border: 2px dashed #cbd5e1; border-radius: 10px; background: #fff;
  touch-action: none; margin-top: 8px; display: block; }
.sign-done { display: flex; gap: 14px; align-items: center; margin-top: 12px; border: 1px solid #bbf7d0; background: #f0fdf4;
  border-radius: 10px; padding: 10px; }
.sign-done img { width: 180px; max-width: 45%; background: #fff; border-radius: 6px; border: 1px solid var(--border); }
.sign-done .action-btn { margin-top: 6px; }

/* Reports (2026-09-30) */
#tab-reports .kpi-grid { margin-bottom: 16px; }
.trend { display: flex; align-items: flex-end; gap: 14px; height: 190px; padding-top: 8px; flex-wrap: wrap; }
.trend-col { flex: 1; min-width: 36px; display: flex; flex-direction: column; align-items: center; height: 160px; }
.trend-bars { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 4px; }
.trend-bars span { width: 40%; max-width: 26px; border-radius: 4px 4px 0 0; min-height: 2px; }
.tb-in { background: var(--primary); } .tb-out { background: #f59e0b; }
.trend-lbl { font-size: .72rem; color: var(--muted); margin-top: 5px; }
.trend-key { width: 100%; font-size: .75rem; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.trend-key span { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.check-row { display: flex !important; align-items: center; gap: 8px; font-weight: 700; color: var(--text); cursor: pointer; }
.check-row input { width: 18px; height: 18px; }

/* ===================== Professional layer (2026-10-01) ===================== */
.btn-icon { padding: 8px 10px; position: relative; }
.btn-icon .ico { margin: 0; }
.navbar .btn-icon { background: rgba(255,255,255,.06); color: #d9e4f5; }
.kbd { font: 700 .66rem Inter, sans-serif; border: 1px solid rgba(255,255,255,.25); border-radius: 4px; padding: 1px 5px; margin-left: 6px; color: #aab7cc; }
.bell-count { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; border-radius: 9px; background: #ef4444; color: #fff;
  font: 800 .66rem/18px Inter, sans-serif; text-align: center; padding: 0 4px; }
.click-row { cursor: pointer; }
.kanban-card { cursor: pointer; }

.chart-card { margin-bottom: 20px; }
.chart-box { position: relative; height: 260px; }

/* drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.35); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 80; }
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.case-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); background: var(--page); z-index: 81;
  transform: translateX(100%); transition: transform .22s ease; display: flex; flex-direction: column; box-shadow: -12px 0 40px rgba(15,23,42,.18); }
.case-drawer.open { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 18px; background: #111827; color: #fff; }
.drawer-head h3 { font-size: 1.15rem; margin-top: 2px; }
.drawer-kicker { font-size: .75rem; color: #aab7cc; font-weight: 600; }
.drawer-head .btn-icon { color: #fff; background: rgba(255,255,255,.08); }
.drawer-body { overflow-y: auto; padding: 16px 18px 40px; display: grid; gap: 14px; align-content: start; }
.cd-status { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cd-stepper { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.cd-stepper button { flex: 1 0 auto; border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 6px 10px;
  font: 700 .72rem Inter, sans-serif; color: var(--muted); cursor: pointer; white-space: nowrap; }
.cd-stepper button.on { background: var(--c); border-color: var(--c); color: #fff; }
.cd-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.cd-actions .action-btn { display: inline-flex; align-items: center; gap: 5px; text-decoration: none; }
.cd-actions .ico { width: 15px; height: 15px; }
.cd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cd-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.cd-card h4 { font-size: .72rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 6px; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; font-size: .86rem; border-bottom: 1px solid #f1f5f9; }
.kv:last-child { border-bottom: 0; } .kv span { color: var(--muted); } .kv b { text-align: right; font-weight: 600; overflow-wrap: anywhere; }
.kv.total b { font-size: 1rem; } .kv b.due { color: #dc2626; }
.cd-thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 6px; }
.cd-thumbs img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: #f1f5f9; cursor: zoom-in; }
.cd-notes { font-size: .86rem; white-space: pre-wrap; }
.cd-timeline { list-style: none; margin: 0; padding: 0; }
.cd-timeline li { position: relative; padding: 5px 0 5px 18px; font-size: .84rem; border-left: 2px solid #e2e8f0; margin-left: 5px; }
.cd-timeline li::before { content: ""; position: absolute; left: -6px; top: 10px; width: 10px; height: 10px; border-radius: 50%; background: #94a3b8; }
.cd-timeline li span { display: inline-block; min-width: 82px; color: var(--muted); font-size: .76rem; }
.cd-timeline .ev-pay::before { background: #059669; } .cd-timeline .ev-stage::before { background: var(--primary); }
.cd-timeline .ev-sign::before, .cd-timeline .ev-photo::before { background: #7c3aed; } .cd-timeline .ev-wa::before { background: #22c55e; }

/* search */
.search-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 90; display: none; align-items: flex-start; justify-content: center; padding: 10vh 12px 12px; }
.search-overlay.open { display: flex; }
.search-panel { width: min(640px, 100%); background: #fff; border-radius: 14px; box-shadow: 0 30px 80px rgba(15,23,42,.35); overflow: hidden; }
.search-bar { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.search-bar input { flex: 1; border: 0; outline: 0; font: 500 1rem Inter, sans-serif; min-width: 0; }
.search-results { max-height: 60vh; overflow-y: auto; padding: 6px; }
.search-results .empty-note { padding: 14px; }
.search-hit { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; text-align: left; padding: 10px; border-radius: 10px; cursor: pointer; font: inherit; color: inherit; }
.search-hit.sel, .search-hit:hover { background: #eef3ff; }
.hit-type { font: 800 .62rem Inter, sans-serif; text-transform: uppercase; letter-spacing: .5px; color: var(--primary); background: #eef3ff; border-radius: 6px; padding: 3px 6px; min-width: 58px; text-align: center; }
.hit-main { flex: 1; min-width: 0; display: grid; } .hit-main small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* reminders */
.reminder-panel { position: fixed; top: 70px; right: 16px; width: min(380px, calc(100vw - 32px)); max-height: 70vh; overflow-y: auto; background: #fff;
  border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 20px 50px rgba(15,23,42,.2); z-index: 85; padding: 14px; }
.reminder-row { width: 100%; border: 0; background: none; text-align: left; cursor: pointer; font: inherit; color: inherit; justify-content: flex-start; gap: 10px; }
.reminder-row:hover { background: #f8fafc; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; margin-top: 6px; }
.dot-red { background: #ef4444; } .dot-amber { background: #f59e0b; } .dot-green { background: #10b981; }

@media (max-width: 680px) {
  .kbd { display: none; }
  .navbar .btn-icon { padding: 7px 9px; }
  .cd-grid { grid-template-columns: 1fr; }
  .reminder-panel { top: 60px; right: 8px; }
  .chart-box { height: 220px; }
  .search-overlay { padding-top: 12px; }
}
/* layer order: navbar 100 < drawer 800 < reminders 850 < search 900 < modals 1000 < toasts 2000 */
.drawer-backdrop { z-index: 800; } .case-drawer { z-index: 801; }
.reminder-panel { z-index: 850; } .search-overlay { z-index: 900; }
@media (max-width: 1700px) {
  .kbd { display: none; }
  .navbar .btn-utility { font-size: 0; padding: 8px 10px; }
  .navbar .btn-utility .ico { margin: 0; }
  .tab-btn { padding: 8px 10px; }
}
@media (min-width: 681px) and (max-width: 1440px) {
  .navbar { grid-template-columns: minmax(0, 1fr) auto; }
  .navbar .nav-tabs { grid-column: 1 / -1; grid-row: 2; justify-self: start; }
  .nav-actions { width: auto; display: flex; }
}
.cd-stepper { min-height: 38px; align-items: center; flex-shrink: 0; }
.cd-stepper button { min-height: 32px; }

/* ---------------- Mailbox tab (2026-10-01) ---------------- */
.btn-sm { padding: 6px 10px; font-size: .8rem; }
.mail-count:not(:empty) { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700; line-height: 18px; text-align: center; }
.mail-folders { display: flex; gap: 6px; }
.mail-folders .btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.mail-actions { display: flex; gap: 8px; align-items: center; }
.mail-wrap { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 14px; align-items: start; }
.mail-list { padding: 6px; max-height: calc(100vh - 230px); overflow-y: auto; }
.mail-row { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--border);
  padding: 10px 10px; cursor: pointer; font: inherit; color: var(--text); border-radius: 8px; }
.mail-row:hover { background: var(--page); }
.mail-row.active { background: #eff6ff; }
.mail-row.unread .mail-from, .mail-row.unread .mail-subj { font-weight: 700; color: var(--dark); }
.mail-row-top { display: flex; justify-content: space-between; gap: 8px; }
.mail-from { font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-date { font-size: .74rem; color: var(--muted); flex-shrink: 0; }
.mail-subj { display: block; font-size: .8rem; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-link { margin-top: 5px; font-size: .68rem; }
.mail-more { width: 100%; margin-top: 8px; }
.mail-reader { padding: 18px 20px; min-height: 300px; min-width: 0; }
.mail-reader-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.mail-reader-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.mail-back { display: none; }
.mail-h { font-size: 1.1rem; color: var(--dark); margin-bottom: 8px; overflow-wrap: anywhere; }
.mail-meta { font-size: .8rem; color: var(--muted); display: grid; gap: 2px; padding-bottom: 12px; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.mail-attach { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.mail-attach .chip { cursor: pointer; }
.mail-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .9rem; line-height: 1.55; margin-top: 14px; color: var(--text); }
.mail-body a { color: var(--primary); }
@media (max-width: 900px) {
  .mail-wrap { grid-template-columns: 1fr; }
  .mail-list { max-height: none; }
  .mail-wrap.reading .mail-list { display: none; }
  .mail-wrap:not(.reading) .mail-reader { display: none; }
  .mail-back { display: inline-flex; color: var(--primary); font-weight: 700; }
  .mail-actions { width: 100%; justify-content: space-between; }
  .mail-reader { background: var(--card); }
  #tab-mail .toolbar-left { flex-wrap: wrap; }
}

/* ---------------- UI polish (2026-10-01) ---------------- */
/* Filters sit on one line instead of stretching across the page. */
.toolbar-left select { width: auto; min-width: 170px; max-width: 260px; }
.toolbar-left .search-input { min-width: 240px; }
@media (max-width: 900px) {
  .toolbar-left select, .toolbar-left .search-input { width: 100%; max-width: none; min-width: 0; }
}
.data-table td.num, .data-table th.num { white-space: nowrap; }

/* Case quick actions + ⋯ menu */
.card-actions.quick { margin-top: 10px; align-items: center; }
.card-actions.quick .action-btn { display: inline-flex; align-items: center; gap: 5px; }
.card-actions.quick .action-btn .ico { width: 15px; height: 15px; }
.action-btn.more { margin-left: auto; padding: 5px 8px; }
.row-actions .card-actions.quick { margin-top: 0; flex-wrap: nowrap; }
.row-actions .action-btn.more { margin-left: 0; }
.case-menu { position: fixed; z-index: 950; min-width: 220px; background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 18px 40px -8px rgba(15,23,42,.28); padding: 6px; opacity: 0; transform: translateY(-4px);
  transition: opacity .12s, transform .12s; }
.case-menu.open { opacity: 1; transform: none; }
.case-menu-head { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; padding: 6px 10px 4px; }
.case-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none;
  font: inherit; font-size: .86rem; color: var(--text); border-radius: 8px; cursor: pointer; text-align: left; }
.case-menu button:hover, .case-menu button:focus-visible { background: var(--page); outline: none; }
.case-menu button .ico { width: 17px; height: 17px; color: var(--muted); flex-shrink: 0; }
.case-menu button.wa .ico { color: #16a34a; }
.case-menu button.danger { color: var(--danger); }
.case-menu button.danger .ico { color: var(--danger); }
.case-menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 6px; }
td.row-actions { display: table-cell; vertical-align: top; }
.card-actions.quick { flex-wrap: nowrap; gap: 5px; }
.card-actions.quick .action-btn { padding: 5px 8px; white-space: nowrap; }
.kanban-card .card-actions.quick { gap: 4px; }
.kanban-card .card-actions.quick .action-btn { padding: 5px 6px; font-size: .75rem; gap: 4px; }
.kanban-card { container-type: inline-size; }
@container (max-width: 250px) {
  .card-actions.quick .action-btn:not(.more) .ico { display: none; }
}
/* A later `.btn { border: 1px solid transparent }` erased every outline button's border. */
.btn-outline { border-color: var(--border); background: #fff; color: var(--text); }
.btn-outline:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn-outline.danger { color: var(--danger); border-color: #fecaca; }
.btn-outline.danger:hover { background: #fef2f2; }
.mail-folders .btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.toolbar-left input[type="month"], .toolbar-left input[type="date"] { width: auto; }
.settings-actions, .dashboard-card > .btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
/* The closed drawer's shadow bled in at the right edge of every screen. */
.case-drawer { transition: transform .22s ease, visibility .22s; }
.case-drawer:not(.open) { visibility: hidden; box-shadow: none; }
@media (max-width: 900px) {
  .kpi-grid > .kpi-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
}

/* ---------------- GST tab (2026-10-01) ---------------- */
.gst-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-bottom: 18px; }
.gst-status { border-left: 4px solid var(--border); }
.gst-status.gst-green { border-left-color: var(--success); }
.gst-status.gst-amber { border-left-color: var(--warning); }
.gst-status.gst-red { border-left-color: var(--danger); background: #fff7f7; }
.gst-line { font-size: .9rem; margin: 4px 0 10px; color: var(--text); }
.gst-status code { background: var(--page); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; font-size: .78rem; }
.gst-kpis { margin-bottom: 18px; }
.text-red { color: var(--danger) !important; }
tr.gst-excluded td { opacity: .55; text-decoration: line-through; }
tr.gst-excluded td:last-child { opacity: 1; text-decoration: none; }
.gst-add { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.gst-add summary { cursor: pointer; font-weight: 700; font-size: .88rem; color: var(--primary); margin-bottom: 10px; }
#tab-gst .kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: .86rem; }
#tab-gst .kv span { color: var(--muted); }
#tab-gst .kv b { text-align: right; }

/* Modals with a <form> between .modal-content and .modal-body/.modal-footer could not scroll:
   the form was a plain block, so the body grew past the screen and .modal-content clipped it —
   on phones the New case form ended at "Brand" with no way to reach Save (2026-10-01). */
.modal-content > form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.modal-body { min-height: 0; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.modal-footer { flex-shrink: 0; }
@media (max-width: 900px) {
  .modal-content, .modal-content.narrow, .modal-content.wide { height: 100dvh; max-height: 100dvh; }
}

/* Documents stay true A4 on phones and are zoomed to fit the screen (fitDoc in app.js), so the
   amount column is never cut off. Printing and PDF always use the real size. */
@media (max-width: 600px) { .document-a4 { width: 210mm; padding: 14mm 15mm; } }
body.printing .document-a4 { zoom: 1 !important; }
@media print { .document-a4 { zoom: 1 !important; } }
.update-bar { position: fixed; left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 1900; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; background: #111827; color: #fff; padding: 10px 12px 10px 16px; border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,.3); font-size: .9rem; font-weight: 600; max-width: 520px; margin: 0 auto; }
@media (min-width: 901px) { .update-bar { bottom: 20px; } }

/* Courier (Delhivery) — 2026-10-01 */
.courier-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 8px 0; border-bottom: 1px solid #f1f5f9; }
.courier-acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.courier-row .courier-acts { margin-top: 0; }
.courier-quote { background: var(--page); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: .9rem; margin: 6px 0 8px; }
