/* Agent portal (login.html, dashboard.html). Same tokens as calculators.html. */

:root {
  --bg: #F3F4EE;
  --surface: #FFFFFF;
  --ink: #16231E;
  --ink-soft: #4A564E;
  --accent: #9C7A3C;
  --sage: #4E6B5B;
  --sage-bg: #EAEFE9;
  --line: #DCDFD3;
  --line-strong: #C7CBBB;
  --focus: #16231E;
  --good: #3D7A4E;
  --good-bg: #E7F1E9;
  --warn: #9C6B2E;
  --warn-bg: #F5EDE0;
  --bad: #A23B3B;
  --bad-bg: #F5E6E6;
  --shadow: 0 1px 2px rgba(22,35,30,0.06);
  --stat-blue: #3E6B8F;
  --stat-blue-bg: #E7EEF3;
  --stat-purple: #6C5B9C;
  --stat-purple-bg: #EFEBF5;
  --stat-gold: #A3792E;
  --stat-gold-bg: #F3E9D6;
  --stat-green: #3D7A4E;
  --stat-green-bg: #E7F1E9;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1713;
    --surface: #17211B;
    --ink: #ECEFE7;
    --ink-soft: #A9B3A6;
    --accent: #D2AF6E;
    --sage: #8FAF9C;
    --sage-bg: #1C2721;
    --line: #2A362E;
    --line-strong: #3A483E;
    --focus: #ECEFE7;
    --good: #7FBF8F;
    --good-bg: #16261B;
    --warn: #D6A55C;
    --warn-bg: #2A2015;
    --bad: #E08080;
    --bad-bg: #2A1717;
    --shadow: 0 1px 2px rgba(0,0,0,0.4);
    --stat-blue: #7FA9C9;
    --stat-blue-bg: #1B2A33;
    --stat-purple: #B7A6DD;
    --stat-purple-bg: #241E33;
    --stat-gold: #D2AF6E;
    --stat-gold-bg: #2C2417;
    --stat-green: #7FBF8F;
    --stat-green-bg: #16261B;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Roboto", -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--sage); }
[hidden] { display: none !important; }
.mono { font-family: "IBM Plex Mono", ui-monospace, monospace; }

/* ---------- Layout ---------- */
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.wrap.narrow { max-width: 440px; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar .wrap { display: flex; align-items: center; gap: 12px; min-height: 60px; }
.brand { display: flex; flex-direction: column; text-decoration: none; color: var(--ink); line-height: 1.2; }
.brand strong { font-family: "Fraunces", Georgia, serif; font-size: 17px; font-weight: 600; }
.brand span { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.topbar .spacer { flex: 1; }
.who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.who .who-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.brand strong { white-space: nowrap; }
@media (max-width: 560px) {
  .who, .brand span, .btn .lbl-long { display: none; }
  .topbar .wrap { gap: 8px; }
}

.page-title { font-family: "Fraunces", Georgia, serif; font-size: 26px; font-weight: 600; margin: 26px 0 4px; letter-spacing: -0.01em; }
.page-sub { color: var(--ink-soft); margin: 0 0 20px; }

/* ---------- Avatars ---------- */
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  object-fit: cover; flex: none;
  background: var(--sage-bg); color: var(--sage);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px;
  border: 1px solid var(--line);
}
.avatar.lg { width: 96px; height: 96px; font-size: 30px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: 9px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: 600 13px "Roboto", sans-serif; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}
.btn:hover { border-color: var(--sage); color: var(--sage); }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn.primary:hover { opacity: 0.88; color: var(--bg); }
.btn.danger:hover { border-color: var(--bad); color: var(--bad); }
.btn.small { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn.block { width: 100%; padding: 12px 16px; font-size: 14.5px; }
.btn[disabled] { opacity: 0.55; cursor: default; }
.btn svg { width: 15px; height: 15px; flex: none; }
.linkish { background: none; border: none; padding: 0; color: var(--sage); font: inherit; cursor: pointer; text-decoration: underline; }

/* ---------- Cards & forms ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card h2 { font-family: "Fraunces", Georgia, serif; font-size: 19px; font-weight: 600; margin: 0 0 4px; }
.card .card-sub { font-size: 13px; color: var(--ink-soft); margin: 0 0 16px; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.field-grid .full { grid-column: 1 / -1; }
@media (max-width: 520px) { .field-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft);
}
.field .hint { text-transform: none; letter-spacing: 0; font-family: "Roboto", sans-serif; font-size: 11px; }
input[type="text"], input[type="email"], input[type="tel"], input[type="password"], input[type="search"] {
  width: 100%; padding: 10px 12px; border-radius: 9px;
  border: 1px solid var(--line-strong); background: var(--bg); color: var(--ink);
  font: 14.5px "Roboto", sans-serif;
}
input:focus { outline: none; border-color: var(--sage); }
input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
input[readonly] { color: var(--ink-soft); }

.msg { border-radius: 10px; padding: 10px 12px; font-size: 13px; margin: 12px 0 0; }
.msg.error { background: var(--bad-bg); color: var(--bad); }
.msg.ok { background: var(--good-bg); color: var(--good); }
.fine { font-size: 12px; color: var(--ink-soft); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 18px; }
.tab {
  padding: 9px 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-soft); font: 600 13px "Roboto", sans-serif; cursor: pointer;
}
.tab:hover { color: var(--ink); border-color: var(--line-strong); }
.tab.active { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.tab:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { border-radius: 14px; padding: 14px 16px; border: 1px solid var(--line); background: var(--surface); }
.stat .stat-label {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft);
}
.stat .stat-value { font-family: "Fraunces", Georgia, serif; font-size: 28px; font-weight: 600; margin-top: 4px; color: var(--ink); }
.stat .stat-note { font-size: 12px; color: var(--ink-soft); }
.stat.blue { background: var(--stat-blue-bg); }
.stat.purple { background: var(--stat-purple-bg); }
.stat.gold { background: var(--stat-gold-bg); }
.stat.green { background: var(--stat-green-bg); }

/* ---------- Daily opens chart (single series: one hue, no legend) ---------- */
.chart { position: relative; padding-top: 30px; }
.chart-bars {
  display: flex; align-items: flex-end; gap: 2px;
  height: 140px; border-bottom: 1px solid var(--line-strong);
}
.chart-bar {
  flex: 1 1 0; min-width: 0; height: 100%;
  display: flex; align-items: flex-end; cursor: default;
}
.chart-bar span {
  display: block; width: 100%;
  background: var(--sage); border-radius: 4px 4px 0 0; min-height: 0;
}
.chart-bar:hover span, .chart-bar:focus span { background: var(--ink); }
.chart-bar:focus { outline: none; }
.chart-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-soft); margin-top: 6px; }
.chart-tip {
  position: absolute; pointer-events: none; transform: translate(-50%, -100%);
  background: var(--ink); color: var(--bg); font-size: 12px; padding: 6px 9px; border-radius: 7px; white-space: nowrap;
}
.chart-max { position: absolute; left: 0; top: 10px; font-size: 11px; color: var(--ink-soft); }
details.table-view { margin-top: 10px; font-size: 12.5px; }
details.table-view summary { cursor: pointer; color: var(--ink-soft); }
details.table-view table { border-collapse: collapse; margin-top: 6px; }
details.table-view td, details.table-view th { padding: 3px 14px 3px 0; text-align: left; }

/* ---------- Lists (links, agents, activity) ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input[type="search"] { flex: 1 1 220px; max-width: 360px; }
.toolbar .count { color: var(--ink-soft); font-size: 12.5px; }

.rows { display: flex; flex-direction: column; gap: 10px; }
.row {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; display: grid; gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}
@media (max-width: 680px) { .row { grid-template-columns: 1fr; } }
.row-main { min-width: 0; display: flex; gap: 12px; align-items: center; }
.row-text { min-width: 0; }
.row-title { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { color: var(--ink-soft); font-size: 12.5px; }
.row-meta span + span::before { content: " · "; }
.row-stats { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-soft); margin-top: 6px; }
.row-stats b { color: var(--ink); font-family: "IBM Plex Mono", ui-monospace, monospace; font-weight: 500; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 680px) { .row-actions { justify-content: flex-start; } }

.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: var(--sage-bg); color: var(--sage); vertical-align: middle;
}
.pill.off { background: var(--bad-bg); color: var(--bad); }

.empty { text-align: center; padding: 34px 20px; color: var(--ink-soft); }
.empty h3 { font-family: "Fraunces", Georgia, serif; color: var(--ink); font-size: 18px; margin: 0 0 6px; }

.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: flex; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 13px; }
.activity li:first-child { border-top: none; }
.activity .when { color: var(--ink-soft); white-space: nowrap; margin-left: auto; font-size: 12px; }
.activity .what { min-width: 0; }

.grid-2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Profile photo ---------- */
.photo-edit { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.photo-edit .btns { display: flex; gap: 8px; flex-wrap: wrap; }

/* Co-branding preview, mirrors the shared-link cards */
.presenter {
  background: var(--bg); border: 1px solid var(--line); border-radius: 11px;
  padding: 12px 14px; font-size: 13px; line-height: 1.55; display: flex; gap: 12px; align-items: flex-start;
}
.presenter .pr-role { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.presenter .pr-name { font-weight: 600; font-size: 14.5px; }
.presenter .pr-sub { color: var(--ink-soft); }
.presenter .avatar { width: 56px; height: 56px; font-size: 18px; }

/* ---------- Dialog ---------- */
dialog.modal {
  width: min(440px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 16px;
  padding: 22px 20px; background: var(--surface); color: var(--ink); box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
dialog.modal::backdrop { background: rgba(15,23,19,0.55); }
dialog.modal h2 { font-family: "Fraunces", Georgia, serif; font-size: 19px; margin: 0 0 8px; }
dialog.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2); z-index: 20; max-width: calc(100vw - 32px);
}

.loading { color: var(--ink-soft); padding: 40px 0; text-align: center; }
footer.portal-foot { text-align: center; color: var(--ink-soft); font-size: 11.5px; padding: 30px 16px 40px; }
