/* ============================================================
   DTF Nest — REDESIGN theme (Stripe-inspired, light, premium corporate)
   Shared across every server-rendered view. Link with <link rel="stylesheet"
   href="/theme.css"> (served publicly, before auth, in server.js).
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  /* ---- Neutrals / surfaces ---- */
  --canvas: #f6f8fb;          /* page background */
  --surface: #ffffff;         /* cards, panels */
  --surface-sunken: #f7f9fc;  /* insets, table headers, wells */
  --surface-hover: #f4f6f9;   /* row hover */

  /* ---- Ink (Stripe navy text ramp) ---- */
  --ink: #0a2540;             /* headings, primary numbers */
  --ink-body: #3c4257;        /* body copy */
  --ink-secondary: #697386;   /* secondary labels */
  --ink-muted: #8792a2;       /* muted / placeholder */

  /* ---- Hairlines ---- */
  --line: #e9edf3;            /* the light divider used sparingly */
  --line-strong: #dfe3ea;

  /* ---- Accent (single, sparing) ---- */
  --accent: #635bff;          /* blurple primary */
  --accent-hover: #524beb;
  --accent-active: #453fd6;
  --accent-wash: #f1f0ff;
  --accent-ring: rgba(99, 91, 255, 0.28);
  --brand-grad: linear-gradient(150deg, #635bff, #8b7bff);

  /* ---- Semantic (financial-dashboard) ---- */
  --pos: #1a936f;             /* positive / paid / success green */
  --pos-wash: #e6f6ef;
  --warn: #b1560f;            /* pending / warning amber-brown */
  --warn-wash: #fdf0e3;
  --neg: #cd3d64;             /* danger / unpaid / red */
  --neg-wash: #fce8ee;
  --info: #3b6fd4;            /* neutral-info blue for data accents */
  --info-wash: #eaf0fc;

  /* ---- Type ---- */
  --font-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

  /* ---- Radius ---- */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-2xl: 20px;
  --r-pill: 999px;

  /* ---- Shadows (soft, layered — the Stripe signature) ---- */
  --shadow-xs: 0 1px 2px rgba(10, 37, 64, 0.06);
  --shadow-sm: 0 1px 3px rgba(10, 37, 64, 0.06), 0 1px 2px rgba(10, 37, 64, 0.04);
  --shadow-md: 0 4px 12px rgba(10, 37, 64, 0.06), 0 1px 3px rgba(10, 37, 64, 0.05);
  --shadow-lg: 0 12px 28px rgba(10, 37, 64, 0.10), 0 4px 10px rgba(10, 37, 64, 0.05);
  --shadow-accent: 0 2px 8px rgba(99, 91, 255, 0.32);

  /* ---- Motion ---- */
  --ease: cubic-bezier(0.2, 0.6, 0.2, 1);
  --dur: 0.16s;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--canvas);
  color: var(--ink-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Typography helpers ---------- */
.h-eyebrow { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-muted); }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px 22px; }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 14px;
  border: none;
  border-radius: var(--r-md);
  padding: 9px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: 0.55; cursor: default; }
.btn:active:not(:disabled) { transform: translateY(0.5px); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong), var(--shadow-xs); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-sunken); }
.btn-ghost { background: transparent; color: var(--ink-secondary); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-sunken); color: var(--ink); }
.btn-danger { background: var(--surface); color: var(--neg); box-shadow: inset 0 0 0 1px #f3d3dc; }
.btn-danger:hover:not(:disabled) { background: var(--neg-wash); }
.btn-success { background: var(--pos); color: #fff; box-shadow: 0 2px 8px rgba(26, 147, 111, 0.28); }
.btn-success:hover:not(:disabled) { background: #167a5c; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: var(--r-sm); }
.btn-lg { padding: 11px 20px; font-size: 15px; }
.btn-block { width: 100%; }

/* ---------- Inputs ---------- */
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-body); margin-bottom: 7px; }
.input, select.input, textarea.input {
  width: 100%;
  background: var(--surface);
  border: none;
  box-shadow: inset 0 0 0 1px var(--line-strong);
  border-radius: var(--r-md);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  transition: box-shadow var(--dur) var(--ease);
}
.input:focus, select.input:focus, textarea.input:focus { box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 3px var(--accent-ring); }
.input::placeholder { color: var(--ink-muted); }
.input:disabled { background: var(--surface-sunken); color: var(--ink-muted); }
.money { position: relative; }
.money .money-prefix { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-muted); font-size: 13px; font-weight: 600; pointer-events: none; }
.money .input { padding-left: 32px; }
.field-hint { font-size: 12px; color: var(--ink-muted); margin: -3px 0 0; line-height: 1.5; }

/* ---------- Badges / pills ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 9px 3px 8px; border-radius: var(--r-pill); line-height: 1.4; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.9; }
.badge-pos { background: var(--pos-wash); color: var(--pos); }
.badge-warn { background: var(--warn-wash); color: var(--warn); }
.badge-neg { background: var(--neg-wash); color: var(--neg); }
.badge-info { background: var(--info-wash); color: var(--info); }
.badge-accent { background: var(--accent-wash); color: var(--accent); }
.badge-admin { background: #f3edff; color: #7c3aed; }
.badge-neutral { background: var(--surface-sunken); color: var(--ink-secondary); box-shadow: inset 0 0 0 1px var(--line); }
.badge-plain::before { display: none; }

/* ---------- Toggle switch ---------- */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: #cfd6e0; border-radius: var(--r-pill); transition: background var(--dur) var(--ease); cursor: pointer; }
.switch .track::before { content: ""; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px; background: #fff; border-radius: 50%; box-shadow: var(--shadow-sm); transition: transform var(--dur) var(--ease); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::before { transform: translateX(16px); }

/* ---------- Table ---------- */
.table { width: 100%; border-collapse: collapse; }
.table thead th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-muted); padding: 11px 16px; background: var(--surface-sunken); white-space: nowrap; }
.table tbody td { padding: 14px 16px; font-size: 14px; color: var(--ink-body); border-top: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover td { background: var(--surface-hover); }
.table .t-primary { font-weight: 600; color: var(--ink); }
td.right, th.right { text-align: right; }
.cell-sub { font-size: 12.5px; color: var(--ink-muted); margin-top: 2px; }
.money-strong { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.actions-cell { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- Table card ---------- */
.table-card { overflow: hidden; }
.table-scroll { overflow-x: auto; }
.table-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 22px; }

/* ---------- Notice banner ---------- */
.notice { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 18px; border-radius: var(--r-lg); background: var(--warn-wash); box-shadow: inset 0 0 0 1px #f4dcc2; margin-bottom: 20px; }
.notice p { margin: 0; font-size: 13.5px; color: #7a4410; line-height: 1.45; }
.notice strong { color: #5c3208; }

/* ---------- Inline message (form feedback) ---------- */
.msg { display: none; border-radius: var(--r-md); padding: 10px 14px; font-size: 13px; margin-bottom: 14px; line-height: 1.45; }
.msg.error { background: var(--neg-wash); color: var(--neg); box-shadow: inset 0 0 0 1px #f3d3dc; }
.msg.success { background: var(--pos-wash); color: var(--pos); box-shadow: inset 0 0 0 1px #c7e8d8; }
.msg.info { background: var(--info-wash); color: var(--info); box-shadow: inset 0 0 0 1px #d3e0f7; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d6dbe4; border-radius: 999px; border: 3px solid var(--canvas); }
::-webkit-scrollbar-thumb:hover { background: #c2c9d4; }

/* ============================================================
   Shared app shell (nav, page, metrics, tabs)
   ============================================================ */

/* ---------- Top navigation ---------- */
.nav { position: sticky; top: 0; z-index: 50; background: rgba(255,255,255,0.85); backdrop-filter: saturate(180%) blur(12px); -webkit-backdrop-filter: saturate(180%) blur(12px); border-bottom: 1px solid var(--line); }
.nav-inner { max-width: 1200px; margin: 0 auto; height: 60px; display: flex; align-items: center; justify-content: space-between; padding: 0 28px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--brand-grad); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 15px; box-shadow: var(--shadow-accent); flex-shrink: 0; }
.brand-name { font-weight: 700; font-size: 16px; color: var(--ink); letter-spacing: -0.01em; }
.brand-badge { font-size: 11px; font-weight: 700; letter-spacing: 0.04em; color: var(--accent); background: var(--accent-wash); padding: 3px 9px; border-radius: var(--r-pill); margin-left: 2px; }
.brand-badge.admin { color: #7c3aed; background: #f3edff; }
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-link { font-size: 14px; font-weight: 500; color: var(--ink-secondary); text-decoration: none; padding: 7px 12px; border-radius: var(--r-md); cursor: pointer; }
.nav-link:hover { background: var(--surface-sunken); color: var(--ink); }
.nav-link.active { color: var(--accent); background: var(--accent-wash); font-weight: 600; }
.nav-right { display: flex; align-items: center; gap: 14px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #e6e9f5; color: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; text-transform: uppercase; text-decoration: none; }

/* ---------- Page ---------- */
.page { max-width: 1200px; margin: 0 auto; padding: 32px 28px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 26px; flex-wrap: wrap; }
.page-title { font-size: 26px; font-weight: 800; color: var(--ink); letter-spacing: -0.02em; margin: 0 0 4px; }
.page-sub { font-size: 14px; color: var(--ink-secondary); margin: 0; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.section-title { font-size: 16px; font-weight: 700; color: var(--ink); letter-spacing: -0.01em; }
.section-sub { font-size: 13px; color: var(--ink-secondary); margin-top: 3px; }

/* ---------- Metric cards ---------- */
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.metric { padding: 18px 20px; }
.metric-label { font-size: 12px; font-weight: 600; color: var(--ink-secondary); margin-bottom: 10px; display: flex; align-items: center; gap: 7px; }
.metric-dot { width: 8px; height: 8px; border-radius: 3px; flex-shrink: 0; }
.metric-value { font-size: 28px; font-weight: 800; color: var(--ink); letter-spacing: -0.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.metric-value .unit { font-size: 16px; font-weight: 600; color: var(--ink-muted); margin-left: 3px; }
.metric-foot { font-size: 12px; color: var(--ink-muted); margin-top: 8px; }
.metric-foot .up { color: var(--pos); font-weight: 600; }

/* ---------- Segmented tabs (top-level view switch) ---------- */
.tabs { display: inline-flex; background: var(--surface); border-radius: var(--r-md); padding: 4px; gap: 2px; box-shadow: inset 0 0 0 1px var(--line-strong), var(--shadow-xs); flex-wrap: wrap; }
.tabs button { border: none; background: transparent; font-family: var(--font-sans); font-size: 13.5px; font-weight: 600; color: var(--ink-secondary); padding: 7px 15px; border-radius: var(--r-sm); cursor: pointer; transition: all var(--dur) var(--ease); }
.tabs button:hover { color: var(--ink); }
.tabs button.on { background: var(--accent-wash); color: var(--accent); }
.tabs-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }

/* ---------- Panels within a tab ---------- */
.tab-pane[hidden] { display: none; }
.form-card { padding: 22px 24px; max-width: 560px; }
.form-grid { display: grid; gap: 16px; }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row > * { flex: 1; min-width: 160px; }

/* ---------- Auth (centered card screens) ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); padding: 36px 34px; }
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 26px; }
.auth-title { font-size: 22px; font-weight: 800; color: var(--ink); letter-spacing: -0.02em; margin: 0 0 6px; }
.auth-sub { font-size: 14px; color: var(--ink-secondary); margin: 0 0 26px; line-height: 1.5; }
.auth-field { margin-bottom: 16px; }
.auth-foot { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); text-align: center; font-size: 13px; color: var(--ink-secondary); line-height: 1.6; }
.auth-foot a { color: var(--accent); text-decoration: none; font-weight: 600; }
.auth-foot a:hover { text-decoration: underline; }
