/* Beamline Partner Portal — mobile-first dark UI. Partners use this almost
   exclusively from a phone browser, so: card lists instead of wide tables,
   44px+ touch targets, 16px inputs (anything smaller makes iOS Safari zoom
   the page on focus), and safe-area padding for notched phones. */
:root {
  --radius: 16px;
  --radius-sm: 12px;
}

:root,
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0e13;
  --surface: #10161d;
  --surface2: #151d26;
  --line: #1e2833;
  --line2: #2a3644;
  --ink: #e8eef4;
  --ink2: #aab8c5;
  --ink3: #788696;
  --accent: #00e5a0;
  --accent-dark: #00c88b;
  --accent-ink: #04261b;
  --accent-2: #00b4d8;          /* the blue half of the brand gradient */
  --accent-line: rgba(0, 229, 160, 0.32);
  --accent-wash: rgba(0, 229, 160, 0.09);
  --accent-ring: rgba(0, 229, 160, 0.14);
  --accent-shadow: rgba(0, 229, 160, 0.25);
  --danger: #ff6b64;
  --danger-wash: rgba(255, 107, 100, 0.12);
  --warn: #ffc857;
  --warn-wash: rgba(255, 200, 87, 0.12);
  --chrome: rgba(10, 14, 19, 0.85);
  --scrim: rgba(4, 8, 12, 0.75);
  --shadow-card: 0 24px 60px rgba(0, 0, 0, 0.4);
  --shadow-toast: 0 10px 30px rgba(0, 0, 0, 0.4);
  --aura-1: rgba(0, 229, 160, 0.09);
  --aura-2: rgba(0, 180, 216, 0.07);
}

/* Same light palette as the marketing site and the app, so a partner who
   switches themes on beamlinesystems.com finds the portal already speaking
   the same language. The accent darkens for the same reason it does there:
   #00e5a0 on white is roughly 1.5:1 and cannot carry text. */
[data-theme="light"] {
  color-scheme: light;
  --bg: #FAFAF9;
  --surface: #FFFFFF;
  --surface2: #F2F3F2;
  --line: #E6E7E6;
  --line2: #D3D5D3;
  --ink: #111318;
  --ink2: #3D4149;
  --ink3: #6E727A;
  --accent: #00875F;
  --accent-dark: #00694A;
  --accent-ink: #FFFFFF;
  --accent-2: #0077A6;
  --accent-line: rgba(0, 135, 95, 0.30);
  --accent-wash: rgba(0, 135, 95, 0.07);
  --accent-ring: rgba(0, 135, 95, 0.16);
  --accent-shadow: rgba(0, 135, 95, 0.20);
  --danger: #C0392B;
  --danger-wash: rgba(192, 57, 43, 0.10);
  --warn: #9A6700;
  --warn-wash: rgba(154, 103, 0, 0.10);
  --chrome: rgba(250, 250, 249, 0.85);
  --scrim: rgba(17, 19, 24, 0.45);
  --shadow-card: 0 14px 34px rgba(17, 19, 24, 0.10);
  --shadow-toast: 0 10px 30px rgba(17, 19, 24, 0.12);
  --aura-1: rgba(0, 168, 118, 0.10);
  --aura-2: rgba(0, 143, 255, 0.07);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg: #FAFAF9; --surface: #FFFFFF; --surface2: #F2F3F2;
    --line: #E6E7E6; --line2: #D3D5D3;
    --ink: #111318; --ink2: #3D4149; --ink3: #6E727A;
    --accent: #00875F; --accent-dark: #00694A; --accent-ink: #FFFFFF; --accent-2: #0077A6;
    --accent-line: rgba(0,135,95,0.30); --accent-wash: rgba(0,135,95,0.07);
    --accent-ring: rgba(0,135,95,0.16); --accent-shadow: rgba(0,135,95,0.20);
    --danger: #C0392B; --danger-wash: rgba(192,57,43,0.10);
    --warn: #9A6700; --warn-wash: rgba(154,103,0,0.10);
    --chrome: rgba(250,250,249,0.85); --scrim: rgba(17,19,24,0.45);
    --shadow-card: 0 14px 34px rgba(17,19,24,0.10);
    --shadow-toast: 0 10px 30px rgba(17,19,24,0.12);
    --aura-1: rgba(0,168,118,0.10); --aura-2: rgba(0,143,255,0.07);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 15px;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
/* Soft brand glow behind everything — same feel as the marketing site. */
.bg-glow {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(600px 380px at 85% -5%, var(--aura-1), transparent 70%),
    radial-gradient(520px 340px at -10% 30%, var(--aura-2), transparent 70%);
}
.login-view, .app-view { position: relative; z-index: 1; }

.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 16px; letter-spacing: -0.2px; }
.brand-logo { width: 30px; height: 25px; object-fit: contain; }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink); font-weight: 900; }
.brand-tag { font-size: 10px; font-weight: 800; letter-spacing: 1px; color: var(--accent); border: 1px solid var(--accent-line); border-radius: 6px; padding: 2px 7px; }

/* ---------- Login ---------- */
.login-view { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 18px; }
.login-view[hidden] { display: none; }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 30px 26px; box-shadow: var(--shadow-card); }
.login-card h1 { font-size: 22px; margin: 20px 0 6px; letter-spacing: -0.3px; }
.login-card .sub { color: var(--ink3); margin: 0 0 22px; line-height: 1.55; font-size: 14px; }
.login-card label { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink3); margin-bottom: 14px; }
.login-card input { width: 100%; margin-top: 7px; padding: 14px; border-radius: var(--radius-sm); border: 1.5px solid var(--line2); background: var(--bg); color: var(--ink); font-size: 16px; }
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.login-card button[type="submit"] { width: 100%; padding: 15px; border: none; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 16px; font-weight: 800; cursor: pointer; margin-top: 4px; box-shadow: 0 8px 24px var(--accent-shadow); }
.login-card button[type="submit"]:hover { background: var(--accent-dark); }
.hint { color: var(--ink3); font-size: 12.5px; margin-top: 16px; text-align: center; }

/* ---------- App shell ---------- */
.app-view[hidden] { display: none; }
.topbar {
  padding: 10px 18px; padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  background: var(--chrome); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
/* Same 760px cap as .content, so the brand and the identity sit above the
   columns they belong to instead of drifting to opposite screen edges with
   dead space between them. */
.topbar-inner {
  max-width: 760px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }

/* Who's signed in, as one object rather than loose grey text — an initial
   chip anchors it, and the tier underneath is the number that decides what
   the partner earns, so it's worth showing on every screen. */
.who { display: flex; align-items: center; gap: 9px; min-width: 0; cursor: pointer; padding: 4px 6px; border-radius: 10px; }
.who:hover { background: var(--surface2); }
.who-avatar {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-ink); font-weight: 900; font-size: 14px;
}
.who-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.who-name { color: var(--ink); font-weight: 700; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.who-tier { color: var(--ink3); font-size: 10.5px; font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase; }

@media (max-width: 520px) {
  .who-text { display: none; }
  .brand-tag { display: none; }
}
.content { max-width: 760px; margin: 0 auto; padding: 24px 18px 72px; }
.content h2 { font-size: 17px; margin: 30px 0 4px; letter-spacing: -0.2px; }
.content h2:first-child { margin-top: 0; }
.view-sub { color: var(--ink3); font-size: 13px; margin: 0 0 14px; line-height: 1.55; }

/* ---------- Stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 10px; }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 15px; }
.stat-card .stat-label { font-size: 10.5px; color: var(--ink3); font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; line-height: 1.4; }
.stat-card .stat-value { font-size: 24px; font-weight: 800; margin-top: 6px; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.stat-card.stat-accent .stat-value { color: var(--accent); }

/* ---------- Hero estimate card ---------- */
.estimate-card {
  background: linear-gradient(135deg, var(--aura-1), var(--aura-2));
  border: 1px solid var(--accent-line); border-radius: var(--radius); padding: 18px; margin: 12px 0 6px;
}
.estimate-card .row { display: flex; flex-wrap: wrap; gap: 16px 26px; }
.estimate-card .cell span { display: block; font-size: 10.5px; color: var(--ink3); font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; margin-bottom: 5px; }
.estimate-card .cell b { font-size: 19px; font-variant-numeric: tabular-nums; }
.estimate-card .cell b.accent { color: var(--accent); font-size: 24px; }
.estimate-note { color: var(--ink3); font-size: 11.5px; margin: 12px 0 0; line-height: 1.5; }
.estimate-card input { border: 1px solid var(--line2); background: var(--bg); color: var(--ink); font-size: 16px; border-radius: var(--radius-sm); padding: 12px; width: 100%; }
.estimate-card input:focus { outline: none; border-color: var(--accent); }

/* ---------- Code cards (replaces the codes table) ---------- */
.code-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 10px; }
.code-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.code-card-head code { font-size: 17px; font-weight: 800; letter-spacing: 1.5px; background: var(--surface2); border: 1px solid var(--line2); border-radius: 9px; padding: 6px 12px; }
.code-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.code-stats div { background: var(--surface2); border-radius: var(--radius-sm); padding: 10px 8px; text-align: center; }
.code-stats span { display: block; font-size: 10px; color: var(--ink3); font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 3px; }
.code-stats b { font-size: 16px; font-variant-numeric: tabular-nums; }

/* ---------- Earnings list (replaces the earnings table) ---------- */
.pay-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.pay-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.pay-row:last-child { border-bottom: none; }
.pay-main { flex: 1; min-width: 0; }
.pay-month { font-weight: 800; font-size: 15px; }
.pay-sub { color: var(--ink3); font-size: 12px; margin-top: 2px; }
.pay-amount { font-weight: 800; font-size: 17px; font-variant-numeric: tabular-nums; text-align: right; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 4px 10px; border: 1px solid var(--line2); color: var(--ink2); white-space: nowrap; }
.badge.good { background: var(--accent-wash); color: var(--accent); border-color: transparent; }
.badge.warn { background: var(--warn-wash); color: var(--warn); border-color: transparent; }
.badge.off { background: var(--danger-wash); color: var(--danger); border-color: transparent; }

.btn { padding: 10px 16px; border-radius: 999px; border: 1px solid var(--line2); background: var(--surface2); color: var(--ink2); font-size: 13.5px; font-weight: 700; cursor: pointer; min-height: 40px; white-space: nowrap; }
/* Sign out shouldn't be the loudest thing on the page. */
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink3); padding: 8px 10px; min-height: 34px; font-size: 13px; }
.btn-ghost:hover { color: var(--ink); background: var(--surface2); border-color: var(--line2); }
.btn:hover { color: var(--ink); }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 800; }
.btn-primary:hover { background: var(--accent-dark); color: var(--accent-ink); }
.btn-block { display: block; width: 100%; }
.btn-small { padding: 7px 12px; font-size: 12.5px; min-height: 34px; }

.error-text { color: var(--danger); font-size: 13px; margin-top: 10px; }
.empty-note { color: var(--ink3); font-size: 13.5px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }

/* ---------- Modals ---------- */
.modal-overlay { position: fixed; inset: 0; background: var(--scrim); display: flex; align-items: flex-end; justify-content: center; padding: 0; z-index: 50; }
.modal-overlay[hidden] { display: none; }
.modal { position: relative; width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--line2); border-radius: 22px 22px 0 0; padding: 26px 22px calc(26px + env(safe-area-inset-bottom)); max-height: 88vh; overflow: auto; }
@media (min-width: 560px) {
  .modal-overlay { align-items: center; padding: 20px; }
  .modal { border-radius: 20px; padding: 26px 24px; }
}
.modal h2, .modal h3 { margin: 0 0 16px; font-size: 18px; }
.modal-close { position: absolute; top: 12px; right: 14px; background: var(--surface2); border: none; color: var(--ink3); font-size: 20px; cursor: pointer; width: 34px; height: 34px; border-radius: 999px; line-height: 1; }
.modal-close:hover { color: var(--ink); }
.modal label { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink3); margin-bottom: 14px; }
.modal input { width: 100%; margin-top: 7px; padding: 14px; border-radius: var(--radius-sm); border: 1.5px solid var(--line2); background: var(--bg); color: var(--ink); font-size: 16px; }
.modal input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.modal .btn { width: 100%; padding: 13px; }
.qr-wrap { text-align: center; margin: 14px 0; }
.qr-wrap img { width: min(240px, 70vw); height: auto; border-radius: 14px; background: #fff; padding: 10px; }

/* ---------- Toasts ---------- */
#toast-stack { position: fixed; bottom: calc(18px + env(safe-area-inset-bottom)); left: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; align-items: center; }
.toast { background: var(--surface2); border: 1px solid var(--line2); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); padding: 12px 16px; font-size: 13.5px; max-width: 440px; width: 100%; box-shadow: var(--shadow-toast); }
.toast.error { border-left-color: var(--danger); }

/* ---------- Phone-width tuning ---------- */
@media (max-width: 480px) {
  .partner-name { display: none; }           /* topbar: brand + two compact buttons */
  .brand-tag { display: none; }              /* brand mark + name is identity enough at this width */
  .topbar .btn { padding: 8px 12px; font-size: 12.5px; min-height: 36px; }
  .content { padding: 20px 14px 72px; }
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .stat-card { padding: 13px 10px; }
  .stat-card .stat-value { font-size: 19px; }
  .stat-card .stat-label { font-size: 9.5px; }
  .estimate-card .cell b { font-size: 17px; }
  .estimate-card .cell b.accent { font-size: 22px; }
}

/* Confirmation after requesting a reset link. It used to be a .hint —
   12.5px muted grey, sitting between two other identical grey hints — so
   the one line telling someone their link was on its way was the least
   visible thing on the card. Given a real box, accent-tinted, so tapping
   "Forgot your password?" visibly does something. */
.notice {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent-line);
  background: var(--accent-wash);
  color: var(--ink);
  font-size: 13.5px;
  line-height: 1.5;
  text-align: left;
}
.notice strong { color: var(--accent); font-weight: 800; }
.notice .notice-sub { display: block; margin-top: 5px; color: var(--ink3); font-size: 12.5px; }

/* No anchor styling existed, so "Forgot your password?" rendered as the
   browser default — blue and underlined on a near-black card, the only
   thing on the page not in the brand palette. */
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.hint a { font-weight: 700; }

/* Header and section nav travel together as one sticky unit — two
   independently-stuck elements would need the tab bar's offset to equal the
   header's exact height, a magic number that breaks the moment padding
   changes. */
.chrome { position: sticky; top: 0; z-index: 20; }

/* Section nav. Sits directly under the header and shares the same
   760px cap, so the underline of the active tab lines up with the column
   of content it governs. */
.tabs {
  border-bottom: 1px solid var(--line);
  background: var(--chrome);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.tabs-inner { max-width: 760px; margin: 0 auto; padding: 0 18px; display: flex; gap: 4px; }
.tab {
  appearance: none; background: none; border: none; cursor: pointer;
  padding: 13px 14px; font-size: 14px; font-weight: 700; color: var(--ink3);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink2); }
.tab-on { color: var(--ink); border-bottom-color: var(--accent); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; border-radius: 6px; }

/* Theme switch. Two of them — one in the header, one on the sign-in card,
   which has no header to hang it from. */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; flex: none;
  border-radius: 999px; border: 1px solid var(--line2);
  background: transparent; color: var(--ink3); cursor: pointer;
  transition: color .16s ease, border-color .16s ease, background .16s ease;
}
.theme-toggle:hover { color: var(--ink); background: var(--surface2); }
.theme-toggle svg { width: 17px; height: 17px; display: block; }
.theme-toggle-inline { margin: 0 auto; }
[data-theme="dark"] .icon-sun, :root:not([data-theme]) .icon-sun { display: block; }
[data-theme="dark"] .icon-moon, :root:not([data-theme]) .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .icon-sun { display: none; }
  :root:not([data-theme]) .icon-moon { display: block; }
}
