/* =====================================================================
   AIBUTAI — app.css
   Part 1: tokens, reset, typography, layout helpers, utilities
   Rule: hardcoded colour sirf :root me. Component hamesha var() use karega.
   ===================================================================== */

/* ---------- 1. tokens (Section 2.7 — LOCK) ---------- */
:root {
  /* brand */
  --brand-600: #4F46E5;
  --brand-700: #4338CA;
  --brand-100: #E0E7FF;
  --brand-50:  #EEF2FF;
  /* money */
  --money: #059669;
  --money-soft: #ECFDF5;
  /* whatsapp */
  --wa: #25D366;
  --wa-dark: #128C7E;
  /* text */
  --ink-900: #0F172A;
  --ink-700: #334155;
  --ink-500: #64748B;
  --ink-400: #94A3B8;
  /* surfaces */
  --line: #E2E8F0;
  --line-soft: #F1F5F9;
  --bg: #F8FAFC;
  --card: #FFFFFF;
  /* status */
  --danger: #DC2626;
  --danger-soft: #FEF2F2;
  --warn: #D97706;
  --warn-soft: #FFFBEB;
  --info: #2563EB;
  --info-soft: #EFF6FF;
  --success: #059669;
  --success-soft: #ECFDF5;
  /* type */
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, "Noto Sans", sans-serif;
  --font-display: "Plus Jakarta Sans", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, Consolas, "Cascadia Mono", monospace;
  /* space */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px; --s5: 20px;
  --s6: 24px; --s7: 32px; --s8: 40px; --s9: 56px; --s10: 72px;
  /* radius */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-pill: 999px;
  /* shadow */
  --sh-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --sh-md: 0 4px 12px rgba(15, 23, 42, .08);
  --sh-lg: 0 12px 32px rgba(15, 23, 42, .12);
  /* layout */
  --site-w: 1160px;
  --dash-w: 1440px;
  --sidebar-w: 264px;
  --topbar-h: 64px;
}

/* dark mode tokens (toggle P8 me aayega) */
[data-theme="dark"] {
  --bg: #0B1220;
  --card: #111C2E;
  --line: #1E2A3D;
  --line-soft: #16233A;
  --ink-900: #E7EDF6;
  --ink-700: #B9C5D6;
  --ink-500: #8496AD;
  --ink-400: #63748C;
}

/* ---------- 2. reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-700);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img, svg, video { max-width: 100%; vertical-align: middle; }
a { color: var(--brand-600); text-decoration: none; }
a:hover { color: var(--brand-700); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
table { border-collapse: collapse; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--s4) 0; }
::selection { background: var(--brand-100); color: var(--ink-900); }

/* ---------- 3. typography ---------- */
h1, h2, h3, h4, h5, h6 { margin: 0 0 var(--s3); color: var(--ink-900); font-weight: 700; }
h1 { font-size: 40px; line-height: 1.15; }
h2 { font-size: 30px; line-height: 1.2; }
h3 { font-size: 22px; line-height: 1.3; font-weight: 600; }
h4 { font-size: 18px; line-height: 1.35; font-weight: 600; }
p { margin: 0 0 var(--s3); }
p:last-child { margin-bottom: 0; }
.text-sm { font-size: 13px; line-height: 1.5; }
.text-xs { font-size: 12px; line-height: 1.4; }

/* ---------- 4. scrollbar ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--ink-400) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: var(--r-pill); border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-400); }

/* ---------- 5. focus ring ---------- */
:focus-visible { outline: 2px solid var(--brand-600); outline-offset: 2px; border-radius: var(--r-sm); }
:focus:not(:focus-visible) { outline: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---------- 6. layout helpers ---------- */
.container { width: 100%; max-width: var(--site-w); margin: 0 auto; padding: 0 var(--s5); }
.grid { display: grid; gap: var(--s5); }
.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)); }
.row { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.between { justify-content: space-between; }
.center { justify-content: center; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: var(--s3); }
.stack-2 { gap: var(--s2); }
.stack-6 { gap: var(--s6); }

/* ---------- 7. utilities ---------- */
.mt-1 { margin-top: var(--s1); } .mt-2 { margin-top: var(--s2); }
.mt-3 { margin-top: var(--s3); } .mt-4 { margin-top: var(--s4); }
.mt-6 { margin-top: var(--s6); } .mt-8 { margin-top: var(--s8); }
.mb-1 { margin-bottom: var(--s1); } .mb-2 { margin-bottom: var(--s2); }
.mb-3 { margin-bottom: var(--s3); } .mb-4 { margin-bottom: var(--s4); }
.mb-6 { margin-bottom: var(--s6); } .mb-8 { margin-bottom: var(--s8); }
.text-muted { color: var(--ink-500); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-money { color: var(--money); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mono { font-family: var(--mono); font-size: 13px; }
.hidden { display: none !important; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.w-full { width: 100%; }
.divider { height: 1px; background: var(--line); border: 0; margin: var(--s4) 0; }
.code {
  font-family: var(--mono); font-size: 13px; background: var(--line-soft);
  padding: 2px 6px; border-radius: var(--r-sm); color: var(--ink-900);
}
.kbd {
  font-family: var(--mono); font-size: 12px; padding: 2px 6px; border-radius: var(--r-sm);
  border: 1px solid var(--line); border-bottom-width: 2px; background: var(--card); color: var(--ink-700);
}
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px;
  border-radius: var(--r-pill); background: var(--brand-50); color: var(--brand-700);
  font-size: 12px; font-weight: 600;
}


/* ---------- 8. buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 40px; padding: 9px 16px; border-radius: var(--r-md);
  border: 1px solid transparent; background: var(--brand-600); color: #fff;
  font-size: 14px; font-weight: 600; line-height: 1.2; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { background: var(--brand-700); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; flex: 0 0 auto; }

.btn-primary { background: var(--brand-600); color: #fff; }
.btn-primary:hover { background: var(--brand-700); }

.btn-secondary { background: var(--card); color: var(--ink-900); border-color: var(--line); box-shadow: var(--sh-sm); }
.btn-secondary:hover { background: var(--line-soft); color: var(--ink-900); border-color: var(--ink-400); }

.btn-ghost { background: transparent; color: var(--ink-700); }
.btn-ghost:hover { background: var(--line-soft); color: var(--ink-900); }

.btn-danger { background: var(--danger); }
.btn-danger:hover { filter: brightness(.92); }

.btn-wa { background: var(--wa); color: var(--ink-900); }
.btn-wa:hover { background: var(--wa-dark); color: #fff; }

.btn-sm { min-height: 32px; padding: 6px 12px; font-size: 13px; border-radius: var(--r-sm); }
.btn-sm svg { width: 16px; height: 16px; }
.btn-lg { min-height: 48px; padding: 12px 22px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-icon { width: 40px; min-height: 40px; padding: 0; }
.btn-icon.btn-sm { width: 32px; min-height: 32px; }

.btn:disabled, .btn[disabled] {
  opacity: .55; cursor: not-allowed; pointer-events: none; box-shadow: none;
}

/* loading spinner (app.js "is-loading" lagata hai) */
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, .5); border-top-color: #fff; border-radius: 50%;
  animation: btn-spin .7s linear infinite;
}
.btn-secondary.loading::after, .btn-ghost.loading::after {
  border-color: var(--line); border-top-color: var(--brand-600);
}
@keyframes btn-spin { to { transform: rotate(360deg); } }


/* ---------- 9. forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--s4); }
.label { font-size: 13px; font-weight: 600; color: var(--ink-900); }
.label .req { color: var(--danger); margin-left: 2px; }
.input, .select, .textarea {
  width: 100%; min-height: 42px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--card); color: var(--ink-900); font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder, .textarea::placeholder { color: var(--ink-400); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-400); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand-600); box-shadow: 0 0 0 3px var(--brand-100);
}
.textarea { min-height: 110px; resize: vertical; line-height: 1.55; }
.select {
  appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.input:disabled, .select:disabled, .textarea:disabled {
  background: var(--line-soft); color: var(--ink-500); cursor: not-allowed;
}
.input.error, .select.error, .textarea.error { border-color: var(--danger); }
.input.error:focus, .select.error:focus, .textarea.error:focus { box-shadow: 0 0 0 3px var(--danger-soft); }
.hint { font-size: 12px; color: var(--ink-500); }
.field-error { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; color: var(--danger); }

.input-group {
  display: flex; align-items: stretch; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--card);
}
.input-group:focus-within { border-color: var(--brand-600); box-shadow: 0 0 0 3px var(--brand-100); }
.input-group .input { border: 0; border-radius: 0; box-shadow: none !important; }
.input-group .prefix, .input-group .suffix {
  display: flex; align-items: center; padding: 0 12px;
  background: var(--line-soft); color: var(--ink-500); font-size: 13px; font-weight: 600;
}

.switch { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink-700); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  position: relative; flex: 0 0 auto; width: 40px; height: 22px;
  border-radius: var(--r-pill); background: var(--line); transition: background .15s;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--card); box-shadow: var(--sh-sm); transition: transform .15s;
}
.switch input:checked + .track { background: var(--brand-600); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--brand-600); outline-offset: 2px; }

.checkbox { display: inline-flex; align-items: flex-start; gap: 8px; font-size: 14px; cursor: pointer; }
.checkbox input { width: 16px; height: 16px; margin-top: 3px; accent-color: var(--brand-600); }

.search { position: relative; }
.search .input { padding-left: 36px; }
.search > svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--ink-400); pointer-events: none;
}

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4) var(--s5); }
.form-grid .full { grid-column: 1 / -1; }


/* ---------- 10. tables ---------- */
.table-wrap {
  width: 100%; overflow-x: auto; border: 1px solid var(--line);
  border-radius: var(--r-lg); background: var(--card);
}
.table { width: 100%; font-size: 14px; }
.table th, .table td { padding: 11px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line-soft); }
.table th {
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-500); background: var(--line-soft); white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--line-soft); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.num { font-weight: 600; color: var(--ink-900); }
.table.compact th, .table.compact td { padding: 8px 12px; font-size: 13px; }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; }
.table-empty td { padding: var(--s8) var(--s4); text-align: center; color: var(--ink-500); }

/* ---------- 11. badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px;
  border-radius: var(--r-pill); font-size: 12px; font-weight: 600; line-height: 1.6;
  background: var(--line-soft); color: var(--ink-700); white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge-green { background: var(--success-soft); color: var(--success); }
.badge-amber { background: var(--warn-soft); color: var(--warn); }
.badge-red { background: var(--danger-soft); color: var(--danger); }
.badge-blue { background: var(--info-soft); color: var(--info); }
.badge-gray { background: var(--line-soft); color: var(--ink-500); }
.badge-brand { background: var(--brand-100); color: var(--brand-700); }
.badge-plain::before { display: none; }

/* ---------- 12. alerts ---------- */
.alert {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--line-soft); color: var(--ink-900); font-size: 14px;
}
.alert svg { flex: 0 0 auto; width: 18px; height: 18px; margin-top: 1px; }
.alert-success { background: var(--success-soft); border-color: var(--success-soft); }
.alert-success svg { color: var(--success); }
.alert-error { background: var(--danger-soft); border-color: var(--danger-soft); }
.alert-error svg { color: var(--danger); }
.alert-warn { background: var(--warn-soft); border-color: var(--warn-soft); }
.alert-warn svg { color: var(--warn); }
.alert-info { background: var(--info-soft); border-color: var(--info-soft); }
.alert-info svg { color: var(--info); }


/* ---------- 13. cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-sm); }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  flex-wrap: wrap; padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line);
}
.card-title { margin: 0; font-size: 16px; font-weight: 600; color: var(--ink-900); }
.card-sub { margin: 2px 0 0; font-size: 13px; color: var(--ink-500); }
.card-body { padding: var(--s5); }
.card-body.flush { padding: 0; }
.card-body.tight { padding: var(--s3); }
.card-foot {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  flex-wrap: wrap; padding: var(--s3) var(--s5);
  border-top: 1px solid var(--line); background: var(--line-soft);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.card-hover { transition: box-shadow .15s, border-color .15s, transform .15s; }
.card-hover:hover { box-shadow: var(--sh-md); border-color: var(--ink-400); transform: translateY(-1px); }
.card-flat { box-shadow: none; }
.card-money { background: var(--money-soft); border-color: var(--success-soft); }
.card-money .card-title { color: var(--money); }

/* ---------- 14. stats ---------- */
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--s4) var(--s5); box-shadow: var(--sh-sm);
}
.stat-label {
  display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; color: var(--ink-500);
}
.stat-value {
  margin-top: 6px; font-size: 26px; font-weight: 700; line-height: 1.2;
  color: var(--ink-900); font-variant-numeric: tabular-nums;
}
.stat-value.money { color: var(--money); }
.stat-delta { display: inline-flex; align-items: center; gap: 3px; margin-top: 6px; font-size: 12px; font-weight: 600; }
.stat-delta.up { color: var(--money); }
.stat-delta.down { color: var(--danger); }
.stat-delta svg { width: 13px; height: 13px; }
.stat-icon {
  display: flex; align-items: center; justify-content: center; width: 38px; height: 38px;
  border-radius: var(--r-md); background: var(--brand-50); color: var(--brand-600);
}


/* ---------- 15. tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab {
  padding: 10px 14px; border: 0; border-bottom: 2px solid transparent;
  background: transparent; color: var(--ink-500); font-size: 14px; font-weight: 600; white-space: nowrap;
}
.tab:hover { color: var(--ink-900); }
.tab.active { color: var(--brand-600); border-bottom-color: var(--brand-600); }
.tab-panel { display: none; padding-top: var(--s5); }
.tab-panel.active { display: block; }

/* ---------- 16. modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  padding: var(--s4); background: rgba(15, 23, 42, .5);
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: 100%; max-width: 520px; max-height: 90vh; overflow: auto;
  background: var(--card); border-radius: var(--r-lg); box-shadow: var(--sh-lg);
}
.modal.modal-lg { max-width: 760px; }
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3);
  padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line);
}
.modal-title { margin: 0; font-size: 17px; font-weight: 600; color: var(--ink-900); }
.modal-body { padding: var(--s5); }
.modal-foot {
  display: flex; justify-content: flex-end; gap: var(--s2);
  padding: var(--s3) var(--s5); border-top: 1px solid var(--line); background: var(--line-soft);
}
body.modal-open { overflow: hidden; }

/* ---------- 17. toast ---------- */
.toast-wrap {
  position: fixed; right: var(--s5); bottom: var(--s5); z-index: 70;
  display: flex; flex-direction: column; gap: var(--s2); max-width: 360px;
}
.toast {
  display: flex; align-items: flex-start; gap: 8px; padding: 11px 14px;
  border-radius: var(--r-md); background: var(--ink-900); color: #fff;
  font-size: 14px; box-shadow: var(--sh-lg); animation: toast-in .18s ease-out;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--info); }
.toast svg { flex: 0 0 auto; width: 17px; height: 17px; margin-top: 1px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- 18. dropdown ---------- */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50;
  min-width: 200px; padding: 6px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--sh-md);
}
.dropdown-menu[hidden] { display: none; }
.dropdown-item {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px;
  border: 0; border-radius: var(--r-sm); background: transparent;
  color: var(--ink-700); font-size: 14px; text-align: left;
}
.dropdown-item:hover { background: var(--line-soft); color: var(--ink-900); }
.dropdown-item svg { width: 16px; height: 16px; color: var(--ink-500); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-head { padding: 8px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.dropdown-sep { height: 1px; margin: 4px 0; background: var(--line); }

/* ---------- 19. tooltip ---------- */
.tooltip { position: relative; }
.tooltip::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%); padding: 5px 8px; border-radius: var(--r-sm);
  background: var(--ink-900); color: #fff; font-size: 12px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .12s;
}
.tooltip:hover::after { opacity: 1; }


/* ---------- 20. empty state ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--s2); padding: var(--s9) var(--s5); text-align: center;
}
.empty-icon {
  display: flex; align-items: center; justify-content: center; width: 56px; height: 56px;
  margin-bottom: var(--s2); border-radius: var(--r-pill); background: var(--line-soft); color: var(--ink-400);
}
.empty-icon svg { width: 26px; height: 26px; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--ink-900); }
.empty-text { max-width: 380px; font-size: 14px; color: var(--ink-500); }

/* ---------- 21. skeleton ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--line-soft) 25%, var(--line) 37%, var(--line-soft) 63%);
  background-size: 400% 100%; animation: skel 1.4s ease infinite; border-radius: var(--r-sm);
}
.skeleton-line { height: 12px; margin-bottom: 8px; }
.skeleton-line:last-child { width: 60%; margin-bottom: 0; }
.skeleton-block { height: 120px; border-radius: var(--r-md); }
@keyframes skel { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- 22. progress ---------- */
.progress { width: 100%; height: 8px; border-radius: var(--r-pill); background: var(--line); overflow: hidden; }
.progress-bar { height: 100%; border-radius: var(--r-pill); background: var(--brand-600); transition: width .3s ease; }
.progress-bar.money { background: var(--money); }
.progress-bar.warn { background: var(--warn); }
.progress-bar.danger { background: var(--danger); }
.progress-sm { height: 5px; }
.progress-meta { display: flex; justify-content: space-between; margin-bottom: 4px; font-size: 12px; color: var(--ink-500); }

/* ---------- 23. timeline ---------- */
.timeline { position: relative; margin: 0; padding: 0 0 0 var(--s5); list-style: none; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 1px; background: var(--line); }
.timeline-item { position: relative; padding-bottom: var(--s4); }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: ""; position: absolute; left: calc(-1 * var(--s5) + 2px); top: 5px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--brand-600);
  box-shadow: 0 0 0 3px var(--brand-50);
}
.timeline-title { font-size: 14px; font-weight: 600; color: var(--ink-900); }
.timeline-time { display: block; margin-top: 2px; font-size: 12px; color: var(--ink-500); }

/* ---------- 24. charts (SVG) ---------- */
.sparkline { display: block; width: 100%; height: 56px; overflow: visible; }
.sparkline path.line { fill: none; stroke: var(--brand-600); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sparkline path.area { fill: var(--brand-50); stroke: none; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; }
.bars-bar { position: relative; flex: 1 1 0; min-width: 6px; border-radius: var(--r-sm) var(--r-sm) 0 0; background: var(--brand-100); }
.bars-bar.hi { background: var(--brand-600); }
.bars-bar[data-label]::after {
  content: attr(data-label); position: absolute; left: 50%; bottom: -20px;
  transform: translateX(-50%); font-size: 11px; color: var(--ink-500); white-space: nowrap;
}
.donut { transform: rotate(-90deg); }
.donut circle { fill: none; stroke-width: 12; }
.donut .track { stroke: var(--line); }
.donut .val { stroke: var(--brand-600); stroke-linecap: round; }


/* ---------- 25. dashboard shell ---------- */
.dash {
  display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh; max-width: var(--dash-w); margin: 0 auto;
}

.dash-sidebar {
  position: sticky; top: 0; z-index: 40; align-self: start; height: 100vh;
  display: flex; flex-direction: column; gap: var(--s2); overflow-y: auto;
  padding: var(--s4) var(--s3); background: var(--card); border-right: 1px solid var(--line);
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: var(--s2) var(--s2) var(--s4); }
.side-brand-mark {
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
  width: 34px; height: 34px; border-radius: var(--r-md);
  background: var(--brand-600); color: #fff; font-size: 15px; font-weight: 700;
}
.side-brand-name { font-size: 15px; font-weight: 700; letter-spacing: -.01em; color: var(--ink-900); }
.side-group { margin-top: var(--s3); }
.side-group-label {
  padding: 0 var(--s3) 6px; font-size: 11px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--ink-400);
}
.side-link {
  display: flex; align-items: center; gap: 10px; padding: 9px var(--s3);
  border-radius: var(--r-md); color: var(--ink-700); font-size: 14px; font-weight: 500;
}
.side-link:hover { background: var(--line-soft); color: var(--ink-900); }
.side-link svg { flex: 0 0 auto; width: 18px; height: 18px; color: var(--ink-500); }
.side-link.active { background: var(--brand-50); color: var(--brand-700); font-weight: 600; }
.side-link.active svg { color: var(--brand-600); }
.side-badge {
  margin-left: auto; padding: 1px 7px; border-radius: var(--r-pill);
  background: var(--brand-100); color: var(--brand-700); font-size: 11px; font-weight: 700;
}
.side-link.active .side-badge { background: var(--brand-600); color: #fff; }
.side-foot { margin-top: auto; padding-top: var(--s3); border-top: 1px solid var(--line); }

.dash-main { display: flex; flex-direction: column; min-width: 0; }
.dash-topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: var(--s3);
  min-height: var(--topbar-h); padding: 0 var(--s5);
  background: var(--card); border-bottom: 1px solid var(--line);
}
.dash-title { margin: 0; font-size: 16px; font-weight: 600; color: var(--ink-900); }
.dash-content {
  flex: 1 1 auto; display: flex; flex-direction: column; gap: var(--s5);
  padding: var(--s5); padding-bottom: var(--s8); max-width: 100%;
}
.dash-page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.dash-page-title { margin: 0; font-size: 22px; font-weight: 700; color: var(--ink-900); }
.dash-page-sub { margin: 2px 0 0; font-size: 14px; color: var(--ink-500); }

/* topbar pieces */
.wallet-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px;
  border: 1px solid var(--success-soft); border-radius: var(--r-pill);
  background: var(--money-soft); color: var(--money); font-size: 14px; font-weight: 700;
}
.wallet-pill svg { width: 16px; height: 16px; }
.wallet-pill.low { background: var(--warn-soft); border-color: var(--warn-soft); color: var(--warn); }
.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--card); color: var(--ink-700);
}
.icon-btn:hover { background: var(--line-soft); color: var(--ink-900); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .dot {
  position: absolute; top: 7px; right: 8px; width: 7px; height: 7px;
  border: 2px solid var(--card); border-radius: 50%; background: var(--danger);
}
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  width: 34px; height: 34px; border-radius: var(--r-pill);
  background: var(--brand-100); color: var(--brand-700); font-size: 13px; font-weight: 700;
}
.avatar-lg { width: 44px; height: 44px; font-size: 15px; }
.user-menu {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px;
  border: 0; border-radius: var(--r-pill); background: transparent;
}
.user-menu:hover { background: var(--line-soft); }
.user-menu-name { font-size: 14px; font-weight: 600; color: var(--ink-900); }
.sidebar-toggle { display: none; }
.dash-overlay { position: fixed; inset: 0; z-index: 35; background: rgba(15, 23, 42, .45); }
.dash-overlay[hidden] { display: none; }

/* ---------- 26. responsive (480 / 768 / 1024 / 1280) ---------- */
@media (max-width: 1279px) {
  .dash { max-width: 100%; }
}
@media (max-width: 1023px) {
  .grid-4, .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash { grid-template-columns: 1fr; }
  .dash-sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w); height: 100%;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--sh-lg);
  }
  .dash.sidebar-open .dash-sidebar { transform: none; }
  .sidebar-toggle { display: inline-flex; }
}
@media (max-width: 767px) {
  h1 { font-size: 30px; }
  h2 { font-size: 24px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .dash-content { gap: var(--s4); padding: var(--s4); padding-bottom: var(--s7); }
  .dash-topbar { padding: 0 var(--s4); }
  .user-menu-name { display: none; }
  .table th, .table td { padding: 9px 11px; }
  .modal-foot { flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; }
  .toast-wrap { left: var(--s4); right: var(--s4); max-width: none; }
}
@media (max-width: 479px) {
  body { font-size: 14px; }
  .dash-content { padding: var(--s3); gap: var(--s3); }
  .card-head, .card-body, .card-foot { padding: var(--s4); }
  .stat { padding: var(--s4); }
  .stat-value { font-size: 22px; }
  .wallet-pill { padding: 5px 9px; font-size: 13px; }
  .btn { min-height: 38px; padding: 8px 14px; }
}


/* ---------- 19. error pages (error.php / 403 / 404 / 500) ---------- */
.err-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s6);
  background: var(--bg);
}
.err-card {
  width: 100%;
  max-width: 540px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-md);
  padding: var(--s8) var(--s7);
  text-align: center;
}
.err-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  padding: 5px 11px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  background: var(--brand-50);
  color: var(--brand-700);
}
.err-code {
  display: block;
  margin: var(--s4) 0 var(--s1);
  font-size: 56px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -.03em;
  color: var(--ink-900);
}
.err-title {
  margin: 0 0 var(--s2);
  font-size: 21px;
  color: var(--ink-900);
}
.err-text {
  margin: 0 auto;
  max-width: 400px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink-500);
}
.err-note {
  margin-top: var(--s4);
  font-size: 12px;
  color: var(--ink-400);
}
.err-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
  justify-content: center;
  margin-top: var(--s6);
}
.err-links {
  margin-top: var(--s6);
  padding-top: var(--s4);
  border-top: 1px solid var(--line-soft);
  font-size: 13px;
  color: var(--ink-500);
}
.err-links a {
  color: var(--brand-600);
  text-decoration: none;
  margin: 0 var(--s2);
}
.err-links a:hover { text-decoration: underline; }

@media (max-width: 480px) {
  .err-card { padding: var(--s6) var(--s5); }
  .err-code { font-size: 44px; }
}

/* ---------- 20. placeholder home (P0 — P1 me replace hoga) ---------- */
.home-card { text-align: left; }
.home-title {
  font-size: 30px;
  margin: var(--s4) 0 var(--s2);
  letter-spacing: -.02em;
}
.home-lead {
  margin: 0;
  max-width: 460px;
}
.home-actions { justify-content: flex-start; }
.home-links { text-align: left; }
.home-next {
  display: block;
  margin-bottom: var(--s2);
}
.home-meta {
  color: var(--ink-400);
  font-size: 12px;
}


/* ---------- 27. dashboard shell v2 (P3) ---------- */
.dash-body { background: var(--bg); }
.dash .skip-link {
  position: absolute; left: -9999px; top: 8px; z-index: 100;
  padding: 8px 14px; border-radius: var(--r-md);
  background: var(--ink-900); color: #fff; font-size: 14px; font-weight: 600;
}
.dash .skip-link:focus { left: 8px; }

.side-brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.side-brand-sub {
  font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--ink-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.side-nav { display: flex; flex-direction: column; }
.side-link.is-soon { color: var(--ink-400); cursor: pointer; }
.side-link.is-soon:hover { background: var(--line-soft); color: var(--ink-700); }
.side-link.is-soon .side-badge { background: var(--line); color: var(--ink-500); }
.side-logout-form { margin: 0; }
.side-logout {
  width: 100%; border: 0; background: transparent; font: inherit;
  text-align: left; cursor: pointer;
}
.side-logout:hover { background: var(--line-soft); color: var(--danger); }

.dash-topbar-title { display: flex; flex-direction: column; min-width: 0; margin-right: auto; }
.dash-title-sub { margin: 0; font-size: 12px; color: var(--ink-500); }
.dash-topbar-right { display: flex; align-items: center; gap: var(--s2); }
.dash-logout-form { margin: 0; }

.dash-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s2); }
.dash-actions .btn { width: 100%; }
.is-disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }

.dash-note { margin: var(--s2) 0 0; }
.dash-note-box { display: flex; align-items: flex-start; gap: var(--s3); }
.dash-note-icon {
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
  width: 40px; height: 40px; border-radius: var(--r-md);
  background: var(--brand-50); color: var(--brand-600);
}
.dash-note-box p { margin: 2px 0 0; }

@media (max-width: 767px) {
  .dash-topbar { flex-wrap: wrap; padding: var(--s2) var(--s3); }
  .dash-topbar-title { order: 3; width: 100%; }
  .dash-topbar-right { margin-left: auto; }
  .wallet-pill { padding: 5px 9px; font-size: 13px; }
}
@media (max-width: 479px) {
  .dash-topbar-right { gap: 6px; }
  .dash-actions { grid-template-columns: 1fr; }
}

/* ---------- 28. table toolbar + pagination (P3.5) ---------- */
.filter-bar {
  display: flex; align-items: flex-end; gap: var(--s3); flex-wrap: wrap;
  padding: var(--s3) var(--s5); border-bottom: 1px solid var(--line);
  background: var(--line-soft);
}
.filter-bar .search .input,
.filter-bar .select { min-height: 38px; }
.filter-bar .select { min-width: 150px; }
.filter-bar .grow { flex: 1 1 220px; }
.filter-bar-actions { margin-left: auto; }

/* bulk selection bar (checkbox select + bulk actions) */
.bulk-bar {
  display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
  padding: var(--s2) var(--s5); border-bottom: 1px solid var(--line);
  background: var(--brand-50); color: var(--brand-700); font-size: 13px;
}
.bulk-bar[hidden] { display: none; }
.bulk-bar .grow { flex: 1 1 200px; }

.pagination { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.page-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--card); color: var(--ink-700);
  font-size: 13px; font-weight: 600; line-height: 1;
}
.page-btn:hover { background: var(--line-soft); color: var(--ink-900); border-color: var(--ink-400); }
.page-btn.active { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.page-btn.is-disabled { opacity: .45; }
.page-ellipsis { padding: 0 2px; font-size: 13px; color: var(--ink-400); }
.page-info { margin-left: auto; font-size: 12px; color: var(--ink-500); }
/* bars ke data-label (bottom:-20px) ke liye neeche jagah */
.card-body .bars { margin-bottom: 22px; }

@media (max-width: 767px) {
  .filter-bar { padding: var(--s3) var(--s4); }
  .filter-bar .select { flex: 1 1 140px; min-width: 0; }
  .page-info { order: 9; width: 100%; margin-left: 0; }
}

/* finance ledger groups (S4.4) — <details class="card ledger-group"> */
.ledger-group > summary { list-style: none; cursor: pointer; border-radius: var(--r-lg) var(--r-lg) 0 0; }
.ledger-group > summary::-webkit-details-marker { display: none; }
.ledger-group > summary:hover { background: var(--line-soft); }
.ledger-group .ledger-chev { display: inline-flex; color: var(--ink-400); transition: transform .15s; }
.ledger-group[open] .ledger-chev { transform: rotate(180deg); }
.ledger-group > .card-body.flush { border-radius: 0 0 var(--r-lg) var(--r-lg); overflow: hidden; }

/* admin apps (S4.5) — app cards + actions repeater */
.app-tile { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex: 0 0 auto; border-radius: var(--r-md); background: var(--brand-50); color: var(--brand-700); }
.app-tile svg { width: 20px; height: 20px; }
.app-tile-sm { width: 28px; height: 28px; border-radius: var(--r-sm); }
.app-tile-sm svg { width: 16px; height: 16px; }
.app-tile-green { background: var(--success-soft); color: var(--success); }
.app-tile-blue { background: var(--info-soft); color: var(--info); }
.app-tile-amber { background: var(--warn-soft); color: var(--warn); }
.app-tile-violet { background: var(--brand-100); color: var(--brand-700); }
.app-tile-slate { background: var(--line-soft); color: var(--ink-500); }
.app-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); }
.app-card-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); padding-top: var(--s3); border-top: 1px solid var(--line-soft); }
.repeater { display: flex; flex-direction: column; gap: var(--s2); }
.repeater-row { display: grid; grid-template-columns: 1.4fr 1.4fr 1fr .8fr auto; gap: var(--s2); align-items: end; }
.repeater-row .field { margin-bottom: 0; }
.repeater-row [data-repeater-remove] { margin-bottom: 1px; }

@media (max-width: 767px) {
  .repeater-row { grid-template-columns: 1fr 1fr; }
  .app-card-meta { grid-template-columns: 1fr 1fr; }
}

/* admin support (S4.7) — ticket conversation bubbles */
.conv { display: flex; flex-direction: column; gap: var(--s3); }
.conv-msg { max-width: 92%; padding: var(--s3) var(--s4); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--card); }
.conv-msg-customer { background: var(--info-soft); border-left: 3px solid var(--info); }
.conv-msg-agent { margin-left: auto; border-left: 3px solid var(--brand-600); background: var(--brand-50); }
.conv-msg-internal { margin-left: auto; background: var(--warn-soft); border: 1px dashed var(--warn); }
.conv-head { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2); margin-bottom: var(--s2); }
.conv-author { font-size: 14px; font-weight: 600; color: var(--ink-900); }
.conv-time { margin-left: auto; font-size: 12px; color: var(--ink-400); }
.conv-body { font-size: 14px; line-height: 1.6; color: var(--ink-700); }

@media (max-width: 767px) {
  .conv-msg { max-width: 100%; }
  .conv-time { margin-left: 0; }
}



/* admin support (S4.7b) — team roster, rating stars, load meters */
.tabs a.tab { display: inline-flex; align-items: center; gap: 6px; }
.stars { position: relative; display: inline-block; font-size: 13px; line-height: 1; letter-spacing: 1.5px; white-space: nowrap; vertical-align: -1px; }
.stars-base { color: var(--line); }
.stars-fill { position: absolute; inset: 0 auto 0 0; width: var(--pct, 0%); overflow: hidden; color: var(--warn); }
.rating { display: flex; align-items: center; gap: 6px; }
.rating-num { font-size: 13px; font-weight: 700; color: var(--ink-900); }
.agent-cell { display: flex; align-items: center; gap: var(--s3); }
.agent-cell .avatar { flex: 0 0 auto; }
.agent-name { font-weight: 600; color: var(--ink-900); }
.agent-meta { font-size: 12px; color: var(--ink-500); }
.load-cell { min-width: 110px; }
.load-meta { display: flex; justify-content: space-between; gap: var(--s2); margin-bottom: 4px; font-size: 12px; color: var(--ink-500); }
.skill-chips { display: flex; flex-wrap: wrap; gap: 4px; max-width: 190px; }
.hist { display: grid; gap: 6px; }
.hist-row { display: grid; grid-template-columns: 30px 1fr 28px; align-items: center; gap: var(--s2); font-size: 12px; color: var(--ink-500); }
.hist-count { text-align: right; font-variant-numeric: tabular-nums; }


@media (max-width: 767px) {
  .skill-chips { max-width: none; }
}

/* =====================================================================
   S4.8 — Trust / Content / Ops / Growth
   Risk score cell, funnel bars, cohort heat grid, system info list.
   ===================================================================== */

/* risk score — number + thin bar (table cell) */
.risk-score { display: flex; align-items: center; gap: var(--s2); min-width: 124px; }
.risk-score-num { min-width: 26px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink-900); }
.risk-score .progress { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }

/* funnel — label / track / count */
.funnel { display: grid; gap: var(--s4); }
.funnel-row { display: grid; grid-template-columns: 160px 1fr 96px; align-items: center; gap: var(--s3); }
.funnel-label { font-size: 13px; font-weight: 600; color: var(--ink-700); }
.funnel-track { height: 28px; background: var(--line-soft); border-radius: var(--r-sm); overflow: hidden; }
.funnel-fill { height: 100%; border-radius: var(--r-sm); background: linear-gradient(90deg, var(--brand-600), var(--brand-700)); }
.funnel-row.soft .funnel-fill { background: linear-gradient(90deg, var(--info), var(--brand-600)); }
.funnel-count { text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--ink-900); }
.funnel-count span { display: block; font-size: 11px; color: var(--ink-500); }

/* cohort retention heat grid */
.cohort-wrap { overflow-x: auto; }
.cohort { width: 100%; border-collapse: separate; border-spacing: 3px; font-size: 12px; }
.cohort th { padding: 4px 6px; font-weight: 600; color: var(--ink-500); text-align: left; white-space: nowrap; }
.cohort th.c { text-align: center; }
.cohort td { padding: 8px 6px; color: var(--ink-700); white-space: nowrap; }
.cohort td.cell { text-align: center; border-radius: var(--r-sm); background: rgba(79, 70, 229, var(--a, .06)); font-variant-numeric: tabular-nums; }
.cohort td.cell.hot { color: #fff; font-weight: 600; }
.cohort td.na { text-align: center; color: var(--ink-400); }

/* system info — definition list */
.sys-list { margin: 0; }
.sys-row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); padding: 9px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.sys-row:last-child { border-bottom: 0; }
.sys-row dt { color: var(--ink-500); }
.sys-row dd { margin: 0; font-weight: 600; color: var(--ink-900); font-variant-numeric: tabular-nums; text-align: right; }
.sys-row dd .progress { margin-top: 6px; min-width: 150px; }

@media (max-width: 767px) {
  .funnel-row { grid-template-columns: 1fr 84px; row-gap: var(--s1); }
  .funnel-track { grid-column: 1 / -1; order: 3; height: 20px; }
  .risk-score { min-width: 96px; }
}


