/* ==========================================================================
   Service Centre Pro — application stylesheet
   Mobile-first, light/dark, print-ready. No external fonts or frameworks:
   the whole UI must work offline on a shop tablet.
   ========================================================================== */

:root {
  --bg: #0b1721;
  --bg-2: #10212c;
  --surface: #152734;
  --surface-2: #1b3241;
  --surface-3: #234354;
  --border: #2d4e5d;
  --border-soft: #254252;
  --text: #e9f5f7;
  --text-dim: #acc6cd;
  --text-faint: #829faa;
  --accent: #2dd4bf;
  --accent-ink: #07312e;
  --accent-soft: rgba(45, 212, 191, 0.15);
  --accent-button: #5eead4;
  --accent-button-2: #14b8a6;
  --blue: #60a5fa;
  --blue-soft: rgba(96, 165, 250, 0.16);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.16);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.16);
  --violet: #8b5cf6;
  --violet-soft: rgba(139, 92, 246, 0.16);
  --cyan: #06b6d4;
  --cyan-soft: rgba(6, 182, 212, 0.16);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 3px 10px rgba(0, 0, 0, 0.3);
  --nav-h: 62px;
  --top-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Tamil", "Latha", sans-serif;
}

[data-theme='light'] {
  --bg: #eef5f7;
  --bg-2: #f7fbfc;
  --surface: #ffffff;
  --surface-2: #f0f7f9;
  --surface-3: #e3f0f3;
  --border: #c8dbe1;
  --border-soft: #e1edf0;
  --text: #15313c;
  --text-dim: #48636d;
  --text-faint: #617d87;
  --accent: #0d857c;
  --accent-ink: #ffffff;
  --accent-soft: rgba(13, 133, 124, 0.11);
  --accent-button: #0f9f95;
  --accent-button-2: #0d766e;
  --blue: #2563eb;
  --blue-soft: rgba(37, 99, 235, 0.1);
  --shadow: 0 10px 26px rgba(21, 49, 60, 0.09);
  --shadow-sm: 0 2px 8px rgba(21, 49, 60, 0.06);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}

h1,
h2,
h3,
h4 {
  margin: 0 0 8px;
  line-height: 1.25;
}

h1 {
  font-size: 1.35rem;
}
h2 {
  font-size: 1.1rem;
}
h3 {
  font-size: 1rem;
}

a {
  color: var(--blue);
  text-decoration: none;
}

[hidden] {
  display: none !important;
}

.muted {
  color: var(--text-dim);
}
.faint {
  color: var(--text-faint);
}
.small {
  font-size: 0.8rem;
}
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.nowrap {
  white-space: nowrap;
}
.center {
  text-align: center;
}
.right {
  text-align: right;
}
.grow {
  flex: 1;
}
.row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.row.wrap {
  flex-wrap: wrap;
}
.col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.spread {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}
.grid-3 {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}
.mt-8 {
  margin-top: 8px;
}
.mt-12 {
  margin-top: 12px;
}
.mt-16 {
  margin-top: 16px;
}
.mb-8 {
  margin-bottom: 8px;
}
.p-0 {
  padding: 0 !important;
}

/* ------------------------------------------------------------------ layout */

#root {
  min-height: 100%;
}

.boot {
  display: grid;
  place-items: center;
  min-height: 100vh;
  gap: 14px;
  color: var(--text-dim);
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---- login ---------------------------------------------------------- */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(900px 500px at 15% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(700px 420px at 100% 0%, var(--blue-soft), transparent 55%), var(--bg);
}

.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px 22px;
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.logo-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--accent-ink);
  background: linear-gradient(140deg, var(--accent-button), var(--accent-button-2));
  flex: 0 0 auto;
}

/* ---- app shell ------------------------------------------------------ */

.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--nav-h) + var(--safe-b));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--top-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
}

.topbar .title {
  font-weight: 700;
  font-size: 1rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

@media (max-width: 480px) {
  .topbar {
    gap: 4px;
    padding-inline: 8px;
  }

  .brand-chip {
    gap: 6px;
  }

  .topbar .title {
    font-size: 0.9rem;
  }
}

.brand-chip .logo-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  font-size: 0.75rem;
}

.icon-btn {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
}

.icon-btn:active {
  background: var(--surface-3);
}

.icon-btn.badge {
  position: relative;
}

.content {
  flex: 1;
  padding: 14px 12px 24px;
  max-width: 1500px;
  width: 100%;
  margin: 0 auto;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.page-head .sub {
  color: var(--text-dim);
  font-size: 0.84rem;
}

/* ---- bottom nav ----------------------------------------------------- */

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  background: color-mix(in srgb, var(--bg-2) 94%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}

.bottom-nav.side {
  display: none;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 0;
  background: none;
  color: var(--text-faint);
  font-size: 0.68rem;
  font-family: var(--font);
  cursor: pointer;
  padding: 6px 2px;
}

.nav-item .ico {
  font-size: 1.25rem;
  line-height: 1;
}

.nav-item.active {
  color: var(--accent);
}

.nav-item.active .ico {
  transform: translateY(-1px);
}

/* ------------------------------------------------------------------ cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}

.card + .card {
  margin-top: 10px;
}

.card.tight {
  padding: 10px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.card-head h2,
.card-head h3 {
  margin: 0;
}

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

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.kpi .label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
}

.kpi .value {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.1;
}

.kpi .foot {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.kpi.accent {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: linear-gradient(160deg, var(--accent-soft), transparent 70%), var(--surface);
}
.kpi.blue {
  border-color: color-mix(in srgb, var(--blue) 40%, var(--border));
}
.kpi.amber {
  border-color: color-mix(in srgb, var(--amber) 40%, var(--border));
}
.kpi.red {
  border-color: color-mix(in srgb, var(--red) 40%, var(--border));
}

/* ------------------------------------------------------------------ forms */

label.field {
  display: block;
  margin-bottom: 10px;
}

label.field > span.lbl {
  display: block;
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 4px;
}

label.field > span.lbl .req {
  color: var(--red);
}

input,
select,
textarea {
  width: 100%;
  font-family: var(--font);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 11px;
  outline: none;
  appearance: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/*
 * The rule above sets `appearance: none` on every input, which erased the native
 * checkbox/radio rendering: the control was still clickable but showed no tick,
 * so "Quote only", "Deduct from stock", "Allow negative stock" and friends looked
 * like they could not be enabled. Restore the native control explicitly.
 */
input[type='checkbox'],
input[type='radio'] {
  appearance: auto;
  -webkit-appearance: auto;
  width: 20px;
  height: 20px;
  min-width: 20px;
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  accent-color: var(--accent);
  cursor: pointer;
}

.check-row {
  cursor: pointer;
  user-select: none;
}

.check-row input[type='checkbox']:focus-visible,
.check-row input[type='radio']:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ------------------------------------------------------- accessory picker */

.acc-picker {
  margin-bottom: 10px;
}

.acc-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 10px;
  margin-bottom: 8px;
}

.acc-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 0.88rem;
  cursor: pointer;
  user-select: none;
}

.acc-item:has(input:checked) {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  background: var(--accent-soft);
  color: var(--text);
}

.acc-item input {
  appearance: auto;
  -webkit-appearance: auto;
  width: 18px;
  height: 18px;
  min-width: 18px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.acc-others {
  display: flex;
  align-items: center;
  gap: 8px;
}

.acc-others-label {
  flex: 0 0 auto;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.acc-others input {
  flex: 1;
}

.acc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.acc-chip {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

@media (max-width: 420px) {
  .acc-grid {
    grid-template-columns: 1fr;
  }
}

textarea {
  min-height: 78px;
  resize: vertical;
}

select {
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 0.9rem;
}

.hint {
  font-size: 0.76rem;
  color: var(--text-faint);
  margin-top: 3px;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin: 0 0 12px;
}

legend {
  padding: 0 6px;
  font-size: 0.78rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ----------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 14px;
  min-height: 42px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  background: linear-gradient(150deg, var(--accent-button), var(--accent-button-2));
  border-color: transparent;
  color: var(--accent-ink);
}

.btn.blue {
  background: linear-gradient(150deg, #60a5fa, #2563eb);
  border-color: transparent;
  color: #04122e;
}

.btn.danger {
  background: var(--red-soft);
  border-color: color-mix(in srgb, var(--red) 55%, var(--border));
  color: #fecaca;
}

.btn.ghost {
  background: transparent;
}

.btn.sm {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 0.82rem;
}

.btn.block {
  width: 100%;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ------------------------------------------------------------------ tables */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  min-width: 520px;
}

table.data th,
table.data td {
  padding: 9px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

table.data th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  z-index: 1;
  white-space: nowrap;
}

table.data tbody tr:last-child td {
  border-bottom: 0;
}

table.data tbody tr.clickable {
  cursor: pointer;
}

table.data tbody tr.clickable:active {
  background: var(--surface-2);
}

table.data td.num,
table.data th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------------- list */

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  color: var(--text);
  font-family: var(--font);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

.list-item:active {
  background: var(--surface-2);
}

.list-item .avatar {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.8rem;
  background: var(--surface-3);
  color: var(--text-dim);
  flex: 0 0 auto;
}

.list-item .body {
  min-width: 0;
  flex: 1;
}

.list-item .title {
  display: block;
  font-weight: 600;
  font-size: 0.94rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item .meta {
  display: block;
  font-size: 0.78rem;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item .tail {
  text-align: right;
  flex: 0 0 auto;
}

.empty {
  text-align: center;
  padding: 34px 16px;
  color: var(--text-faint);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.empty .big {
  font-size: 1.8rem;
  display: block;
  margin-bottom: 6px;
}

/* ------------------------------------------------------------------- pills */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--text-dim);
  white-space: nowrap;
}

.pill.green {
  background: var(--accent-soft);
  color: #5eead4;
}
.pill.blue {
  background: var(--blue-soft);
  color: #93c5fd;
}
.pill.amber {
  background: var(--amber-soft);
  color: #fcd34d;
}
.pill.red {
  background: var(--red-soft);
  color: #fca5a5;
}
.pill.violet {
  background: var(--violet-soft);
  color: #c4b5fd;
}
.pill.cyan {
  background: var(--cyan-soft);
  color: #67e8f9;
}

[data-theme='light'] .pill.green {
  color: #0d766e;
}

[data-theme='light'] .btn.danger {
  color: #b91c1c;
}

[data-theme='light'] .offline-banner {
  color: #854d0e;
}
[data-theme='light'] .pill.blue {
  color: #1d4ed8;
}
[data-theme='light'] .pill.amber {
  color: #b45309;
}
[data-theme='light'] .pill.red {
  color: #b91c1c;
}
[data-theme='light'] .pill.violet {
  color: #6d28d9;
}
[data-theme='light'] .pill.cyan {
  color: #0e7490;
}

/* --------------------------------------------------------------- kanban */

.kanban {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x proximity;
}

.kanban-col {
  flex: 0 0 250px;
  scroll-snap-align: start;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 72vh;
}

.kanban-col > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  padding: 2px 4px 6px;
  border-bottom: 1px solid var(--border-soft);
}

.kanban-col .cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding-right: 2px;
}

.job-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.job-card:active {
  background: var(--surface-2);
}

.job-card.p-URGENT {
  border-left-color: var(--red);
}
.job-card.p-HIGH {
  border-left-color: var(--amber);
}
.job-card.p-NORMAL {
  border-left-color: var(--blue);
}
.job-card.p-LOW {
  border-left-color: var(--text-faint);
}

.job-card .jn {
  font-size: 0.72rem;
  color: var(--text-faint);
  font-family: ui-monospace, monospace;
}

.job-card .cust {
  font-weight: 600;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-card .dev {
  font-size: 0.76rem;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-card .foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 2px;
  font-size: 0.72rem;
  color: var(--text-faint);
}

/* ------------------------------------------------------------------ modal */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(4, 8, 16, 0.62);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet {
  width: min(760px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow);
  animation: slide-up 0.18s ease-out;
}

@keyframes slide-up {
  from {
    transform: translateY(18px);
    opacity: 0.4;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.sheet-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 14px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}

.sheet-head h2 {
  margin: 0;
  font-size: 1.02rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-body {
  padding: 14px;
}

.sheet-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 8px;
  padding: 12px 14px calc(12px + var(--safe-b));
  background: var(--bg-2);
  border-top: 1px solid var(--border);
}

.sheet-foot .btn {
  flex: 1;
}

/* ------------------------------------------------------------------ toast */

.toast-wrap {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--nav-h) + var(--safe-b) + 12px);
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(430px, calc(100vw - 24px));
  pointer-events: none;
}

.toast {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.87rem;
  box-shadow: var(--shadow);
  animation: slide-up 0.16s ease-out;
}

.toast.error {
  border-left-color: var(--red);
}
.toast.warn {
  border-left-color: var(--amber);
}
.toast.info {
  border-left-color: var(--blue);
}

/* ------------------------------------------------------------------- misc */

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 12px;
}

.tab {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 0.83rem;
  font-family: var(--font);
  cursor: pointer;
  white-space: nowrap;
}

.tab.active {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  color: var(--text);
  font-weight: 600;
}

.searchbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.searchbar input {
  flex: 1;
}

.stat-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px dashed var(--border-soft);
  font-size: 0.88rem;
}

.stat-line:last-child {
  border-bottom: 0;
}

.stat-line .k {
  color: var(--text-dim);
}

.stat-line .v {
  font-weight: 600;
  text-align: right;
}

.total-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-top: 10px;
}

.total-box .line {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-size: 0.88rem;
}

.total-box .line.grand {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 8px;
  font-size: 1.05rem;
  font-weight: 700;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 6px;
}

.timeline li {
  position: relative;
  padding: 0 0 12px 18px;
  border-left: 2px solid var(--border);
}

.timeline li:last-child {
  border-left-color: transparent;
  padding-bottom: 0;
}

.timeline li::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

.timeline .t-status {
  font-weight: 600;
  font-size: 0.88rem;
}

.timeline .t-meta {
  font-size: 0.74rem;
  color: var(--text-faint);
}

.chip-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 8px;
}

.qty-input {
  width: 74px;
  text-align: center;
}

.offline-banner {
  background: var(--amber-soft);
  border-bottom: 1px solid color-mix(in srgb, var(--amber) 45%, var(--border));
  color: #fde68a;
  padding: 6px 12px;
  font-size: 0.8rem;
  text-align: center;
}

.install-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--blue-soft);
  border: 1px solid color-mix(in srgb, var(--blue) 45%, var(--border));
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 0.85rem;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
}

.photo-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.link-btn {
  background: none;
  border: 0;
  color: var(--blue);
  font-family: var(--font);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 4px 0;
}

.warn-text {
  color: var(--amber);
}
.danger-text {
  color: var(--red);
}
.ok-text {
  color: var(--accent);
}

/* ------------------------------------------------------------ responsive */

@media (min-width: 720px) {
  body {
    font-size: 15.5px;
  }

  .content {
    padding: 18px 20px 30px;
  }

  .kpi-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

  .grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .overlay {
    align-items: center;
  }

  .sheet {
    border-radius: var(--radius-lg);
    border-bottom: 1px solid var(--border);
    max-height: 88vh;
  }

  .sheet-foot {
    padding-bottom: 12px;
  }
}

@media (min-width: 1080px) {
  .shell {
    display: grid;
    grid-template-columns: 232px 1fr;
    grid-template-rows: var(--top-h) 1fr;
    grid-template-areas:
      'side top'
      'side main';
    padding-bottom: 0;
  }

  .topbar {
    grid-area: top;
  }

  .content {
    grid-area: main;
    overflow-y: auto;
    height: calc(100vh - var(--top-h));
  }

  .bottom-nav:not(.side) {
    display: none;
  }

  .bottom-nav.side {
    display: grid;
    grid-area: side;
    position: sticky;
    top: 0;
    height: 100vh;
    grid-template-columns: 1fr;
    grid-auto-rows: 54px;
    align-content: start;
    padding-top: 14px;
    gap: 4px;
    border-top: 0;
    border-right: 1px solid var(--border);
    overflow-y: auto;
  }

  .nav-item {
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    font-size: 0.9rem;
    padding: 0 18px;
  }

  .nav-item .ico {
    font-size: 1.1rem;
  }

  .nav-item.active {
    background: var(--accent-soft);
    border-radius: 0 12px 12px 0;
  }

  .kanban-col {
    flex: 1 1 240px;
    max-height: 76vh;
  }

  .toast-wrap {
    bottom: 22px;
  }

  table.data {
    min-width: 0;
  }
}

/* ----------------------------------------------------------------- print */

@media print {
  :root {
    --bg: #fff;
    --surface: #fff;
    --text: #000;
  }

  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 12px;
  }

  .topbar,
  .bottom-nav,
  .toast-wrap,
  .no-print,
  .offline-banner,
  .install-banner {
    display: none !important;
  }

  .shell {
    display: block;
    padding: 0;
  }

  .content {
    padding: 0;
    height: auto;
    overflow: visible;
  }

  .card,
  .table-wrap {
    border: 1px solid #999 !important;
    box-shadow: none !important;
    background: #fff !important;
    color: #000 !important;
  }

  .print-only {
    display: block !important;
  }

  table.data th {
    background: #eee !important;
    color: #000 !important;
  }

  a {
    color: #000 !important;
  }
}

.print-only {
  display: none;
}
/* WhatsApp template preview follows the active light/dark palette. */
.wa-preview {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}
