:root {
  --paper: #f6f4ef;
  --surface: #ffffff;
  --surface-alt: #fbfaf7;
  --surface-tint: #f1ede4;
  --line: #e4ded2;
  --line-strong: #cfc6b4;
  --ink: #1e1b18;
  --ink-soft: #5c554c;
  --ink-muted: #847b70;
  --brass: #8b6216;
  --brass-bg: #faf4e4;
  --brass-line: #e4d4a8;
  --garnet: #6d262b;
  --garnet-dark: #521a1e;
  --sage: #1e6b48;
  --sage-bg: #ebf7f0;
  --amber: #a85508;
  --amber-bg: #fef5e7;
  --crimson: #b42318;
  --crimson-bg: #fef2f2;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(30, 27, 24, 0.05);
  --shadow-md: 0 8px 28px rgba(30, 27, 24, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Noto Sans Devanagari", sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

.serif {
  font-family: "Iowan Old Style", "Georgia", "Noto Serif Devanagari", serif;
}

.icon {
  display: inline-block;
  vertical-align: -3px;
  flex-shrink: 0;
}

/* Top Utility Bar — light, crisp, understated */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 10px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.brand-monogram {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--garnet);
  color: #f6ebd4;
  display: grid;
  place-items: center;
  font-family: "Iowan Old Style", Georgia, serif;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand-copy h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.brand-copy p {
  margin: 0;
  font-size: 0.76rem;
  color: var(--ink-muted);
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.segmented {
  display: inline-flex;
  background: var(--surface-tint);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px;
}

.segmented button {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
}

.segmented button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.segmented-compact button {
  padding: 6px 10px;
}

/* Workspace Shell with Sidebar */
.workspace {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  min-height: calc(100vh - 58px);
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

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

.nav-item {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  padding: 9px 12px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.88rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav-item-label {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.nav-item:hover {
  background: var(--surface-tint);
  color: var(--ink);
}

.nav-item.active {
  background: var(--brass-bg);
  color: var(--brass);
  font-weight: 600;
}

.nav-badge {
  background: var(--garnet);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
}

.sidebar-rates {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 0.79rem;
}

.sidebar-rates-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--ink-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.05em;
}

.rate-line {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  color: var(--ink-soft);
}

.rate-line strong {
  color: var(--ink);
  font-weight: 600;
}

.main-pane {
  padding: 22px 26px 60px;
  max-width: 1220px;
  width: 100%;
}

/* Page Header */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.page-head h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-head p {
  margin: 2px 0 0;
  color: var(--ink-muted);
  font-size: 0.85rem;
}

/* Stat Strip — clean hairline metric strip instead of puffy boxes */
.metrics-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  overflow: hidden;
}

.metric-cell {
  padding: 16px 18px;
  border-right: 1px solid var(--line);
}

.metric-cell:last-child {
  border-right: 0;
}

.metric-label {
  font-size: 0.77rem;
  color: var(--ink-muted);
  font-weight: 500;
}

.metric-val {
  font-size: 1.38rem;
  font-weight: 700;
  color: var(--ink);
  margin: 3px 0 2px;
  letter-spacing: -0.02em;
}

.metric-sub {
  font-size: 0.75rem;
  color: var(--ink-soft);
}

/* Panels / Cards */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

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

.panel-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Toolbar & Inputs */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.search-field {
  position: relative;
  flex: 1;
  min-width: 240px;
}

.search-field .icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-muted);
  pointer-events: none;
}

.search-field input {
  width: 100%;
  padding: 8px 12px 8px 35px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-alt);
  font-size: 0.88rem;
  color: var(--ink);
}

.search-field input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--brass);
  box-shadow: 0 0 0 3px rgba(139, 98, 22, 0.1);
}

/* Buttons */
.btn {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 600;
  font-size: 0.84rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
}

.btn:hover {
  background: var(--surface-tint);
}

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

.btn-primary {
  background: var(--garnet);
  border-color: var(--garnet);
  color: #fff;
}

.btn-primary:hover {
  background: var(--garnet-dark);
}

.btn-brass {
  background: var(--brass);
  border-color: var(--brass);
  color: #fff;
}

.btn-brass:hover {
  background: #755110;
}

.btn-sage {
  background: var(--sage);
  border-color: var(--sage);
  color: #fff;
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--ink-soft);
}

.btn-ghost:hover {
  background: var(--surface-tint);
  color: var(--ink);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
  border-radius: 7px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--surface-tint);
  color: var(--ink);
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th {
  text-align: left;
  padding: 9px 10px;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

tbody tr.clickable-row {
  cursor: pointer;
  transition: background 0.1s ease;
}

tbody tr.clickable-row:hover td {
  background: var(--surface-alt);
}

.customer-cell {
  display: flex;
  align-items: center;
  gap: 11px;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 9px;
  object-fit: cover;
  border: 1px solid var(--line);
  flex-shrink: 0;
}

.avatar-lg {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--line-strong);
}

/* Subtle Status Tags */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.tag-sage {
  background: var(--sage-bg);
  color: var(--sage);
}

.tag-amber {
  background: var(--amber-bg);
  color: var(--amber);
}

.tag-crimson {
  background: var(--crimson-bg);
  color: var(--crimson);
}

.tag-brass {
  background: var(--brass-bg);
  color: var(--brass);
  border-color: var(--brass-line);
}

.tag-neutral {
  background: var(--surface-tint);
  color: var(--ink-soft);
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.field input,
.field select,
.field textarea {
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font-size: 0.88rem;
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--brass);
  box-shadow: 0 0 0 3px rgba(139, 98, 22, 0.1);
}

/* Biometric Capture Panels */
.bio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.bio-card {
  border: 1px solid var(--line);
  background: var(--surface-alt);
  border-radius: var(--radius);
  padding: 14px;
}

.video-frame {
  width: 100%;
  height: 190px;
  background: #191714;
  border-radius: 8px;
  object-fit: cover;
  display: block;
  margin: 10px 0;
}

.fp-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 10px 0;
}

.fp-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface-tint);
  color: var(--ink-soft);
  display: grid;
  place-items: center;
}

.fp-circle.captured {
  background: var(--sage-bg);
  color: var(--sage);
}

/* LTV Safety Bar */
.ltv-meter {
  margin-top: 10px;
}

.ltv-track {
  height: 7px;
  background: var(--surface-tint);
  border-radius: 999px;
  overflow: hidden;
  margin: 6px 0;
}

.ltv-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.25s ease, background 0.25s ease;
}

/* Slide-over Bahi-Khata Drawer */
.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  justify-content: flex-end;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(25, 22, 18, 0.42);
  backdrop-filter: blur(2px);
}

.drawer-panel {
  position: relative;
  width: min(760px, 100vw);
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 40px rgba(20, 16, 12, 0.16);
  display: flex;
  flex-direction: column;
  animation: slideIn 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes slideIn {
  from {
    transform: translateX(30px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.drawer-head {
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-alt);
}

.drawer-kicker {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--brass);
}

.drawer-head h2 {
  margin: 2px 0 0;
  font-size: 1.15rem;
}

.drawer-body {
  padding: 20px 22px 40px;
  overflow-y: auto;
  flex: 1;
}

.drawer-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.drawer-tab {
  border: 0;
  background: transparent;
  padding: 8px 14px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
}

.drawer-tab.active {
  color: var(--garnet);
  border-bottom-color: var(--garnet);
}

/* Interactive Range Slider */
input[type="range"].range-slider {
  width: 100%;
  accent-color: var(--garnet);
  cursor: pointer;
}

.sim-box {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}

/* Parchi / Physical Receipt styling */
.parchi-sheet {
  border: 1px solid var(--line-strong);
  background: #fffdf9;
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
}

.parchi-header {
  text-align: center;
  border-bottom: 1px dashed var(--line-strong);
  padding-bottom: 12px;
  margin-bottom: 14px;
}

.parchi-stamp {
  display: inline-block;
  border: 1.5px solid var(--sage);
  color: var(--sage);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  transform: rotate(-2deg);
}

/* Customer Passbook Shell */
.passbook-shell {
  max-width: 920px;
  margin: 0 auto;
  padding: 24px 18px 60px;
}

.passbook-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.timeline-bar {
  height: 8px;
  background: var(--surface-tint);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0;
}

.timeline-progress {
  height: 100%;
  background: var(--garnet);
  border-radius: 999px;
}

.summary-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-top: 12px;
}

/* Login Container */
.auth-wrap {
  max-width: 420px;
  margin: 48px auto;
  padding: 0 16px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 26px;
  box-shadow: var(--shadow-md);
}

/* Modal */
dialog.modal {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 0;
  width: min(720px, 94vw);
  max-height: 88vh;
  overflow: auto;
  box-shadow: 0 20px 50px rgba(20, 16, 12, 0.22);
  background: var(--surface);
}

dialog.modal::backdrop {
  background: rgba(20, 16, 12, 0.45);
  backdrop-filter: blur(2px);
}

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-alt);
}

.modal-body {
  padding: 18px;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 90;
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 10px 14px;
  }
  .nav-list {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .nav-item {
    width: auto;
  }
  .sidebar-rates {
    display: none;
  }
  .metrics-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .main-pane {
    padding: 16px 14px 50px;
  }
}

@media print {
  .topbar,
  .sidebar,
  .drawer-tabs,
  .no-print {
    display: none !important;
  }
  .drawer-overlay {
    position: static;
  }
  .drawer-backdrop {
    display: none;
  }
  .drawer-panel {
    width: 100%;
    height: auto;
    border: 0;
    box-shadow: none;
  }
}
