/* frontend/css/app.css */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ════════════════════════════════════════════════════════════════
   DESIGN TOKENS
   The whole app is driven by these variables (no hardcoded theme
   colors in markup), so the palette can be swapped wholesale.
   :root = LIGHT theme (default — matches what accounting users
   expect from QBO/Xero and prints cleanly).
   [data-theme="dark"] = the original purple+black theme, opt-in.
   ════════════════════════════════════════════════════════════════ */
:root {
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Surfaces & ink — LIGHT */
  --bg:          #f5f6f8;   /* app canvas */
  --surface:     #ffffff;   /* cards / panels / sidebar / topbar */
  --surface-2:   #f1f2f5;   /* hover rows, inputs, subtle fills */
  --border:      rgba(17,20,45,0.09);
  --border-md:   rgba(17,20,45,0.16);
  --text:        #1a1a2e;   /* primary ink */
  --text-2:      #5a5670;   /* secondary */
  --text-3:      #8b8799;   /* muted / tertiary */

  /* Brand accent (gold) */
  --accent:        #c9971f;
  --accent-dark:   #a2760f;
  --accent-light:  #f7edd4;   /* light tint for active/selected states */
  --on-accent:     #241a05;   /* dark ink for text/icons on a gold background */

  /* Positive / success / money — GREEN (distinct from brand accent) */
  --positive:       #16a34a;
  --positive-dark:  #15803d;
  --positive-light: #dcfce7;
  /* Negative / destructive */
  --red:        #dc2626;
  --red-light:  #fdecea;
  /* Warning */
  --warning:        #d97706;
  --warning-light:  #fef3c7;
  /* Info */
  --info:        #2563eb;
  --info-light:  #e0ecfd;

  /* Back-compat + semantic aliases. A lot of markup references the old
     names (--green, --primary, --danger, --success, --warning, --color-...);
     map them onto the canonical tokens so every reference resolves
     (several were previously undefined). */
  --green:       var(--accent);
  --green-dark:  var(--accent-dark);
  --green-light: var(--accent-light);
  --primary:       var(--accent);
  --primary-dark:  var(--accent-dark);
  --danger:        var(--red);
  --success:       var(--positive);
  --color-text:    var(--text);
  --color-text-2:  var(--text-2);
  --color-text-3:  var(--text-3);
  --color-surface: var(--surface);
  --color-border:  var(--border);
  --color-bg:      var(--bg);

  /* Radii */
  --radius:      8px;
  --radius-lg:   12px;
  --radius-sm:   6px;

  /* Spacing scale (4px base) — used by the spacing/gap utility classes */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(17,20,45,0.06);
  --shadow-md: 0 4px 16px rgba(17,20,45,0.08);
  --shadow-lg: 0 12px 40px rgba(17,20,45,0.16);

  --sidebar-w:   220px;
  --topbar-h:    52px;
}

/* ── DARK theme (opt-in) — the original purple+black palette ───── */
[data-theme="dark"] {
  --bg:          #0a0a0f;
  --surface:     #15131d;
  --surface-2:   #1e1b2b;
  --border:      rgba(255,255,255,0.09);
  --border-md:   rgba(255,255,255,0.17);
  --text:        #ece9f5;
  --text-2:      #a29db8;
  --text-3:      #6b6580;
  --accent:        #d9ad3f;
  --accent-dark:   #b8860b;
  --accent-light:  #34301d;   /* dark gold fill for active states on dark */
  --on-accent:     #201a08;   /* dark ink for text/icons on a gold background */
  --positive:       #22c55e;
  --positive-dark:  #16a34a;
  --positive-light: #16331f;
  --red:        #f0686b;
  --red-light:  #3a1d1d;
  --warning:        #f59e0b;
  --warning-light:  #3a2e12;
  --info:        #60a5fa;
  --info-light:  #16243f;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.45);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.55);
}

body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
a { text-decoration: none; color: inherit; }
button { font-family: var(--font); cursor: pointer; }
input, select, textarea { font-family: var(--font); }

/* Financial figures line up in columns: lining + tabular numerals on every
   surface that shows numbers. This is the single biggest "real accounting
   software" cue — amounts in a column share the same glyph width. */
td, th, input, .metric-value, .num, table, .amount, .auth-input {
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

/* ── Auth ── */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 2rem 1.5rem; gap: 3.5rem; flex-wrap: wrap;
}

/* Logged-out landing hero (sits beside the sign-in card) */
.auth-hero { max-width: 460px; }
.auth-hero .auth-logo { margin-bottom: 1.75rem; }
.auth-hero-title {
  font-size: 2.1rem; font-weight: 600; line-height: 1.18;
  letter-spacing: -0.5px; margin-bottom: 1rem;
}
.auth-hero-sub { font-size: 1.02rem; color: var(--text-2); line-height: 1.6; margin-bottom: 1.5rem; }
.auth-hero-feats { list-style: none; display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1.9rem; }
.auth-hero-feats li { position: relative; padding-left: 1.6rem; font-size: 0.92rem; color: var(--text-2); }
.auth-hero-feats li::before { content: '\2713'; position: absolute; left: 0; color: var(--green); font-weight: 700; }
.auth-hero-cta { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.auth-cta {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 18px; border-radius: var(--radius); font-size: 14px; font-weight: 500;
  border: 0.5px solid var(--border-md); color: var(--text); background: var(--surface);
  transition: all 0.15s; cursor: pointer;
}
.auth-cta:hover { background: var(--surface-2); }
.auth-cta-primary { background: var(--green); color: var(--on-accent); border-color: var(--green); }
.auth-cta-primary:hover { background: var(--green-dark); }

@media (max-width: 900px) {
  .auth-wrap { flex-direction: column; gap: 2rem; }
  .auth-hero { max-width: 400px; text-align: center; }
  .auth-hero-cta { justify-content: center; }
}
.auth-card {
  background: var(--surface); border: 0.5px solid var(--border-md);
  border-radius: var(--radius-lg); padding: 2rem; width: 100%; max-width: 380px;
}
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 1.75rem; }
.auth-logo-mark {
  width: 36px; height: 36px; border-radius: 10px; background: var(--green);
  display: flex; align-items: center; justify-content: center;
}
.auth-logo-mark i { color: #fff; font-size: 18px; }
.auth-logo-name { font-size: 20px; font-weight: 500; }
.auth-logo-name span { color: var(--green); }
.auth-title { font-size: 17px; font-weight: 500; margin-bottom: 4px; }
.auth-sub   { font-size: 13px; color: var(--text-2); margin-bottom: 1.5rem; }
.auth-field { margin-bottom: 12px; }
.auth-label { font-size: 12px; color: var(--text-2); margin-bottom: 4px; display: block; }
.auth-input {
  width: 100%; padding: 9px 12px; border-radius: var(--radius);
  border: 0.5px solid var(--border-md); background: var(--surface-2);
  color: var(--text); font-size: 14px; outline: none; transition: border-color 0.15s;
}
.auth-input:focus { border-color: var(--green); }
.auth-btn {
  width: 100%; padding: 10px; background: var(--green); color: var(--on-accent);
  border: none; border-radius: var(--radius); font-size: 14px; font-weight: 500;
  margin-top: 8px; transition: background 0.15s;
}
.auth-btn:hover { background: var(--green-dark); }
.auth-switch { font-size: 13px; color: var(--text-2); text-align: center; margin-top: 1rem; }
.auth-switch a { color: var(--green); font-weight: 500; cursor: pointer; }
.auth-error { background: #FAECE7; color: #993C1D; border-radius: var(--radius); padding: 8px 12px; font-size: 13px; margin-bottom: 12px; }

/* ── App shell ── */
#app { display: none; }
.app-layout { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface); border-right: 0.5px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 9px; padding: 1rem 1.25rem;
  border-bottom: 0.5px solid var(--border);
}
.sidebar-logo-mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--green);
  display: flex; align-items: center; justify-content: center;
}
.sidebar-logo-mark i { color: #fff; font-size: 16px; }
.sidebar-logo-name { font-size: 16px; font-weight: 500; }
.sidebar-logo-name span { color: var(--green); }

.sidebar-section { padding: 1rem 0.75rem 0.5rem; }
.sidebar-section-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.7px; color: var(--text-3); padding: 0 0.5rem; margin-bottom: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px;
  border-radius: var(--radius); font-size: 13px; color: var(--text-2);
  cursor: pointer; border: none; background: transparent; width: 100%;
  text-align: left; transition: all 0.15s; margin-bottom: 2px;
}
.nav-item i { font-size: 16px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--green-light); color: var(--green-dark); font-weight: 500; }
.nav-item .badge-count {
  margin-left: auto; background: var(--red); color: #fff;
  border-radius: 20px; font-size: 10px; padding: 1px 6px; font-weight: 500;
}

/* Nav group (collapsible) */
.nav-group { margin-bottom: 2px; }
.nav-group-header {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px;
  border-radius: var(--radius); font-size: 13px; color: var(--text-2);
  cursor: pointer; border: none; background: transparent; width: 100%;
  text-align: left; transition: all 0.15s;
}
.nav-group-header i.ti { font-size: 16px; flex-shrink: 0; }
.nav-group-header:hover { background: var(--surface-2); color: var(--text); }
.nav-group-header.group-active { color: var(--text); font-weight: 500; }
.nav-group-arrow { margin-left: auto; font-size: 12px !important; transition: transform 0.2s; }
.nav-group-items { display: none; padding-left: 10px; }
.nav-group-items.open { display: block; }
.nav-item.nav-sub { padding-left: 28px; font-size: 12.5px; }

/* Coming-soon nav item */
.nav-item.nav-soon { opacity: 0.45; pointer-events: none; }

.sidebar-bottom { margin-top: auto; padding: 0.75rem; border-top: 0.5px solid var(--border); }
.user-pill {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px;
  border-radius: var(--radius); background: var(--surface-2);
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: #E6F1FB;
  color: #185FA5; font-size: 11px; font-weight: 500;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.user-name  { font-size: 12px; font-weight: 500; }
.user-role  { font-size: 11px; color: var(--text-3); }
.logout-btn {
  margin-left: auto; border: none; background: transparent;
  color: var(--text-3); padding: 4px; cursor: pointer; border-radius: 4px;
}
.logout-btn:hover { color: var(--red); }

/* Main content */
.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  height: var(--topbar-h); flex-shrink: 0; position: relative;
  border-bottom: 0.5px solid var(--border);
  padding: 0 1.5rem; display: flex; align-items: center; justify-content: space-between;
  background: var(--surface);
}
.topbar-title { font-size: 15px; font-weight: 500; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.whatsnew-link { display: flex; align-items: center; gap: 6px; width: 100%; background: none; border: none; color: var(--text-2); font-size: .82rem; cursor: pointer; padding: 6px 8px; margin-bottom: 6px; border-radius: 6px; }
.whatsnew-link:hover { background: var(--surface-2); color: var(--text); }
.whatsnew-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); display: inline-block; margin-left: auto; }
/* Keep the account-identifier chip (with its Switch-account button) in normal flex flow
   beside the page title — NOT absolutely centered — so it never sits behind the topbar
   search bar. flex-shrink:0 keeps the Switch button visible even when space is tight. */
#topbar-company { flex-shrink: 0; }

.page-content { flex: 1; overflow-y: auto; padding: 1.5rem; }
.app-footer { flex-shrink: 0; display: flex; align-items: center; gap: 12px; padding: 10px 24px; border-top: 1px solid var(--border); background: var(--surface); color: var(--text-3); font-size: 12px; }
.app-footer a { color: var(--text-2); text-decoration: none; }
.app-footer a:hover { color: var(--accent); text-decoration: underline; }
.app-footer .sep { color: var(--text-3); }
.app-footer-spacer { flex: 1; }
.app-footer-trust { display: inline-flex; align-items: center; gap: 5px; color: var(--positive); }

/* ── Page tabs ── */
.page-tabs {
  display: flex; gap: 0; border-bottom: 2px solid var(--border);
  margin-bottom: 1.25rem; overflow-x: auto;
}
.page-tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; font-size: 13px; font-weight: 500;
  color: var(--text-2); background: transparent; border: none;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  cursor: pointer; transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.page-tab i { font-size: 15px; }
.page-tab:hover { color: var(--text); }
.page-tab.active { color: var(--green-dark); border-bottom-color: var(--green-dark); }

/* Status pills used in client tabs */
.status-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 500; padding: 2px 8px;
  border-radius: 20px; white-space: nowrap;
}
.pill-green  { background: var(--positive-light); color: var(--positive-dark); }
.pill-orange { background: var(--warning-light); color: var(--warning); }
.pill-red    { background: var(--red-light); color: var(--red); }
.pill-blue   { background: var(--info-light); color: var(--info); }
.pill-gray   { background: var(--surface-2); color: var(--text-3); }

/* ── Reusable components ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius); font-size: 13px; font-weight: 500;
  border: 0.5px solid var(--border-md); background: var(--surface); color: var(--text);
  transition: background 0.15s; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--green); color: var(--on-accent); border-color: var(--green); }
.btn-primary:hover { background: var(--green-dark); border-color: var(--green-dark); }
.btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger:hover { filter: brightness(0.9); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

.metrics-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 1.5rem; }
.metric-card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 1rem 1.25rem; }
.metric-label { font-size: 12px; color: var(--text-2); margin-bottom: 6px; display: flex; align-items: center; gap: 5px; }
.metric-value { font-size: 22px; font-weight: 500; letter-spacing: -0.4px; }
.metric-delta { font-size: 12px; color: var(--text-3); margin-top: 4px; }

.panel { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.panel-hd {
  padding: 0.85rem 1.25rem; border-bottom: 0.5px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.panel-title { font-size: 14px; font-weight: 500; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; color: var(--text-3); padding: 0.6rem 1.25rem; border-bottom: 0.5px solid var(--border); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; background: var(--surface); }
td { padding: 0.8rem 1.25rem; border-bottom: 0.5px solid var(--border); font-size: 13px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); }

/* Sticky header: header row stays pinned while the body scrolls. The scroll
   container is .page-content (or a .table-wrap), so top:0 pins to its top. */
thead th { position: sticky; top: 0; z-index: 2; }

/* Right-align + tabular for amount columns. Add class="num" to money <td>/<th>. */
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }
.num-neg { color: var(--red); }

/* Sortable tables: headers become clickable with a sort affordance. Applied
   automatically to any table that has a <thead> (opt out with data-nosort). */
table thead th[data-sortable] { cursor: pointer; user-select: none; padding-right: 1.6rem; position: relative; }
table thead th[data-sortable]:hover { color: var(--text-2); }
table thead th[data-sortable]::after {
  content: '\2195'; position: absolute; right: 0.6rem; opacity: 0.25; font-size: 11px;
}
table thead th[data-sort="asc"]::after  { content: '\2191'; opacity: 0.9; color: var(--accent); }
table thead th[data-sort="desc"]::after { content: '\2193'; opacity: 0.9; color: var(--accent); }

/* Client-side pagination controls (added by paginateTable). */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 0.6rem 1.25rem; font-size: 12.5px; color: var(--text-2); border-top: 0.5px solid var(--border); }
.pager button { border: 0.5px solid var(--border-md); background: var(--surface); color: var(--text); border-radius: var(--radius-sm); padding: 3px 9px; font-size: 12.5px; cursor: pointer; }
.pager button:disabled { opacity: 0.4; cursor: default; }
.pager button:not(:disabled):hover { background: var(--surface-2); }

.field { margin-bottom: 12px; }
.label { font-size: 12px; color: var(--text-2); margin-bottom: 4px; display: block; }
.input, .select, .textarea {
  width: 100%; padding: 8px 10px; border-radius: var(--radius);
  border: 0.5px solid var(--border-md); background: var(--surface-2);
  color: var(--text); font-size: 13px; outline: none; transition: border-color 0.15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Required-field marker: add class="req" to a .label */
.label.req::after { content: ' *'; color: var(--red); }
/* Inline validation: toggle .error on the field/input + show .field-error text */
.input.error, .select.error, .textarea.error { border-color: var(--red); }
.input.error:focus, .select.error:focus, .textarea.error:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 18%, transparent); }
.field-error { color: var(--red); font-size: 12px; margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.field-hint  { color: var(--text-3); font-size: 12px; margin-top: 4px; }

/* ── Settings page: responsive multi-column layout that uses the full width ── */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 16px;
  align-items: start;
}
.settings-grid > .panel { margin: 0; }            /* spacing handled by grid gap */
.settings-grid > .settings-wide { grid-column: 1 / -1; }  /* table panels span full width */
@media (max-width: 720px) { .settings-grid { grid-template-columns: 1fr; } }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 100;
  display: none; align-items: center; justify-content: center; padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 0.5px solid var(--border-md);
  width: 100%; max-width: 520px; max-height: 85vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.modal--wide { max-width: 900px; }
.modal-hd {
  padding: 1rem 1.25rem; border-bottom: 0.5px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.modal-hd h3 { font-size: 15px; font-weight: 500; }
.modal-close { border: none; background: transparent; font-size: 18px; cursor: pointer; color: var(--text-3); padding: 2px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 1.25rem; overflow-y: auto; flex: 1; }
.modal-footer { padding: 1rem 1.25rem; border-top: 0.5px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: var(--surface); border: 0.5px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: var(--radius);
  padding: 0.7rem 1rem; font-size: 13px; color: var(--text);
  box-shadow: var(--shadow-md);
  display: flex; align-items: center; gap: 8px; z-index: 200;
  animation: slideUp 0.25s ease;
}
.toast.toast--success { border-left-color: var(--positive); }
.toast.toast--error   { border-left-color: var(--red); }
.toast.toast--warning { border-left-color: var(--warning); }
.toast.toast--info    { border-left-color: var(--accent); }
.toast.hide { animation: slideDown 0.25s ease forwards; }
@keyframes slideUp   { from { transform: translateY(16px); opacity: 0; } }
@keyframes slideDown { to   { transform: translateY(16px); opacity: 0; } }

/* ── Loading ── */
.loading { text-align: center; padding: 2rem; color: var(--text-3); font-size: 13px; }

/* Branded splash (first paint) + reusable spinner */
.app-splash { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 4.5rem 1rem; color: var(--text-3); font-size: 13px; }
.app-splash .splash-mark { width: 46px; height: 46px; border-radius: 13px; background: var(--accent); color: var(--on-accent); display: flex; align-items: center; justify-content: center; font-size: 24px; box-shadow: var(--shadow-md); }
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--border-md); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
.spinner.sm { width: 14px; height: 14px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 1.4s; } }

/* ── Skeleton loaders ──────────────────────────────────────────
   Shimmer placeholders that mirror the shape of the content being
   loaded, so the layout doesn't jump and perceived latency drops. */
.skeleton {
  position: relative; overflow: hidden;
  background: var(--surface-2); border-radius: var(--radius-sm);
}
.skeleton::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--text) 7%, transparent), transparent);
  transform: translateX(-100%); animation: skeleton-shimmer 1.3s infinite;
}
@keyframes skeleton-shimmer { 100% { transform: translateX(100%); } }
.sk-line { height: 12px; margin: 8px 0; }
.sk-line.sk-sm { width: 40%; } .sk-line.sk-md { width: 65%; } .sk-line.sk-lg { width: 90%; }
.sk-table { border: 0.5px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.sk-row { display: flex; gap: 16px; padding: 0.8rem 1.25rem; border-bottom: 0.5px solid var(--border); }
.sk-row:last-child { border-bottom: none; }
.sk-row .skeleton { height: 14px; flex: 1; }
.sk-cards { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; }
@media (max-width: 900px) { .sk-cards { grid-template-columns: 1fr 1fr; } }
.sk-card { height: 84px; }
@media (prefers-reduced-motion: reduce) { .skeleton::after { animation: none; } }

/* ── Empty state ───────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-3); }
.empty-state .es-ic {
  width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--text-3); font-size: 26px;
}
.empty-state .es-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.empty-state .es-sub { font-size: 13px; color: var(--text-2); max-width: 380px; margin: 0 auto 16px; line-height: 1.55; }

/* First-run "getting started" cards (empty dashboard) */
.gs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); border-top: 0.5px solid var(--border); }
@media (max-width: 600px) { .gs-grid { grid-template-columns: 1fr; } }
.gs-card { display: flex; gap: 12px; align-items: flex-start; padding: 1.1rem 1.25rem; background: var(--surface); border: none; text-align: left; cursor: pointer; transition: background 0.12s; width: 100%; }
.gs-card:hover { background: var(--surface-2); }
.gs-card .gs-ic { width: 38px; height: 38px; border-radius: 10px; background: var(--accent-light); color: var(--accent-dark); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.gs-card .gs-tt { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.gs-card .gs-ds { font-size: 12.5px; color: var(--text-2); }

/* ── Filter bar ── */
.filter-bar { display: flex; gap: 8px; padding: 0.75rem 1.25rem; background: var(--surface-2); border-bottom: 0.5px solid var(--border); flex-wrap: wrap; align-items: center; }
.chip { padding: 4px 12px; border-radius: 20px; font-size: 12px; cursor: pointer; border: 0.5px solid var(--border-md); background: transparent; color: var(--text-2); transition: all 0.15s; }
.chip.active { background: var(--green); color: var(--on-accent); border-color: var(--green); }
.chip:hover:not(.active) { background: var(--surface); }
.search-box {
  display: flex; align-items: center; gap: 6px; padding: 0 1.25rem 0.75rem;
  border-bottom: 0.5px solid var(--border);
}
.search-box i { color: var(--text-3); font-size: 15px; }
.search-box input { border: none; background: transparent; font-size: 13px; color: var(--text); outline: none; flex: 1; font-family: var(--font); }
.search-box input::placeholder { color: var(--text-3); }

/* ── Charts ── */
.chart-container { padding: 1rem 1.25rem; }

/* ── Mobile hamburger button ── */
.hamburger-btn {
  display: none; border: none; background: transparent; cursor: pointer;
  color: var(--text-2); font-size: 20px; padding: 4px 8px; margin-right: 4px;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .hamburger-btn { display: flex; align-items: center; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 300;
    transform: translateX(-100%); transition: transform 0.25s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay {
    display: none; position: fixed; inset: 0; z-index: 299;
    background: rgba(0,0,0,0.4);
  }
  .sidebar-overlay.open { display: block; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .summary-cards { grid-template-columns: 1fr 1fr; }
  .topbar-actions { gap: 4px; }
  .topbar-actions .btn { padding: 5px 8px; font-size: 12px; }
}
@media (max-width: 600px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .summary-cards { grid-template-columns: 1fr; }
  .page-content { padding: .75rem; }
  .data-table th, .data-table td { padding: 6px 8px; font-size: 12px; }
  .modal { max-width: 100vw; max-height: 95vh; border-radius: var(--radius) var(--radius) 0 0; }
  .modal-overlay { align-items: flex-end; }
}

/* ── 8-Tab primary sidebar nav ───────────────────────────────── */
.snav { padding: .5rem .6rem; display: flex; flex-direction: column; gap: 1px; flex: 1; }
.snav-btn {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px;
  border-radius: var(--radius); font-size: 13px; color: var(--text-2);
  background: none; border: none; width: 100%; text-align: left;
  cursor: pointer; transition: all .15s; font-weight: 400;
}
.snav-btn:hover { background: var(--surface-2); color: var(--text); }
.snav-btn.active { background: var(--green-light); color: var(--green-dark); font-weight: 500; }
.snav-ic {
  width: 28px; height: 28px; display: flex; align-items: center;
  justify-content: center; font-size: 16px; flex-shrink: 0; border-radius: 7px;
}
.snav-create .snav-ic { background: var(--green); color: var(--on-accent); }
.snav-divider { height: .5px; background: var(--border); margin: 5px 4px; }

/* ── All Apps sliding panel ───────────────────────────────────── */
.all-apps-panel {
  position: fixed; left: var(--sidebar-w); top: 0; bottom: 0; width: 300px;
  background: var(--surface); border-right: .5px solid var(--border);
  z-index: 200; display: flex; flex-direction: column;
  transform: translateX(-100%); transition: transform .22s ease, visibility .22s;
  box-shadow: 4px 0 24px rgba(0,0,0,.1);
  pointer-events: none; visibility: hidden;
}
.all-apps-panel.open { transform: translateX(0); pointer-events: auto; visibility: visible; }
.aa-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: .85rem 1rem; border-bottom: .5px solid var(--border); flex-shrink: 0;
}
.aa-hd-title { font-weight: 600; font-size: 14px; }
.aa-close {
  background: none; border: none; cursor: pointer; color: var(--text-3);
  padding: 4px 6px; border-radius: 6px; font-size: 16px; line-height: 1;
}
.aa-close:hover { color: var(--text); background: var(--surface-2); }
.aa-search { padding: .55rem .75rem; border-bottom: .5px solid var(--border); flex-shrink: 0; }
.aa-search input {
  width: 100%; padding: 6px 10px; border-radius: var(--radius);
  border: .5px solid var(--border-md); background: var(--surface-2);
  color: var(--text); font-size: 13px; outline: none;
}
.aa-search input:focus { border-color: var(--green); }
.aa-body { flex: 1; overflow-y: auto; padding: .6rem .5rem 1rem; }
.aa-cat { margin-bottom: .6rem; }
.aa-cat-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .7px;
  color: var(--text-3); padding: 0 6px; margin-bottom: 3px;
}
.aa-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.aa-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px;
  border-radius: var(--radius); font-size: 12.5px; color: var(--text-2);
  background: none; border: none; cursor: pointer; text-align: left;
  transition: all .12s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.aa-item i { font-size: 14px; flex-shrink: 0; }
.aa-item:hover { background: var(--surface-2); color: var(--text); }
.aa-item.active { background: var(--green-light); color: var(--green-dark); font-weight: 500; }
.panel-backdrop {
  position: fixed; inset: 0; z-index: 199; background: rgba(0,0,0,.18); display: none;
}
.panel-backdrop.open { display: block; }

/* ── Create flyout ────────────────────────────────────────────── */
.create-flyout {
  position: fixed; left: calc(var(--sidebar-w) + 8px);
  width: 220px; background: var(--surface);
  border: .5px solid var(--border-md); border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,.15); z-index: 350; padding: .4rem;
  display: none; animation: fadeIn .1s ease;
}
.create-flyout.open { display: block; }
.cf-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-3); padding: 4px 8px 2px; display: block;
}
.cf-item {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px;
  border-radius: var(--radius); font-size: 13px; color: var(--text);
  background: none; border: none; cursor: pointer; width: 100%; text-align: left; transition: all .12s;
}
.cf-item:hover { background: var(--surface-2); }
.cf-item i { font-size: 15px; color: var(--text-2); flex-shrink: 0; }
.cf-divider { height: .5px; background: var(--border); margin: .3rem 0; }

/* ── More menu ────────────────────────────────────────────────── */
.more-menu {
  position: fixed; left: calc(var(--sidebar-w) + 8px); bottom: 56px;
  width: 200px; background: var(--surface);
  border: .5px solid var(--border-md); border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,.15); z-index: 350; padding: .4rem;
  display: none; animation: fadeIn .1s ease;
}
.more-menu.open { display: block; }
.mm-item {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px;
  border-radius: var(--radius); font-size: 13px; color: var(--text);
  background: none; border: none; cursor: pointer; width: 100%; text-align: left; transition: all .12s;
}
.mm-item:hover { background: var(--surface-2); }
.mm-item i { font-size: 15px; color: var(--text-2); flex-shrink: 0; }
.mm-divider { height: .5px; background: var(--border); margin: .3rem 0; }

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

/* ── Bookmarks view page ──────────────────────────────────────── */
.bm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.bm-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 20px 12px; border-radius: var(--radius-lg);
  background: var(--surface); border: .5px solid var(--border);
  cursor: pointer; transition: all .15s; text-align: center;
  color: var(--text-2); font-size: 13px; font-weight: 500;
}
.bm-card:hover { border-color: var(--green); color: var(--green-dark); box-shadow: 0 2px 12px rgba(0,0,0,.06); }
.bm-card-ic { font-size: 26px; color: var(--green); }

/* ── Feed page ────────────────────────────────────────────────── */
.feed-list { display: flex; flex-direction: column; gap: 2px; }
.feed-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  border-radius: var(--radius); background: var(--surface); cursor: pointer; transition: all .12s;
}
.feed-item:hover { box-shadow: 0 1px 6px rgba(0,0,0,.07); }
.feed-ic {
  width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.feed-body { flex: 1; min-width: 0; }
.feed-title { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-sub { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }
.feed-right { text-align: right; flex-shrink: 0; }
.feed-amt { font-size: 13px; font-weight: 500; }
.feed-date { font-size: 11px; color: var(--text-3); }

/* ── Readability bump + on-screen fit ────────────────────────── */
body { font-size: 15px; }

/* Tables */
th { font-size: 12px; }
td, .data-table td { font-size: 14px; }

/* Controls */
.btn { font-size: 14px; }
.btn-sm { font-size: 13px; }
.input, .select, .textarea { font-size: 14px; }
.label { font-size: 13px; }
.chip { font-size: 13px; }
.search-box input { font-size: 14px; }

/* Panels / cards / headings */
.panel-title { font-size: 15px; }
.metric-label { font-size: 13px; }
.metric-value { font-size: 24px; }
.modal-hd h3 { font-size: 16px; }
.loading { font-size: 14px; }
.toast { font-size: 14px; }

/* Sidebar + topbar */
.snav-btn { font-size: 14px; }
.nav-item, .nav-group-header { font-size: 14px; }
.nav-item.nav-sub { font-size: 13.5px; }
.topbar-title { font-size: 16px; }

/* Static practice tabs */
.page-tab { font-size: 14px; }

/* Dynamic tab bars (Sales / Expenses / Payroll / Time / Inventory / Taxes / …):
   wrap so every tab stays visible instead of scrolling off-screen, and enlarge
   the labels. !important overrides the inline styles set in JS. */
.practice-banking-tab-bar { flex-wrap: wrap !important; overflow-x: visible !important; row-gap: 2px; }
.practice-banking-tab-bar > button { font-size: 0.92rem !important; padding: 0.55rem 1rem !important; }

/* Never let a wide page break the app shell — contain overflow to the content area */
.page-content { overflow-x: auto; }

/* ══════════════════════════════════════════════════════════════
   ACCESSIBILITY
   ══════════════════════════════════════════════════════════════ */
/* Visible keyboard focus on every interactive element (mouse clicks
   stay clean via :focus-visible). Inputs keep their own focus ring. */
a:focus-visible, button:focus-visible, .btn:focus-visible, .nav-item:focus-visible,
.snav-btn:focus-visible, .page-tab:focus-visible, .chip:focus-visible,
[tabindex]:focus-visible, .modal-close:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm);
}
input:focus-visible, textarea:focus-visible { outline: none; }
/* Screen-reader-only helper for labels on icon-only controls */
.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;
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ══════════════════════════════════════════════════════════════
   THEME TOGGLE (topbar)
   ══════════════════════════════════════════════════════════════ */
.theme-toggle {
  border: 0.5px solid var(--border-md); background: var(--surface); color: var(--text-2);
  border-radius: var(--radius); width: 32px; height: 32px; display: inline-flex;
  align-items: center; justify-content: center; cursor: pointer; font-size: 16px;
  flex-shrink: 0; transition: all 0.15s;
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text); }
/* Show the right icon for the current theme (set by JS as ti-moon / ti-sun) */

/* ══════════════════════════════════════════════════════════════
   ELEVATION / MICRO-INTERACTIONS
   ══════════════════════════════════════════════════════════════ */
.metric-card, .panel { transition: box-shadow 0.15s, border-color 0.15s; }
.metric-card:hover { box-shadow: var(--shadow-sm); }
.btn:active, .auth-btn:active, .snav-btn:active { transform: translateY(0.5px); }

/* ══════════════════════════════════════════════════════════════
   UTILITY CLASSES
   Small, composable helpers to replace the most common inline
   styles (spacing / flex / text / color). Use these instead of
   style="..." in new markup.
   ══════════════════════════════════════════════════════════════ */
.flex { display: flex; } .inline-flex { display: inline-flex; }
.flex-col { flex-direction: column; } .flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; } .items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; } .justify-end { justify-content: flex-end; }
.justify-center { justify-content: center; }
.flex-1 { flex: 1; } .flex-shrink-0 { flex-shrink: 0; }
.grid { display: grid; }
.gap-1 { gap: var(--space-1); } .gap-2 { gap: var(--space-2); } .gap-3 { gap: var(--space-3); } .gap-4 { gap: var(--space-4); }
.mt-1 { margin-top: var(--space-1); } .mt-2 { margin-top: var(--space-2); } .mt-3 { margin-top: var(--space-3); } .mt-4 { margin-top: var(--space-4); }
.mb-1 { margin-bottom: var(--space-1); } .mb-2 { margin-bottom: var(--space-2); } .mb-3 { margin-bottom: var(--space-3); } .mb-4 { margin-bottom: var(--space-4); }
.mr-1 { margin-right: var(--space-1); } .mr-2 { margin-right: var(--space-2); }
.p-2 { padding: var(--space-2); } .p-3 { padding: var(--space-3); } .p-4 { padding: var(--space-4); }
.text-right { text-align: right; } .text-center { text-align: center; }
.text-muted { color: var(--text-2); } .text-faint { color: var(--text-3); }
.text-pos { color: var(--positive); } .text-neg { color: var(--red); } .text-accent { color: var(--accent); }
.fw-500 { font-weight: 500; } .fw-600 { font-weight: 600; } .fw-700 { font-weight: 700; }
.fs-sm { font-size: 12px; } .fs-lg { font-size: 16px; } .fs-xl { font-size: 20px; }
.w-full { width: 100%; } .nowrap { white-space: nowrap; }

/* ══════════════════════════════════════════════════════════════
   PRINT — screen chrome hidden; documents (invoices / statements /
   pay stubs) get a clean, paper-grade layout.
   ══════════════════════════════════════════════════════════════ */
@media print {
  .sidebar, .topbar, .topbar-actions, .hamburger-btn, .theme-toggle,
  .sidebar-overlay, .toast, .modal-overlay, .btn, .all-apps-panel,
  .panel-backdrop, .create-flyout, .more-menu, .page-tabs, .filter-bar,
  .pager, .app-footer, .no-print { display: none !important; }
  .app-layout { display: block; height: auto; overflow: visible; }
  .main-area { width: 100%; overflow: visible; }
  .page-content { padding: 0; overflow: visible; }
  body { background: #fff; color: #000; font-size: 12px; }
  .panel { border: none !important; box-shadow: none !important; }
  thead th { position: static; }       /* sticky breaks paged printing */
  tr, .metric-card, .print-doc-section { break-inside: avoid; }
  a[href]::after { content: ''; }
}

/* Document layout used by printDocument() for invoices/statements/stubs.
   Works both on-screen (preview) and in the print window. */
.print-doc {
  max-width: 760px; margin: 0 auto; padding: 40px; color: #14121c;
  font-family: var(--font); background: #fff; line-height: 1.5;
}
.print-doc-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 32px; gap: 24px; }
.print-doc-brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; }
.print-doc-brand .pd-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: var(--on-accent); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.print-doc-title { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; text-align: right; }
.print-doc-meta { font-size: 12px; color: #555; text-align: right; margin-top: 4px; }
.print-doc-parties { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.print-doc-parties h4 { font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px; color: #888; margin-bottom: 5px; }
.print-doc table { width: 100%; border-collapse: collapse; margin: 8px 0 20px; }
.print-doc th { background: #f6f3fc; color: #444; text-transform: uppercase; font-size: 10px; letter-spacing: 0.5px; padding: 9px 12px; text-align: left; border-bottom: 1.5px solid #e5e1f0; }
.print-doc td { padding: 9px 12px; border-bottom: 1px solid #eee; font-size: 12.5px; }
.print-doc .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.print-doc-totals { margin-left: auto; width: 280px; }
.print-doc-totals .row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13px; }
.print-doc-totals .row.grand { border-top: 2px solid #14121c; margin-top: 6px; padding-top: 10px; font-size: 16px; font-weight: 700; }
.print-doc-foot { margin-top: 40px; padding-top: 16px; border-top: 1px solid #eee; font-size: 11.5px; color: #777; }
