/*!
 * Hisaab — Business Admin Dashboard
 * Version 1.0.0 · Plain CSS, no build step required.
 *
 * Contents
 *  1. Fonts
 *  2. Design tokens (light + dark)
 *  3. Base
 *  4. App layout (sidebar, topbar, content)
 *  5. Components (card, button, badge, form, table, tabs, dropdown, modal, toast …)
 *  6. Page parts (KPI ledger, charts, kanban, calendar, invoice, auth)
 *  7. Utilities
 *  8. Responsive + print
 */

/* 1. Fonts ------------------------------------------------------------- */
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("bricolage-grotesque-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Sans";
  src: url("instrument-sans-latin-wght-normal.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

/* 2. Tokens ------------------------------------------------------------ */
:root {
  /* Brand — change these two to rebrand the whole template */
  --primary: #0f6e5a;
  --primary-strong: #0a5545;
  --primary-soft: #e3f1ec;
  --accent: #d9922e;
  --accent-soft: #fbf0de;

  --bg: #f3f6f4;
  --surface: #ffffff;
  --surface-2: #f8faf9;
  --ink: #1b2330;
  --ink-2: #4a5566;
  --ink-3: #646e7e;
  --line: #e2e8e5;
  --line-strong: #cfd8d4;

  --success: #1e7a48;
  --success-soft: #e2f4e9;
  --warning: #b7791f;
  --warning-text: #8e6323;  /* darker shade for small warning text (AA contrast) */
  --warning-soft: #fcf1dc;
  --danger: #b83f3a;
  --danger-soft: #fbe6e4;
  --info: #3c6ca3;
  --info-soft: #e5eef8;

  /* Chart series */
  --c1: var(--primary);
  --c2: var(--accent);
  --c3: #5b7fa6;
  --c4: #c8657a;
  --c5: #8a9a5b;

  --font-ui: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Bricolage Grotesque", "Instrument Sans", system-ui, sans-serif;

  --r-lg: 16px;
  --r-md: 10px;
  --r-sm: 6px;
  --shadow: 0 1px 2px rgba(20, 40, 33, .05), 0 8px 24px -12px rgba(20, 40, 33, .12);
  --shadow-pop: 0 12px 40px -12px rgba(20, 40, 33, .28);
  --sidebar-w: 256px;
  --topbar-h: 64px;
  --focus: 0 0 0 3px color-mix(in srgb, var(--primary) 35%, transparent);
  color-scheme: light;
}

[data-theme="dark"] {
  --primary: #3fbf9a;
  --primary-strong: #63d3b1;
  --primary-soft: #133a30;
  --accent: #eba94c;
  --accent-soft: #3a2b14;

  --bg: #0d1412;
  --surface: #141d1a;
  --surface-2: #18231f;
  --ink: #e6eeea;
  --ink-2: #b2bfb9;
  --ink-3: #82918a;
  --line: #24312c;
  --line-strong: #31413b;

  --success: #4cc27f;
  --success-soft: #16301f;
  --warning: #e1a84a;
  --warning-text: #e1a84a;
  --warning-soft: #33280f;
  --danger: #ec7a72;
  --danger-soft: #3a1a18;
  --info: #7ea8d8;
  --info-soft: #172537;

  --c1: var(--primary);
  --c2: var(--accent);
  --c3: #7ea8d8;
  --c4: #e0899b;
  --c5: #a9b878;

  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .5);
  --shadow-pop: 0 16px 48px -12px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

/* 3. Base -------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-display); color: var(--ink); margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 650; }
h3 { font-size: 16px; font-weight: 650; }
h4 { font-size: 14px; font-weight: 650; }
p { margin: 0 0 1em; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
.num, table, .kpi-value { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

/* 4. Layout ------------------------------------------------------------ */
.app { --sb: var(--sidebar-w); display: grid; grid-template-columns: var(--sb) minmax(0, 1fr); min-height: 100vh;
  background: linear-gradient(90deg, var(--surface) 0 var(--sb), var(--line) var(--sb) calc(var(--sb) + 1px), transparent calc(var(--sb) + 1px)); }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; height: var(--topbar-h); padding: 0 20px; border-bottom: 1px solid var(--line); color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 21px; letter-spacing: -.02em; }

.nav { flex: 1; overflow-y: auto; padding: 14px 12px 20px; }
.nav-group + .nav-group { margin-top: 18px; }
.nav-title { font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 0 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; border-radius: var(--r-md);
  color: var(--ink-2); font-weight: 500; font-size: 14.5px;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary-strong); font-weight: 600; }
[data-theme="dark"] .nav a.active { color: var(--primary); }
.nav svg { width: 19px; height: 19px; flex: none; }
.nav .count { margin-left: auto; font-size: 12px; font-weight: 600; background: var(--accent-soft); color: var(--warning-text); padding: 1px 8px; border-radius: 99px; }

.sidebar-foot { padding: 14px; border-top: 1px solid var(--line); }
.plan-note { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; font-size: 13px; color: var(--ink-2); }
.plan-note strong { display: block; color: var(--ink); font-size: 14px; margin-bottom: 2px; }
.meter { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 10px 0 4px; }
.meter > span { display: block; height: 100%; background: var(--primary); border-radius: inherit; }

.sidebar-backdrop { display: none; }
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.search { position: relative; flex: 1; max-width: 420px; }
.search svg { position: absolute; left: 12px; top: 50%; translate: 0 -50%; width: 17px; height: 17px; color: var(--ink-3); pointer-events: none; }
.search input { width: 100%; height: 40px; padding: 0 64px 0 38px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-md); }
.search kbd { position: absolute; right: 10px; top: 50%; translate: 0 -50%; font: 600 11px var(--font-ui); color: var(--ink-3); border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px; background: var(--surface-2); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn {
  position: relative; width: 40px; height: 40px; display: inline-grid; place-items: center;
  border: 1px solid transparent; background: transparent; border-radius: var(--r-md); color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface); border-color: var(--line); color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn .dot { position: absolute; top: 9px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }
.menu-toggle { display: none; }
.user-btn { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.user-btn .who { text-align: left; line-height: 1.2; }
.user-btn .who b { display: block; font-size: 13.5px; }
.user-btn .who small { color: var(--ink-3); font-size: 12px; }

.content { padding: 28px; max-width: 1480px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.crumbs { display: flex; gap: 6px; font-size: 13px; color: var(--ink-3); margin-bottom: 6px; }
.crumbs a { color: var(--ink-3); }
/* Links inside running text are underlined so they don't rely on colour alone */
p a:not(.btn), .plan-note a, .check a { text-decoration: underline; text-underline-offset: 2px; }
.crumbs span::before { content: "/"; margin-right: 6px; }
.footer { margin-top: auto; padding: 18px 28px; font-size: 13px; color: var(--ink-3); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-top: 1px solid var(--line); }

.grid { display: grid; gap: 20px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.span-12 { grid-column: span 12; } .span-8 { grid-column: span 8; } .span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; } .span-5 { grid-column: span 5; } .span-4 { grid-column: span 4; } .span-3 { grid-column: span 3; }
.stack > * + * { margin-top: 20px; }

/* Collapsed sidebar (desktop) */
.sidebar-collapsed .app { --sb: 76px; }
.sidebar-collapsed .brand-name, .sidebar-collapsed .nav-title, .sidebar-collapsed .nav span:not(.sr-only),
.sidebar-collapsed .nav .count, .sidebar-collapsed .sidebar-foot { display: none; }
.sidebar-collapsed .nav a { justify-content: center; }
.sidebar-collapsed .brand { justify-content: center; padding: 0; }

/* 5. Components -------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 0; }
.card-head p { margin: 2px 0 0; font-size: 13px; color: var(--ink-3); }
.card-body { padding: 18px 20px 20px; }
.card-flush { padding: 0; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13.5px; color: var(--ink-3); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--r-md);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
[data-theme="dark"] .btn-primary { color: #06231c; }
.btn-primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #2b1a04; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
[data-theme="dark"] .btn-danger { background: #c2413b; border-color: #c2413b; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 99px; font-size: 12.5px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-warning { background: var(--warning-soft); color: var(--warning-text); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge-primary { background: var(--primary-soft); color: var(--primary); border-color: transparent; }

.avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; flex: none; background: var(--c3); }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-lg { width: 72px; height: 72px; font-size: 24px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { border: 2px solid var(--surface); margin-left: -8px; }
.avatar-stack .avatar:first-child { margin-left: 0; }
.person { display: flex; align-items: center; gap: 11px; min-width: 0; }
.person b { display: block; font-weight: 600; font-size: 14px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person small { display: block; color: var(--ink-3); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Forms */
.field { display: grid; gap: 6px; }
.field + .field { margin-top: 16px; }
.label { font-weight: 600; font-size: 13.5px; color: var(--ink); }
.hint { font-size: 12.5px; color: var(--ink-3); }
.input, .select, .textarea {
  width: 100%; height: 42px; padding: 0 13px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-md);
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 110px; padding: 11px 13px; resize: vertical; }
.select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%237a8494' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
.input.is-invalid { border-color: var(--danger); }
.error-text { color: var(--danger); font-size: 12.5px; display: none; }
.is-invalid ~ .error-text, .field.has-error .error-text { display: block; }
.input-group { display: flex; }
.input-group .input { border-radius: var(--r-md) 0 0 var(--r-md); }
.input-group .addon { display: grid; place-items: center; padding: 0 13px; border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 var(--r-md) var(--r-md) 0; background: var(--surface-2); color: var(--ink-3); font-size: 14px; }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 44px; }
.input-wrap .icon-btn { position: absolute; right: 2px; top: 1px; width: 40px; height: 40px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .field + .field { margin-top: 0; }

.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); margin: 0; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-size: 14px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 40px; height: 24px; background: var(--line-strong); border-radius: 99px; position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: var(--focus); }

.dropzone { border: 1.5px dashed var(--line-strong); border-radius: var(--r-lg); padding: 28px; text-align: center; color: var(--ink-2); background: var(--surface-2); cursor: pointer; }
.dropzone.is-over { border-color: var(--primary); background: var(--primary-soft); }
.dropzone svg { width: 30px; height: 30px; margin: 0 auto 8px; color: var(--primary); }

/* Table */
.table-wrap { overflow-x: auto; position: relative; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; font-size: 12.5px; color: var(--ink-3); padding: 11px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .right, .table th.right { text-align: right; }
.table th[data-sort] { cursor: pointer; user-select: none; }
.table th[data-sort]::after { content: "↕"; margin-left: 6px; opacity: .35; }
.table th[data-dir="asc"]::after { content: "↑"; opacity: 1; }
.table th[data-dir="desc"]::after { content: "↓"; opacity: 1; }
.table-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.table-tools .input, .table-tools .select { height: 38px; width: auto; }
.table-tools .input { min-width: 240px; flex: 1; max-width: 340px; }
.pager { display: flex; gap: 4px; }
.pager button { min-width: 34px; height: 34px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 13px; }
.pager button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
[data-theme="dark"] .pager button.active { color: #06231c; }
.pager button:disabled { opacity: .4; cursor: default; }
.empty-row td { text-align: center; padding: 40px 16px; color: var(--ink-3); }

/* Tabs */
/* The divider line is an inset shadow so the row never scrolls vertically (avoids a stray scrollbar on Android) */
.tabs { display: flex; gap: 4px; box-shadow: inset 0 -1px 0 var(--line); overflow-x: auto; overflow-y: hidden; }
.tab { background: none; border: 0; padding: 11px 14px; font-weight: 600; font-size: 14px; color: var(--ink-3); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--primary); }
.tab-panel[hidden] { display: none; }
.segmented { display: inline-flex; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); }
.segmented button { border: 0; background: none; padding: 5px 12px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--ink-3); cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* Dropdown */
.dropdown { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-pop); padding: 6px; z-index: 60; display: none;
}
.dropdown.open > .menu { display: block; }
.menu a, .menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: var(--r-sm); color: var(--ink-2); background: none; border: 0; font-size: 14px; text-align: left; cursor: pointer; }
.menu a:hover, .menu button:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.menu svg { width: 17px; height: 17px; }
.menu hr { margin: 6px 0; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--primary); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.notif { display: flex; gap: 11px; padding: 10px; border-radius: var(--r-sm); }
.notif:hover { background: var(--surface-2); }
.notif p { margin: 0; font-size: 13.5px; color: var(--ink-2); }
.notif p b { color: var(--ink); }
.notif small { color: var(--ink-3); font-size: 12px; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal.open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(10, 20, 17, .5); }
.modal-dialog { position: relative; width: 100%; max-width: 520px; max-height: calc(100vh - 40px); overflow: auto; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); border: 1px solid var(--line); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--line); }
@media (prefers-reduced-motion: no-preference) {
  .modal.open .modal-dialog { animation: pop .18s ease-out; }
  @keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
}

/* Toast */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 120; display: grid; gap: 10px; }
.toast { display: flex; align-items: center; gap: 12px; min-width: 280px; max-width: 380px; padding: 12px 14px; border-radius: var(--r-md); background: var(--ink); color: var(--bg); box-shadow: var(--shadow-pop); font-size: 14px; }
.toast svg { width: 19px; height: 19px; color: var(--primary); flex: none; }
[data-theme="dark"] .toast { background: #e6eeea; color: #0d1412; }
[data-theme="dark"] .toast svg { color: #0f6e5a; }

/* Alerts, progress, misc */
.alert { display: flex; gap: 12px; padding: 13px 15px; border-radius: var(--r-md); font-size: 14px; border: 1px solid transparent; }
.alert svg { width: 19px; height: 19px; flex: none; margin-top: 1px; }
.alert p { margin: 2px 0 0; }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-warning { background: var(--warning-soft); color: var(--warning-text); }
.alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert-info { background: var(--info-soft); color: var(--info); }
.alert b { color: inherit; }
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: inherit; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; padding-bottom: 0; }
.list > li:first-child { padding-top: 0; }
.muted { color: var(--ink-3); }
.trend { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-size: 13px; }
.trend.up { color: var(--success); }
.trend.down { color: var(--danger); }
.trend svg { width: 14px; height: 14px; }
.kbd { font: 600 12px var(--font-ui); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; background: var(--surface-2); }
.skeleton { background: linear-gradient(90deg, var(--line) 25%, var(--surface-2) 50%, var(--line) 75%); background-size: 200% 100%; border-radius: var(--r-sm); height: 12px; }
@media (prefers-reduced-motion: no-preference) { .skeleton { animation: shimmer 1.4s infinite linear; } @keyframes shimmer { to { background-position: -200% 0; } } }
.tooltip-wrap { position: relative; display: inline-flex; }
.tooltip-wrap [role="tooltip"] { position: absolute; bottom: calc(100% + 8px); left: 50%; translate: -50% 0; background: var(--ink); color: var(--bg); font-size: 12.5px; padding: 5px 9px; border-radius: var(--r-sm); white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .15s; }
.tooltip-wrap:hover [role="tooltip"], .tooltip-wrap:focus-within [role="tooltip"] { opacity: 1; }
@media (max-width: 480px) { .tooltip-wrap [role="tooltip"] { white-space: normal; width: max-content; max-width: min(240px, calc(100vw - 32px)); } }

/* 6. Page parts -------------------------------------------------------- */
/* KPI ledger: one card, figures separated by ruled columns */
.ledger { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ledger-cell { padding: 20px 22px; position: relative; }
.ledger-cell + .ledger-cell { border-left: 1px dashed var(--line-strong); }
.kpi-label { font-size: 13.5px; color: var(--ink-2); font-weight: 500; display: flex; align-items: center; gap: 8px; }
.kpi-label i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.kpi-value { font-family: var(--font-display); font-size: 32px; font-weight: 650; letter-spacing: -.025em; margin: 6px 0 4px; line-height: 1.1; }
.kpi-value small { font-size: 17px; font-weight: 600; color: var(--ink-3); margin-left: 2px; }
.kpi-foot { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-3); }
.kpi-spark { height: 34px; margin-top: 10px; }

.stat-mini { display: flex; align-items: center; gap: 14px; }
.stat-mini .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.stat-mini .ic svg { width: 21px; height: 21px; }
.stat-mini b { font-family: var(--font-display); font-size: 22px; font-weight: 650; display: block; line-height: 1.2; }
.stat-mini span { color: var(--ink-3); font-size: 13px; }

/* Charts */
.chart { position: relative; width: 100%; }
.chart svg { overflow: visible; }
.chart .axis text { fill: var(--ink-3); font-size: 11.5px; font-family: var(--font-ui); }
.chart .gridline { stroke: var(--line); stroke-dasharray: 3 4; }
.chart-tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-pop); border-radius: var(--r-md); padding: 9px 11px; font-size: 12.5px; min-width: 140px; opacity: 0; transition: opacity .1s; z-index: 5; }
.chart-tip.show { opacity: 1; }
.chart-tip b { display: block; font-size: 12.5px; margin-bottom: 4px; }
.chart-tip div { display: flex; align-items: center; gap: 7px; color: var(--ink-2); }
.chart-tip div span { margin-left: auto; color: var(--ink); font-weight: 600; padding-left: 12px; }
.chart-tip i, .legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; flex: none; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.donut-wrap { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 20px; align-items: center; }
.card-body:has(> .donut-wrap) { container-type: inline-size; }
@container (max-width: 360px) { .donut-wrap { grid-template-columns: 150px minmax(0, 1fr); gap: 14px; } }
@container (max-width: 310px) { .donut-wrap { grid-template-columns: 1fr; justify-items: center; } .donut-wrap > .list { width: 100%; } }
.donut-center { font-family: var(--font-display); }

.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; font-size: 14px; }
.bar-row + .bar-row { margin-top: 14px; }
.bar-row .progress { grid-column: 1 / -1; height: 6px; }

/* Activity timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 26px; font-size: 14px; color: var(--ink-2); }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--surface); border: 2px solid var(--primary); }
.timeline li::after { content: ""; position: absolute; left: 9px; top: 20px; bottom: 2px; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline b { color: var(--ink); font-weight: 600; }
.timeline small { display: block; color: var(--ink-3); font-size: 12.5px; margin-top: 2px; }

/* Product thumb */
.thumb { width: 42px; height: 42px; border-radius: var(--r-md); display: grid; place-items: center; flex: none; }
.thumb svg { width: 22px; height: 22px; }

/* Customer cards */
.cust-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px; }
.cust { padding: 20px; text-align: center; }
.cust .avatar { margin: 0 auto 12px; }
.cust h3 { font-size: 16px; }
.cust p { color: var(--ink-3); font-size: 13.5px; margin: 2px 0 14px; }
.cust-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; border-top: 1px solid var(--line); margin: 0 -20px -20px; }
.cust-stats div { padding: 12px 6px; font-size: 12px; color: var(--ink-3); }
.cust-stats div + div { border-left: 1px solid var(--line); }
.cust-stats b { display: block; font-size: 15px; color: var(--ink); font-family: var(--font-display); }

/* Kanban */
.board { display: grid; grid-template-columns: repeat(4, minmax(260px, 1fr)); gap: 18px; overflow-x: auto; padding-bottom: 8px; }
.column { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px; min-height: 420px; display: flex; flex-direction: column; }
.column-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 4px 12px; }
.column-head h3 { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.column-head h3 i { width: 8px; height: 8px; border-radius: 50%; }
.column-list { display: grid; gap: 10px; flex: 1; align-content: start; min-height: 60px; border-radius: var(--r-md); }
.column-list.is-over { outline: 2px dashed var(--primary); outline-offset: 4px; }
.task.touch-drag { position: fixed; z-index: 90; pointer-events: none; box-shadow: var(--shadow-pop); opacity: .95; }
.task-placeholder { border: 2px dashed var(--line-strong); border-radius: var(--r-md); }
.add-task-form { margin-top: 10px; display: grid; gap: 8px; }
.add-task-form .flex { justify-content: flex-end; }
.task { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 13px; cursor: grab; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.task:active { cursor: grabbing; }
.task.dragging { opacity: .45; }
.task h4 { font-family: var(--font-ui); font-size: 14px; font-weight: 600; margin: 8px 0 10px; }
.task-meta { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; color: var(--ink-3); }
.task-meta span { display: inline-flex; align-items: center; gap: 5px; }
.task-meta svg { width: 14px; height: 14px; }
.add-task { margin-top: 10px; border: 1px dashed var(--line-strong); background: transparent; border-radius: var(--r-md); padding: 9px; color: var(--ink-3); font-weight: 600; cursor: pointer; }
.add-task:hover { color: var(--primary); border-color: var(--primary); }

/* Calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.cal-head h2 { min-width: 180px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-dow { padding: 10px 12px; font-size: 12.5px; font-weight: 600; color: var(--ink-3); border-bottom: 1px solid var(--line); }
.cal-day { min-height: 112px; padding: 8px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 13px; }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day.other { background: var(--surface-2); color: var(--ink-3); }
.cal-day .d { font-weight: 600; display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; }
.cal-day.today .d { background: var(--primary); color: #fff; }
[data-theme="dark"] .cal-day.today .d { color: #06231c; }
.event { display: block; margin-top: 4px; padding: 3px 7px; border-radius: 5px; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid; }
.ev-1 { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.ev-2 { background: var(--accent-soft); color: var(--warning-text); border-color: var(--accent); }
.ev-3 { background: var(--info-soft); color: var(--info); border-color: var(--info); }
.ev-4 { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }

/* Invoice */
.invoice { padding: 40px; }
.invoice-top { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.invoice-top h1, .invoice-top .invoice-title { font-size: 34px; font-weight: 700; }
.invoice-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; padding: 28px 0; }
.invoice-meta h4, .invoice-meta h3 { font-size: 12.5px; color: var(--ink-3); font-family: var(--font-ui); font-weight: 600; margin-bottom: 6px; }
.invoice-meta p { margin: 0; font-size: 14px; color: var(--ink-2); }
.invoice-meta p b { color: var(--ink); }
.totals { margin-left: auto; max-width: 320px; width: 100%; margin-top: 20px; }
.totals div { display: flex; justify-content: space-between; padding: 7px 0; font-size: 14px; color: var(--ink-2); }
.totals .grand { border-top: 2px solid var(--ink); margin-top: 6px; padding-top: 12px; font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--ink); }

/* Profile */
.cover { height: 150px; border-radius: var(--r-lg) var(--r-lg) 0 0; background:
  repeating-linear-gradient(90deg, transparent 0 39px, color-mix(in srgb, #fff 9%, transparent) 39px 40px),
  repeating-linear-gradient(0deg, transparent 0 39px, color-mix(in srgb, #fff 9%, transparent) 39px 40px),
  linear-gradient(120deg, var(--primary-strong), var(--primary) 60%, var(--accent)); }
.profile-head { display: flex; align-items: flex-end; gap: 18px; padding: 0 24px 20px; flex-wrap: wrap; }
.profile-head .avatar { border: 4px solid var(--surface); margin-top: -40px; width: 96px; height: 96px; font-size: 30px; }
.profile-head .grow { flex: 1; min-width: 200px; }
.profile-head p { margin: 2px 0 0; color: var(--ink-3); }

/* Settings */
.settings-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; align-items: start; }
.side-tabs { display: grid; gap: 2px; position: sticky; top: calc(var(--topbar-h) + 20px); }
.side-tabs .tab { text-align: left; border: 0; border-radius: var(--r-md); margin: 0; padding: 9px 12px; }
.side-tabs .tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.setting-row:last-child { border-bottom: 0; }
.setting-row p { margin: 2px 0 0; font-size: 13.5px; color: var(--ink-3); }

/* Auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
.auth-form { display: flex; flex-direction: column; padding: 32px clamp(24px, 6vw, 88px); }
.auth-form .inner { margin: auto 0; width: 100%; max-width: 400px; }
.auth-form h1 { font-size: 30px; margin: 0 0 8px; }
.auth-form .lead { color: var(--ink-2); margin-bottom: 28px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: 13px; margin: 22px 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.auth-art { position: relative; overflow: hidden; background: var(--primary-strong); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: flex-end; }
[data-theme="dark"] .auth-art { background: #0f2a23; }
.auth-art .ledger-lines { position: absolute; inset: 0; background:
  repeating-linear-gradient(0deg, transparent 0 47px, rgba(255,255,255,.08) 47px 48px);
  mask-image: linear-gradient(180deg, #000 40%, transparent); }
.auth-art .ledger-lines::before { content: ""; position: absolute; top: 0; bottom: 0; left: 72px; border-left: 1px solid rgba(217,146,46,.55); }
.auth-quote { position: relative; max-width: 460px; }
.auth-quote p { font-family: var(--font-display); font-size: 26px; line-height: 1.3; font-weight: 500; letter-spacing: -.01em; }
.auth-quote footer { margin-top: 18px; display: flex; align-items: center; gap: 12px; opacity: .9; font-size: 14px; }
.auth-figs { position: relative; display: flex; gap: 14px; margin-bottom: 36px; flex-wrap: wrap; }
.auth-figs div { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14); border-radius: var(--r-md); padding: 14px 16px; min-width: 150px; }
.auth-figs b { display: block; font-family: var(--font-display); font-size: 26px; font-weight: 650; }
.auth-figs span { font-size: 13px; opacity: .8; }
.social-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Error page */
.error-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; text-align: center; }
.error-page .code { font-family: var(--font-display); font-size: clamp(96px, 20vw, 180px); font-weight: 800; line-height: 1; letter-spacing: -.05em; color: var(--primary); }
.error-page .code span { color: var(--accent); }
.error-page p { color: var(--ink-2); max-width: 420px; margin: 12px auto 26px; }

/* Components page */
.demo-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.swatch { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; font-size: 12.5px; }
.swatch i { display: block; height: 56px; }
.swatch div { padding: 8px 10px; }
.swatch b { display: block; font-size: 13px; }

/* 7. Utilities --------------------------------------------------------- */
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .wrap { flex-wrap: wrap; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; } .mb-0 { margin-bottom: 0; } .mb-16 { margin-bottom: 16px; }
.text-right { text-align: right; } .text-center { text-align: center; } .small { font-size: 13px; } .strong { font-weight: 600; color: var(--ink); }
.w-100 { width: 100%; } .nowrap { white-space: nowrap; }
.bg-primary-soft { background: var(--primary-soft); color: var(--primary); }
.bg-accent-soft { background: var(--accent-soft); color: var(--warning); }
.bg-info-soft { background: var(--info-soft); color: var(--info); }
.bg-danger-soft { background: var(--danger-soft); color: var(--danger); }

/* 8. Responsive -------------------------------------------------------- */
@media (max-width: 1280px) {
  .span-3 { grid-column: span 6; }
  .ledger { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ledger-cell:nth-child(3) { border-left: 0; }
  .ledger-cell:nth-child(n+3) { border-top: 1px dashed var(--line-strong); }
}
@media (max-width: 1100px) {
  .span-8, .span-7, .span-6, .span-5, .span-4 { grid-column: span 12; }
  .board { grid-template-columns: repeat(4, 280px); }
}
@media (max-width: 960px) {
  .app, .sidebar-collapsed .app { grid-template-columns: minmax(0, 1fr); background: none; }
  .sidebar { position: fixed; left: 0; top: 0; width: 280px; transform: translateX(-100%); visibility: hidden; transition: transform .25s ease, visibility 0s linear .25s; box-shadow: var(--shadow-pop); }
  .sidebar-open .sidebar { transform: none; visibility: visible; transition: transform .25s ease; }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(10,20,17,.45); z-index: 35; display: none; }
  .sidebar-open .sidebar-backdrop { display: block; }
  .menu-toggle { display: inline-grid; }
  .collapse-toggle { display: none; }
  .sidebar-collapsed .brand-name, .sidebar-collapsed .nav-title, .sidebar-collapsed .nav span:not(.sr-only), .sidebar-collapsed .nav .count, .sidebar-collapsed .sidebar-foot { display: revert; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .settings-layout { grid-template-columns: 1fr; }
  .side-tabs { position: static; display: flex; overflow-x: auto; }
  .invoice-meta { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .content { padding: 18px 16px; }
  .topbar { padding: 0 12px; gap: 6px; }
  .search { display: none; }
  .user-btn .who, .hide-sm { display: none; }
  .span-3 { grid-column: span 12; }
  .ledger { grid-template-columns: 1fr; }
  .ledger-cell + .ledger-cell { border-left: 0; border-top: 1px dashed var(--line-strong); }
  .form-grid { grid-template-columns: 1fr; }
  .donut-wrap { grid-template-columns: 1fr; justify-items: center; }
  .invoice { padding: 22px; }
  .invoice-meta { grid-template-columns: 1fr; }
  .cal-day { min-height: 74px; padding: 4px; }
  .event { font-size: 10.5px; padding: 2px 4px; }
  .footer { padding: 16px; }
  h1 { font-size: 24px; }
  .table-tools .input { min-width: 0; max-width: none; flex: 1 1 100%; }
  .table-tools .btn { margin-left: 0 !important; }
  .social-btns { grid-template-columns: 1fr; }
}
@media print {
  .sidebar, .topbar, .footer, .no-print, .toasts { display: none !important; }
  .app { display: block; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 0; }
  body { background: #fff; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* Theme toggle icon */
.theme-sun { display: none; }
[data-theme="dark"] .theme-sun { display: contents; }
[data-theme="dark"] .theme-moon { display: none; }

/* Calendar filters, saved note, hidden cards */
.hide-ev-1 .ev-1, .hide-ev-2 .ev-2, .hide-ev-3 .ev-3, .hide-ev-4 .ev-4 { display: none; }
.saved-note { font-size: 13px; color: var(--success); display: inline-flex; align-items: center; }
[hidden] { display: none !important; }

/* Scrollable tables get a visible focus ring when reached with the keyboard */
.table-wrap:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
