/* ============================================================
   app.css — components for the Foothill Admin Tools site
   ------------------------------------------------------------
   Reads tokens.css and nothing else. There is deliberately not a
   single raw hex value in this file: change the brand in
   tokens.css and every screen follows.

   Shape of the design: a calm near-white base with generous
   whitespace and soft rounded cards, and the brand gradient held
   back for a small number of places (logo mark, primary buttons,
   progress fills). The admin surface itself stays dense and flat,
   because it is a tool.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }

h1, h2, h3 { margin: 0; font-family: var(--font-display); color: var(--ink); line-height: var(--lh-tight); }
h1 { font-size: var(--fs-2xl); font-weight: var(--fw-bold); letter-spacing: -.01em; }
h2 { font-size: var(--fs-md); font-weight: var(--fw-semi); }

/* utilities */
.muted { color: var(--ink-3); }
.small { font-size: var(--fs-xs); }
.strong { font-weight: var(--fw-semi); }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }
.empty { text-align: center; color: var(--ink-3); padding: var(--sp-10) var(--sp-5); }
.notes { margin: 0; white-space: pre-wrap; line-height: var(--lh-relaxed); color: var(--ink-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }

/* ============================================================
   App bar
   ============================================================ */
.appbar {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-6);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}
.appbar .brand { display: flex; align-items: center; gap: var(--sp-3); cursor: pointer; }
.appbar .brand:hover { opacity: .9; }

/* the one place the full brand gradient appears in the chrome */
.brand-mark {
  width: 38px; height: 38px; flex: none;
  border-radius: var(--r-md);
  background: var(--grad-brand);
  padding: 2px;
  display: grid; place-items: center;
  box-shadow: var(--sh-1);
}
.brand-mark img {
  width: 100%; height: 100%; object-fit: contain;
  background: var(--surface);
  border-radius: calc(var(--r-md) - 3px);
}
.appbar .title { font-size: var(--fs-base); font-weight: var(--fw-semi); line-height: 1.15; color: var(--ink); }
.appbar .title small {
  display: block; font-size: var(--fs-xs); font-weight: var(--fw-medium);
  color: var(--ink-3); letter-spacing: var(--track-caps); text-transform: uppercase;
}

.topnav { display: flex; gap: var(--sp-1); margin-left: var(--sp-4); }
.topnav-btn {
  border: 0; background: transparent; color: var(--ink-2);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-pill);
  font-size: var(--fs-base); font-weight: var(--fw-medium);
}
.topnav-btn:hover { background: var(--surface-2); color: var(--ink); }
.topnav-btn.active { background: var(--brand-soft); color: var(--brand); font-weight: var(--fw-semi); }
body.dark .topnav-btn.active { color: var(--ink); }

.userchip { display: flex; align-items: center; gap: var(--sp-2); }
.userchip .avatar {
  width: 30px; height: 30px; border-radius: var(--r-pill);
  background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center;
  font-size: var(--fs-xs); font-weight: var(--fw-bold);
}
body.dark .userchip .avatar { color: var(--ink); }
.userchip .who { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--ink-2); }
.userchip button {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  padding: var(--sp-1) var(--sp-3); border-radius: var(--r-sm); font-size: var(--fs-xs);
}
.userchip button:hover { background: var(--surface-2); color: var(--ink); }

/* ============================================================
   Page + cards
   ============================================================ */
.page { max-width: var(--maxw); margin: 0 auto; padding: var(--sp-8) var(--sp-6) var(--sp-16); }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-6);
}
.page-head .sub { color: var(--ink-3); font-size: var(--fs-sm); margin-top: var(--sp-1); }
.head-tools { display: flex; gap: var(--sp-2); flex-wrap: wrap; justify-content: flex-end; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
  margin-bottom: var(--sp-5);
  overflow: hidden;
}
.card > .card-head {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.card > .card-head h2 { font-family: var(--font-body); font-size: var(--fs-base); font-weight: var(--fw-semi); }
.card > .card-body { padding: var(--sp-5); }

/* A 3px gradient rule at the top of a card. Decorative only — it
   never sits behind text, so the AA rule for status text holds. */
.card.accent-attention { border-top: 3px solid transparent; background-image: var(--grad-attention), linear-gradient(var(--surface), var(--surface)); background-origin: border-box; background-clip: border-box, padding-box; background-repeat: no-repeat; background-size: 100% 3px, 100% 100%; }
.card.accent-info      { border-top: 3px solid transparent; background-image: var(--grad-info),      linear-gradient(var(--surface), var(--surface)); background-origin: border-box; background-clip: border-box, padding-box; background-repeat: no-repeat; background-size: 100% 3px, 100% 100%; }
.card.accent-success   { border-top: 3px solid transparent; background-image: var(--grad-success),   linear-gradient(var(--surface), var(--surface)); background-origin: border-box; background-clip: border-box, padding-box; background-repeat: no-repeat; background-size: 100% 3px, 100% 100%; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-size: var(--fs-base); font-weight: var(--fw-semi);
  background: var(--surface-2); color: var(--ink);
  transition: filter .15s ease, background .15s ease;
  white-space: nowrap;
}
.btn:hover { filter: brightness(.97); }
.btn:disabled { opacity: .5; cursor: default; filter: none; }

/* the primary CTA — the truncated brand ramp, AA-safe with white */
.btn-primary { background: var(--grad-cta); color: var(--on-brand); box-shadow: var(--sh-1); }
.btn-primary:hover { background: var(--grad-cta-hi); filter: none; }

.btn-outline { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-outline:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-ghost.danger { color: var(--danger); }
.btn-ghost.danger:hover { background: var(--danger-bg); }
.btn-danger { background: var(--danger); color: var(--on-brand); }
.btn-dark { background: var(--ink); color: var(--surface); }

.btn-sm { padding: var(--sp-1) var(--sp-3); font-size: var(--fs-xs); border-radius: var(--r-sm); }
.btn-lg { padding: var(--sp-3) var(--sp-5); font-size: var(--fs-md); border-radius: var(--r-md); }
.btn-block { width: 100%; }

/* ============================================================
   Forms
   ============================================================ */
label.field { display: block; margin-bottom: var(--sp-4); }
label.field > span {
  display: block; margin-bottom: var(--sp-2);
  font-size: var(--fs-xs); font-weight: var(--fw-semi);
  color: var(--ink-2); letter-spacing: var(--track-caps); text-transform: uppercase;
}
label.field > span small { text-transform: none; letter-spacing: 0; font-weight: var(--fw-normal); }
input, select, textarea {
  width: 100%;
  padding: var(--sp-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--fs-base);
}
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: var(--focus);
}
textarea { resize: vertical; }
.row { display: flex; gap: var(--sp-4); flex-wrap: wrap; }
.row > * { flex: 1; min-width: 170px; }

.form-err {
  background: var(--danger-bg); color: var(--danger);
  border-radius: var(--r-md); padding: var(--sp-3);
  font-size: var(--fs-sm); font-weight: var(--fw-medium);
  margin-bottom: var(--sp-4);
}
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 68px; }
.pw-toggle {
  position: absolute; right: var(--sp-2); top: 50%; transform: translateY(-50%);
  border: 0; background: var(--surface-2); color: var(--ink-2);
  padding: var(--sp-1) var(--sp-2); border-radius: var(--r-sm);
  font-size: var(--fs-xs); font-weight: var(--fw-semi);
}
.pw-toggle:hover { background: var(--surface-3); color: var(--ink); }

.search-box {
  max-width: 320px; padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-pill); background: var(--surface);
}
.toolbar { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; margin-bottom: var(--sp-5); }

/* segmented control */
.seg { display: inline-flex; gap: var(--sp-1); padding: var(--sp-1); background: var(--surface-2); border-radius: var(--r-pill); }
.seg-btn {
  border: 0; background: transparent; color: var(--ink-2);
  padding: var(--sp-1) var(--sp-4); border-radius: var(--r-pill);
  font-size: var(--fs-sm); font-weight: var(--fw-medium);
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.active { background: var(--surface); color: var(--ink); font-weight: var(--fw-semi); box-shadow: var(--sh-1); }

/* ============================================================
   KPI tiles
   ============================================================ */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-6); }
.kpi {
  position: relative; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--sp-5); box-shadow: var(--sh-1);
}
.kpi-ico { position: absolute; right: var(--sp-4); top: var(--sp-4); font-size: var(--fs-lg); opacity: .35; }
.kpi-v { font-family: var(--font-display); font-size: var(--fs-3xl); font-weight: var(--fw-bold); line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi-k { margin-top: var(--sp-3); font-size: var(--fs-xs); font-weight: var(--fw-semi); color: var(--ink-3); text-transform: uppercase; letter-spacing: var(--track-caps); }
.kpi.kpi-bad  .kpi-v { color: var(--st-late-fg); }
.kpi.kpi-now  .kpi-v { color: var(--st-now-fg); }
.kpi.kpi-warn .kpi-v { color: var(--st-now-fg); }

/* ============================================================
   Banners
   ============================================================ */
.attn {
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  padding: var(--sp-4); border-radius: var(--r-lg);
  border: 1px solid var(--line); background: var(--surface);
  margin-bottom: var(--sp-4); font-size: var(--fs-base);
}
.attn .spacer { flex: 1; }
.attn-warn { background: var(--st-now-bg); border-color: transparent; color: var(--st-now-fg); }
.attn-bad  { background: var(--st-late-bg); border-color: transparent; color: var(--st-late-fg); font-weight: var(--fw-medium); }

/* ============================================================
   Tables
   ============================================================ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.grid { width: 100%; border-collapse: collapse; font-size: var(--fs-base); }
table.grid thead th {
  background: var(--surface-2); color: var(--ink-3);
  text-align: left; padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-xs); font-weight: var(--fw-semi);
  text-transform: uppercase; letter-spacing: var(--track-caps);
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.grid tbody td { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover td { background: var(--surface-2); }
table.grid .num { text-align: right; font-variant-numeric: tabular-nums; }

table.grid.steps tbody tr.st-overdue td { background: var(--st-late-bg); }
table.grid.steps tbody tr.st-today td { background: var(--st-now-bg); }
table.grid.steps tbody tr.st-done td { opacity: .68; }
table.grid.steps tbody tr:hover td { background: var(--surface-2); }
.db { display: block; font-size: var(--fs-xs); color: var(--ink-3); }

/* row action cell, pinned to the right of the portfolio table */
.row-act { text-align: right; white-space: nowrap; }

/* ============================================================
   Badges, chips, pills
   ============================================================ */
.sbadge {
  display: inline-block; padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: var(--fw-semi); white-space: nowrap;
}
.sb-ok   { background: var(--st-ok-bg);   color: var(--st-ok-fg); }
.sb-late { background: var(--st-late-bg); color: var(--st-late-fg); }
.sb-now  { background: var(--st-now-bg);  color: var(--st-now-fg); }
.sb-soon { background: var(--st-soon-bg); color: var(--st-soon-fg); }
.sb-none { background: var(--st-none-bg); color: var(--st-none-fg); }
.sb-warn { background: var(--st-now-bg);  color: var(--st-now-fg); }

.pill {
  display: inline-block; padding: var(--sp-1) var(--sp-3); border-radius: var(--r-pill);
  background: var(--brand-soft); color: var(--brand);
  font-size: var(--fs-xs); font-weight: var(--fw-semi);
}
body.dark .pill { color: var(--ink); }
.pill-late { background: var(--st-late-bg); color: var(--st-late-fg); }
.pill-now  { background: var(--st-now-bg);  color: var(--st-now-fg); }
.pill-soon { background: var(--st-soon-bg); color: var(--st-soon-fg); }

.chan {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: var(--sp-1) var(--sp-3); border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: var(--fw-semi); white-space: nowrap;
}
.chan i { font-style: normal; }
.chan-dialer { background: var(--ch-dialer-bg); color: var(--ch-dialer-fg); }
.chan-email  { background: var(--ch-email-bg);  color: var(--ch-email-fg); }
.chan-text   { background: var(--ch-text-bg);   color: var(--ch-text-fg); }
.chan-offer  { background: var(--ch-offer-bg);  color: var(--ch-offer-fg); }
.chan-other  { background: var(--ch-other-bg);  color: var(--ch-other-fg); }

.offer {
  display: inline-block; padding: var(--sp-1) var(--sp-2); border-radius: var(--r-sm);
  background: var(--ink); color: var(--surface);
  font-size: var(--fs-xs); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums;
}

/* ============================================================
   Today worklist
   ============================================================ */
.wl { list-style: none; margin: 0; padding: 0; }
.wl-row { display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-4) 0; border-bottom: 1px solid var(--line); }
.wl-row:first-child { padding-top: 0; }
.wl-row:last-child { border-bottom: 0; padding-bottom: 0; }
.wl-check {
  flex: none; width: 32px; height: 32px; border-radius: var(--r-pill);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-3);
  display: grid; place-items: center; font-size: var(--fs-base); font-weight: var(--fw-bold);
  transition: background .15s ease, color .15s ease;
}
/* the success gradient earns its place here: a completed action */
.wl-check:hover { background: var(--grad-success); color: var(--on-brand); border-color: transparent; }
.wl-check:disabled { opacity: .4; }
.wl-main { flex: 1; min-width: 0; }
.wl-top { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; font-size: var(--fs-base); }
.wl-top b { font-weight: var(--fw-semi); }
.wl-sub { margin-top: var(--sp-1); font-size: var(--fs-xs); color: var(--ink-3); }
.wl-due { flex: none; text-align: right; }
.wl-due b { display: block; font-size: var(--fs-sm); font-weight: var(--fw-semi); }
.wl-due small { display: block; font-size: var(--fs-xs); color: var(--ink-3); }

.who-list { list-style: none; margin: 0; padding: 0; }
.who-list li { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) 0; border-bottom: 1px solid var(--line); }
.who-list li:last-child { border-bottom: 0; }
.who-list .avatar { width: 32px; height: 32px; border-radius: var(--r-pill); display: grid; place-items: center; background: var(--surface-2); }
.who-list .meta b { display: block; font-size: var(--fs-base); font-weight: var(--fw-semi); }
.who-list .meta small { color: var(--ink-3); font-size: var(--fs-xs); }
.av-warn { background: var(--st-now-bg) !important; color: var(--st-now-fg) !important; }

/* ============================================================
   Progress — the brand gradient, no text on top
   ============================================================ */
.prog { display: flex; align-items: center; gap: var(--sp-3); min-width: 130px; }
.prog-bar { flex: 1; height: 6px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.prog-bar i { display: block; height: 100%; background: var(--grad-brand); border-radius: var(--r-pill); }
.prog span { font-size: var(--fs-xs); color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ============================================================
   Settings: portfolio flows and their groups
   ============================================================ */
.sec-note { margin: 0 0 var(--sp-5); line-height: var(--lh-relaxed); color: var(--ink-3); font-size: var(--fs-sm); }
.grp { margin-bottom: var(--sp-6); }
.grp:last-child { margin-bottom: 0; }
.grp-head {
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  padding-bottom: var(--sp-3); border-bottom: 1px solid var(--line); margin-bottom: var(--sp-2);
}
.grp-head .spacer { flex: 1; }
.grp-name { font-weight: var(--fw-semi); font-size: var(--fs-md); color: var(--ink); }
.grp-empty { font-size: var(--fs-sm); padding: var(--sp-4) 0; margin: 0; color: var(--ink-3); }

.cad-row { display: flex; align-items: flex-start; gap: var(--sp-5); flex-wrap: wrap; padding: var(--sp-4) 0; border-bottom: 1px solid var(--line); }
.cad-row:last-child { border-bottom: 0; }
.cad-row-main { flex: 1; min-width: 260px; }
.cad-row-top { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.cad-row-top b { font-size: var(--fs-md); font-weight: var(--fw-semi); }
.cad-row-actions { display: flex; align-items: flex-end; gap: var(--sp-3); flex-wrap: wrap; }
.cad-row-btns { display: flex; gap: var(--sp-2); }
.grp-move > span { display: block; margin-bottom: var(--sp-1); font-size: var(--fs-xs); font-weight: var(--fw-semi); color: var(--ink-3); text-transform: uppercase; letter-spacing: var(--track-caps); }
.grp-move select { width: auto; min-width: 160px; padding: var(--sp-2) var(--sp-3); font-size: var(--fs-sm); }

.cad-strip { display: flex; gap: var(--sp-1); flex-wrap: wrap; margin-top: var(--sp-3); }
.strip-item {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px var(--sp-2); border-radius: var(--r-sm);
  font-size: var(--fs-xs); cursor: default;
}
.strip-item i { font-style: normal; }
.strip-item em { font-style: normal; font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }

.cad-list { list-style: none; margin: 0; padding: 0; }
.cad-list li { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) 0; border-bottom: 1px solid var(--line); font-size: var(--fs-base); }
.cad-list li:last-child { border-bottom: 0; }
.cad-day { flex: none; width: 66px; font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.cad-label { flex: 1; min-width: 0; }
table.grid.cad-edit input, table.grid.cad-edit select { padding: var(--sp-2); font-size: var(--fs-sm); }
table.grid.cad-edit td { padding: var(--sp-2); }

/* ============================================================
   Modal
   ============================================================ */
.modal-back {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 18, 34, .45);
  backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: var(--sp-4);
}
.modal {
  width: 100%; max-width: 460px;
  background: var(--surface); border-radius: var(--r-xl);
  box-shadow: var(--sh-pop); overflow: hidden;
}
.modal-wide { max-width: 780px; }
.modal .modal-head {
  padding: var(--sp-5) var(--sp-5) var(--sp-3);
  font-family: var(--font-display); font-size: var(--fs-lg); font-weight: var(--fw-bold); color: var(--ink);
}
.modal .modal-body { padding: 0 var(--sp-5) var(--sp-2); max-height: 68vh; overflow-y: auto; }
.modal .modal-body p { margin-top: 0; color: var(--ink-2); line-height: var(--lh-relaxed); }
.modal .modal-foot {
  padding: var(--sp-4) var(--sp-5); display: flex; gap: var(--sp-2); justify-content: flex-end;
  border-top: 1px solid var(--line);
}

/* ============================================================
   Toast
   ============================================================ */
#toast {
  position: fixed; left: 50%; bottom: var(--sp-8); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--surface);
  padding: var(--sp-3) var(--sp-5); border-radius: var(--r-pill);
  font-size: var(--fs-base); font-weight: var(--fw-medium);
  box-shadow: var(--sh-3); opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease; z-index: 200;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--danger); color: var(--on-brand); }

/* ============================================================
   Login
   ============================================================ */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: var(--sp-6); background: var(--bg); }
.login-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl); box-shadow: var(--sh-3);
  padding: var(--sp-8);
}
.login-brand { text-align: center; margin-bottom: var(--sp-6); }
.login-brand .brand-mark { width: 56px; height: 56px; margin: 0 auto var(--sp-4); border-radius: var(--r-lg); }
.login-brand .brand-mark img { border-radius: calc(var(--r-lg) - 3px); }
.login-brand h1 { font-size: var(--fs-xl); margin-bottom: var(--sp-1); }
.login-brand p { margin: 0; font-size: var(--fs-sm); color: var(--ink-3); }
.login-foot { text-align: center; font-size: var(--fs-xs); color: var(--ink-3); margin: var(--sp-5) 0 0; }

/* ============================================================
   Date picker
   ============================================================ */
.dp { position: relative; }
.dp-wrap { display: flex; }
.dp-text {
  flex: 1; min-width: 0;
  border-radius: var(--r-md) 0 0 var(--r-md);
  border-right: 0;
}
.dp-cal {
  flex: none; padding: 0 var(--sp-3);
  border: 1px solid var(--line-strong); border-left: 0;
  border-radius: 0 var(--r-md) var(--r-md) 0;
  background: var(--surface-2); color: var(--ink-2); font-size: var(--fs-base);
}
.dp-cal:hover { background: var(--surface-3); }
.dp-wrap:focus-within .dp-text,
.dp-wrap:focus-within .dp-cal { border-color: var(--brand); }
.dp.dp-bad .dp-text, .dp.dp-bad .dp-cal { border-color: var(--danger); }
.dp-bad-msg { display: block; margin-top: var(--sp-1); font-size: var(--fs-xs); color: var(--danger); }
.dp-hint { display: block; margin-top: var(--sp-2); font-size: var(--fs-xs); }

/* − / + step nudge on the portfolio rows */
.nudge { display: inline-flex; vertical-align: middle; margin-right: var(--sp-1); }
.nudge-btn {
  width: 28px; height: 28px; padding: 0;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2);
  font-size: var(--fs-md); font-weight: var(--fw-bold); line-height: 1;
}
.nudge-btn:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.nudge-btn:last-child { border-radius: 0 var(--r-sm) var(--r-sm) 0; border-left: 0; }
.nudge-btn:hover:not(:disabled) { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); }
.nudge-btn:disabled { opacity: .35; cursor: default; }

/* Portalled to <body> while open and positioned from the trigger's rect,
   so a scrolling modal body can never clip it. */
.dp-pop {
  position: fixed; z-index: 300;
  width: 268px; padding: var(--sp-3);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-pop);
}
.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-2); }
.dp-title { font-weight: var(--fw-semi); font-size: var(--fs-base); }
.dp-nav {
  width: 28px; height: 28px; border: 1px solid var(--line); background: var(--surface);
  border-radius: var(--r-sm); color: var(--ink-2); font-size: var(--fs-md); line-height: 1;
}
.dp-nav:hover { background: var(--surface-2); color: var(--ink); }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-cell { height: 32px; display: grid; place-items: center; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.dp-dowc { font-size: var(--fs-xs); font-weight: var(--fw-semi); color: var(--ink-3); text-transform: uppercase; }
.dp-day { border: 0; background: transparent; color: var(--ink); font-variant-numeric: tabular-nums; }
.dp-day:hover { background: var(--surface-2); }
.dp-day.we { color: var(--ink-3); }
.dp-day.today { box-shadow: inset 0 0 0 1px var(--brand); font-weight: var(--fw-semi); }
.dp-day.sel { background: var(--grad-cta); color: var(--on-brand); font-weight: var(--fw-semi); }
.dp-day.sel:hover { background: var(--grad-cta-hi); }
.dp-pad { pointer-events: none; }
.dp-foot { display: flex; justify-content: space-between; margin-top: var(--sp-2); padding-top: var(--sp-2); border-top: 1px solid var(--line); }

/* ============================================================
   Phones
   ============================================================ */
@media (max-width: 720px) {
  .appbar { flex-wrap: wrap; padding: var(--sp-3) var(--sp-4); gap: var(--sp-3); }
  .topnav { order: 3; width: 100%; margin-left: 0; overflow-x: auto; }
  .appbar .spacer { display: none; }
  .userchip { margin-left: auto; }
  .userchip .who { display: none; }
}
@media (max-width: 640px) {
  .page { padding: var(--sp-5) var(--sp-4) var(--sp-12); }
  .page-head { align-items: flex-start; }
  .head-tools { justify-content: flex-start; }
  .head-tools .btn { flex: 1 1 auto; }

  h1 { font-size: var(--fs-xl); }
  .kpi-v { font-size: var(--fs-2xl); }

  .wl-row { flex-wrap: wrap; }
  .wl-due { width: 100%; text-align: left; padding-left: 48px; }
  .wl-due b, .wl-due small { display: inline; }
  .wl-due small { margin-left: var(--sp-2); }

  table.grid { min-width: 640px; }

  .grp-head .spacer { display: none; }
  .cad-row-actions { width: 100%; }
  .grp-move { flex: 1; min-width: 150px; }
  .grp-move select { width: 100%; min-width: 0; }

  /* iOS zooms any input under 16px on focus */
  input, select, textarea { font-size: var(--fs-md); }
  .dp-pop { width: 100%; min-width: 260px; }
}
