/* ==========================================================================
   VSLA Manager – application design system (on top of Pico CSS resets)
   ========================================================================== */
:root {
  --brand: #0f766e;            /* teal 700 */
  --brand-strong: #115e59;
  --brand-soft: #ccfbf1;
  --brand-tint: #f0fdfa;
  --accent: #d97706;           /* amber 600 */
  --accent-soft: #fef3c7;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --surface: #f5f7fa;
  --card: #ffffff;
  --ok: #15803d; --ok-soft: #dcfce7;
  --warn: #b45309; --warn-soft: #fef3c7;
  --bad: #b91c1c; --bad-soft: #fee2e2;
  --info: #1d4ed8; --info-soft: #dbeafe;
  --radius: 12px; --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 4px 14px rgba(15, 23, 42, .08);
  --sidebar-w: 236px;

}
/* Pico sets its palette on [data-theme=light]; override at equal-or-higher specificity */
:root, :root[data-theme=light], [data-theme=light], :root:not([data-theme=dark]) {
  --pico-font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --pico-font-size: 93.75%;
  --pico-line-height: 1.45;
  --pico-primary: var(--brand);
  --pico-primary-background: var(--brand);
  --pico-primary-hover-background: var(--brand-strong);
  --pico-primary-border: var(--brand);
  --pico-primary-hover: var(--brand-strong);
  --pico-primary-underline: transparent;
  --pico-primary-focus: rgba(15, 118, 110, .25);
  --pico-border-radius: var(--radius-sm);
  --pico-form-element-spacing-vertical: .5rem;
  --pico-form-element-spacing-horizontal: .75rem;
  --pico-spacing: .9rem;
  --pico-background-color: var(--surface);
  --pico-color: var(--ink);
  --pico-muted-border-color: var(--line);
  --pico-card-background-color: var(--card);
  --pico-h1-color: var(--ink);
  --pico-h2-color: var(--ink);
  --pico-h3-color: var(--ink);
}
html { scroll-behavior: smooth; }
body { background: var(--surface); color: var(--ink); font-feature-settings: "tnum" 1, "cv11" 1; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3 { letter-spacing: -.01em; font-weight: 700; }
h1 { font-size: 1.55rem; margin-bottom: .35rem; }
h2 { font-size: 1.15rem; margin: 1.4rem 0 .6rem; }
h3 { font-size: 1rem; margin-bottom: .4rem; }
strong { font-weight: 600; }
code { font-size: .85em; background: #eef2f7; padding: .1rem .35rem; border-radius: 4px; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { background: #0b2f2c; color: #d9f2ef; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.1rem .9rem; color: #fff; font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em; }
.sidebar .brand:hover { text-decoration: none; }
.logo { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #14b8a6, #0f766e); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: .95rem; flex: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); }
.sidebar nav { padding: .25rem .6rem; flex: 1; }
.sidebar .nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: #6fb8ae; padding: .9rem .6rem .35rem; }
.sidebar a.nav { display: flex; align-items: center; gap: .65rem; padding: .5rem .65rem; border-radius: 8px; color: #cfe9e5; font-size: .92rem; font-weight: 500; }
.sidebar a.nav:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.sidebar a.nav.active { background: rgba(20,184,166,.18); color: #fff; }
.sidebar a.nav svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.sidebar a.nav .pill { margin-left: auto; }
.sidebar .user { border-top: 1px solid rgba(255,255,255,.1); padding: .8rem 1rem; display: flex; align-items: center; gap: .6rem; }
.sidebar .avatar { width: 32px; height: 32px; border-radius: 50%; background: #14b8a6; color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .85rem; flex: none; }
.sidebar .user .meta { min-width: 0; line-height: 1.2; }
.sidebar .user .name { color: #fff; font-weight: 600; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .user .role { font-size: .72rem; color: #8fd0c7; }
.sidebar .user form { margin-left: auto; }
.sidebar .user button { background: transparent; border: 1px solid rgba(255,255,255,.2); color: #d9f2ef; padding: .25rem .5rem; font-size: .75rem; width: auto; margin: 0; border-radius: 6px; white-space: nowrap; flex: none; }
.sidebar .user button:hover { background: rgba(255,255,255,.1); }
.topbar { display: none; }
.content { min-width: 0; }
main.container { max-width: 1280px; padding: 1.5rem 2rem 4rem; margin: 0; }
main.container.wide { max-width: 1560px; }
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(84vw, 300px); transform: translateX(-100%); transition: transform .2s ease; z-index: 50; }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(15,23,42,.45); }
  .topbar { display: flex; align-items: center; gap: .75rem; padding: .65rem 1rem; background: #0b2f2c; color: #fff; position: sticky; top: 0; z-index: 40; }
  .topbar .brand { color: #fff; font-weight: 700; display: flex; align-items: center; gap: .5rem; }
  .topbar .brand:hover { text-decoration: none; }
  .topbar button { background: transparent; border: 0; color: #fff; width: auto; margin: 0; padding: .3rem; display: grid; place-items: center; }
  .topbar .spacer { flex: 1; }
  .topbar .pill { font-size: .72rem; }
  main.container { padding: 1rem 1rem 5rem; }
}

/* ---------- Page header & typography helpers ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.page-head .actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }
.page-head .actions a, .page-head .actions button { margin: 0; padding: .45rem .9rem; font-size: .88rem; width: auto; }
.eyebrow { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; margin-bottom: .2rem; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1.25rem; font-size: .9rem; margin: 0 0 1rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ---------- Buttons ---------- */
button, [role=button], input[type=submit] { font-weight: 600; box-shadow: var(--shadow-sm); }
button.secondary, [role=button].secondary { --pico-background-color: #475569; --pico-border-color: #475569; }
button.outline, [role=button].outline { box-shadow: none; --pico-color: var(--ink-2); --pico-border-color: var(--line-2); background: var(--card); }
button.outline:hover, [role=button].outline:hover { background: #f1f5f9; --pico-border-color: var(--line-2); --pico-color: var(--ink); }
.btn-sm { padding: .28rem .65rem; font-size: .8rem; width: auto; margin: 0; }
.btn-danger { --pico-background-color: var(--bad); --pico-border-color: var(--bad); }
.btn-secondary { --pico-background-color: #64748b; --pico-border-color: #64748b; }
.inline-form { display: inline; }

/* ---------- Flash / banners ---------- */
.flash { padding: .65rem 1rem; border-radius: var(--radius-sm); margin-bottom: .75rem; border: 1px solid; font-size: .92rem; display: flex; gap: .6rem; align-items: flex-start; }
.flash::before { content: ""; width: 8px; height: 8px; border-radius: 50%; margin-top: .45rem; flex: none; background: currentColor; }
.flash.success { background: var(--ok-soft); border-color: #86efac; color: #14532d; }
.flash.error { background: var(--bad-soft); border-color: #fca5a5; color: #7f1d1d; }
.flash.warning { background: var(--warn-soft); border-color: #fcd34d; color: #78350f; }
.flash.info { background: var(--info-soft); border-color: #93c5fd; color: #1e3a8a; }
.offline-bar { background: var(--warn-soft); color: #78350f; border-bottom: 1px solid #fcd34d; padding: .5rem 1rem; font-size: .88rem; text-align: center; }

/* ---------- Tiles ---------- */
.table-wrap td.nowrap, .table-wrap .nowrap { white-space: nowrap; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: .7rem; margin-bottom: 1.25rem; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem .8rem; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.tile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--brand); opacity: .9; }
.tiles.t-amber .tile::before { background: var(--accent); }
.tiles.t-blue .tile::before { background: var(--info); }
.tiles.t-rose .tile::before { background: #be185d; }
.tiles.t-slate .tile::before { background: #64748b; }
.tile .label { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.tile .value { font-size: 1.45rem; font-weight: 700; line-height: 1.25; margin-top: .15rem; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.tile .sub { font-size: .78rem; color: var(--muted); margin-top: .15rem; }

/* ---------- Cards & grids ---------- */
article, article.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1rem 1.1rem; margin-bottom: 1rem; }
article.card > header { padding: .55rem 1.1rem; margin: -1rem -1.1rem .8rem; font-weight: 600; font-size: .92rem; background: #f8fafc; border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; color: var(--ink-2); }
article.card .table-wrap { border: 0; box-shadow: none; margin: 0; border-radius: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.chart-box { position: relative; height: 250px; }
.chart-box.tall { height: 320px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 1rem; }
.table-wrap table, article table { margin: 0; }
table { font-size: .88rem; --pico-table-border-color: var(--line); }
table th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; white-space: nowrap; background: #f8fafc; border-bottom: 1px solid var(--line); }
table th a { color: var(--ink-2); }
table td, table th { padding: .5rem .7rem; vertical-align: middle; }
table.compact td, table.compact th { padding: .35rem .6rem; }
tbody tr:hover td { background: #f8fafc; }
tfoot td { font-weight: 700; background: #f8fafc; border-top: 2px solid var(--line-2); }
td.right, th.right { font-variant-numeric: tabular-nums; }
tr.muted td { color: var(--muted); }

/* ---------- Badges & pills ---------- */
.badge, .pill { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 600; white-space: nowrap; line-height: 1.5; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.late, .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.stale, .badge.bad, .badge.never { background: var(--bad-soft); color: var(--bad); }
.badge.neutral { background: #eef2f7; color: #475569; }
.badge.info { background: var(--info-soft); color: var(--info); }
.pill { background: var(--accent); color: #fff; }

/* ---------- Filters & forms ---------- */
.filters { display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: end; margin-bottom: 1rem; padding: .75rem .9rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.filters label { margin: 0; font-size: .74rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.filters select, .filters input { margin: .2rem 0 0; padding: .35rem .6rem; height: auto; font-size: .88rem; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--ink); }
.filters button { margin: 0; padding: .4rem .85rem; width: auto; font-size: .85rem; }
form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .25rem 1rem; }
form label { font-size: .86rem; font-weight: 500; color: var(--ink-2); }
form input, form select, form textarea { margin-bottom: .7rem; font-size: .92rem; }
form input[type=checkbox] { margin-bottom: 0; }
.help { font-size: .8rem; color: var(--muted); margin: -.4rem 0 .7rem; }
details summary { cursor: pointer; font-weight: 500; }
details.dropdown summary { padding: .35rem .6rem; }
progress { height: .5rem; }

/* ---------- Meeting entry sheet ---------- */
.sheet { width: 100%; border-collapse: collapse; }
.sheet th { position: sticky; top: 0; z-index: 1; text-align: center; }
.sheet th.name { text-align: left; }
.sheet td { padding: .25rem .3rem; border-bottom: 1px solid var(--line); }
.sheet input, .sheet select { margin: 0; padding: .3rem .4rem; height: 2.1rem; font-size: .9rem; }
.sheet input[type=number] { width: 6.5rem; text-align: right; }
.sheet input.shares { width: 4rem; text-align: center; font-weight: 600; }
.sheet select { width: auto; padding-right: 1.9rem; }
.sheet .name { white-space: nowrap; font-weight: 600; }
.sheet .name small { display: block; font-weight: 400; color: var(--muted); font-size: .76rem; }
.sheet tr.absent td { background: #f8fafc; }
.sheet tr.absent td.name { color: var(--muted); }
.sheet tbody tr:hover td { background: var(--brand-tint); }
.sheet .loan-cell { white-space: nowrap; }
.sheet .nl { display: flex; gap: .3rem; align-items: center; }
.sheet .nl select { min-width: 7rem; }
.sheet .nl input.term { width: 3.6rem; }
.sheet .nl small { line-height: 2rem; }
.sticky-bar { position: sticky; bottom: 0; background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -6px 16px rgba(15,23,42,.06); padding: .65rem 1rem; margin: 1rem -1rem 0; display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; z-index: 2; }
.sticky-bar button { width: auto; margin: 0; }
.sticky-bar .totals { margin-left: auto; font-size: .84rem; color: var(--ink-2); }
@media (max-width: 800px) {
  h1 { font-size: 1.3rem; }
  .page-head h1 { line-height: 1.25; }
  .sheet, .sheet tbody { display: block; width: 100%; }
  .table-wrap:has(.sheet) { border: 0; box-shadow: none; background: transparent; overflow: visible; }
  .sheet thead { display: none; }
  .sheet tbody tr { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .6rem .7rem; margin-bottom: .6rem; box-shadow: var(--shadow-sm); }
  .sheet tbody td { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .25rem 0; border: 0; }
  .sheet tbody td > input, .sheet tbody td > select { max-width: 55%; }
  .sheet tbody td .nl { flex-wrap: wrap; justify-content: flex-end; max-width: 75%; }
  .sheet tbody td::before { content: attr(data-label); font-size: .76rem; color: var(--muted); margin-right: .5rem; }
  .sheet tbody td.name { display: block; font-size: 1rem; padding-bottom: .4rem; border-bottom: 1px dashed var(--line); margin-bottom: .3rem; }
  .sheet tbody td.name::before { content: none; }
  .sheet input[type=number] { width: 8rem; }
  .sticky-bar { margin: 1rem -1rem 0; }
}

/* ---------- Login ---------- */
body.auth { background: radial-gradient(1200px 600px at 20% -10%, #14b8a6 0%, transparent 60%), radial-gradient(900px 500px at 110% 110%, #d97706 0%, transparent 55%), #0b2f2c; min-height: 100vh; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: 100%; max-width: 400px; background: var(--card); border-radius: 16px; padding: 2rem 2rem 1.5rem; box-shadow: 0 30px 60px rgba(0,0,0,.35); }
.auth-card .brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.1rem; margin-bottom: 1.4rem; color: var(--ink); }
.auth-card h1 { font-size: 1.35rem; margin-bottom: .2rem; }
.auth-card p.muted { margin-bottom: 1.2rem; }
.auth-card button { width: 100%; }
.auth-foot { text-align: center; color: rgba(255,255,255,.7); font-size: .8rem; margin-top: 1rem; }

/* ---------- Misc ---------- */
.print-only { display: none; }
@media print {
  .sidebar, .topbar, .no-print, .sticky-bar, .offline-bar { display: none !important; }
  .shell { display: block; }
  main.container { max-width: 100%; padding: 0; }
  .print-only { display: block; }
  .tile, article, .table-wrap { box-shadow: none; }
}
