/* GB Realty marketing tasks. Mobile first. No framework, no build step. */

/* GB Realty CRM portal theme: navy topbar, white panels, Mulish, CRM blue. */
:root {
  color-scheme: light;

  --bg: #f2f5f9;
  --surface: #ffffff;
  --surface-2: #f4f7fa;
  --surface-3: #e9eef4;
  --border: #e2e8f0;
  --text: #33415c;
  --text-dim: #4a5a6b;
  --heading: #10294e;
  --navy: #122B50;
  --accent: #3995d0;
  --accent-soft: #e8f3fb;
  --danger: #ec344c;
  --danger-soft: #fdedf0;
  --danger-border: #f7c4cd;

  --open: #6c757d;
  --progress: #3995d0;
  --approval: #f59440;
  --blocked: #ec344c;
  --done: #11998e;
  --cancelled: #9aa1a9;

  --radius: 14px;
  --gap: 14px;
  --shadow: 0 2px 6px rgba(18, 43, 80, .06), 0 1px 3px rgba(18, 43, 80, .08);
  --shadow-lg: 0 12px 32px rgba(18, 43, 80, .22);
  --header-h: 56px;
}

* { box-sizing: border-box; }

/* A display rule on a class beats the UA rule for [hidden], so say it here
   once rather than remembering to hide things a second way. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 "Mulish", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

h1, h2, h3 { margin: 0 0 .4em; line-height: 1.25; font-weight: 700; }
h1, h2 { color: var(--heading); }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.02rem; }
h3 { font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); }
a { color: var(--accent); }

/* ------------------------------------------------------------------ forms */

label { display: block; font-size: .78rem; font-weight: 600; margin: 12px 0 5px; color: var(--text-dim); }

input[type=email], input[type=password], input[type=text], input[type=date],
input[type=number], input[type=search], select, textarea {
  width: 100%;
  padding: 10px 11px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 42px;
}
textarea { min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
input:disabled, select:disabled, textarea:disabled {
  background: var(--surface-2);
  color: var(--text-dim);
  cursor: not-allowed;
}

button {
  font: inherit;
  font-weight: 600;
  padding: 9px 14px;
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}
button:hover:not(:disabled) { filter: brightness(1.07); }
button.secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
button.ghost { background: transparent; color: var(--text-dim); border-color: transparent; padding: 6px 8px; min-height: 34px; }
button.ghost:hover { background: var(--surface-2); color: var(--text); }
button.danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
button:disabled { opacity: .5; cursor: default; }
button.small { min-height: 34px; padding: 5px 10px; font-size: .82rem; }
.full { width: 100%; }

.field-error { color: var(--danger); font-size: .8rem; margin-top: 5px; }

/* ------------------------------------------------------------------ login */

.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  width: 100%;
  max-width: 380px;
}

.brand { font-weight: 700; letter-spacing: .02em; }
.brand span { color: var(--accent); }
.sub { color: var(--text-dim); font-size: .85rem; margin-bottom: 16px; }

.msg {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: .86rem;
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}
.msg:empty { display: none; }

/* ----------------------------------------------------------------- header */

header.top {
  position: sticky; top: 0; z-index: 30;
  height: var(--header-h);
  background: var(--navy);
  border-bottom: none;
  box-shadow: 0 2px 10px rgba(18, 43, 80, .25);
  padding: 0 12px;
  display: flex; align-items: center; gap: 10px;
}
header.top .brand { color: #fff; }
header.top .brand span { color: #6db9ec; }
header.top .who { margin-left: auto; font-size: .78rem; color: rgba(255, 255, 255, .65); text-align: right; line-height: 1.25; }
header.top .who b { display: block; color: #fff; font-weight: 600; font-size: .84rem; }
header.top .bell { color: #fff; }
header.top .bell:hover { background: rgba(255, 255, 255, .12); }
header.top .bell.has { border-color: rgba(255, 255, 255, .3); }
header.top button.ghost { color: rgba(255, 255, 255, .8); }
header.top button.ghost:hover { background: rgba(255, 255, 255, .12); color: #fff; }

.tabs { display: flex; gap: 2px; background: rgba(255, 255, 255, .08); padding: 3px; border-radius: 9px; }
.tabs button {
  background: transparent; color: rgba(255, 255, 255, .72); border: none;
  min-height: 32px; padding: 4px 12px; font-size: .86rem; font-weight: 600; border-radius: 7px;
}
.tabs button[aria-selected=true] { background: #fff; color: var(--navy); box-shadow: var(--shadow); }

/* ---------------------------------------------------------------- filters */

.filters {
  position: sticky; top: var(--header-h); z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  display: flex; gap: 8px; align-items: center;
  overflow-x: auto;
  scrollbar-width: thin;
}
.filters > * { flex: 0 0 auto; }
.filters select, .filters input[type=search] {
  min-height: 36px; padding: 5px 9px; font-size: .86rem; width: auto; min-width: 116px;
  background: var(--surface);
}
.filters input[type=search] { min-width: 180px; }

.toggle {
  min-height: 36px; padding: 5px 11px; font-size: .84rem;
  background: var(--surface); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 20px;
}
.toggle[aria-pressed=true] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.spacer { flex: 1 1 auto !important; min-width: 4px; }

.count-note { font-size: .8rem; color: var(--text-dim); padding: 0 2px; }

/* ------------------------------------------------------------------ board */

.board {
  display: flex;
  gap: 10px;
  padding: 12px;
  align-items: flex-start;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  min-height: calc(100dvh - var(--header-h) - 58px);
}

.col {
  flex: 0 0 84vw;
  max-width: 320px;
  scroll-snap-align: start;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  display: flex; flex-direction: column; gap: 8px;
}
.col.drop { outline: 2px dashed var(--accent); outline-offset: -3px; background: var(--accent-soft); }
.col > header { display: flex; align-items: center; gap: 7px; padding: 2px 4px; }
.col > header .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--open); flex: 0 0 auto; }
.col > header .name { font-weight: 600; font-size: .88rem; }
.col > header .n { margin-left: auto; font-size: .76rem; color: var(--text-dim); background: var(--surface-3); border-radius: 20px; padding: 1px 8px; }
.col-open .dot { background: var(--open); }
.col-in_progress .dot { background: var(--progress); }
.col-awaiting_approval .dot { background: var(--approval); }
.col-blocked .dot { background: var(--blocked); }
.col-done .dot { background: var(--done); }
.col-cancelled .dot { background: var(--cancelled); }

.col .stack { display: flex; flex-direction: column; gap: 8px; min-height: 24px; }

/* ------------------------------------------------------------------- card */

.task {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--open);
  border-radius: 9px;
  box-shadow: var(--shadow);
  padding: 10px 11px;
  cursor: pointer;
}
.task:hover { border-color: var(--accent); }
.task.dragging { opacity: .45; }
.task.s-in_progress { border-left-color: var(--progress); }
.task.s-awaiting_approval { border-left-color: var(--approval); }
.task.s-blocked { border-left-color: var(--blocked); }
.task.s-done { border-left-color: var(--done); }
.task.s-cancelled { border-left-color: var(--cancelled); }
.task.overdue { border-left-color: var(--danger); }
.task.s-done .title, .task.s-cancelled .title { color: var(--text-dim); }

.task .title { font-weight: 600; font-size: .93rem; padding-right: 26px; }
.task .meta { margin-top: 7px; display: flex; flex-wrap: wrap; gap: 5px 8px; font-size: .78rem; color: var(--text-dim); align-items: center; }
.task .blocked-note {
  margin-top: 7px; font-size: .78rem; color: var(--danger);
  background: var(--danger-soft); border: 1px solid var(--danger-border);
  border-radius: 6px; padding: 4px 7px;
}
.task .move {
  position: absolute; top: 6px; right: 6px;
  min-height: 26px; padding: 0 7px; line-height: 1;
  background: transparent; border: none; color: var(--text-dim); font-size: 1.1rem; font-weight: 700;
}
.task .move:hover { background: var(--surface-2); color: var(--text); }

.chip {
  font-size: .73rem;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 20px;
  padding: 1px 8px;
  white-space: nowrap;
}
.chip.urgent, .chip.high { border-color: var(--danger-border); color: var(--danger); background: var(--danger-soft); }
.chip.money { font-variant-numeric: tabular-nums; }
.chip.flagged { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.chip.rera { border-color: var(--approval); color: var(--approval); }
.due.late { color: var(--danger); font-weight: 600; }
.revised { text-decoration: line-through; opacity: .55; margin-right: 3px; }

.empty { color: var(--text-dim); padding: 26px 12px; text-align: center; font-size: .88rem; }

/* ------------------------------------------------------------------ table */

.table-wrap { padding: 12px; overflow-x: auto; }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 940px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table.grid th, table.grid td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--border); font-size: .86rem; vertical-align: middle; }
table.grid tr:first-child th:first-child { border-top-left-radius: var(--radius); }
table.grid tr:first-child th:last-child { border-top-right-radius: var(--radius); }
table.grid thead th {
  background: var(--surface-2); font-size: .76rem; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-dim); white-space: nowrap; cursor: pointer; user-select: none;
}
table.grid thead th.plain { cursor: default; }
table.grid thead th .arrow { opacity: .45; margin-left: 3px; }
table.grid tbody tr:hover { background: var(--surface-2); }
table.grid tbody tr.sel { background: var(--accent-soft); }
table.grid tbody tr:last-child td { border-bottom: none; }
table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.grid td.editable { cursor: text; }
table.grid td.editable:hover { box-shadow: inset 0 0 0 1px var(--border); border-radius: 4px; }
table.grid td .cell-input { width: 100%; min-height: 30px; padding: 3px 5px; font-size: .86rem; }
table.grid td.readonly-cell { color: var(--text-dim); }
.tick { width: 34px; }
.tick input { width: 17px; height: 17px; min-height: 0; accent-color: var(--accent); }

.bulkbar {
  position: sticky; bottom: 0; z-index: 25;
  margin: 0 12px 12px;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 10px 12px;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.bulkbar .n { font-weight: 600; font-size: .88rem; }
.bulkbar select { width: auto; min-width: 130px; min-height: 36px; padding: 5px 9px; font-size: .85rem; }

/* ----------------------------------------------------------------- drawer */

.scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(12, 16, 20, .5);
  backdrop-filter: blur(1px);
}
.drawer {
  position: fixed; z-index: 41;
  inset: auto 0 0 0;
  height: 92dvh;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 14px 14px 0 0;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
}
.drawer > header {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: 10px; flex: 0 0 auto;
}
.drawer > header .grow { flex: 1 1 auto; min-width: 0; }
.drawer > header h2 { margin: 0; font-size: 1rem; word-break: break-word; }
.drawer > header .sub { margin: 2px 0 0; font-size: .78rem; }
.drawer .body { flex: 1 1 auto; overflow-y: auto; padding: 12px 14px 26px; -webkit-overflow-scrolling: touch; }
.drawer .foot {
  flex: 0 0 auto; padding: 10px 14px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; align-items: center; background: var(--surface);
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}

.grid2 { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
.section { border-top: 1px solid var(--border); margin-top: 18px; padding-top: 14px; }
.section:first-of-type { border-top: none; margin-top: 4px; padding-top: 0; }

.readonly-banner {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: .82rem; color: var(--text-dim); margin-bottom: 12px;
}

.history { display: flex; flex-direction: column; gap: 7px; }
.entry { font-size: .82rem; display: flex; gap: 8px; align-items: baseline; }
.entry .when { color: var(--text-dim); font-variant-numeric: tabular-nums; flex: 0 0 auto; font-size: .76rem; }
.entry .what { color: var(--text); }
.entry .what b { font-weight: 600; }
.entry .old { color: var(--text-dim); text-decoration: line-through; }

.comment { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; font-size: .86rem; }
.comment .byline { font-size: .74rem; color: var(--text-dim); margin-bottom: 2px; }

.revision {
  font-size: .82rem; background: var(--surface-2); border-left: 3px solid var(--approval);
  border-radius: 0 6px 6px 0; padding: 7px 9px;
}

/* ------------------------------------------------------------------ toast */

.toasts {
  position: fixed; z-index: 60; left: 12px; right: 12px; bottom: 12px;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  max-width: 560px; width: 100%;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 9px; box-shadow: var(--shadow-lg);
  padding: 10px 12px; font-size: .86rem;
}
.toast.bad { border-left-color: var(--danger); }
.toast b { display: block; margin-bottom: 2px; }

/* ------------------------------------------------------------------ menu */

.menu {
  position: fixed; z-index: 50;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 9px; box-shadow: var(--shadow-lg); padding: 5px;
  min-width: 190px;
}
.menu button {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: transparent; color: var(--text); border: none;
  min-height: 38px; padding: 6px 9px; font-weight: 500; font-size: .87rem; border-radius: 6px;
}
.menu button:hover { background: var(--surface-2); }
.menu button[disabled] { opacity: .4; }
.menu .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }

/* ---------------------------------------------------------------- desktop */

@media (min-width: 760px) {
  :root { --gap: 16px; }
  .col { flex: 1 1 0; min-width: 250px; max-width: none; }
  .board { min-height: calc(100dvh - var(--header-h) - 58px); }
  .grid2 { grid-template-columns: 1fr 1fr; }
  .drawer {
    inset: 0 0 0 auto;
    width: 470px; height: 100dvh;
    border-radius: 0; border-top: none; border-left: 1px solid var(--border);
  }
  .toasts { left: auto; right: 18px; bottom: 18px; align-items: flex-end; }
}

@media (max-width: 759px) {
  header.top .who { display: none; }
  .drawer .foot { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: no-preference) {
  .drawer { animation: rise .16s ease-out; }
  @keyframes rise { from { transform: translateY(14px); opacity: .4; } }
}

/* -------------------------------------------------------------- campaigns */

.camps { padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.camps-bar { display: flex; gap: 8px; }

.camp {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--open);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}
.camp-active { border-left-color: var(--progress); }
.camp-planned { border-left-color: var(--open); }
.camp-closed { border-left-color: var(--done); }
.camp-cancelled { border-left-color: var(--cancelled); }

.camp > header { display: flex; align-items: flex-start; gap: 10px; }
.camp > header .grow { flex: 1 1 auto; min-width: 0; }
.camp > header h2 { margin: 0; font-size: 1.02rem; }
.camp > header .sub { margin: 2px 0 0; font-size: .8rem; color: var(--text-dim); }
.camp .objective { margin: 8px 0 0; font-size: .86rem; color: var(--text-dim); }

.chip.st-active { border-color: var(--progress); color: var(--progress); }
.chip.st-closed { border-color: var(--done); color: var(--done); }
.chip.st-cancelled { color: var(--cancelled); }

/* budget against spend */
.budget { margin-top: 12px; }
.budget-line { font-size: .86rem; }
.budget-spent { font-weight: 600; font-variant-numeric: tabular-nums; }
.budget-of { color: var(--text-dim); }
.bar {
  position: relative; height: 9px; margin: 6px 0 5px;
  background: var(--surface-3); border-radius: 20px; overflow: hidden;
}
.bar-fill { position: absolute; inset: 0 auto 0 0; border-radius: 20px; }
.bar-fill.est { background: var(--accent); opacity: .35; }
.bar-fill.paid { background: var(--accent); }
.bar-fill.over { background: var(--danger); opacity: 1; }
.bar-fill.est.over { opacity: .4; }
.budget-foot {
  display: flex; gap: 12px; font-size: .78rem; color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.budget-foot .over { color: var(--danger); font-weight: 600; }

.stats { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 12px; }
.stat { display: flex; flex-direction: column; }
.stat b { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); }
.stat.warn b { color: var(--danger); }

.camp-tasks { margin-top: 12px; border-top: 1px solid var(--border); }
.camp-task {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: transparent; color: var(--text); border: none;
  border-bottom: 1px solid var(--border); border-left: 3px solid var(--open);
  border-radius: 0; padding: 9px 8px; min-height: 42px; font-weight: 500; font-size: .87rem;
}
.camp-task:last-child { border-bottom: none; }
.camp-task:hover { background: var(--surface-2); }
.camp-task.s-in_progress { border-left-color: var(--progress); }
.camp-task.s-awaiting_approval { border-left-color: var(--approval); }
.camp-task.s-blocked { border-left-color: var(--blocked); }
.camp-task.s-done { border-left-color: var(--done); }
.camp-task.overdue { border-left-color: var(--danger); }
.ct-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct-meta {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
  font-size: .78rem; color: var(--text-dim); font-weight: 400;
}

@media (max-width: 620px) {
  .camp-task { flex-wrap: wrap; align-items: flex-start; }
  .ct-title { white-space: normal; flex: 1 1 100%; }
  .ct-meta { flex-wrap: wrap; }
}

/* --------------------------------------------------------------- calendar */

.cal-wrap { padding: 12px; }

.cal-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.cal-month { margin: 0; font-size: 1.02rem; min-width: 150px; }

.cal {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.cal-head {
  background: var(--surface-2); padding: 6px 8px;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-dim); font-weight: 600; text-align: center;
}
.cal-day {
  background: var(--surface);
  min-height: 104px;
  padding: 5px 5px 7px;
  display: flex; flex-direction: column; gap: 3px;
  cursor: pointer;
}
.cal-day:hover { background: var(--surface-2); }
.cal-day.outside { background: var(--bg); }
.cal-day.outside .cal-num { opacity: .4; }
.cal-day.today .cal-num > span:first-child {
  background: var(--accent); color: #fff; border-radius: 50%;
  width: 22px; height: 22px; display: inline-grid; place-items: center;
}
.cal-day.picked { outline: 2px solid var(--accent); outline-offset: -2px; }

.cal-num {
  display: flex; align-items: center; justify-content: space-between;
  font-size: .8rem; font-weight: 600; min-height: 22px;
}
.cal-count {
  font-size: .68rem; font-weight: 600; color: var(--text-dim);
  background: var(--surface-3); border-radius: 20px; padding: 0 6px;
}

.cal-pill {
  display: flex; align-items: center; gap: 3px;
  width: 100%; text-align: left;
  background: var(--surface-2); color: var(--text);
  border: none; border-left: 3px solid var(--open);
  border-radius: 4px; padding: 2px 5px; min-height: 22px;
  font-size: .74rem; font-weight: 500; line-height: 1.3;
}
.cal-pill:hover { background: var(--surface-3); }
.cal-pill.s-in_progress { border-left-color: var(--progress); }
.cal-pill.s-awaiting_approval { border-left-color: var(--approval); }
.cal-pill.s-blocked { border-left-color: var(--blocked); }
.cal-pill.s-done { border-left-color: var(--done); opacity: .6; }
.cal-pill.s-cancelled { border-left-color: var(--cancelled); opacity: .5; }
.cal-pill.overdue { border-left-color: var(--danger); color: var(--danger); }
.cal-pill .moved { flex: 0 0 auto; color: var(--approval); font-size: .8rem; }
.cal-pill-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cal-more { font-size: .7rem; color: var(--text-dim); padding-left: 5px; }

.cal-undated {
  margin-top: 10px; font-size: .82rem; color: var(--text-dim);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px;
}
.cal-undated b { color: var(--text); }

.cal-panel {
  margin-top: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.cal-panel > header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.cal-panel > header h2 { margin: 0; font-size: .95rem; }

/* On a phone a 7-column month grid is unreadable at full height, so the
   cells shrink to a dot-count and the day panel does the real work. */
@media (max-width: 700px) {
  .cal-day { min-height: 62px; padding: 3px; }
  .cal-pill-text, .cal-more { display: none; }
  .cal-pill { min-height: 6px; height: 6px; padding: 0; border-left-width: 0; border-radius: 20px; background: var(--open); }
  .cal-pill.s-in_progress { background: var(--progress); }
  .cal-pill.s-awaiting_approval { background: var(--approval); }
  .cal-pill.s-blocked { background: var(--blocked); }
  .cal-pill.s-done { background: var(--done); }
  .cal-pill.overdue { background: var(--danger); }
  .cal-pill .moved { display: none; }
  .cal-head { font-size: .62rem; padding: 5px 2px; }
  .cal-num { font-size: .74rem; }
}

/* -------------------------------------------------------------- dashboard */

.dash { padding: 12px; display: flex; flex-direction: column; gap: 14px; }

/* The board, when it lives on the dashboard between the figures and panels. */
.board-embed-title { margin: 8px 2px 8px; font-size: 1rem; }
.dash .board { padding: 0; min-height: 0; }

/* CRM-portal stat cards: 20px radius, 135deg gradients, white text, big emoji. */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 14px; }
.tile {
  position: relative; overflow: hidden;
  background: var(--navy); border: none;
  border-radius: 20px; box-shadow: 0 10px 24px rgba(18, 43, 80, .18);
  padding: 16px 18px; min-height: 104px;
  display: flex; flex-direction: column; gap: 1px; justify-content: center;
  color: #fff;
}
.tile b { font-size: 1.9rem; line-height: 1.1; font-variant-numeric: tabular-nums; color: #fff; }
.tile span { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: rgba(255, 255, 255, .85); }
.tile small { font-size: .7rem; color: rgba(255, 255, 255, .75); margin-top: 3px; max-width: calc(100% - 46px); }
.tile.warn b { color: #fff; }
.tile .tile-emoji {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  font-size: 40px; line-height: 1; opacity: .9; pointer-events: none;
}
.tile.g-red    { background: linear-gradient(135deg, #ff416c, #ff4b2b); }
.tile.g-purple { background: linear-gradient(135deg, #667eea, #764ba2); }
.tile.g-amber  { background: linear-gradient(135deg, #f7971e, #ffd200); }
.tile.g-blue   { background: linear-gradient(135deg, #396afc, #2948ff); }
.tile.g-green  { background: linear-gradient(135deg, #11998e, #38ef7d); }

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.panel > h3 {
  margin: 0; padding: 12px 16px; border-bottom: 1px solid var(--border); background: #fff;
  color: var(--heading); text-transform: none; letter-spacing: 0; font-size: .95rem; font-weight: 800;
}
.panel-body { padding: 4px 0; }
.panel-ok { padding: 14px; font-size: .86rem; color: var(--text-dim); }
.note { font-size: .76rem; color: var(--text-dim); margin: 4px 14px 12px; }

.dash-row {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: transparent; color: var(--text); border: none;
  border-bottom: 1px solid var(--border); border-radius: 0;
  padding: 9px 14px; min-height: 46px; font-weight: 500; font-size: .87rem;
}
.dash-row:last-child { border-bottom: none; }
.dash-row:hover { background: var(--surface-2); }
.dash-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.dash-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-sub { font-size: .76rem; color: var(--text-dim); font-weight: 400; }
.dash-badge {
  flex: 0 0 auto; font-size: .76rem; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 20px; padding: 1px 9px; font-variant-numeric: tabular-nums;
}
.dash-badge.over { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }

.load-row { display: flex; align-items: center; gap: 10px; padding: 7px 14px; }
.load-name { flex: 0 0 100px; font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.load-row .bar { flex: 1 1 auto; margin: 0; }
.load-n { flex: 0 0 auto; font-size: .78rem; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.load-n b { color: var(--text); }
.load-n .over, .spend-foot .over, .gap-head b.over { color: var(--danger); font-weight: 600; }

.spend-row { padding: 9px 14px; border-bottom: 1px solid var(--border); }
.spend-row:last-of-type { border-bottom: none; }
.spend-head { display: flex; justify-content: space-between; gap: 10px; font-size: .86rem; }
.spend-label { font-weight: 600; }
.spend-figs { color: var(--text-dim); font-variant-numeric: tabular-nums; text-align: right; }
.spend-foot { display: flex; gap: 12px; font-size: .76rem; color: var(--text-dim); font-variant-numeric: tabular-nums; }

.gap { border-bottom: 1px solid var(--border); }
.gap:last-child { border-bottom: none; }
.gap-head { display: flex; align-items: baseline; gap: 8px; padding: 9px 14px 3px; font-size: .84rem; }
.gap-head b { font-variant-numeric: tabular-nums; }
.gap-head span { color: var(--text-dim); }
.gap .dash-row { padding-left: 26px; min-height: 38px; }

@media (max-width: 620px) {
  .load-name { flex: 0 0 76px; font-size: .8rem; }
  .spend-head { flex-direction: column; gap: 1px; }
  .spend-figs { text-align: left; }
}

/* --------------------------------------------------------------- settings */

.admin-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; border-bottom: 1px solid var(--border);
}
.admin-row:last-child { border-bottom: none; }
.admin-row.off { opacity: .55; }
.admin-main { flex: 1 1 auto; min-width: 0; }
.admin-name { font-weight: 600; font-size: .88rem; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.admin-sub { font-size: .76rem; color: var(--text-dim); }
.admin-row select { width: auto; min-width: 140px; min-height: 34px; padding: 4px 8px; font-size: .82rem; }
.admin-actions { display: flex; gap: 4px; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; }

.admin-form {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  padding: 9px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.admin-form input { flex: 1 1 160px; min-height: 36px; padding: 5px 9px; font-size: .86rem; }

.admin-pass { padding: 4px 14px 14px; max-width: 380px; }

@media (max-width: 700px) {
  .admin-row { flex-wrap: wrap; }
  .admin-main { flex: 1 1 100%; }
  .admin-row select { flex: 1 1 auto; }
  .admin-actions { flex: 1 1 100%; justify-content: flex-start; }
}

/* First sign-in: nothing but the password form. */
.dash.forced { max-width: 460px; margin: 0 auto; padding-top: 32px; }

/* ------------------------------------------------------------------- bell */

.bell {
  position: relative;
  background: transparent; border: 1px solid transparent; color: var(--text);
  min-height: 36px; padding: 2px 8px; font-size: 1.05rem; line-height: 1;
}
.bell:hover { background: var(--surface-2); }
.bell.has { border-color: var(--border); }
.bell-n {
  font-size: .68rem; font-weight: 700; line-height: 1;
  background: var(--accent); color: #fff;
  border-radius: 20px; padding: 2px 5px; margin-left: 2px;
  vertical-align: text-top;
}
.bell.late .bell-n { background: var(--danger); color: #fff; }

.bell-panel {
  position: fixed; z-index: 50;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  max-height: 70dvh; overflow-y: auto;
}
.bell-panel h3 { margin: 0; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.bell-group {
  padding: 8px 12px 3px; font-size: .72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim);
}
.bell-panel .dash-row { padding: 8px 12px; min-height: 42px; }

/* ==========================================================================
   Phone. Measured at 390px against the real DOM, not guessed.
   Two things were wrong: the header was 788px wide so every page scrolled
   sideways, and most controls were under the 44px a thumb needs.
   ========================================================================== */

@media (max-width: 700px) {
  /* Nothing may push the page wider than the screen. */
  html, body { max-width: 100%; overflow-x: hidden; }

  /* The header keeps everything on one row and scrolls the tabs instead. */
  header.top {
    height: auto;
    min-height: 52px;
    padding: 6px 8px;
    gap: 6px;
  }
  header.top .brand { font-size: .9rem; flex: 0 0 auto; }
  header.top .brand span { display: none; }   /* "GB" is enough at this width */

  .tabs {
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { flex: 0 0 auto; min-height: 44px; padding: 4px 12px; }

  /* Thumb-sized controls everywhere. */
  header.top button,
  .filters button,
  .filters select,
  .filters input[type=search],
  .admin-actions button,
  .admin-form button,
  .cal-bar button,
  .bulkbar button,
  .bulkbar select,
  .drawer .foot button {
    min-height: 44px;
  }
  header.top .bell { min-width: 44px; padding: 2px 10px; }
  .toggle { min-height: 44px; padding: 5px 14px; }

  /* Cards and rows are the primary targets on a phone. */
  .task { padding: 12px; }
  .task .move { min-height: 44px; min-width: 44px; top: 2px; right: 2px; }
  .camp-task, .dash-row, .bell-panel .dash-row { min-height: 48px; }

  /* In the month grid the day cell is the target; the dots are decoration. */
  .cal-pill { pointer-events: none; }
  .cal-day { min-height: 66px; }

  /* Table cells stay editable, so their inputs need the same height. */
  table.grid td .cell-input { min-height: 40px; }

  /* Sign out is a long word for a narrow bar. */
  header.top button.ghost.small { padding: 6px 10px; }
}

/* Very narrow phones: drop the sign-out label to an icon so the row holds. */
@media (max-width: 400px) {
  header.top .who { display: none; }
  header.top #signout-label { display: none; }
}

/* The checkbox cell is the target, not the 17px box inside it. */
.tickbox {
  display: flex; align-items: center; justify-content: center;
  margin: 0; min-width: 34px; min-height: 34px; cursor: pointer;
}

@media (max-width: 700px) {
  .tabs button { min-height: 46px; }
  .tickbox { min-width: 44px; min-height: 44px; }
  .tickbox input { width: 20px; height: 20px; }
  table.grid td .ghost.small,
  table.grid td button { min-height: 44px; }
}

/* A tick and its wording are one target. */
.checkline {
  display: flex; align-items: center; gap: 8px;
  margin: 0; font-size: .88rem; color: var(--text); font-weight: 500;
  min-height: 34px; cursor: pointer;
}
.checkline input { width: 17px; height: 17px; min-height: 0; accent-color: var(--accent); flex: 0 0 auto; }

@media (max-width: 700px) {
  /* Everything clickable clears 44px unless it is decoration inside a
     bigger target (calendar dots) or already sized (the card move button). */
  button:not(.cal-pill) { min-height: 44px; }
  .checkline { min-height: 44px; }
  .checkline input { width: 20px; height: 20px; }
  .drawer select, .drawer input, .drawer textarea { min-height: 44px; }
  .drawer textarea { min-height: 76px; }
}

/* Urgent and Important both earn a red chip; High is amber; Normal is quiet. */
.chip.important { border-color: var(--danger-border); color: var(--danger); background: var(--danger-soft); }
.chip.high { border-color: var(--approval); color: var(--approval); background: transparent; }

.addable { display: block; }
.addable-form { display: flex; gap: 6px; align-items: center; }
.addable-form input { flex: 1 1 auto; min-width: 0; }
