/* ================================================================
   Design tokens
   ================================================================ */

:root {
  --bg-top: #f7f8fb;
  --bg-bottom: #eef0f6;
  --surface: #ffffff;
  --surface-alt: #f6f7fa;
  --surface-hover: #eef0f5;
  --border: #e6e8ee;
  --border-strong: #d7dbe3;
  --text: #131722;
  --text-muted: #667085;
  --text-faint: #98a2b3;

  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #6366f1;
  --primary-soft: #eef1ff;

  --success: #059669;
  --success-bg: #ecfdf5;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --info: #2563eb;
  --info-bg: #eff6ff;

  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-md: 0 8px 24px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 20px 44px rgba(16, 24, 40, 0.14), 0 2px 8px rgba(16, 24, 40, 0.06);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;

  --sidebar-w: 234px;
  --sidebar-w-collapsed: 68px;
  --header-h: 64px;
}

:root[data-theme="dark"] {
  --bg-top: #0b0d12;
  --bg-bottom: #06070a;
  --surface: #12141c;
  --surface-alt: #171a24;
  --surface-hover: #1e222d;
  --border: #232733;
  --border-strong: #2e3341;
  --text: #edeff4;
  --text-muted: #9aa3b5;
  --text-faint: #6b7383;

  --primary: #6d68f5;
  --primary-dark: #5b54f0;
  --primary-light: #8a85ff;
  --primary-soft: rgba(109, 104, 245, 0.16);

  --success: #22c58b;
  --success-bg: rgba(34, 197, 139, 0.12);
  --error: #f8746c;
  --error-bg: rgba(248, 116, 108, 0.12);
  --warning: #f6b93b;
  --warning-bg: rgba(246, 185, 59, 0.12);
  --info: #5da3fa;
  --info-bg: rgba(93, 163, 250, 0.12);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 24px 48px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 480px);
  color: var(--text);
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease;
}

::selection { background: var(--primary-soft); color: var(--primary-dark); }

/* ================================================================
   Header
   ================================================================ */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  height: var(--header-h);
  padding: 0 24px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 9px;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}

.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { background: var(--surface-alt); color: var(--text); }

#mobile-menu-btn { display: none; }

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

.brand-logo-img {
  height: 22px;
  width: auto;
  display: block;
  flex-shrink: 0;
  background: #fff;
  border-radius: 6px;
  padding: 5px 9px;
  box-shadow: var(--shadow-xs);
}

.brand-text { min-width: 0; }
.breadcrumb { font-size: 11.5px; color: var(--text-faint); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.breadcrumb .sep { margin: 0 4px; }
.breadcrumb .current { color: var(--text-muted); font-weight: 500; }

.header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 12.5px;
  color: var(--text);
}

.badge-label { color: var(--text-faint); }
.badge strong { color: var(--text); font-weight: 600; }

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}

.status-dot.ok { background: var(--success); box-shadow: 0 0 0 3px var(--success-bg); }
.status-dot.err { background: var(--error); box-shadow: 0 0 0 3px var(--error-bg); }

/* user menu */

.user-menu { position: relative; }

.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 4px 10px 4px 4px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
}

.user-menu-btn:hover { background: var(--surface-alt); }

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(150deg, var(--primary-light), var(--primary-dark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  font-weight: 700;
  flex-shrink: 0;
}

.user-menu-btn .chev { width: 12px; height: 12px; color: var(--text-faint); }

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 190px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 50;
  display: none;
}

.user-menu-dropdown.open { display: block; animation: pop-in 0.12s ease; }

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  border: none;
  background: transparent;
  padding: 9px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  text-align: left;
  font-family: inherit;
}

.user-menu-item svg { width: 14px; height: 14px; color: var(--text-faint); }
.user-menu-item:hover { background: var(--surface-alt); }
.user-menu-item.danger { color: var(--error); }
.user-menu-item.danger svg { color: var(--error); }
.user-menu-item.danger:hover { background: var(--error-bg); }

.user-menu-meta {
  padding: 8px 10px 6px;
  font-size: 11px;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ================================================================
   App shell (sidebar layout)
   ================================================================ */

.app-shell {
  display: flex;
  align-items: flex-start;
  width: 100%;
  padding: 22px 28px 60px;
  gap: 26px;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 18, 0.5);
  z-index: 39;
}

.sidebar-backdrop.show { display: block; animation: fade-in 0.15s ease; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: calc(var(--header-h) + 20px);
  transition: width 0.18s ease;
}

.sidebar-scroll {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-height: calc(100vh - var(--header-h) - 40px);
  overflow-y: auto;
  padding-right: 2px;
}

.nav-group-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  font-weight: 700;
  padding: 0 10px;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
}

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

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  border: none;
  background: transparent;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  text-align: left;
  font-family: inherit;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-link span { overflow: hidden; text-overflow: ellipsis; }

.nav-link:hover { background: var(--surface-alt); color: var(--text); }

.nav-link.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.sidebar-footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

/* collapsed (icon rail) — desktop only */

.sidebar.collapsed { width: var(--sidebar-w-collapsed); }
.sidebar.collapsed .nav-group-label,
.sidebar.collapsed .nav-link span,
.sidebar.collapsed .brand-text { display: none; }
.sidebar.collapsed .nav-link { justify-content: center; padding: 10px; }
.sidebar.collapsed #sidebar-collapse-btn svg { transform: rotate(180deg); }

.app-content { flex: 1; min-width: 0; }

@media (max-width: 960px) {
  #mobile-menu-btn { display: flex; }

  .sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    height: 100vh;
    width: 260px;
    z-index: 40;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 16px;
    box-shadow: var(--shadow-lg);
    transition: left 0.22s ease;
  }

  .sidebar.mobile-open { left: 0; }
  .sidebar.collapsed { width: 260px; }
  .sidebar.collapsed .nav-group-label,
  .sidebar.collapsed .nav-link span { display: block; }
  .sidebar.collapsed .nav-link { justify-content: flex-start; padding: 9px 10px; }

  #sidebar-collapse-btn { display: none; }
}

/* ================================================================
   Layout / typography
   ================================================================ */

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade-in 0.18s ease; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.section-head h2 { margin: 0 0 5px; font-size: 21px; letter-spacing: -0.015em; font-weight: 700; }
.subtitle { margin: 0; color: var(--text-muted); font-size: 13.5px; line-height: 1.55; max-width: 62ch; }

h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 700;
  margin: 26px 0 10px;
}

h3 .muted { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 12.5px; }
.muted { color: var(--text-faint); font-size: 12.5px; }
.hint { font-weight: 400; text-transform: none; color: var(--text-faint); }

/* ================================================================
   Forms
   ================================================================ */

form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 26px 22px;
  box-shadow: var(--shadow-sm);
}

.row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: flex-end;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 210px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-muted);
}

label.grow { flex: 2 1 280px; }

input, textarea, select {
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea { resize: vertical; }

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

input:hover, textarea:hover, select:hover { border-color: var(--border-strong); }

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

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M0 0l5 6 5-6z' fill='%2398a2b3'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
  cursor: pointer;
}

input[type="radio"] { width: auto; padding: 0; }

/* ================================================================
   Segmented control
   ================================================================ */

.segmented {
  display: inline-flex;
  gap: 4px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 4px;
  border-radius: 11px;
}

.segmented-option { position: relative; cursor: pointer; margin: 0; }

.segmented-option input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  margin: 0;
}

.segmented-option span {
  display: block;
  padding: 8px 20px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.segmented-option input:checked + span {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

/* ================================================================
   Tables
   ================================================================ */

.table-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 12px;
  background: var(--surface);
}

.table-scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead th {
  background: var(--surface-alt);
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  font-weight: 700;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-alt); }

table input, table select {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  padding: 7px 8px;
  border-radius: 6px;
  font-size: 13.5px;
}

table input:hover, table select:hover { border-color: var(--border); }

table input:focus, table select:focus {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.amt { font-variant-numeric: tabular-nums; color: var(--text-muted); font-weight: 500; }

.del-item, .del-tax {
  border: none;
  background: transparent;
  color: var(--text-faint);
  width: 28px;
  height: 28px;
  border-radius: 7px;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}

.del-item:hover, .del-tax:hover { background: var(--error-bg); color: var(--error); }

/* ================================================================
   Buttons
   ================================================================ */

button {
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}

button:hover { background: var(--surface-alt); border-color: var(--border-strong); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button:disabled:hover { background: var(--surface); transform: none; }

button.primary {
  background: linear-gradient(180deg, var(--primary-light), var(--primary));
  border-color: var(--primary-dark);
  color: #fff;
  font-weight: 600;
  padding: 11px 20px;
  margin-top: 6px;
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.3), 0 6px 14px rgba(79, 70, 229, 0.22);
}

button.primary:hover { background: linear-gradient(180deg, var(--primary), var(--primary-dark)); }

button.primary.is-loading { position: relative; color: transparent; pointer-events: none; }

button.primary.is-loading::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 15px; height: 15px;
  margin: -7.5px 0 0 -7.5px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.spin { animation: spin 0.8s linear infinite; }

/* ================================================================
   Totals
   ================================================================ */

.total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px 16px;
  margin: 16px 0 4px;
}

.total-label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.total-value { font-size: 19px; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }

/* ================================================================
   Dashboard — greeting + hero cards
   ================================================================ */

.dash-greeting {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.dash-greeting h2 { margin: 0 0 4px; font-size: 23px; font-weight: 800; letter-spacing: -0.02em; }
.dash-greeting .subtitle { margin: 0; }

.hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.hero-card {
  position: relative;
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  color: #fff;
  overflow: hidden;
  min-height: 128px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
  isolation: isolate;
}

.hero-card.c-blue { background: linear-gradient(135deg, #5b8def, #3454d1); }
.hero-card.c-amber { background: linear-gradient(135deg, #f7a94a, #dc7f14); }
.hero-card.c-rose { background: linear-gradient(135deg, #fb7f97, #dc2f57); }
.hero-card.c-violet { background: linear-gradient(135deg, #ac8bfa, #7c3aed); }

.hero-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }

.hero-card-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  opacity: 0.88;
}

.hero-card-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.hero-card-icon svg { width: 16px; height: 16px; }

.hero-card-value {
  font-size: 24px;
  font-weight: 800;
  margin-top: 12px;
  font-variant-numeric: tabular-nums;
  position: relative;
  z-index: 1;
}

.hero-card-value.money::before { content: "₹"; font-size: 0.62em; margin-right: 1px; opacity: 0.85; }

.hero-card-sub { font-size: 11.5px; opacity: 0.9; margin-top: 3px; position: relative; z-index: 1; }

.hero-card-wave {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 34px;
  z-index: 0;
}

/* ================================================================
   Dashboard — monthly trend chart
   ================================================================ */

.trend-chart { width: 100%; height: auto; overflow: visible; }
.trend-chart .grid-line { stroke: var(--border); stroke-width: 1; }
.trend-chart .axis-label { fill: var(--text-faint); font-size: 9.5px; font-family: inherit; }
.trend-chart .month-label { fill: var(--text-faint); font-size: 10px; font-family: inherit; text-anchor: middle; }
.trend-chart .bar-sales { fill: var(--primary); }
.trend-chart .bar-purchase { fill: #d97706; }

/* ================================================================
   Dashboard — radial gauge (outstanding)
   ================================================================ */

.radial-wrap { display: flex; align-items: center; justify-content: center; gap: 20px; padding: 8px 0 4px; }
.radial-center-value { font-size: 17px; font-weight: 800; fill: var(--text); font-family: inherit; text-anchor: middle; }
.radial-center-label { font-size: 9px; fill: var(--text-faint); font-family: inherit; text-anchor: middle; text-transform: uppercase; letter-spacing: 0.05em; }

/* ================================================================
   Dashboard — activity list (recent vouchers)
   ================================================================ */

.activity-list { display: flex; flex-direction: column; }

.activity-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--border);
}

.activity-item:last-child { border-bottom: none; }

.activity-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
}

.activity-icon svg { width: 16px; height: 16px; }
.activity-icon.cash { background: linear-gradient(135deg, #5b8def, #3454d1); }
.activity-icon.credit { background: linear-gradient(135deg, #34c98f, #059669); }

.activity-body { flex: 1; min-width: 0; }
.activity-title { font-size: 13.5px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-sub { font-size: 11.5px; color: var(--text-faint); margin-top: 1px; }
.activity-amount { font-size: 13.5px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; flex-shrink: 0; }

/* ================================================================
   Dashboard — KPI cards & charts
   ================================================================ */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}

.stat-tile {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 17px 18px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--primary-soft);
  color: var(--primary);
}

.stat-icon svg { width: 18px; height: 18px; }

.stat-tile.accent-success .stat-icon { background: var(--success-bg); color: var(--success); }
.stat-tile.accent-error .stat-icon { background: var(--error-bg); color: var(--error); }
.stat-tile.accent-warning .stat-icon { background: var(--warning-bg); color: var(--warning); }
.stat-tile.accent-info .stat-icon { background: var(--info-bg); color: var(--info); }

.stat-body { min-width: 0; }

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  font-weight: 700;
  margin-bottom: 6px;
  white-space: nowrap;
}

.stat-value {
  font-size: 21px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.stat-value.money::before {
  content: "₹";
  font-size: 0.62em;
  margin-right: 1px;
  color: var(--text-faint);
  font-weight: 600;
}

.stat-tile.warn .stat-value { color: var(--error); }

.chart-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 16px;
  margin-bottom: 8px;
}

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

.chart-card-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chart-legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--text-muted); font-weight: 500; }
.chart-legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }

.bar-chart { display: flex; flex-direction: column; gap: 14px; }

.bar-chart-row { display: flex; align-items: center; gap: 12px; }
.bar-chart-label { width: 64px; flex-shrink: 0; font-size: 12.5px; font-weight: 600; color: var(--text-muted); }

.bar-chart-track {
  flex: 1;
  height: 22px;
  background: var(--surface-alt);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.bar-chart-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  min-width: 2px;
}

.bar-chart-fill.sales { background: linear-gradient(90deg, var(--primary-light), var(--primary)); }
.bar-chart-fill.purchase { background: linear-gradient(90deg, #f59e0b, #d97706); }

.bar-chart-value { width: 96px; text-align: right; font-size: 12.5px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; flex-shrink: 0; }

.donut-wrap { height: 100%;display: flex; align-items: center; gap: 20px; justify-content: center; padding: 6px 0; }
.donut-wrap svg { flex-shrink: 0; }

.donut-legend { display: flex; flex-direction: column; gap: 10px; }
.donut-legend-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.donut-legend-item .dot { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }
.donut-legend-item .lbl { color: var(--text-muted); }
.donut-legend-item .val { font-weight: 700; color: var(--text); margin-left: 4px; }

.master-filter { display: block; width: 100%; margin: 10px 0 12px; }

/* ================================================================
   Toasts
   ================================================================ */

#toast-container {
  position: fixed;
  top: 76px;
  right: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 340px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--info);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.2s ease;
  font-size: 13px;
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--error); }
.toast.warning { border-left-color: var(--warning); }

.toast-icon { flex-shrink: 0; margin-top: 1px; }
.toast-icon svg { width: 16px; height: 16px; }
.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--error); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info .toast-icon { color: var(--info); }

.toast-msg { flex: 1; color: var(--text); line-height: 1.45; }
.toast-close { border: none; background: transparent; padding: 0; color: var(--text-faint); cursor: pointer; flex-shrink: 0; }
.toast-close:hover { color: var(--text); background: transparent; }

.toast.leaving { animation: toast-out 0.15s ease forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(16px); }
}

/* ================================================================
   Skeleton loaders & empty states
   ================================================================ */

.skel {
  background: linear-gradient(90deg, var(--surface-alt) 25%, var(--surface-hover) 37%, var(--surface-alt) 63%);
  background-size: 400% 100%;
  animation: skel-shimmer 1.4s ease infinite;
  border-radius: 6px;
}

@keyframes skel-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.skel-stat-value { width: 70px; height: 21px; }

.skel-row td { padding: 10px 12px; }
.skel-row .skel { height: 12px; width: 80%; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 36px 20px;
  color: var(--text-faint);
  text-align: center;
}

.empty-state svg { width: 30px; height: 30px; color: var(--text-faint); opacity: 0.7; }
.empty-state .empty-title { font-size: 13.5px; font-weight: 600; color: var(--text-muted); }
.empty-state .empty-hint { font-size: 12px; }

/* ================================================================
   Result panel
   ================================================================ */

.result-wrap { margin-top: 18px; }

.result-banner {
  display: none;
  align-items: center;
  gap: 10px;
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 10px;
}

.result-banner.show { display: flex; }
.result-banner svg { width: 16px; height: 16px; flex-shrink: 0; }

.result-banner.success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(5, 150, 105, 0.25); }
.result-banner.error { background: var(--error-bg); color: var(--error); border: 1px solid rgba(220, 38, 38, 0.25); }

.result-details {
  margin-top: 8px;
}

.result-details summary {
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 6px;
  user-select: none;
}

.result-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 6px;
}

.result {
  background: #0b1020;
  color: #c7cedb;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid #1c2333;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 20px;
  max-height: 320px;
  overflow: auto;
}

.result:empty::before { content: "—"; color: #3a4356; }

.result.success { border-color: var(--success); box-shadow: 0 0 0 1px rgba(5, 150, 105, 0.3) inset; }
.result.error { border-color: var(--error); box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.3) inset; }

/* ================================================================
   Responsive
   ================================================================ */

@media (max-width: 640px) {
  .row { flex-direction: column; align-items: stretch; }
  label.grow { min-width: 0; }
  .chart-grid { grid-template-columns: 1fr; }
  .header-right .badge.status-badge { display: none; }
}

/* ================================================================
   Login — split screen
   ================================================================ */

:root {
  --login-illu-1: #cfe0ff;
  --login-illu-2: #eef4ff;
}

:root[data-theme="dark"] {
  --login-illu-1: #1c2440;
  --login-illu-2: #12151f;
}

.login-split {
  display: flex;
  min-height: 100vh;
}

.login-illustration {
  flex: 1 1 46%;
  background: linear-gradient(160deg, var(--login-illu-2), var(--login-illu-1));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

.login-illustration svg { width: 100%; max-width: 380px; height: auto; }

.login-form-side {
  flex: 1 1 54%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  background: var(--surface);
}

.login-theme-btn { position: absolute; top: 24px; right: 28px; }

.login-form-inner { width: 100%; max-width: 380px; }

.login-form-inner .flow-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 36px; }
.login-form-inner .flow-brand .brand-logo-img { height: 80px; }

.login-welcome { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 6px; color: var(--primary); }
.login-form-inner .subtitle { margin: 0 0 24px; }

.login-form-inner form { box-shadow: none; border: none; padding: 0; background: transparent; }
.login-form-inner label { margin-bottom: 16px; }
.login-form-inner input { width: 100%; }
.login-form-inner button.primary { width: 100%; margin-top: 4px; }

.login-hint {
  margin: 20px 0 0;
  font-size: 12px;
  color: var(--text-faint);
  text-align: center;
  line-height: 1.5;
}

.flow-error {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid rgba(220, 38, 38, 0.25);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

.flow-error.show { display: block; }

@media (max-width: 860px) {
  .login-illustration { display: none; }
  .login-form-side { flex: 1 1 100%; }
}

/* ================================================================
   Searchable dropdown (autocomplete combobox)
   ================================================================ */

.ss { position: relative; }
.ss select { display: none; }

.ss-input {
  width: 100%;
  cursor: text;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M0 0l5 6 5-6z' fill='%2398a2b3'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
}

.ss-input:disabled { cursor: not-allowed; opacity: 0.6; }

.ss-clear {
  position: absolute;
  top: 50%;
  right: 26px;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--text-faint);
  width: 20px;
  height: 20px;
  border-radius: 5px;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}

.ss-clear:hover { background: var(--surface-alt); color: var(--text); }

.ss-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 40;
  max-height: 260px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 4px;
}

.ss-item {
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 13.5px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ss-item:hover, .ss-item.hl { background: var(--primary-soft); color: var(--primary); }
.ss-item.selected { font-weight: 600; }

.ss-empty {
  padding: 10px;
  font-size: 13px;
  color: var(--text-faint);
  text-align: center;
}

table .ss { width: 100%; }

table .ss-input {
  padding: 7px 26px 7px 8px;
  font-size: 13.5px;
  border-color: transparent;
  background-color: transparent;
}

table .ss-input:hover { border-color: var(--border); }

table .ss-input:focus {
  border-color: var(--primary);
  background-color: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

table .ss-clear { right: 22px; }
