/* 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 {
  --bg: #0a0e13;
  --surface: #10161d;
  --surface2: #151d26;
  --line: #1e2833;
  --line2: #2a3644;
  --ink: #e8eef4;
  --ink2: #aab8c5;
  --ink3: #6c7a89;
  --accent: #00e5a0;
  --accent-dark: #00c88b;
  --accent-ink: #04261b;
  --danger: #ff6b64;
  --warn: #ffc857;
  --radius: 16px;
  --radius-sm: 12px;
}
* { 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%, rgba(0, 229, 160, 0.09), transparent 70%),
    radial-gradient(520px 340px at -10% 30%, rgba(0, 180, 216, 0.07), 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, #00e5a0, #00b4d8); color: #04261b; font-weight: 900; }
.brand-tag { font-size: 10px; font-weight: 800; letter-spacing: 1px; color: var(--accent); border: 1px solid rgba(0, 229, 160, 0.35); 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: 0 24px 60px rgba(0, 0, 0, 0.4); }
.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 rgba(0, 229, 160, 0.14); }
.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 rgba(0, 229, 160, 0.25); }
.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 {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 18px; padding-top: max(12px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  background: rgba(10, 14, 19, 0.85); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  position: sticky; top: 0; z-index: 20;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }
.partner-name { color: var(--ink2); font-weight: 700; margin-right: 4px; font-size: 13.5px; }
.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, rgba(0, 229, 160, 0.09), rgba(0, 180, 216, 0.05));
  border: 1px solid rgba(0, 229, 160, 0.28); 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: rgba(0, 229, 160, 0.12); color: var(--accent); border-color: transparent; }
.badge.warn { background: rgba(255, 200, 87, 0.12); color: var(--warn); border-color: transparent; }
.badge.off { background: rgba(255, 107, 100, 0.12); 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; }
.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: rgba(4, 8, 12, 0.75); 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 rgba(0, 229, 160, 0.14); }
.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: 0 10px 30px rgba(0,0,0,0.4); }
.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; }
}
