/* ============================================================================
 * APP — screen-specific rules. Primitives live in core.css.
 * ============================================================================ */

/* ── Overview: the fleet strip ───────────────────────────────────────────────
 * Four counts, worst first. Data-Views §8: the eye takes the left edge first,
 * so "needs action" is leftmost — not alphabetical, not green-first. */

.fleet-strip{
  display:flex;gap:8px;flex-wrap:wrap;margin-top:14px;
}
.fleet-chip{
  display:inline-flex;align-items:center;gap:7px;
  height:30px;padding:0 12px;border-radius:var(--radius-pill);
  background:var(--surface2);border:1px solid var(--border);
  font-size:13px;font-weight:500;
}
.fleet-chip .n{font-weight:700;font-variant-numeric:tabular-nums}
.fleet-chip.zero{opacity:.4}

.income-panel{display:flex;flex-wrap:wrap;gap:26px;align-items:flex-end}
.income-main{min-width:200px}
.income-side{display:flex;gap:28px;flex-wrap:wrap;margin-left:auto}

/* ── Roster rows ─────────────────────────────────────────────────────────────
 * Data-Views §6 list-row anatomy: primary text (name, bold) + one muted
 * secondary line + one right-aligned metadatum. Identical height, identical
 * alignment, every row. §8: F-pattern — the name leads at the left edge. */

.roster{display:flex;flex-direction:column}

.rrow{
  display:flex;align-items:center;gap:12px;
  padding:12px 14px;
  border-bottom:1px solid var(--border);
  position:relative;
  min-height:64px;              /* identical height, and well over 44px */
  transition:background .12s;
}
.rrow:hover{background:var(--state-hover)}
.rrow:last-child{border-bottom:0}

.rrow-light{display:flex;align-items:center;justify-content:center;width:10px;flex:none}
.rrow-body{flex:1;min-width:0}
.rrow-name{
  font-size:14.5px;font-weight:600;letter-spacing:-.01em;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.rrow-meta{
  font-size:12.5px;color:var(--muted);margin-top:2px;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
/* The reason a row is not green is never the muted colour — that would make the
   only actionable sentence on the row the least readable thing on it. */
.rrow-meta.red{color:var(--danger)}
.rrow-meta.amber{color:var(--amber)}
.rrow-meta.unknown{color:var(--unknown)}

.rrow-right{text-align:right;flex:none}
.rrow-figure{font-size:14px;font-weight:600;font-variant-numeric:tabular-nums}
.rrow-sub{font-size:11.5px;color:var(--muted);margin-top:2px}

/* Selection: full-row tint PLUS a left accent bar tying the row to the pane.
   Data-Views §4 — "selection is always visibly lit". */
.rrow.selected{background:var(--state-selected)}
.rrow.selected::before{
  content:"";position:absolute;left:0;top:0;bottom:0;width:3px;
  background:var(--accent);
}

/* ── Master–detail ───────────────────────────────────────────────────────────
 * Data-Views §4. Desktop ≥981px: persistent left list + detail filling the
 * rest, the two scrolling INDEPENDENTLY so a long history never drags the list.
 * Phone ≤980px: full swap, driven by .has-selection — CSS decides split vs
 * swap by WIDTH, not by device. */

.md{display:flex;gap:0;min-height:calc(100vh - 52px);align-items:stretch}

.md-list{
  width:var(--list-w);flex:none;
  border-right:1px solid var(--border);
  display:flex;flex-direction:column;min-width:0;
}
.md-filters{
  position:sticky;top:0;z-index:2;
  background:var(--bg);
  padding:0 14px 12px;
  border-bottom:1px solid var(--border);
}
.md-scroll{overflow-y:auto;flex:1;min-height:0}

.md-detail{
  flex:1;min-width:0;
  overflow-y:auto;
  padding:0 0 40px 26px;
}

/* Data-Views §4: "Never a blank pane." No selection is a designed placeholder,
   and we deliberately do NOT auto-select on load. */
.md-placeholder{
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  min-height:340px;text-align:center;color:var(--muted);padding:40px 20px;
}
.md-placeholder .ph-icon{color:var(--dim);margin-bottom:14px}
.md-placeholder .ph-icon svg{width:30px;height:30px}
.md-placeholder-title{font-size:15px;color:var(--text-soft);font-weight:500;margin-bottom:6px}
.md-placeholder-body{font-size:13.5px;max-width:38ch;line-height:1.55}

.md-back{display:none}

/* ── Search & filters ────────────────────────────────────────────────────────
 * Data-Views §3 order: search box (leading icon) → sort → chips. No count chip
 * inside the search box — the filtered list beneath it already is the count. */

.search{position:relative;margin-bottom:10px}
.search .ic{
  position:absolute;left:11px;top:50%;transform:translateY(-50%);
  color:var(--muted);width:15px;height:15px;pointer-events:none;
}
.search input{padding-left:34px}

.chips{
  display:flex;gap:6px;
  /* §3: one line at every width — they scroll, they never wrap. */
  overflow-x:auto;white-space:nowrap;
  scrollbar-width:none;padding-bottom:2px;
}
.chips::-webkit-scrollbar{display:none}
.chip{
  height:30px;padding:0 12px;border-radius:var(--radius-pill);
  border:1px solid var(--border-mid);background:transparent;
  color:var(--muted);font:inherit;font-size:12.5px;font-weight:500;
  cursor:pointer;flex:none;
  transition:background .12s,color .12s,border-color .12s;
}
.chip:hover{color:var(--text);border-color:var(--border-emph)}
.chip.active{
  background:rgba(var(--accent-rgb),.18);
  border-color:rgba(var(--accent-rgb),.5);
  color:var(--accent-text);
}

/* ── Client detail pane ──────────────────────────────────────────────────────
 * Data-Views §6 profile header: identity top-left, stat strip below, primary
 * action top-right. */

.cd-head{
  display:flex;align-items:flex-start;gap:16px;flex-wrap:wrap;
  padding:20px 0 16px;border-bottom:1px solid var(--border);
}
.cd-identity{flex:1;min-width:220px}
.cd-name{font-size:22px;font-weight:700;letter-spacing:-.02em;display:flex;align-items:center;gap:10px}
.cd-line{font-size:13px;color:var(--muted);margin-top:5px}
.cd-line a{color:var(--accent-text)}
.cd-line a:hover{text-decoration:underline;text-underline-offset:2px}
.cd-actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap}

.cd-why{
  margin-top:16px;padding:13px 15px;border-radius:var(--radius-md);
  border:1px solid var(--border-mid);background:var(--surface2);
}
.cd-why.red{border-color:rgba(var(--danger-rgb),.35);background:rgba(var(--danger-rgb),.07)}
.cd-why.amber{border-color:rgba(var(--amber-rgb),.3);background:rgba(var(--amber-rgb),.06)}
.cd-why.unknown{border-color:rgba(var(--unknown-rgb),.32);background:rgba(var(--unknown-rgb),.07)}
.cd-why-title{font-size:12px;font-weight:700;text-transform:uppercase;letter-spacing:.07em;margin-bottom:8px}
.cd-why.red .cd-why-title{color:var(--danger)}
.cd-why.amber .cd-why-title{color:var(--amber)}
.cd-why.unknown .cd-why-title{color:var(--unknown)}
.cd-why ul{margin:0;padding-left:18px;font-size:13.5px;line-height:1.6;color:var(--text-soft)}

/* Signal grid — every check, passing or not. Data-Views §7: never hide a
   warning behind a click, so all seven are on the surface. */
.signals{
  display:grid;gap:1px;background:var(--border);
  border:1px solid var(--border);border-radius:var(--radius-md);overflow:hidden;
  grid-template-columns:repeat(auto-fit,minmax(190px,1fr));
}
.signal{background:var(--surface);padding:11px 13px;display:flex;gap:9px;align-items:flex-start}
.signal .light{margin-top:5px}
.signal-label{font-size:12px;font-weight:600}
.signal-reason{font-size:12px;color:var(--muted);margin-top:2px;line-height:1.45}

/* Progressive disclosure — Data-Views §7: two tiers max, honest label, fixed
   location. The poll log is the ONLY thing collapsed here; money, obligations
   and warnings all stay on the surface. */
details.disclose{border-top:1px solid var(--border);margin-top:18px;padding-top:14px}
details.disclose > summary{
  cursor:pointer;list-style:none;
  font-size:12.5px;font-weight:600;color:var(--text-soft);
  display:flex;align-items:center;gap:7px;min-height:32px;
}
details.disclose > summary::-webkit-details-marker{display:none}
details.disclose > summary::after{
  content:"";width:6px;height:6px;flex:none;
  border-right:1.5px solid var(--muted);border-bottom:1.5px solid var(--muted);
  transform:rotate(45deg);margin-left:2px;transition:transform .15s;
}
details.disclose[open] > summary::after{transform:rotate(-135deg)}
details.disclose > summary:hover{color:var(--text)}
.disclose-body{padding-top:12px}

/* Poll log rows */
.polls{font-size:12.5px}
.poll{display:flex;gap:10px;align-items:baseline;padding:6px 0;border-top:1px solid var(--border)}
.poll:first-child{border-top:0}
.poll-when{width:64px;flex:none;color:var(--muted);font-variant-numeric:tabular-nums}
.poll-msg{flex:1;min-width:0}
.poll.ok .poll-msg{color:var(--text-soft)}
.poll.fail .poll-msg{color:var(--danger)}
.poll-ms{color:var(--muted);font-variant-numeric:tabular-nums;flex:none}

/* ── Alerts feed ─────────────────────────────────────────────────────────── */

.alert-row{
  display:flex;gap:13px;align-items:flex-start;
  padding:14px 0;border-top:1px solid var(--border);
}
.alert-row:first-child{border-top:0}
.alert-row.acked{opacity:.5}
.alert-body{flex:1;min-width:0}
.alert-msg{font-size:14px;font-weight:500;line-height:1.4}
.alert-meta{font-size:12px;color:var(--muted);margin-top:4px}
.alert-meta a{color:var(--accent-text)}
.alert-meta a:hover{text-decoration:underline;text-underline-offset:2px}
.alert-actions{flex:none}

/* ── Finance ─────────────────────────────────────────────────────────────── */

.period-nav{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.period-label{font-size:14px;font-weight:600;font-variant-numeric:tabular-nums;min-width:112px}

/* A CSS-only trend bar. Not a charting library: twelve monthly totals do not
   need 90KB of JavaScript, and UX_PRINCIPLES §12 forbids blocking third-party
   scripts. §9 requires the plain-language sentence beside it either way. */
.trend{display:flex;align-items:flex-end;gap:5px;height:96px;margin-top:6px}
.trend-col{flex:1;display:flex;flex-direction:column;justify-content:flex-end;align-items:center;gap:6px;min-width:0}
.trend-bar{
  width:100%;max-width:34px;
  background:rgba(var(--accent-rgb),.35);
  border-radius:3px 3px 0 0;min-height:2px;
  transition:background .12s;
}
.trend-col.current .trend-bar{background:var(--accent)}
.trend-col:hover .trend-bar{background:var(--accent-text)}
.trend-label{
  font-size:10px;color:var(--muted);
  white-space:nowrap;font-variant-numeric:tabular-nums;
}

.est{
  font-size:10px;text-transform:uppercase;letter-spacing:.06em;
  color:var(--amber);margin-left:6px;font-weight:700;
}

/* ── Settings: the connection checklist ──────────────────────────────────── */

.check{
  display:flex;gap:12px;align-items:flex-start;
  padding:14px 0;border-top:1px solid var(--border);
}
.check:first-child{border-top:0}
.check-icon{margin-top:1px;flex:none}
.check-icon.ok{color:var(--green)}
.check-icon.todo{color:var(--amber)}
.check-body{flex:1;min-width:0}
.check-label{font-size:14px;font-weight:600}
.check-detail{font-size:13px;color:var(--text-soft);margin-top:3px}
.check-next{font-size:12.5px;color:var(--muted);margin-top:6px;line-height:1.5}

.token-box{
  font-family:var(--font-mono);font-size:12.5px;
  padding:10px 12px;border-radius:var(--radius-md);
  background:var(--bg);border:1px solid var(--border-mid);
  word-break:break-all;user-select:all;margin-top:8px;
}

/* ── Auth screens ────────────────────────────────────────────────────────── */

.auth-wrap{
  min-height:100vh;display:flex;align-items:center;justify-content:center;
  padding:24px 20px;
}
.auth-card{width:100%;max-width:400px}
.auth-brand{margin-bottom:26px}
.auth-brand-name{font-size:20px;font-weight:700;letter-spacing:-.02em}
.auth-brand-sub{
  font-size:11px;color:var(--muted);text-transform:uppercase;
  letter-spacing:.09em;margin-top:4px;
}
.auth-card .field{max-width:none}
.auth-card .btn.primary{width:100%;min-height:44px;margin-top:4px}

/* ── Error page ──────────────────────────────────────────────────────────── */

.err-wrap{
  min-height:70vh;display:flex;flex-direction:column;
  align-items:center;justify-content:center;text-align:center;padding:30px 20px;
}
.err-code{font-size:12px;letter-spacing:.14em;color:var(--muted);text-transform:uppercase}
.err-title{font-size:22px;font-weight:600;margin:10px 0 8px}
.err-msg{color:var(--text-soft);max-width:44ch;line-height:1.6;margin-bottom:22px}

/* ── Phone: master-detail becomes a full swap ────────────────────────────── */

@media (max-width:980px){
  .md{flex-direction:column;min-height:0}
  .md-list{width:100%;border-right:0}
  .md-detail{padding:0 0 40px;display:none}
  .md-scroll{overflow:visible}

  /* One view at a time, with a Back affordance. Data-Views §4. */
  .md.has-selection .md-list{display:none}
  .md.has-selection .md-detail{display:block}
  .md.has-selection .md-back{
    display:inline-flex;align-items:center;gap:6px;
    min-height:44px;padding:0 4px;margin:6px 0 2px;
    color:var(--muted);font-size:14px;font-weight:500;
  }
  .md-filters{position:static;padding:0 0 12px}

  .income-side{margin-left:0;gap:20px}
  .cd-head{padding-top:14px}
  .cd-actions{width:100%}
  .cd-actions .btn{flex:1}
}
