/* Fastpost Management Hub — app stylesheet (Cash Flow v1)
   Built on the Modernist tokens. Load order in _Layout.cshtml:
   1) modernist.css (tokens + base components, copied from the design system)
   2) fastpost-hub.css (this file: app shell and Cash Flow patterns)
   No business logic depends on these classes. */

/* ---------- Tokens used by the app (aliases of Modernist tokens) ---------- */
:root {
  --hub-rail-width: 232px;
  --hub-content-max: 1200px;
  --hub-page-pad-x: clamp(16px, 4vw, 48px);
  --hub-neg: var(--color-accent-700);          /* negative money text */
  --hub-muted: var(--color-neutral-700);       /* secondary text, 4.5:1 on ground */
  --hub-rule-strong: 2px solid var(--color-divider);
  --hub-rule: 1px solid var(--color-divider);
  --hub-rule-soft: 1px solid var(--color-neutral-300);
}
a { color: var(--color-accent-700); }
a:hover { color: var(--color-accent-600); }
.num { font-variant-numeric: tabular-nums; }
.money-neg { color: var(--hub-neg); }
.text-muted { color: var(--hub-muted); }

/* ---------- App shell ---------- */
.hub-shell { min-height: 100vh; display: flex; flex-wrap: wrap; }
.hub-rail {
  flex: 1 1 var(--hub-rail-width); max-width: 100%;
  background: var(--color-surface); border-right: var(--hub-rule-strong);
  padding: 24px 16px; display: flex; flex-direction: column; gap: 28px;
}
.hub-main { flex: 999 1 640px; min-width: 0; padding: 32px var(--hub-page-pad-x) 64px; }
.hub-content { max-width: var(--hub-content-max); display: flex; flex-direction: column; gap: 24px; }
@media (min-width: 880px) { .hub-rail { flex: 0 0 var(--hub-rail-width); position: sticky; top: 0; height: 100vh; } }

.hub-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.hub-brand-mark { width: 14px; height: 14px; background: var(--color-accent); flex: none; }
.hub-brand-name { font-family: var(--font-heading); font-weight: 800; font-size: 17px; line-height: 1.15; letter-spacing: -0.01em; }
.hub-brand-sub { font-size: 12px; line-height: 1.15; color: var(--hub-muted); }

.hub-nav-group { display: flex; flex-direction: column; gap: 6px; }
.hub-nav-label, .hub-eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--hub-muted);
}
.hub-nav-label { padding: 0 8px 4px; }
.hub-nav-items { display: flex; flex-wrap: wrap; gap: 2px; }
.hub-nav-link {
  flex: 1 1 180px; display: flex; align-items: center; gap: 8px; padding: 8px;
  font-size: 14px; color: var(--color-text); text-decoration: none;
}
.hub-nav-link::before { content: ""; width: 6px; height: 6px; flex: none; background: transparent; }
.hub-nav-link:hover { background: color-mix(in srgb, var(--color-text) 6%, transparent); color: var(--color-text); }
.hub-nav-link[aria-current="page"] { background: var(--color-bg); font-weight: 600; }
.hub-nav-link[aria-current="page"]::before { background: var(--color-accent); }
.hub-nav-link.is-disabled { color: var(--color-neutral-600); pointer-events: none; padding-left: 22px; }
.hub-nav-link.is-disabled::before { display: none; }
.hub-user { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 8px 0; border-top: var(--hub-rule); font-size: 13px; }
.hub-user a { color: var(--hub-muted); }

/* ---------- Page header ---------- */
.page-header { display: flex; flex-direction: column; gap: 6px; padding-bottom: 20px; border-bottom: var(--hub-rule-strong); }
.page-header-row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-header-text { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.page-title { font-size: 30px; margin: 0; }
.page-sub { margin: 0; font-size: 14px; color: var(--hub-muted); }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.page-back { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; text-decoration: none; align-self: flex-start; }
.page-header--form { gap: 10px; }
.section-title { font-size: 18px; margin: 0; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; }

/* ---------- Buttons (extends Modernist .btn) ---------- */
.btn { white-space: nowrap; flex: none; justify-content: flex-start; }
.btn-danger { border-color: var(--color-divider); color: var(--color-accent-700); }
.btn-danger:hover { background: var(--color-accent-100); }
.btn-danger:active { background: var(--color-accent-200); }
.btn-row { font-size: 13px; } /* use with .btn-ghost for table row actions */
.seg-opt { white-space: nowrap; }

/* ---------- KPI strip ---------- */
.kpi-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); border-top: var(--hub-rule-strong); border-bottom: var(--hub-rule); overflow: hidden; }
.kpi { margin-left: -1px; border-left: var(--hub-rule); padding: 16px 20px; display: flex; flex-direction: column; gap: 4px; }
.kpi-label { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--hub-muted); }
.kpi-value { font-family: var(--font-heading); font-weight: 800; font-size: 24px; line-height: 1.15; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.kpi-value.is-neg { color: var(--hub-neg); }
.kpi-sub { font-size: 13px; color: var(--hub-muted); }

/* ---------- Forecast summary band ---------- */
.fc-summary { display: flex; flex-wrap: wrap; border-top: var(--hub-rule-strong); border-bottom: var(--hub-rule); }
.fc-low { flex: 2 1 460px; min-width: 0; padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.fc-low.is-below-min { background: var(--color-neutral-100); box-shadow: inset 0 4px 0 var(--color-accent); }
.fc-low.is-below-zero { background: var(--color-accent-100); box-shadow: inset 0 4px 0 var(--color-accent); }
.fc-low-figures { display: flex; flex-wrap: wrap; gap: 16px 40px; }
.fc-low .kpi-label { color: var(--color-neutral-800); }
.fc-big { font-family: var(--font-heading); font-weight: 800; font-size: 40px; line-height: 1.1; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fc-big.is-neg { color: var(--hub-neg); }
.fc-msg { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; font-size: 14px; }
.fc-msg-text { display: inline-flex; align-items: flex-start; gap: 8px; flex: 1 1 320px; }
.fc-msg-text strong { font-weight: 800; }
.fc-low.is-below-zero .fc-msg-text strong { color: var(--color-accent-800); }
.fc-summary .kpi { flex: 1 1 190px; margin-left: 0; padding: 20px 24px; }
.fc-summary .kpi-value { font-size: 28px; }

/* ---------- Forecast chart ---------- */
.fc-chart { display: flex; gap: 10px; }
.fc-chart-axis { width: 44px; flex: none; height: 240px; position: relative; font-size: 11px; color: var(--hub-muted); font-variant-numeric: tabular-nums; }
.fc-chart-plot { flex: 1; min-width: 0; position: relative; height: 240px; border-bottom: var(--hub-rule); }
.fc-chart-plot svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.fc-line { fill: none; stroke: var(--color-text); stroke-width: 2; vector-effect: non-scaling-stroke; }
.fc-zero { stroke: var(--color-text); stroke-width: 1; vector-effect: non-scaling-stroke; }
.fc-min { stroke: var(--color-accent); stroke-width: 1; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }
.fc-neg-area { fill: var(--color-accent); }
.fc-grid { position: absolute; left: 0; right: 0; border-top: var(--hub-rule-soft); pointer-events: none; }
.fc-months { display: flex; margin-left: 54px; font-size: 11px; color: var(--hub-muted); }
.fc-months span { min-width: 0; border-left: var(--hub-rule); padding-left: 4px; white-space: nowrap; overflow: hidden; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12px; color: var(--hub-muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Tables (extends Modernist .table) ---------- */
.table-wrap { overflow-x: auto; }
.table { font-variant-numeric: tabular-nums; }
.table td { height: 56px; }
.table .col-num { text-align: right; white-space: nowrap; }
.table .col-actions { width: 180px; }
.table .row-actions { display: flex; justify-content: flex-end; gap: 4px; }
.cell-stack { display: flex; flex-direction: column; line-height: 1.3; }
.cell-stack > :first-child { font-weight: 600; }
.cell-stack > .cell-sub { font-size: 12px; font-weight: 400; color: var(--hub-muted); }
.cell-sub.is-alert { color: var(--color-accent-700); font-weight: 600; }
.amount { font-weight: 600; }
.amount.is-skipped { font-weight: 400; text-decoration: line-through; color: var(--color-neutral-600); }
tr.is-overdue, tr.is-below-zero { background: var(--color-accent-100); }
tr.is-skipped { color: var(--hub-muted); }
tr.is-selected { background: var(--color-neutral-200); }
/* Forecast daily detail: items grouped by day */
.ledger td { height: auto; padding-top: 12px; padding-bottom: 12px; vertical-align: top; }
.ledger tr.day-item td { border-bottom: var(--hub-rule-soft); }
.ledger tr.day-item td.col-date { border-bottom: 0; }
.ledger tr.day-last td { border-bottom: var(--hub-rule); }
.ledger .bal { font-weight: 800; }

/* ---------- Status tags ---------- */
.status {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  padding: 2px 8px; line-height: 1.5; white-space: nowrap; border: 1px solid transparent;
}
.status::before { content: ""; width: 6px; height: 6px; background: currentColor; }
.status--planned   { border-color: var(--color-neutral-500); color: var(--color-neutral-800); }  /* Not paid, Expected */
.status--done      { background: var(--color-neutral-200); color: var(--color-neutral-900); }    /* Paid, Received */
.status--late      { background: var(--color-accent-100); border-color: var(--color-accent-300); color: var(--color-accent-800); } /* Overdue, Late */
.status--skipped   { border: 1px dashed var(--color-neutral-500); color: var(--color-neutral-700); }
.status--active    { border-color: var(--color-neutral-500); color: var(--color-neutral-900); }
.status--paused    { background: var(--color-neutral-200); color: var(--color-neutral-700); }
.status--below-min { border-color: var(--color-accent); color: var(--color-accent-700); }
.status--below-zero{ background: var(--color-accent-700); color: var(--color-bg); }
.recurring-icon { width: 13px; height: 13px; color: var(--color-neutral-600); flex: none; }

/* ---------- Notices & alerts ---------- */
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border: var(--hub-rule); background: var(--color-surface); font-size: 14px; }
.notice svg { flex: none; margin-top: 2px; }
.flash { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 14px; border: var(--hub-rule); background: var(--color-neutral-100); font-size: 14px; }
.flash-text { flex: 1; }

/* ---------- List toolbar ---------- */
.list-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.month-stepper { display: flex; align-items: center; }
.month-stepper-label { height: 36px; display: flex; align-items: center; padding: 0 14px; border-top: var(--hub-rule); border-bottom: var(--hub-rule); font-weight: 600; font-size: 14px; white-space: nowrap; }
.search { position: relative; flex: 1 1 220px; max-width: 320px; margin-left: auto; }
.search svg { position: absolute; left: 10px; top: 10px; color: var(--color-neutral-600); }
.search .input { padding-left: 34px; }

/* ---------- Forms ---------- */
.form-page { max-width: 800px; display: flex; flex-direction: column; gap: 24px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px 24px; }
.form-grid .span-all { grid-column: 1 / -1; }
.form-section { display: flex; flex-direction: column; gap: 20px; padding-top: 20px; border-top: var(--hub-rule); }
.input-money { position: relative; }
.input-money::before { content: "$"; position: absolute; left: 10px; top: 8px; font-size: 14px; color: var(--hub-muted); }
.input-money .input { padding-left: 22px; font-variant-numeric: tabular-nums; }
.field-hint { margin-top: 6px; font-size: 13px; color: var(--hub-muted); }
.field-error { margin-top: 6px; font-size: 13px; color: var(--color-accent-700); }
.input.input-validation-error { border-color: var(--color-accent-700); background: var(--color-accent-100); }
.field-validation-error { display: block; margin-top: 6px; font-size: 13px; color: var(--color-accent-700); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--color-accent); }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 20px; border-top: var(--hub-rule-strong); }
.form-actions .spacer { flex: 1; }
.form-with-aside { display: flex; flex-wrap: wrap; gap: 40px; align-items: flex-start; }
.form-with-aside > .form-main { flex: 999 1 480px; min-width: 0; max-width: 800px; display: flex; flex-direction: column; gap: 24px; }
.form-with-aside > .form-aside { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; border-top: var(--hub-rule-strong); }
.occurrence { display: flex; align-items: center; gap: 12px; min-height: 48px; border-top: var(--hub-rule); font-size: 14px; font-variant-numeric: tabular-nums; }
.occurrence-date { flex: 1; }
.occurrence.is-skipped .occurrence-date { color: var(--color-neutral-600); text-decoration: line-through; }

/* ---------- Empty state ---------- */
.empty { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 40px 24px; border-top: var(--hub-rule-strong); border-bottom: var(--hub-rule); }
.empty-title { font-weight: 800; font-size: 18px; }
.empty p { margin: 0; font-size: 14px; color: var(--hub-muted); max-width: 52ch; }

/* ---------- Dialog (Modernist .dialog) ---------- */
.dialog-backdrop { z-index: 50; }
.dialog-body { opacity: 1; color: var(--color-neutral-800); }
