/* ============================================================
   TF ADMIN — dashboard styles (mirrors marketing site palette)
   ============================================================ */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--f-body);
  font-size: 14px;
  line-height: 1.55;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; border-radius: 4px; }

/* Show the section matching body[data-view], hide the rest. */
body[data-view="loading"] #view-auth,
body[data-view="loading"] #view-app,
body[data-view="loading"] #view-pass,
body[data-view="auth"]    #view-app,
body[data-view="auth"]    #view-loading,
body[data-view="auth"]    #view-pass,
body[data-view="app"]     #view-auth,
body[data-view="app"]     #view-loading,
body[data-view="app"]     #view-pass,
body[data-view="pass"]    #view-auth,
body[data-view="pass"]    #view-app,
body[data-view="pass"]    #view-loading { display: none; }
#view-pass { display: grid; place-items: center; min-height: 100vh; padding: var(--gutter, 24px); }
#view-pass .auth-err:empty { display: none; }

/* ---------- LOADING ---------- */
#view-loading {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: var(--bg);
}
.boot-logo img {
  height: 64px; opacity: .9;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

/* ---------- AUTH ---------- */
#view-auth, #view-pass {
  min-height: 100vh;
  display: grid; place-items: center;
  background:
    radial-gradient(800px 600px at 70% 30%, rgba(217,164,65,.14), transparent 60%),
    linear-gradient(135deg, #0A0A0C, #131418 60%, #1A1206);
  padding: 40px 20px;
}
.auth-card {
  width: 100%; max-width: 460px;
  background: linear-gradient(180deg, rgba(255,255,255,.03), transparent);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  padding: 44px 40px 40px;
  backdrop-filter: blur(20px);
}
.auth-logo img { height: 44px; margin-bottom: 28px; }
.auth-card .eyebrow {
  font-family: var(--f-mono); font-size: 11px; letter-spacing: .22em;
  text-transform: uppercase; color: var(--muted); font-weight: 500;
  display: flex; align-items: center; gap: 12px;
}
.auth-card .eyebrow::before {
  content: ''; width: 22px; height: 1px; background: var(--red);
}
.auth-card h1 {
  font-family: var(--f-display); font-size: 40px; font-weight: 700;
  letter-spacing: -.02em; margin: 14px 0 14px;
}
.auth-sub { color: var(--muted); font-size: 14px; margin-bottom: 28px; }
#auth-form, #pass-form { display: flex; flex-direction: column; gap: 14px; }
#auth-form label, #pass-form label {
  display: block;
  font-family: var(--f-mono); font-size: 11px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--muted); font-weight: 500;
  margin-bottom: 6px;
}
#auth-form input, #pass-form input {
  display: block; width: 100%;
  padding: 14px 18px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  color: var(--fg); font-family: var(--f-body); font-size: 16px;
  box-sizing: border-box;
}
#auth-form input:focus, #pass-form input:focus { outline: none; border-color: var(--red); background: rgba(255,255,255,.06); }
#pass-form button[type="submit"] { margin-top: 6px; align-self: flex-start; }
#pass-confirm-wrap { display: flex; flex-direction: column; gap: 14px; }
#view-pass .auth-err:empty { display: none; }
#view-pass .btn-ghost { margin-top: 12px; }
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 24px;
  font-family: var(--f-body); font-weight: 500; font-size: 14px;
  border-radius: var(--r-pill); cursor: pointer;
  transition: background 200ms var(--ease), color 200ms var(--ease), transform 200ms var(--ease), border-color 200ms var(--ease);
}
.btn-primary { background: var(--red); color: var(--black); }
.btn-primary:hover { background: var(--red-dim); }
.btn-arrow::after { content: '→'; transition: transform 200ms var(--ease); }
.btn-arrow:hover::after { transform: translateX(4px); }
.btn-ghost { border: 1px solid var(--rule-strong); color: var(--fg); padding: 10px 18px; font-size: 13px; }
.btn-ghost:hover { background: var(--fg); color: var(--bg); }
.btn-sm { padding: 8px 14px; font-size: 12px; }
.btn-danger { background: rgba(217,164,65,.12); color: var(--red); border: 1px solid rgba(217,164,65,.3); padding: 10px 18px; font-size: 13px; }
.btn-danger:hover { background: var(--red); color: var(--black); }

.auth-hint { margin-top: 24px; font-family: var(--f-mono); font-size: 11px; color: var(--muted); }
.auth-hint code { background: rgba(255,255,255,.04); padding: 3px 8px; border-radius: 4px; }
.auth-demo { margin-top: 14px; font-family: var(--f-mono); font-size: 10px; color: var(--red); letter-spacing: .12em; }

/* ---------- APP LAYOUT ---------- */
#view-app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* ---------- SIDEBAR ---------- */
.sidebar {
  background: #08080A;
  border-right: 1px solid var(--rule);
  display: flex; flex-direction: column;
  padding: 24px 0;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sb-logo {
  padding: 0 28px 24px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 18px;
}
.sb-logo img { height: 36px; }

.sb-nav { flex: 1; display: flex; flex-direction: column; gap: 4px; padding: 0 16px; }
.sb-group-label {
  font-family: var(--f-mono); font-size: 10px; letter-spacing: .22em;
  text-transform: uppercase; color: var(--muted);
  padding: 18px 14px 8px; font-weight: 500;
}
.sb-item {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 14px;
  border-radius: var(--r-md);
  color: var(--muted); font-size: 14px;
  cursor: pointer;
  transition: background 180ms var(--ease), color 180ms var(--ease);
  position: relative;
  width: 100%; text-align: left;
}
.sb-item:hover { background: rgba(255,255,255,.04); color: var(--fg); }
.sb-item.active {
  background: var(--red-soft);
  color: var(--fg);
}
.sb-item.active::before {
  content: ''; position: absolute; left: -16px; top: 6px; bottom: 6px;
  width: 3px; background: var(--red); border-radius: 0 2px 2px 0;
}
.sb-item .icon {
  width: 18px; height: 18px;
  display: grid; place-items: center; opacity: .9;
  flex-shrink: 0;
}
.sb-item .icon svg { width: 100%; height: 100%; }
.sb-item .badge {
  margin-left: auto;
  background: var(--red); color: var(--black);
  font-family: var(--f-mono); font-size: 10px; font-weight: 600;
  padding: 2px 7px; border-radius: 999px;
  min-width: 20px; text-align: center;
}

.sb-preview { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; margin: 6px 12px; border: 1px solid var(--rule); border-radius: 10px; background: rgba(255,255,255,.03); }
.sb-preview-l { display: flex; flex-direction: column; gap: 3px; font-size: 13px; font-weight: 500; flex: 1; cursor: default; }
.sb-preview-sub { font-family: var(--f-mono); font-size: 10px; letter-spacing: .12em; color: var(--muted); font-weight: 500; text-transform: uppercase; }
.sb-toggle { position: relative; width: 38px; height: 22px; border-radius: 11px; background: rgba(255,255,255,.18); border: 0; cursor: pointer; transition: background var(--t-fast, .2s) ease; flex-shrink: 0; }
.sb-toggle.on { background: var(--red, var(--gold)); }
.sb-toggle-knob { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,.45); transition: left var(--t-fast, .2s) ease; }
.sb-toggle.on .sb-toggle-knob { left: 18px; }

.sb-foot {
  padding: 16px 16px 0;
  border-top: 1px solid var(--rule);
  margin: 20px 16px 0;
}
.sb-user { display: flex; align-items: center; gap: 12px; padding: 8px 4px; }
.sb-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--red); color: var(--black);
  display: grid; place-items: center;
  font-family: var(--f-mono); font-size: 12px; font-weight: 600;
  flex-shrink: 0;
}
.sb-user-name { font-size: 13px; font-weight: 500; }
.sb-user-role { font-family: var(--f-mono); font-size: 10px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted); }
.sb-signout {
  display: block; width: 100%;
  padding: 10px 14px; margin-top: 12px;
  border-radius: var(--r-md);
  font-family: var(--f-mono); font-size: 11px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--muted);
  text-align: left;
  transition: color 180ms var(--ease), background 180ms var(--ease);
}
.sb-signout:hover { color: var(--red); background: rgba(255,255,255,.03); }

/* ---------- MAIN ---------- */
.main { padding: 28px 36px 60px; min-width: 0; }
.topbar {
  display: flex; justify-content: space-between; align-items: end;
  padding-bottom: 28px; margin-bottom: 32px;
  border-bottom: 1px solid var(--rule);
  flex-wrap: wrap; gap: 16px;
}
.topbar-eyebrow {
  font-family: var(--f-mono); font-size: 11px; letter-spacing: .22em;
  text-transform: uppercase; color: var(--muted); font-weight: 500; margin-bottom: 8px;
}
.topbar h1 {
  font-family: var(--f-display); font-size: clamp(28px, 3vw, 38px);
  font-weight: 700; letter-spacing: -.02em; margin: 0;
}
.topbar-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Mobile nav: burger + slide-in sidebar drawer ---------- */
.adm-burger {
  display: none; flex: 0 0 auto; position: relative;
  width: 42px; height: 42px;
  border: 1px solid var(--rule); border-radius: 11px;
  background: rgba(255,255,255,.025); cursor: pointer;
  transition: border-color 180ms var(--ease), background 180ms var(--ease);
}
.adm-burger:hover { border-color: var(--rule-strong); background: rgba(255,255,255,.05); }
.adm-burger span {
  position: absolute; left: 50%; top: 50%; width: 18px; height: 2px; margin-left: -9px;
  background: var(--fg); border-radius: 2px;
  transition: transform .26s var(--ease), opacity .2s var(--ease);
}
.adm-burger span:nth-child(1) { transform: translateY(-5.5px); }
.adm-burger span:nth-child(3) { transform: translateY(5.5px); }
body.admin-nav-open .adm-burger span:nth-child(1) { transform: rotate(45deg); }
body.admin-nav-open .adm-burger span:nth-child(2) { opacity: 0; }
body.admin-nav-open .adm-burger span:nth-child(3) { transform: rotate(-45deg); }

.adm-nav-back {
  position: fixed; inset: 0; z-index: 49;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none; transition: opacity .3s var(--ease);
}
body.admin-nav-open .adm-nav-back { opacity: 1; pointer-events: auto; }

/* ---------- PANE COMMONS ---------- */
.pane { min-height: 300px; }

/* KPI cards */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px;
  margin-bottom: 36px;
}
.kpi {
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  padding: 24px 24px 20px;
  background: linear-gradient(180deg, rgba(255,255,255,.025), transparent);
}
.kpi .k {
  font-family: var(--f-mono); font-size: 10px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--muted); font-weight: 500;
}
.kpi .v {
  font-family: var(--f-display); font-size: 36px;
  font-weight: 700; letter-spacing: -.02em;
  color: var(--fg); margin: 8px 0 4px; line-height: 1.05;
}
.kpi .d { font-family: var(--f-mono); font-size: 11px; color: var(--muted); font-weight: 500; }
.kpi .d.up   { color: #4ADE80; }
.kpi .d.down { color: var(--red); }
@media (max-width: 1200px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }

/* Filter bar */
.filter-bar {
  display: flex; gap: 12px; flex-wrap: wrap;
  margin-bottom: 18px; padding-bottom: 18px;
  border-bottom: 1px solid var(--rule);
  align-items: center;
}
.filter-bar .search {
  flex: 1; min-width: 240px;
  padding: 10px 14px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  color: var(--fg); font-size: 13px;
}
.filter-bar .search:focus { outline: none; border-color: var(--red); }
.filter-bar select {
  padding: 10px 14px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  color: var(--fg); font-size: 13px; font-family: var(--f-body);
}
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font-family: var(--f-mono); font-size: 11px; letter-spacing: .12em;
  padding: 7px 12px;
  border: 1px solid var(--rule); border-radius: var(--r-pill);
  color: var(--muted); cursor: pointer;
  transition: all 180ms var(--ease);
  text-transform: uppercase; font-weight: 500;
}
.chip:hover { color: var(--fg); border-color: var(--rule-strong); }
.chip.active { background: var(--red-soft); color: var(--red); border-color: var(--red); }

/* Tables */
.table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.table thead th {
  text-align: left; font-family: var(--f-mono); font-size: 10px;
  letter-spacing: .18em; text-transform: uppercase; color: var(--muted);
  padding: 14px 18px;
  background: rgba(255,255,255,.025);
  border-bottom: 1px solid var(--rule);
  font-weight: 500;
}
.table tbody td {
  padding: 16px 18px; font-size: 14px;
  border-bottom: 1px solid var(--rule);
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background 120ms var(--ease); cursor: pointer; }
.table tbody tr:hover { background: rgba(255,255,255,.025); }
.table .muted { color: var(--muted); }
.table .num { font-family: var(--f-mono); }

/* Status badges */
.badge {
  display: inline-block;
  font-family: var(--f-mono); font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; font-weight: 500;
  padding: 4px 10px; border-radius: var(--r-pill);
  border: 1px solid currentColor;
}
.badge.green  { color: #4ADE80; background: rgba(74,222,128,.08); }
.badge.amber  { color: #F59E0B; background: rgba(245,158,11,.08); }
.badge.red    { color: var(--red); background: var(--red-soft); }
.badge.blue   { color: #60A5FA; background: rgba(96,165,250,.08); }
.badge.gray   { color: var(--muted); background: rgba(255,255,255,.04); }

/* Cards / grid layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 1080px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.card {
  border: 1px solid var(--rule); border-radius: var(--r-lg);
  padding: 24px;
  background: linear-gradient(180deg, rgba(255,255,255,.025), transparent);
}
.card h3 { font-family: var(--f-display); font-weight: 600; font-size: 18px;
  letter-spacing: -.01em; margin: 0 0 16px; }

/* Empty state */
.empty {
  padding: 60px 24px; text-align: center;
  border: 1px dashed var(--rule);
  border-radius: var(--r-lg);
  color: var(--muted); font-size: 14px;
}

/* Detail panel (modal) */
.modal-back {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.62);
  backdrop-filter: blur(8px);
  display: grid; place-items: center;
  padding: 24px;
  animation: modalFade .25s var(--ease);
}
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #131418;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-lg);
  width: 100%; max-width: 720px;
  max-height: 84vh; overflow-y: auto;
  padding: 32px;
}
.modal h2 { font-family: var(--f-display); font-weight: 600; font-size: 24px;
  letter-spacing: -.01em; margin: 0 0 8px; }
.modal-sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.modal-row { display: flex; justify-content: space-between; align-items: baseline;
  padding: 10px 0; border-bottom: 1px solid var(--rule); }
.modal-row:last-child { border-bottom: 0; }
.modal-row .k { font-family: var(--f-mono); font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted); font-weight: 500; }
.modal-row .v { color: var(--fg); text-align: right; font-size: 14px; }
/* Per-window booking breakdown */
.bk-wins { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.bk-win { display: flex; justify-content: space-between; gap: 14px; align-items: baseline; }
.bk-win-name { color: var(--fg); font-size: 13px; white-space: nowrap; }
.bk-win-spec { color: var(--muted); font-family: var(--f-mono); font-size: 11px; text-align: right; }
.modal-actions { display: flex; gap: 10px; margin-top: 24px; flex-wrap: wrap; }

/* Modal forms (New charge / booking / campaign / automation) */
.mform { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 4px; }
.mform label { display: flex; flex-direction: column; gap: 6px;
  font-family: var(--f-mono); font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted); font-weight: 500; }
.mform .full { grid-column: 1 / -1; }
.mform input, .mform select, .mform textarea {
  width: 100%; padding: 11px 14px;
  background: rgba(255,255,255,.03); border: 1px solid var(--rule);
  border-radius: 10px; color: var(--fg);
  font-family: var(--f-body); font-size: 14px; letter-spacing: normal; text-transform: none;
}
.mform input:focus, .mform select:focus, .mform textarea:focus { outline: none; border-color: var(--red); }
.mform textarea { resize: vertical; }
.mf-err { color: var(--red); font-family: var(--f-mono); font-size: 11px; letter-spacing: .06em; min-height: 14px; }
#mf-splitrow { display: flex; }
@media (max-width: 640px) { .mform { grid-template-columns: 1fr; } }

/* Booking reschedule strip (detail modal) */
.bk-resched { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 18px; padding: 14px; border: 1px dashed var(--rule-strong); border-radius: 10px; }
.bk-resched input, .bk-resched select {
  padding: 8px 12px; background: rgba(255,255,255,.03);
  border: 1px solid var(--rule); border-radius: 8px; color: var(--fg);
  font-family: var(--f-body); font-size: 13px;
}

/* CRM */
.crm-banner { display: flex; gap: 12px; align-items: flex-start;
  border: 1px solid var(--red); background: var(--red-soft);
  border-radius: var(--r-lg); padding: 14px 18px; margin-bottom: 20px;
  font-size: 13.5px; line-height: 1.55; color: var(--fg); }
.crm-banner .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red);
  margin-top: 5px; flex-shrink: 0; animation: crmPulse 1.8s ease infinite; }
@keyframes crmPulse { 50% { opacity: .35; } }
.crm-note { margin-top: 16px; font-family: var(--f-mono); font-size: 11px;
  letter-spacing: .04em; color: var(--muted); font-weight: 500; line-height: 1.6; }
.auto-list { display: flex; flex-direction: column; gap: 10px; }
.auto-row { display: flex; align-items: center; gap: 16px;
  border: 1px solid var(--rule); border-radius: var(--r-lg); padding: 16px 18px; }
.auto-main { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.auto-main .muted { font-size: 12.5px; }
.switch { position: relative; display: inline-block; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; z-index: 2; }
.switch .track { display: block; width: 40px; height: 22px; border-radius: 999px;
  background: rgba(255,255,255,.12); border: 1px solid var(--rule-strong);
  transition: background 180ms var(--ease); position: relative; }
.switch .track::after { content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%; background: var(--fg);
  transition: transform 180ms var(--ease); }
.switch input:checked + .track { background: var(--red); border-color: var(--red); }
.switch input:checked + .track::after { transform: translateX(18px); background: #0A0A0C; }

/* Funnel */
.fun-row { display: grid; grid-template-columns: 120px 1fr 44px 44px;
  align-items: center; gap: 14px; padding: 9px 0; }
.fun-label { font-size: 13px; color: var(--muted); }
.fun-bar { height: 18px; background: rgba(255,255,255,.05); border-radius: 6px; overflow: hidden; }
.fun-bar i { display: block; height: 100%;
  background: linear-gradient(90deg, var(--red), rgba(217,164,65,.45)); border-radius: 6px; }
.fun-n { text-align: right; font-weight: 600; }
.fun-conv { text-align: right; font-size: 12px; }

/* Posts editor */
.posts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 980px) { .posts-grid { grid-template-columns: 1fr; } }
.post {
  border: 1px solid var(--rule); border-radius: var(--r-lg);
  padding: 20px; cursor: pointer;
  transition: border-color 180ms var(--ease), transform 180ms var(--ease);
}
.post:hover { border-color: var(--red); transform: translateY(-2px); }
.post .meta { font-family: var(--f-mono); font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 8px; font-weight: 500; }
.post h4 { font-family: var(--f-display); font-weight: 600; font-size: 16px;
  letter-spacing: -.01em; margin: 0 0 8px; line-height: 1.3; }
.post .excerpt { color: var(--muted); font-size: 13px; line-height: 1.5; }

/* Sparkline */
.spark {
  height: 60px; margin-top: 12px;
  display: flex; align-items: end; gap: 4px;
}
.spark .bar {
  flex: 1; background: linear-gradient(180deg, var(--red), rgba(217,164,65,.3));
  border-radius: 2px 2px 0 0;
  min-height: 4px;
}

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: #15171C; color: var(--fg);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-md);
  padding: 12px 20px;
  font-size: 13px; box-shadow: 0 20px 50px rgba(0,0,0,.4);
  opacity: 0; pointer-events: none;
  z-index: 200;
  transition: opacity 280ms var(--ease), transform 280ms var(--ease);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Photo gallery (warranty claims) */
.photo-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin: 14px 0;
}
.photo-grid img {
  aspect-ratio: 4/3; object-fit: cover; border-radius: var(--r-md);
}

/* ---------- VIEW TOGGLE (Table / Calendar) ---------- */
.view-toggle-row {
  display: flex; gap: 16px; align-items: center;
  flex-wrap: wrap; padding-bottom: 18px; border-bottom: 1px solid var(--rule);
  margin-bottom: 18px;
}
.view-toggle {
  display: inline-flex;
  border: 1px solid var(--rule);
  border-radius: var(--r-pill);
  padding: 3px;
  background: rgba(255,255,255,.03);
}
.vt-btn {
  padding: 8px 18px;
  font-family: var(--f-mono);
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  border-radius: var(--r-pill);
  color: var(--muted); font-weight: 500;
  transition: all 180ms var(--ease);
}
.vt-btn:hover { color: var(--fg); }
.vt-btn.active { background: var(--red); color: var(--black); }

/* ---------- CALENDAR ---------- */
.cal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 16px; flex-wrap: wrap;
}
.cal-month {
  font-family: var(--f-display); font-weight: 600; font-size: 22px;
  letter-spacing: -.01em; margin: 0;
}
.cal-legend {
  display: flex; gap: 18px; font-family: var(--f-mono); font-size: 10px;
  letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
  font-weight: 500; margin-bottom: 16px; flex-wrap: wrap;
}
.cal-legend span { display: inline-flex; align-items: center; gap: 8px; }
.cal-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 2px;
}
.cal-dot.c-red    { background: var(--red); }
.cal-dot.c-blue   { background: #60A5FA; }
.cal-dot.c-green  { background: #4ADE80; }

.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.cal-dow {
  background: var(--ink);
  padding: 10px 12px;
  font-family: var(--f-mono); font-size: 10px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--muted); font-weight: 500;
  text-align: center;
}
.cal-cell {
  background: var(--bg);
  min-height: 108px;
  padding: 8px 8px 6px;
  display: flex; flex-direction: column; gap: 6px;
  transition: background 180ms var(--ease);
}
.cal-cell.pad { background: rgba(255,255,255,.015); }
.cal-cell.has { background: rgba(255,255,255,.02); }
.cal-cell.today { background: rgba(217,164,65,.06); }
.cal-cell.today .cal-num { color: var(--red); font-weight: 700; }
.cal-num {
  font-family: var(--f-mono); font-size: 13px; font-weight: 500;
  color: var(--muted);
}
.cal-chips { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.cal-chip {
  display: flex; gap: 6px; align-items: center;
  padding: 4px 6px; border-radius: var(--r-sm);
  font-family: var(--f-mono); font-size: 10px;
  letter-spacing: .04em; font-weight: 500;
  cursor: pointer;
  transition: transform 120ms var(--ease), filter 120ms var(--ease);
  border: 1px solid;
  overflow: hidden;
}
.cal-chip:hover { transform: translateX(2px); filter: brightness(1.15); }
.cal-chip .cc-t { flex-shrink: 0; }
.cal-chip .cc-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-chip.cc-red    { background: rgba(217,164,65,.16);  border-color: rgba(217,164,65,.45); color: #FBA9AB; }
.cal-chip.cc-blue   { background: rgba(96,165,250,.14); border-color: rgba(96,165,250,.4); color: #B6D4FF; }
.cal-chip.cc-green  { background: rgba(74,222,128,.12); border-color: rgba(74,222,128,.4); color: #A7F3D0; }
.cal-chip.cc-gray   { background: rgba(255,255,255,.04); border-color: var(--rule); color: var(--muted); }
.cal-more {
  font-family: var(--f-mono); font-size: 9px; color: var(--muted);
  padding: 2px 6px; font-weight: 500;
}

@media (max-width: 980px) {
  .cal-cell { min-height: 80px; padding: 6px; }
  .cal-chip { font-size: 9px; }
  .cal-chip .cc-name { display: none; }
}

/* Responsive */
@media (max-width: 880px) {
  #view-app { grid-template-columns: 1fr; }
  /* Sidebar becomes a left slide-in drawer; the topbar burger toggles it. */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
    width: min(86vw, 300px); height: 100%;
    transform: translateX(-100%);
    transition: transform .32s cubic-bezier(.22, .61, .36, 1);
  }
  body.admin-nav-open .sidebar { transform: translateX(0); box-shadow: 0 24px 70px rgba(0,0,0,.6); }
  body.admin-nav-open { overflow: hidden; }
  .adm-burger { display: inline-flex; align-items: center; justify-content: center; }
  .topbar { align-items: center; }
  .topbar > div:first-of-type { flex: 1; min-width: 0; }
  .main { padding: 20px 18px 60px; }
  .table thead { display: none; }
  .table tbody td { display: block; padding: 8px 14px; border-bottom: 0; }
  .table tbody tr { display: block; padding: 12px 0; border-bottom: 1px solid var(--rule); }
}

/* Chat inboxes (SMS + WhatsApp) */
.chat-wrap{display:grid;grid-template-columns:300px 1fr;border:1px solid var(--rule);border-radius:14px;overflow:hidden;min-height:560px}
.chat-list{border-right:1px solid var(--rule);overflow-y:auto;max-height:72vh}
.chat-list-head{display:flex;justify-content:space-between;align-items:center;padding:14px 16px;border-bottom:1px solid var(--rule);font-family:var(--f-display);font-weight:600;font-size:14px}
.chat-conv{padding:12px 16px;border-bottom:1px solid var(--rule);cursor:pointer}
.chat-conv:hover{background:rgba(255,255,255,.03)}
.chat-conv.active{background:rgba(217,164,65,.10)}
.cc-top{display:flex;justify-content:space-between;gap:8px}
.cc-top strong{font-size:13.5px}
.cc-prev{font-size:12px;margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat-time{font-size:11px}
.chat-main{display:flex;flex-direction:column;min-height:560px}
.chat-head{padding:14px 18px;border-bottom:1px solid var(--rule);font-family:var(--f-display);font-weight:600}
.chat-thread{flex:1;overflow-y:auto;max-height:56vh;padding:18px;display:flex;flex-direction:column;gap:10px}
.msg{display:flex;flex-direction:column;max-width:74%}
.msg.in{align-self:flex-start;align-items:flex-start}
.msg.out{align-self:flex-end;align-items:flex-end}
.msg .bubble{padding:9px 13px;border-radius:14px;font-size:14px;line-height:1.45}
.msg.in .bubble{background:rgba(255,255,255,.06);border-top-left-radius:4px}
.msg.out .bubble{background:var(--gold);color:#0A0A0C;border-top-right-radius:4px}
.msg-meta{font-size:10px;margin-top:3px}
.chat-compose{display:flex;gap:8px;align-items:flex-end;padding:14px;border-top:1px solid var(--rule);flex-wrap:wrap}
.chat-compose textarea{flex:1;min-width:200px;resize:vertical;padding:10px 12px;border:1px solid var(--rule);border-radius:8px;background:transparent;color:var(--fg);font-family:var(--f-body);font-size:14px}
.chat-to{width:100%;padding:10px 12px;border:1px solid var(--rule);border-radius:8px;background:transparent;color:var(--fg);margin-bottom:4px}
.chat-note{padding:0 14px 12px;font-size:12px}
.chat-empty{padding:28px 18px;color:var(--muted);font-size:14px;text-align:center}
@media(max-width:860px){.chat-wrap{grid-template-columns:1fr}.chat-list{max-height:240px}}
.pass-link-row { margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--rule); display: flex; flex-direction: column; gap: 10px; }
.pass-link-row .auth-hint { margin: 0; }
.pass-link-row .btn-ghost { align-self: flex-start; }
/* magic-link-first sign-in */
#link-form .btn-primary, #pw-form .btn-primary { margin-top: 18px; }
.auth-alt { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--rule); }
.auth-altlink { background: none; border: 0; padding: 0; cursor: pointer;
  font-family: var(--f-mono); font-size: 12px; letter-spacing: .04em; color: var(--muted);
  text-decoration: underline; text-underline-offset: 3px; transition: color .15s; }
.auth-altlink:hover { color: var(--gold, #D9A441); }
#pw-form { margin-top: 16px; }
#pw-form .pw-row { display: flex; align-items: center; gap: 16px; margin-top: 16px; flex-wrap: wrap; }
#pw-form .pw-row .btn-primary { margin-top: 0; }
.sb-account { background: none; border: 0; padding: 0; cursor: pointer; text-align: left;
  font-size: 13px; color: var(--muted); margin-bottom: 8px; transition: color .15s; }
.sb-account:hover { color: var(--gold, #D9A441); }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
