:root {
  --bg: #0e2a33;
  --bg-soft: #10303a;
  --bg-elevated: #1b4450;
  --surface: #ffffff;
  --surface-alt: #f4f3ef;
  --surface-sunken: #ecebe5;
  --border: #e0ded7;
  --border-soft: #eeede7;
  --text: #17211f;
  --text-soft: #4a5652;
  --text-muted: #8a9591;
  --sidebar-text: #b7c6c3;
  --sidebar-muted: #7e918d;
  --primary: #0e726d;
  --primary-dark: #0a5751;
  --accent: #d09a37;
  --success: #1b7a48;
  --success-soft: #dcefe3;
  --warn: #a9680a;
  --warn-soft: #f6e8d2;
  --danger: #b13327;
  --danger-soft: #f6ddd8;
  --info-soft: #dceceb;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 1px 2px rgba(23, 33, 31, 0.05);
  --shadow-md: 0 4px 14px rgba(23, 33, 31, 0.08);
  --shadow-lg: 0 14px 30px rgba(23, 33, 31, 0.14);
  --focus-shadow: 0 0 0 3px rgba(14, 114, 109, 0.16);
  --line: #e0ded7;
  --muted: #8a9591;
  --primary-soft: rgba(14, 114, 109, 0.12);
  --z-dropdown: 1050;
  --sidebar-w: 248px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow-x: clip;
}

body {
  font-family: var(--font);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(14, 114, 109, 0.18); }

.is-hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; }

input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  width: 100%;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: var(--focus-shadow);
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .03em;
}

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

/* ── Loading ─────────────────────────────────────────────── */
.loading-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  color: #fff;
  flex-direction: column;
  gap: 18px;
  font-weight: 600;
  letter-spacing: .01em;
}
.loading-screen .spinner {
  width: 42px;
  height: 42px;
  border: 3px solid rgba(255,255,255,.16);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Login ───────────────────────────────────────────────── */
.login-view {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 900;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 384px;
  background: #fff;
  border-radius: 12px;
  border-top: 3px solid var(--accent);
  padding: 34px 30px;
  box-shadow: var(--shadow-lg);
}
.login-card .login-logo {
  width: 50px;
  height: 50px;
  border-radius: 11px;
  background: var(--accent);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  box-shadow: 0 3px 10px rgba(208, 154, 55, 0.35);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.01em; }
.login-card p.sub { margin: 0 0 22px; color: var(--text-muted); font-size: 13px; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; margin-top: 8px; padding: 11px 15px; }
.login-message {
  margin-top: 14px;
  font-size: 13px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  display: none;
}
.login-message.show { display: block; }
.login-message.error { background: var(--danger-soft); color: #8f1c12; }
.login-message.warn { background: var(--warn-soft); color: #7a4405; }
.login-message.info { background: var(--info-soft); color: #0b5955; }

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

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-soft);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  border-right: 1px solid rgba(0, 0, 0, .2);
}
.sidebar-backdrop { display: none; }
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar .brand .brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .28);
}
.sidebar .brand h1 { margin: 0; font-size: 16px; color: #fff; letter-spacing: -.01em; }
.sidebar .brand p { margin: 3px 0 0; font-size: 11px; color: var(--sidebar-muted); }
.nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.nav-btn {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  color: var(--sidebar-text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 3px;
  text-align: left;
  transition: background .12s, color .12s, border-color .12s;
}
.nav-btn:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-btn.active {
  background: rgba(14, 114, 109, .30);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}
.nav-btn .nav-icon {
  width: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  opacity: .85;
}
.nav-btn:hover .nav-icon { opacity: 1; }
.nav-btn.active .nav-icon { opacity: 1; color: #f4d9a4; }
.nav-btn .nav-icon svg { display: block; }
.icon { width: 18px; height: 18px; flex: none; }
.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  border-radius: 4px;
  padding: 1px 6px;
}
.sidebar-footer { padding: 12px 10px; border-top: 1px solid rgba(255,255,255,.08); }
.nav-btn-danger { color: #eaa79f; }
.nav-btn-danger:hover { background: rgba(177,51,39,.22); color: #fff; }

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 13px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  padding: 2px;
  color: var(--text);
}
.menu-toggle svg { display: block; }
.title-block h2 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.title-block p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-muted); }
.topbar-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }
.chip {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text-soft);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.content { padding: 22px; flex: 1; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 15px;
  font-size: 13.5px;
  font-weight: 600;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(23, 33, 31, .12);
  transition: background .15s, box-shadow .15s, transform .08s;
  white-space: nowrap;
}
.btn:hover { background: var(--primary-dark); box-shadow: 0 3px 8px rgba(23, 33, 31, .18); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
.btn-subtle { background: #fff; color: var(--text-soft); border-color: var(--border); box-shadow: none; }
.btn-subtle:hover { background: var(--surface-alt); border-color: #cfcdc5; }
.btn-success { background: var(--success); }
.btn-success:hover { background: #14603a; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #91271e; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-icon { background: transparent; border: 0; color: var(--text-muted); font-size: 15px; padding: 4px 6px; border-radius: 6px; }
.btn-icon:hover { background: var(--surface-alt); color: var(--text); }

/* ── Cards / layout ──────────────────────────────────────── */
.panel { display: none; }
.panel.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card-head {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.card-head h3 { margin: 0; font-size: 15px; letter-spacing: -.01em; }
.card-head p { margin: 3px 0 0; font-size: 12px; color: var(--text-muted); }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 17px 18px;
  box-shadow: var(--shadow);
  transition: box-shadow .15s, transform .15s;
}
.stat:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat .stat-label { font-size: 11.5px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.stat .stat-value { font-size: 24px; font-weight: 800; margin-top: 7px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 5px; }
.stat.accent-blue { border-color: var(--primary); }
.stat.accent-green { border-color: var(--success); }
.stat.accent-amber { border-color: var(--warn); }
.stat.accent-red { border-color: var(--danger); }

/* ── Status Badge ─────────────────────────────── */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: capitalize;
}
.status-pending { background: var(--warn-soft); color: #7a4405; }
.status-in_progress { background: var(--info-soft); color: #0b5955; }
.status-completed { background: var(--success-soft); color: #14583a; }
.status-delivered { background: #e6e4de; color: #4a5652; }

/* ── Payment Badge ─────────────────────────────── */
.pay-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.pay-full { background: var(--success-soft); color: #14583a; }
.pay-partial { background: var(--info-soft); color: #0b5955; }
.pay-none { background: var(--danger-soft); color: #8f1c12; }

/* ── Ledger Title ───────────────────────────────── */
.ledger-title {
  margin: 16px 0 8px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--text-soft);
}

/* ── Locked Tag ─────────────────────────────────── */
.locked-tag {
  font-size: 10px;
  font-weight: 700;
  background: var(--text-muted);
  color: #fff;
  padding: 3px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ── Form Locked Notice ─────────────────────────── */
.form-locked-notice {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  color: #856404;
  margin-bottom: 12px;
}

/* ── Controls ──────────────────────────────────────── */
.controls {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.controls .control { min-width: 130px; }
.controls .control.grow { flex: 1; min-width: 200px; }
.controls .control label { margin-bottom: 4px; }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.data thead th {
  text-align: left;
  background: var(--surface-alt);
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
table.data tbody tr { transition: background .1s; }
table.data tbody tr:hover { background: #faf9f5; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data .actions { text-align: right; white-space: nowrap; }
.empty-row td {
  text-align: center;
  color: var(--text-muted);
  padding: 36px 14px !important;
  font-size: 13px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: capitalize;
}
.badge-green { background: var(--success-soft); color: #14583a; }
.badge-amber { background: var(--warn-soft); color: #7a4405; }
.badge-red { background: var(--danger-soft); color: #8f1c12; }
.badge-blue { background: var(--info-soft); color: #0b5955; }
.badge-gray { background: #e6e4de; color: #4a5652; }

.muted { color: var(--text-muted); }
.positive { color: var(--success); font-weight: 700; }
.negative { color: var(--danger); font-weight: 700; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ── Modals ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 32, 39, .55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  z-index: 200;
  overflow-y: auto;
}
.modal {
  background: #fff;
  border-radius: 10px;
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 80px);
  box-shadow: var(--shadow-lg);
  animation: fade .16s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal.modal-wide { max-width: 860px; }
.modal.modal-xl { max-width: 1040px; }
.modal > form {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}
.modal > .modal-body, .modal > form .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}
.modal-head, .modal-foot { flex: none; }
.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px; }
.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-errors {
  background: var(--danger-soft);
  color: #8f1c12;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-size: 13px;
  display: none;
}
.form-errors.show { display: block; }

/* ── Line items (sale / purchase) ───────────────────────── */
.line-items { width: 100%; border-collapse: collapse; }
.line-items th {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-soft);
  text-align: left;
  padding: 7px 8px;
  border-bottom: 1px solid var(--border);
}
.line-items td { padding: 6px 8px; vertical-align: top; }
.line-items input, .line-items select { padding: 7px 9px; }
.line-items .li-remove { color: var(--danger); }

.totals-box {
  margin-left: auto;
  width: 100%;
  max-width: 320px;
  margin-top: 14px;
}
.totals-box .totals-row {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  font-size: 13.5px;
  border-bottom: 1px dashed var(--border);
}
.totals-box .totals-row.grand {
  border-bottom: 0;
  font-size: 17px;
  font-weight: 800;
  padding-top: 12px;
}
.totals-box .totals-row.grand input {
  width: 130px;
  text-align: right;
  font-size: 16px;
  font-weight: 700;
}

/* ── Toasts ──────────────────────────────────────────────── */
.toast-root {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}
.toast {
  background: #fff;
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 13px 16px;
  font-size: 13.5px;
  animation: fade .18s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }

.bar-track { background: var(--surface-sunken); border-radius: 6px; height: 8px; overflow: hidden; min-width: 70px; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 6px; }

/* ── Stock/IMEI ──────────────────────────────────────────── */
.imei-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.imei-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  font-size: 13px;
}
.imei-check { display: flex; align-items: center; gap: 10px; }
.imei-check input { width: auto; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .sidebar {
    width: min(var(--sidebar-w), calc(100vw - 48px));
    height: 100dvh;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: none;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar.open + .sidebar-backdrop { display: block; }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgba(11, 32, 39, .42);
  }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .grid-4, .grid-3, .grid-2, .grid-5 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .view-grid { grid-template-columns: 1fr; }
  .content { padding: 15px; }
  .topbar { padding: 12px 15px; }
  .topbar-actions { display: none; }
  .modal-overlay { padding: 12px; align-items: center; }
  .modal { max-height: calc(100dvh - 24px); border-radius: 8px; }
  .modal-head, .modal-body, .modal-foot { padding-left: 15px; padding-right: 15px; }
  .modal-body { overflow-y: auto; }
  .modal-foot { flex-wrap: wrap; }
  .modal-foot .btn { flex: 1 1 120px; }
  .toast-root { top: 10px; right: 10px; left: 10px; max-width: none; }
  input, select, textarea { font-size: 16px; }
  .controls .control, .controls .control.grow { min-width: min(100%, 200px); }
  .controls .control.grow { flex-basis: 100%; }
  .tab-bar { margin-left: -15px; margin-right: -15px; padding: 0 15px; }
  .report-tabs { display: flex; width: max-content; }
  .card-card-row { gap: 12px; align-items: flex-start; }
  .card-card-row > * { min-width: 0; overflow-wrap: anywhere; }
}

/* ── Searchable Select ───────────────────────────────────── */
.searchable-select {
  position: relative;
  width: 100%;
}
.searchable-select-native {
  position: absolute !important;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  width: 100%;
  height: 100%;
}
.searchable-select-input {
  padding-right: 34px;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 13px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.searchable-select.is-open .searchable-select-input {
  border-color: #14b8a6;
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.12);
}
.searchable-select-dropdown {
  z-index: var(--z-dropdown) !important;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-height: 240px;
  overflow: auto;
  display: none;
}
.searchable-select-portal .searchable-select-dropdown {
  display: block;
}
.searchable-select-portal {
  position: fixed;
  z-index: var(--z-dropdown) !important;
  display: none;
  pointer-events: auto;
}
.searchable-select-portal.is-positioned {
  display: block;
}
.searchable-select-portal .searchable-select-dropdown {
  display: block;
  position: static;
  border: none;
  box-shadow: none;
  background: transparent;
  max-height: none;
  overflow: visible;
}
.searchable-select-portal .searchable-select-list {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-height: 240px;
  overflow: auto;
  padding: 6px;
}
.searchable-select-list {
  padding: 6px;
  display: grid;
  gap: 4px;
}
.searchable-select-option,
.searchable-select-empty {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 9px 10px;
  text-align: left;
  font-size: 13px;
  background: transparent;
  color: var(--text);
}
.searchable-select-option {
  cursor: pointer;
}
.searchable-select-option:hover,
.searchable-select-option.is-selected {
  background: var(--primary-soft);
  color: var(--primary);
}
.searchable-select-option:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
.searchable-select-empty {
	color: var(--muted);
}
/* ── End Searchable Select ─────────────────────────────── */

/* ── View Modal ─────────────────────────────────────── */
.view-progress {
	display: flex;
	gap: 4px;
	margin-bottom: 18px;
	padding: 10px 0;
	border-bottom: 1px solid var(--border-soft);
}
.view-step {
	flex: 1;
	text-align: center;
	font-size: 10px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .03em;
	padding: 6px 4px;
	border-radius: var(--radius-sm);
	background: var(--surface-sunken);
	color: var(--text-muted);
	transition: all .15s;
}
.view-step.view-step-active {
	background: var(--primary-soft);
	color: var(--primary);
}
.view-step.view-step-current {
	background: var(--primary);
	color: #fff;
	box-shadow: 0 2px 6px rgba(14, 114, 109, .3);
}
.view-grid {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 12px;
}
.view-item {
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: 8px 10px;
	background: var(--surface-alt);
	border-radius: var(--radius-sm);
	border: 1px solid var(--border-soft);
}
.view-item.span-2 {
	grid-column: 1 / -1;
}
.view-item-highlight {
	background: var(--primary-soft);
	border-color: var(--primary);
}
.view-label {
	font-size: 10px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .04em;
	color: var(--text-muted);
}
.view-value {
	font-size: 14px;
	font-weight: 700;
	color: var(--text);
}

/* ── Repair Count Badge ─────────────────────────────── */
.repair-count-badge {
	font-size: 11px;
	background: var(--surface-alt);
	color: var(--text-muted);
	padding: 4px 10px;
	border-radius: 10px;
	font-weight: 600;
}



/* ── Responsive Repair Listing ────────────────────── */
.repair-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  overflow: hidden;
  transition: box-shadow .15s;
}
.repair-card:hover { box-shadow: var(--shadow-md); }
.card-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface-alt);
  flex-wrap: wrap;
}
.card-card-head strong { font-size: 14px; }
.card-date { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.card-card-body { padding: 10px 14px; }
.card-card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border-soft);
}
.card-card-row:last-child { border-bottom: 0; }
.card-card-label { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.card-card-highlight { background: var(--primary-soft); margin: 0 -14px; padding: 8px 14px; border-bottom-color: transparent; }
.card-card-actions {
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  border-top: 1px solid var(--border-soft);
  flex-wrap: wrap;
}
.empty-cards {
  text-align: center;
  padding: 36px 14px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Compact Table Styles ──────────────────────────── */
table.data.compact th,
table.data.compact td { padding: 8px 10px; }
table.data.compact { font-size: 13px; }
table.data.compact .actions { white-space: nowrap; }

/* ── Responsive Layout ─────────────────────────────── */
@media (max-width: 760px) {
  #repairsTableBody { display: none !important; }
  #repairCardsView { display: block !important; }
  #repairSummaryCards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.table-wrap { overflow-x: auto; }
  .card-card-actions .btn { flex: 1; text-align: center; justify-content: center; min-width: 0; }
  .card-card-head { flex-direction: column; align-items: flex-start; }
}
@media (min-width: 761px) {
  #repairCardsView { display: none !important; }
  #repairsTableBody { display: table-row-group !important; }
}

/* ── Responsive Summary Cards ──────────────────────── */
@media (max-width: 760px) {
  #repairSummaryCards .stat .stat-value { font-size: 20px; }
  #repairPaymentSummary .stat .stat-value { font-size: 20px; }
}

/* ── Tab Bar ──────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 12px;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: thin;
}
.tab-btn {
  background: none;
  border: none;
  padding: 8px 16px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text-soft);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
  flex: 0 0 auto;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ── Compact Repair Summary Cards ────────── */
#repairSummaryCards .stat {
  padding: 8px 10px;
  text-align: center;
}
#repairSummaryCards .stat .stat-label { font-size: 10px; }
#repairSummaryCards .stat .stat-value { font-size: 18px; margin-top: 3px; }


/* ── Mobile list cards ───────────────────────────────────── */
@media (max-width: 760px) {
  table.data { min-width: 0; }
  table.data thead { display: none; }
  table.data, table.data tbody, table.data tbody tr, table.data tbody td { display: block; width: 100%; }
  table.data tbody { padding: 10px; }
  table.data tbody tr {
    margin-bottom: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    background: var(--surface);
  }
  table.data tbody tr:last-child { margin-bottom: 0; }
  table.data tbody td {
    display: grid;
    grid-template-columns: minmax(92px, 38%) minmax(0, 1fr);
    gap: 10px;
    padding: 7px 0;
    border-bottom: 1px solid var(--border-soft);
    text-align: left;
    overflow-wrap: anywhere;
  }
  table.data tbody td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .04em;
    text-align: left;
    text-transform: uppercase;
  }
  table.data tbody td.num, table.data tbody td.actions { text-align: left; }
  table.data tbody td.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 10px;
    border-bottom: 0;
  }
  table.data tbody td.actions::before { display: none; }
  table.data tbody td.actions .btn { flex: 1 1 auto; }
  table.data tbody tr.empty-row { padding: 0; border: 0; box-shadow: none; }
  table.data tbody tr.empty-row td { display: block; padding: 28px 10px !important; border: 0; text-align: center; }
  table.data tbody tr.empty-row td::before { display: none; }
}

/* ── Print Styles ────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .card-head .btn, .controls, .actions {
    display: none !important;
  }
  .content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; }
  #repairCardsView { display: none !important; }
  #repairsTableBody { display: table-row-group !important; }
}
