/* ============================================================
   Insyt Billing Hub — brand stylesheet
   Teal #20b3b0 · Leaf #88b63f · Charcoal #3a3c3e/#585b5d · Cream #f6f5f1
   Fraunces (headings) · Manrope (body)
   Mobile-first: every screen works cleanly at 380px.
   ============================================================ */
:root {
  --teal: #20b3b0;
  --teal-dark: #189190;
  --teal-soft: #e6f6f6;
  --teal-line: #bfe6e5;
  --leaf: #88b63f;
  --leaf-soft: #eef5e2;
  --leaf-dark: #6f9a2e;
  --charcoal: #3a3c3e;
  --slate: #585b5d;
  --muted: #8a8d8f;
  --faint: #a9abad;
  --cream: #f6f5f1;
  --cream-2: #eeece4;
  --line: #e4e1d8;
  --white: #fff;
  --gold: #c9a24b;
  --gold-soft: #fbf5e6;
  --red: #c0392b;
  --red-soft: #fdeceb;
  --red-line: #f2c3be;
  --amber: #b7791f;
  --amber-soft: #fdf6e3;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --sh-sm: 0 1px 2px rgba(58, 60, 62, .06);
  --sh: 0 2px 10px rgba(58, 60, 62, .07);
  --sh-lg: 0 10px 34px rgba(58, 60, 62, .13);
  --nav-w: 232px;
  --tab-h: 62px;
  --top-h: 58px;
  --ff-head: 'Fraunces', Georgia, 'Times New Roman', serif;
  --ff-body: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--ff-body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--charcoal);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
}
h1, h2, h3, h4 { font-family: var(--ff-head); font-weight: 600; color: var(--charcoal); margin: 0; letter-spacing: -.2px; line-height: 1.25; }
h1 { font-size: 25px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0 0 12px; }
a { color: var(--teal-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2.5px solid var(--teal); outline-offset: 2px; border-radius: 4px; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--charcoal); color: #fff; padding: 10px 16px; border-radius: 0 0 var(--r) 0;
}
.skip-link:focus { left: 0; }

/* ---------------- Top bar ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 60;
  background: rgba(255, 255, 255, .93);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  height: var(--top-h);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; height: 100%;
  padding: 0 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--teal), var(--leaf));
  color: #fff; font-size: 15px; box-shadow: var(--sh-sm); flex: none;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-family: var(--ff-head); font-weight: 600; font-size: 17px; color: var(--charcoal); }
.brand-sub { font-size: 10.5px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.topbar-icon {
  position: relative; width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  color: var(--slate); background: transparent;
}
.topbar-icon:hover { background: var(--cream); text-decoration: none; color: var(--teal-dark); }

.usermenu { position: relative; }
.usermenu > summary { list-style: none; cursor: pointer; display: grid; place-items: center; }
.usermenu > summary::-webkit-details-marker { display: none; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--charcoal); color: #fff; font-weight: 700; font-size: 13px;
}
.usermenu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 226px; z-index: 70;
  background: #fff; border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh-lg);
  padding: 6px; animation: pop .13s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: none; } }
.usermenu-head { padding: 10px 12px 12px; border-bottom: 1px solid var(--cream-2); margin-bottom: 6px; display: flex; flex-direction: column; gap: 2px; }
.usermenu-head strong { font-size: 14px; }
.usermenu-head span { font-size: 12px; color: var(--muted); word-break: break-all; }
.usermenu-panel a, .usermenu-panel button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px;
  border: 0; background: none; font: inherit; font-size: 13.5px; color: var(--slate);
  border-radius: var(--r-sm); cursor: pointer; text-align: left;
}
.usermenu-panel a:hover, .usermenu-panel button:hover { background: var(--cream); color: var(--charcoal); text-decoration: none; }
.usermenu-panel i { width: 15px; color: var(--muted); }
.role-chip {
  align-self: flex-start; margin-top: 5px; font-size: 10px; text-transform: uppercase;
  letter-spacing: .07em; padding: 2.5px 8px; border-radius: 99px; font-weight: 700;
}
.role-admin { background: var(--teal-soft); color: var(--teal-dark); }
.role-operator { background: var(--leaf-soft); color: var(--leaf-dark); }

/* ---------------- Side nav (desktop) ---------------- */
.sidenav { display: none; }

/* ---------------- Bottom tab bar (mobile) ---------------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(6, 1fr);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 9.5px; text-decoration: none; padding-top: 6px; min-width: 0;
}
.tabbar a.active { color: var(--teal-dark); }
.tabbar a.active .tab-ico { background: var(--teal-soft); }
.tab-ico { position: relative; width: 34px; height: 25px; border-radius: 9px; display: grid; place-items: center; font-size: 14.5px; }
.tab-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: -.1px; }
.dot-badge {
  position: absolute; top: -3px; right: 1px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 99px; background: var(--red); color: #fff; font-size: 9.5px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid #fff; line-height: 1;
}
.nav-badge {
  margin-left: auto; min-width: 21px; height: 21px; padding: 0 6px; border-radius: 99px;
  background: var(--red-soft); color: var(--red); font-size: 11.5px; font-weight: 700;
  display: grid; place-items: center;
}

/* ---------------- Main ---------------- */
main { max-width: 1180px; margin: 0 auto; padding: 18px 14px 30px; }
main.no-nav { display: grid; place-items: center; min-height: calc(100vh - var(--top-h)); padding: 24px 16px; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-sub { color: var(--muted); font-size: 13.5px; margin: 5px 0 0; max-width: 62ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- Cards ---------------- */
.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 18px; box-shadow: var(--sh-sm); margin-bottom: 16px;
}
.card-tight { padding: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card-note { font-size: 12.5px; color: var(--muted); margin: -6px 0 14px; }
.card-cream { background: var(--cream); }

/* ---------------- KPI tiles ---------------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.kpi {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 14px; box-shadow: var(--sh-sm); display: block; color: inherit; position: relative; overflow: hidden;
}
.kpi:hover { text-decoration: none; border-color: var(--teal-line); box-shadow: var(--sh); }
.kpi-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi-value { font-family: var(--ff-head); font-size: 23px; font-weight: 600; margin-top: 7px; letter-spacing: -.4px; word-break: break-word; }
.kpi-foot { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.kpi-in .kpi-value { color: var(--leaf-dark); }
.kpi-out .kpi-value { color: var(--charcoal); }
.kpi-net .kpi-value { color: var(--teal-dark); }
.kpi-net.is-negative .kpi-value { color: var(--red); }
.kpi-due .kpi-value { color: var(--amber); }
.kpi-risk .kpi-value { color: var(--red); }
.kpi-accent { position: absolute; inset: 0 auto 0 0; width: 3.5px; }
.kpi-in .kpi-accent { background: var(--leaf); }
.kpi-out .kpi-accent { background: var(--slate); }
.kpi-net .kpi-accent { background: var(--teal); }
.kpi-due .kpi-accent { background: var(--gold); }
.kpi-risk .kpi-accent { background: var(--red); }

/* ---------------- Stat strip ---------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat { padding: 12px 14px; background: var(--cream); border-radius: var(--r); }
.stat-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.stat-value { font-family: var(--ff-head); font-size: 19px; margin-top: 4px; }
.stat-foot { font-size: 11.5px; color: var(--muted); }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 15px; border-radius: var(--r); border: 1px solid var(--line);
  background: #fff; color: var(--charcoal); font: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: .13s; white-space: nowrap; min-height: 42px;
}
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); border-color: var(--teal-dark); }
.btn-leaf { background: var(--leaf); border-color: var(--leaf); color: #fff; }
.btn-leaf:hover { background: var(--leaf-dark); border-color: var(--leaf-dark); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--red); border-color: var(--red-line); background: var(--red-soft); }
.btn-danger:hover { background: #fbdedb; }
.btn-sm { padding: 7px 11px; font-size: 12.5px; min-height: 36px; border-radius: var(--r-sm); }
.btn-lg { padding: 13px 20px; font-size: 15px; min-height: 48px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- Forms ---------------- */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--slate); margin-bottom: 5px; }
.hint { font-size: 11.5px; color: var(--muted); font-weight: 400; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=search], select, textarea {
  width: 100%; padding: 11px 13px; font: inherit; font-size: 15px; color: var(--charcoal);
  background: #fff; border: 1px solid var(--line); border-radius: var(--r);
  transition: .13s; -webkit-appearance: none; appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238a8d8f' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; padding-right: 34px;
}
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--teal); box-shadow: 0 0 0 3.5px var(--teal-soft); }
textarea { min-height: 110px; resize: vertical; line-height: 1.6; font-size: 14px; }
.field { margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
.check { display: flex; align-items: flex-start; gap: 9px; font-size: 14px; font-weight: 500; color: var(--charcoal); cursor: pointer; margin-bottom: 12px; }
.check input { width: 19px; height: 19px; margin: 1px 0 0; accent-color: var(--teal); flex: none; }
.check span.hint { display: block; margin-top: 2px; }
fieldset { border: 0; padding: 0; margin: 0 0 8px; }
legend { font-family: var(--ff-head); font-size: 15px; font-weight: 600; margin-bottom: 10px; padding: 0; }
.inline-form { display: inline; }

/* ---------------- Tables / lists ---------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -18px; padding: 0 18px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 520px; }
table.data th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 700; padding: 0 12px 9px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data td { padding: 12px; border-bottom: 1px solid var(--cream-2); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #fcfcfa; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }

/* Mobile record list (replaces tables under 720px) */
.rows { display: flex; flex-direction: column; gap: 9px; }
.row-card {
  display: block; background: #fff; border: 1px solid var(--line); border-radius: var(--r);
  padding: 13px 14px; color: inherit; box-shadow: var(--sh-sm);
}
.row-card:hover { text-decoration: none; border-color: var(--teal-line); }
.row-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.row-title { font-weight: 700; font-size: 14.5px; color: var(--charcoal); }
.row-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.row-amount { font-family: var(--ff-head); font-size: 16px; font-weight: 600; white-space: nowrap; }
.row-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 9px; font-size: 12px; color: var(--slate); align-items: center; }
.row-meta i { color: var(--faint); width: 12px; }

/* ---------------- Chips / badges ---------------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3.5px 9px; border-radius: 99px;
  font-size: 11px; font-weight: 700; letter-spacing: .02em; white-space: nowrap;
  background: var(--cream-2); color: var(--slate);
}
.chip i { font-size: 9px; }
.chip-paid { background: var(--leaf-soft); color: var(--leaf-dark); }
.chip-open { background: var(--teal-soft); color: var(--teal-dark); }
.chip-due { background: var(--gold-soft); color: var(--gold); }
.chip-overdue { background: var(--red-soft); color: var(--red); }
.chip-risk { background: var(--red); color: #fff; }
.chip-void { background: var(--cream-2); color: var(--muted); text-decoration: line-through; }
.chip-paused { background: var(--amber-soft); color: var(--amber); }
.chip-churned { background: var(--cream-2); color: var(--muted); }
.chip-active { background: var(--leaf-soft); color: var(--leaf-dark); }
.chip-tier { background: var(--teal-soft); color: var(--teal-dark); }
.chip-warn { background: var(--amber-soft); color: var(--amber); }
.chip-lg { font-size: 12px; padding: 5px 11px; }
.chip-ghost { background: transparent; border: 1px solid var(--line); color: var(--slate); }

/* ---------------- Flash / callouts ---------------- */
.flash {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--r);
  font-size: 13.5px; margin-bottom: 16px; line-height: 1.5; border: 1px solid transparent;
}
.flash i { margin-top: 2px; flex: none; }
.flash-ok { background: var(--leaf-soft); color: #4c6b1f; border-color: #d5e5b8; }
.flash-warn { background: var(--amber-soft); color: #7a5c14; border-color: #eddcae; }
.flash-err { background: var(--red-soft); color: var(--red); border-color: var(--red-line); }
.flash-info { background: var(--teal-soft); color: var(--teal-dark); border-color: var(--teal-line); }

.callout { background: var(--cream); border-left: 3.5px solid var(--teal); border-radius: 0 var(--r) var(--r) 0; padding: 13px 15px; font-size: 13px; color: var(--slate); margin-bottom: 16px; }
.callout strong { color: var(--charcoal); }
.callout-gold { border-left-color: var(--gold); background: var(--gold-soft); }

/* ---------------- Empty state ---------------- */
.empty { text-align: center; padding: 38px 18px; color: var(--muted); }
.empty-ico {
  width: 58px; height: 58px; border-radius: 50%; background: var(--cream); color: var(--teal);
  display: grid; place-items: center; font-size: 22px; margin: 0 auto 14px;
}
.empty h3 { margin-bottom: 6px; }
.empty p { font-size: 13.5px; max-width: 44ch; margin: 0 auto 14px; }

/* ---------------- Bar charts ---------------- */
.bars { display: flex; flex-direction: column; gap: 11px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.bar-label { font-size: 13px; font-weight: 600; color: var(--charcoal); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-value { font-size: 12.5px; color: var(--slate); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-track { grid-column: 1 / -1; height: 9px; background: var(--cream-2); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--teal), #4cc6c3); transition: width .5s ease-out; }
.bar-fill-leaf { background: linear-gradient(90deg, var(--leaf), #a5cc63); }
.bar-fill-slate { background: linear-gradient(90deg, var(--slate), #7c7f81); }
.bar-row a { color: inherit; }
.bar-row a:hover .bar-label { color: var(--teal-dark); }

/* Dual (in/out) trend chart */
.trend { display: flex; align-items: flex-end; gap: 5px; height: 152px; padding-top: 8px; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.trend-bars { display: flex; align-items: flex-end; gap: 3px; height: 118px; width: 100%; justify-content: center; }
.trend-bar { width: 46%; max-width: 20px; border-radius: 4px 4px 0 0; min-height: 3px; transition: height .5s; position: relative; }
.trend-in { background: linear-gradient(180deg, #a5cc63, var(--leaf)); }
.trend-out { background: linear-gradient(180deg, #8d9092, var(--slate)); }
.trend-label { font-size: 10px; color: var(--muted); text-align: center; white-space: nowrap; }
.legend { display: flex; gap: 14px; justify-content: center; margin-top: 12px; font-size: 12px; color: var(--slate); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.swatch-in { background: var(--leaf); }
.swatch-out { background: var(--slate); }

/* Gauge / meter */
.meter { height: 9px; background: var(--cream-2); border-radius: 99px; overflow: hidden; margin: 8px 0 5px; }
.meter-fill { height: 100%; border-radius: 99px; background: var(--leaf); }
.meter-fill.warn { background: var(--gold); }
.meter-fill.bad { background: var(--red); }

/* ---------------- Detail / definition lists ---------------- */
dl.detail { margin: 0; display: grid; grid-template-columns: 1fr; gap: 0; }
dl.detail > div { display: flex; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--cream-2); }
dl.detail > div:last-child { border-bottom: 0; }
dl.detail dt { font-size: 12.5px; color: var(--muted); flex: none; }
dl.detail dd { margin: 0; font-size: 13.5px; font-weight: 600; text-align: right; word-break: break-word; }

/* ---------------- Timeline ---------------- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--cream-2); }
.tl-item { position: relative; padding-bottom: 16px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot {
  position: absolute; left: -26px; top: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 2.5px solid var(--line); display: grid; place-items: center; font-size: 7px; color: #fff;
}
.tl-sent .tl-dot { border-color: var(--leaf); background: var(--leaf); }
.tl-pending .tl-dot { border-color: var(--teal-line); }
.tl-cancelled .tl-dot { border-color: var(--cream-2); background: var(--cream-2); }
.tl-failed .tl-dot { border-color: var(--red); background: var(--red); }
.tl-skipped .tl-dot { border-color: var(--gold); background: var(--gold); }
.tl-title { font-size: 13.5px; font-weight: 600; }
.tl-meta { font-size: 12px; color: var(--muted); margin-top: 1px; }

/* ---------------- Match queue card ---------------- */
.queue-card { border: 1px solid var(--line); border-radius: var(--r-lg); background: #fff; padding: 16px; margin-bottom: 14px; box-shadow: var(--sh-sm); }
.queue-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.queue-amount { font-family: var(--ff-head); font-size: 24px; font-weight: 600; color: var(--leaf-dark); letter-spacing: -.4px; }
.queue-narrative {
  font-size: 11.5px; color: var(--slate); background: var(--cream); border-radius: var(--r-sm);
  padding: 9px 11px; margin: 12px 0; word-break: break-word; line-height: 1.5; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.cand { border: 1px solid var(--line); border-radius: var(--r); padding: 12px; margin-bottom: 9px; background: #fff; }
.cand-high { border-color: var(--leaf); background: var(--leaf-soft); }
.cand-medium { border-color: var(--teal-line); background: #f4fbfb; }
.cand-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.cand-why { font-size: 12px; color: var(--slate); margin: 7px 0 10px; }

/* ---------------- Login ---------------- */
.auth-wrap { width: 100%; max-width: 408px; }
.auth-card { background: #fff; border: 1px solid var(--line); border-radius: var(--r-xl); padding: 30px 26px; box-shadow: var(--sh-lg); }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand .brand-mark { width: 52px; height: 52px; border-radius: 16px; font-size: 22px; margin: 0 auto 12px; }
.auth-brand h1 { font-size: 22px; }
.auth-brand p { font-size: 13px; color: var(--muted); margin: 5px 0 0; }
.auth-foot { text-align: center; font-size: 11.5px; color: var(--faint); margin-top: 18px; line-height: 1.6; }

/* ---------------- Misc ---------------- */
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.strong { font-weight: 700; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.pos { color: var(--leaf-dark); }
.neg { color: var(--red); }
.divider { height: 1px; background: var(--cream-2); margin: 16px 0; border: 0; }
.stack > * + * { margin-top: 10px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.hidden { display: none !important; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1 1 190px; min-width: 0; }
.tabs { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 3px; margin-bottom: 14px; -webkit-overflow-scrolling: touch; }
.tabs a {
  padding: 8px 13px; border-radius: 99px; font-size: 13px; font-weight: 600; color: var(--slate);
  background: #fff; border: 1px solid var(--line); white-space: nowrap;
}
.tabs a.active { background: var(--charcoal); border-color: var(--charcoal); color: #fff; }
.tabs a:hover { text-decoration: none; }
.month-nav { display: flex; align-items: center; gap: 8px; }
.month-nav .m { font-family: var(--ff-head); font-size: 15px; font-weight: 600; min-width: 118px; text-align: center; }
.pill-link { font-size: 12.5px; font-weight: 600; }
.overflow-note { font-size: 11.5px; color: var(--faint); margin-top: 10px; }
code, .code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: var(--cream); padding: 2px 6px; border-radius: 5px; }
pre.code { padding: 12px; overflow-x: auto; line-height: 1.5; margin: 0; }
.avatar-lg { width: 46px; height: 46px; border-radius: 14px; background: var(--teal-soft); color: var(--teal-dark); display: grid; place-items: center; font-family: var(--ff-head); font-weight: 600; font-size: 17px; flex: none; }
.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; }

/* ============ Tablet ============ */
@media (min-width: 620px) {
  h1 { font-size: 28px; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .grid2 { grid-template-columns: 1fr 1fr; }
  .cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
  main { padding: 22px 20px 34px; }
  .card { padding: 20px; }
  .table-wrap { margin: 0 -20px; padding: 0 20px; }
}

/* ============ Desktop: side nav replaces tab bar ============ */
@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .tabbar { display: none; }
  .sidenav {
    display: flex; flex-direction: column; gap: 3px; position: fixed;
    top: var(--top-h); left: 0; bottom: 0; width: var(--nav-w);
    background: #fff; border-right: 1px solid var(--line); padding: 16px 12px; z-index: 55; overflow-y: auto;
  }
  .sidenav a {
    display: flex; align-items: center; gap: 11px; padding: 11px 13px; border-radius: var(--r);
    color: var(--slate); font-size: 14px; font-weight: 600;
  }
  .sidenav a:hover { background: var(--cream); color: var(--charcoal); text-decoration: none; }
  .sidenav a.active { background: var(--teal-soft); color: var(--teal-dark); }
  .sidenav a i { width: 17px; text-align: center; font-size: 14px; }
  main.has-nav { margin-left: var(--nav-w); max-width: none; padding: 26px 30px 40px; }
  main.has-nav > * { max-width: 1140px; }
  .cols3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; align-items: start; }
  .cols-2-1 { display: grid; grid-template-columns: 1.55fr 1fr; gap: 18px; align-items: start; }
  table.data { min-width: 0; }
  .hide-desktop { display: none !important; }
}
@media (max-width: 899px) {
  .hide-mobile { display: none !important; }
}
@media (min-width: 720px) {
  .rows-mobile-only { display: none !important; }
}
@media (max-width: 719px) {
  .table-desktop-only { display: none !important; }
}

@media print {
  .topbar, .sidenav, .tabbar, .page-actions, .btn { display: none !important; }
  body { background: #fff; padding: 0; }
  main.has-nav { margin: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
