/* WiS investor apps — shared layout (cap-table / financials / roadmap / one-pager)
   Loaded AFTER wis-theme.css. Single source of layout truth so pages stay consistent. */

body { background: hsl(var(--background)); }

.page { max-width: 1150px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }

/* ── Top bar ───────────────────────────────────────────── */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2rem; flex-wrap: wrap; gap: .75rem; }
.topbar h1 { font-size: 1.4rem; font-family: var(--font-heading); font-weight: 700; margin: 0; }
.topbar .sub { margin: .25rem 0 0; font-size: .8rem; color: hsl(var(--muted-foreground)); }
.topbar-actions { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }

/* ── Metric cards ──────────────────────────────────────── */
.card-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; margin-bottom: 2rem; }
.metric-card { background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: var(--radius); padding: 1rem 1.2rem; min-width: 0; }
.metric-card .val { font-size: clamp(1.1rem, 2.2vw, 1.5rem); font-weight: 700; font-family: var(--font-heading); color: hsl(var(--primary)); line-height: 1.15; overflow-wrap: anywhere; }
.metric-card .lbl { font-size: .72rem; color: hsl(var(--muted-foreground)); margin-top: .25rem; }

/* ── Sections ──────────────────────────────────────────── */
.section { background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: var(--radius); margin-bottom: 1.5rem; overflow: hidden; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .85rem 1.25rem; border-bottom: 1px solid hsl(var(--border)); flex-wrap: wrap; }
.section-head h2 { font-size: .9rem; font-weight: 600; margin: 0; }
.section-body { padding: 1.25rem; }
.section-body.scroll-x { overflow-x: auto; }

/* ── Tables ────────────────────────────────────────────── */
.tbl { width: 100%; border-collapse: collapse; font-size: .83rem; }
.tbl th { text-align: left; padding: .5rem .7rem; font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: hsl(var(--muted-foreground)); border-bottom: 1px solid hsl(var(--border)); white-space: nowrap; }
.tbl td { padding: .55rem .7rem; border-bottom: 1px solid hsl(var(--border) / .5); vertical-align: top; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr.total td { font-weight: 700; background: hsl(var(--secondary)); }
.tbl input[type=number], .tbl input[type=text], .tbl select, .tbl textarea {
  background: hsl(var(--background)); border: 1px solid hsl(var(--border)); color: hsl(var(--foreground));
  border-radius: .4rem; padding: .3rem .55rem; font-size: .82rem; width: 100%; min-width: 70px; font-family: inherit;
}
.tbl input:focus, .tbl select:focus, .tbl textarea:focus { outline: none; border-color: hsl(var(--primary)); }
.tbl textarea { resize: vertical; min-height: 2.2rem; }

/* ── Status badges ─────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: .25rem; padding: .2rem .55rem; border-radius: 999px; font-size: .68rem; font-weight: 600; white-space: nowrap; }
.badge-done     { background: hsl(var(--accent) / .15);  color: hsl(var(--accent));  border: 1px solid hsl(var(--accent) / .35); }
.badge-progress { background: hsl(45 90% 55% / .15);     color: hsl(45 90% 60%);     border: 1px solid hsl(45 90% 55% / .35); }
.badge-plan     { background: hsl(var(--secondary));     color: hsl(var(--muted-foreground)); border: 1px solid hsl(var(--border)); }
.badge-early    { background: hsl(168 60% 20% / .5);     color: hsl(var(--primary)); border: 1px solid hsl(var(--primary) / .35); }

/* ── Charts: FIXED-HEIGHT containers (prevents layout drift/growth) ── */
.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.25rem; margin-bottom: 1.5rem; }
.chart-box { background: hsl(var(--background)); border: 1px solid hsl(var(--border)); border-radius: var(--radius); padding: 1rem; min-width: 0; }
.chart-box h3, .chart-box h4 { font-size: .8rem; font-weight: 600; margin: 0 0 .75rem; color: hsl(var(--muted-foreground)); }
.chart-area { position: relative; height: 260px; width: 100%; }
.chart-area.tall { height: 320px; }
.chart-area canvas { position: absolute; inset: 0; max-width: 100%; }

/* ── Notes ─────────────────────────────────────────────── */
.note { font-size: .78rem; color: hsl(var(--muted-foreground)); padding: .7rem 1rem; background: hsl(var(--primary) / .06); border: 1px solid hsl(var(--primary) / .2); border-radius: .6rem; line-height: 1.6; }
.note strong { color: hsl(var(--primary)); }

/* ── Tabs ──────────────────────────────────────────────── */
.main-tabs { display: flex; gap: .1rem; background: hsl(var(--secondary)); border-radius: var(--radius); padding: .25rem; margin-bottom: 2rem; width: fit-content; max-width: 100%; overflow-x: auto; }
.main-tab { padding: .45rem 1.1rem; border-radius: calc(var(--radius) - 4px); font-size: .85rem; font-weight: 500; cursor: pointer; color: hsl(var(--muted-foreground)); transition: var(--transition); white-space: nowrap; }
.main-tab.active { background: hsl(var(--card)); color: hsl(var(--foreground)); box-shadow: 0 1px 6px rgba(0,0,0,.3); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Edit mode (admin only) ────────────────────────────── */
.admin-only { display: none !important; }
body.is-admin .admin-only { display: inline-flex !important; }
body.edit-mode .edit-hide { display: none !important; }
.view-only { display: inline; }
body.edit-mode .view-only { display: none !important; }
.edit-only { display: none !important; }
body.edit-mode .edit-only { display: revert !important; }
body.edit-mode .section { border-color: hsl(45 90% 55% / .4); }
.edit-banner { display: none; font-size: .75rem; padding: .4rem .8rem; border-radius: .5rem; background: hsl(45 90% 55% / .12); color: hsl(45 90% 65%); border: 1px solid hsl(45 90% 55% / .3); }
body.edit-mode .edit-banner { display: inline-flex; align-items: center; gap: .4rem; }

/* ── Save status pill ──────────────────────────────────── */
.save-status { font-size: .78rem; padding: .3rem .7rem; border-radius: .4rem; }
.save-status.ok { color: hsl(var(--accent)); background: hsl(var(--accent) / .1); }
.save-status.err { color: hsl(0 70% 65%); background: hsl(0 70% 65% / .1); }
.save-status.saving { color: hsl(var(--muted-foreground)); }

/* ── Responsive guards ─────────────────────────────────── */
@media (max-width: 640px) {
  .page { padding: 1.25rem .9rem 3rem; }
  .card-row { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
}
