/* EYB dashboard. Brand: navy #0F1E3D, cyan #22D3EE; Manrope for text, Quicksand for headings. */

:root {
  color-scheme: dark;
  --bg: #0A1530;
  --surface: #0F1E3D;
  --surface-2: #15284F;
  --border: rgba(255, 255, 255, 0.09);
  --text: #E9EFF9;
  --muted: #9AABC6;
  --accent: #22D3EE;
  --accent-ink: #062033;
  --accent-soft: rgba(34, 211, 238, 0.13);
  --good: #34D399;
  --warning: #FBBF24;
  --critical: #F87171;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  --radius: 14px;
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Quicksand', var(--font);
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #F3F6FB;
    --surface: #FFFFFF;
    --surface-2: #EDF2F9;
    --border: rgba(15, 30, 61, 0.1);
    --text: #0F1E3D;
    --muted: #55657F;
    --accent: #0E7490;
    --accent-ink: #FFFFFF;
    --accent-soft: rgba(14, 116, 144, 0.1);
    --good: #15803D;
    --warning: #B45309;
    --critical: #B91C1C;
    --shadow: 0 1px 2px rgba(15, 30, 61, 0.06);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.2; margin: 0; }
h1 { font-size: 26px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- buttons & inputs ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: 600 14px/1 var(--font);
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  min-height: 40px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--critical); }
.btn.small { min-height: 32px; padding: 6px 10px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
input[type=password], input[type=search], input[type=text] {
  width: 100%;
  font: 15px var(--font);
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
}
input:focus-visible, .btn:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(380px, 100%);
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 28px; display: grid; gap: 12px; box-shadow: var(--shadow);
}
.login-logo { border-radius: 14px; }
.login-card label { font-weight: 600; font-size: 14px; margin-top: 6px; }
#code-box { display: grid; gap: 8px; }
#code-box p { margin: 0; }
.error { color: var(--critical); min-height: 1.2em; margin: 0; font-size: 14px; }

/* ---------- layout ---------- */
.shell { min-height: 100vh; display: grid; grid-template-columns: 220px minmax(0, 1fr); }
.side {
  position: sticky; top: 0; height: 100vh;
  border-right: 1px solid var(--border); background: var(--surface);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font: 700 20px var(--display); padding: 0 8px; }
.brand img { border-radius: 9px; }
.side-nav { display: grid; gap: 2px; }
.side-nav a {
  color: var(--muted); text-decoration: none; font-weight: 600;
  padding: 9px 10px; border-radius: 9px; display: flex; align-items: center; justify-content: space-between;
}
.side-nav a:hover { color: var(--text); background: var(--surface-2); }
.side-nav a.active { color: var(--text); background: var(--accent-soft); }
.side-user { margin: auto 8px 0; }
.side-logout { margin-top: 0; }
.badge {
  background: var(--accent); color: var(--accent-ink);
  font: 700 11px/1 var(--font); border-radius: 999px; padding: 3px 7px; min-width: 20px; text-align: center;
}
.view { padding: 28px 32px 48px; max-width: 1180px; width: 100%; min-width: 0; outline: none; }
.tabbar { display: none; }

@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .board { grid-auto-columns: minmax(78vw, 1fr); }
  .side { display: none; }
  .view { padding: 18px 16px calc(92px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a {
    position: relative; display: grid; justify-items: center; gap: 2px;
    color: var(--muted); text-decoration: none; font: 600 11px var(--font); padding: 4px 0;
  }
  .tabbar a.active { color: var(--accent); }
  .tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .tabbar .badge { position: absolute; top: 0; left: 55%; }
  h1 { font-size: 22px; }
}

/* ---------- page parts ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); align-items: start; }
.section { margin-top: 24px; }
.section > h2 { margin-bottom: 10px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); min-width: 0;
}
.card > h2, .card > h3 { margin-bottom: 10px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }

/* Stat tiles: label, value, one line of context. */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 820px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi .value { font: 700 28px/1.15 var(--font); font-variant-numeric: tabular-nums; margin-top: 4px; letter-spacing: -0.01em; }
.kpi .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
a.kpi { color: inherit; text-decoration: none; }
a.kpi:hover { border-color: var(--accent); }

/* Status always carries a word, never color alone. */
.status { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.good { color: var(--good); }
.status.warning { color: var(--warning); }
.status.critical { color: var(--critical); }
.status.neutral { color: var(--muted); }
.chip {
  display: inline-block; font-size: 12px; font-weight: 700; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; white-space: nowrap;
}
.agent { color: var(--text); background: var(--surface-2); border-color: transparent; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 11px 0; border-top: 1px solid var(--border); display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.list > li:first-child { border-top: 0; padding-top: 2px; }
.list .main { min-width: 0; flex: 1; }
.list .title { font-weight: 600; }
a.title { color: var(--text); text-decoration: none; }
a.title:hover { color: var(--accent); text-decoration: underline; }
.list .meta { color: var(--muted); font-size: 13px; }
.list .right { text-align: right; white-space: nowrap; }
.list a.row { color: inherit; text-decoration: none; display: contents; }
.clickable { cursor: pointer; }
.clickable:hover .title { color: var(--accent); }

.empty { color: var(--muted); padding: 6px 0; }
.empty .say { display: block; margin-top: 6px; color: var(--text); font-style: italic; }
.loading { color: var(--muted); padding: 40px 0; }
.notice { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: 12px 14px; border-radius: 8px; }

/* Reports written in markdown */
.prose h4 { font: 700 14px var(--display); margin: 14px 0 4px; text-transform: none; }
.prose h4:first-child { margin-top: 0; }
.prose p { margin: 4px 0; }
.prose ul { margin: 2px 0 6px; padding-left: 18px; }
.prose li { margin: 2px 0; }
details > summary { cursor: pointer; font-weight: 700; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: 'Show'; font-size: 13px; color: var(--accent); }
details[open] > summary::after { content: 'Hide'; }
details[open] > summary { margin-bottom: 10px; }

/* Approvals */
.approval .msg {
  white-space: pre-wrap; word-break: break-word; font: 14px/1.55 var(--font);
  background: var(--surface-2); border-radius: 10px; padding: 12px 14px; margin: 10px 0 12px;
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs .btn.active { background: var(--accent-soft); border-color: var(--accent); }

/* Sales pipeline */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input { max-width: 320px; }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x proximity; }
.column { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; scroll-snap-align: start; min-height: 120px; }
.column h3 { display: flex; justify-content: space-between; margin-bottom: 10px; }
.column h3 .count { color: var(--muted); font-family: var(--font); }
.lead { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; border: 1px solid transparent; }
.lead:hover, .lead:focus-visible { border-color: var(--accent); outline: none; }
.lead .name { font-weight: 700; }
.lead .meta { font-size: 13px; color: var(--muted); }
.lead .tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; align-items: center; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-size: 12px; font-weight: 700; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 9px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
td.amount, th.amount { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

/* Calendar */
.day + .day { margin-top: 18px; }
.day h3 { margin-bottom: 6px; }
.event-time { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 64px; }
.check { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--muted); background: transparent; cursor: pointer; flex: none; margin-top: 1px; }
.check:hover { border-color: var(--good); }

/* Contact drawer */
.drawer {
  border: 0; padding: 0; margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: min(520px, 100vw); max-width: 100vw;
  background: var(--bg); color: var(--text); border-left: 1px solid var(--border);
}
.drawer::backdrop { background: rgba(3, 8, 20, 0.55); }
.drawer-inner { padding: 20px 20px 40px; display: grid; gap: 14px; }
.drawer-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 14px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; word-break: break-word; }
.kpis.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis.three .value { font-size: 20px; }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); font-weight: 600; padding: 10px 16px; border-radius: 10px;
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; }
@media (min-width: 821px) { .toast { bottom: 28px; } }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* ---------- calendar: month grid and week timeline ---------- */
.cal-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 14px; }
.cal-title { margin: 0 4px; }
.cal-head .spacer { flex: 1; }
.item {
  display: block; font-size: 12px; line-height: 1.3; padding: 2px 6px; border-radius: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.item.ev { background: var(--accent-soft); color: var(--text); border-left: 3px solid var(--accent); }
.item.tk { border: 1px dashed var(--muted); color: var(--muted); }
.item.more { color: var(--muted); }
.item.legend { display: inline; padding: 0 5px; }

.month {
  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;
}
.month .wd { background: var(--surface); padding: 8px; font-size: 12px; font-weight: 700; color: var(--muted); }
.cell {
  appearance: none; border: 0; margin: 0; text-align: left; font: inherit; color: var(--text); cursor: pointer;
  background: var(--surface); min-height: 112px; padding: 6px; display: flex; flex-direction: column; gap: 3px; min-width: 0;
}
.cell:hover { background: var(--surface-2); }
.cell.other { background: var(--bg); }
.cell.other .num { color: var(--muted); }
.cell .num { font-weight: 700; font-size: 13px; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; flex: none; }
.cell.today .num { background: var(--accent); color: var(--accent-ink); }
.cell.selected { box-shadow: inset 0 0 0 2px var(--accent); }
.cell:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.dots { display: none; gap: 3px; justify-content: center; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.dots i.tk { background: transparent; border: 1px solid var(--muted); }

.week-wrap { overflow: auto; max-height: 70vh; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.week { display: grid; grid-template-columns: 52px repeat(7, minmax(92px, 1fr)); min-width: 720px; }
.week .corner, .week .dayhead { position: sticky; top: 0; z-index: 3; background: var(--surface); border-bottom: 1px solid var(--border); }
.week .dayhead {
  appearance: none; border-top: 0; border-right: 0; border-left: 1px solid var(--border); font: 700 13px var(--font);
  color: var(--muted); padding: 8px 4px; cursor: pointer;
}
.week .dayhead .dnum { color: var(--text); font-size: 16px; margin-left: 4px; }
.week .dayhead.today, .week .dayhead.today .dnum { color: var(--accent); }
.week .dayhead, .week .corner { height: 40px; }
/* The all-day row (trips, to-dos) stays pinned under the day names while the hours scroll. */
.week .allday-label, .week .allday { position: sticky; top: 40px; z-index: 3; background: var(--surface); border-bottom: 1px solid var(--border); }
.week .allday-label { font-size: 11px; color: var(--muted); padding: 6px 4px; text-align: right; }
.week .allday { border-left: 1px solid var(--border); padding: 4px; display: grid; gap: 3px; align-content: start; min-height: 30px; max-height: 96px; overflow-y: auto; min-width: 0; }
.hour-label { height: 44px; font-size: 11px; color: var(--muted); text-align: right; padding-right: 6px; transform: translateY(-7px); font-variant-numeric: tabular-nums; }
.daycol {
  position: relative; height: calc(44px * 24); border-left: 1px solid var(--border);
  background-image: repeating-linear-gradient(to bottom, var(--border) 0 1px, transparent 1px 44px);
}
.block {
  position: absolute; left: 2px; right: 2px; overflow: hidden; z-index: 1;
  background: var(--surface-2); border-left: 3px solid var(--accent); border-radius: 6px;
  padding: 2px 6px; font-size: 12px; line-height: 1.3; box-shadow: var(--shadow);
}
.nowline { position: absolute; left: 0; right: 0; height: 2px; background: var(--critical); z-index: 2; }
.nowline::before { content: ''; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--critical); }

@media (max-width: 820px) {
  .cell { min-height: 56px; align-items: center; padding: 4px 2px; }
  .cell .item { display: none; }
  .dots { display: flex; }
  .month .wd { text-align: center; padding: 6px 0; }
  .cal-title { width: 100%; order: -1; margin: 0; }
  .cal-head .spacer { display: none; }
}

/* ---------- marketing: chart, meter lists, tooltip ---------- */
.chart { width: 100%; height: auto; display: block; margin-top: 4px; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font: 11px var(--font); font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--accent); }
.chart .hit { fill: transparent; cursor: default; outline: none; }
.chart .hit.active, .chart .hit:focus-visible { fill: var(--accent-soft); }
.chart-tip {
  position: fixed; z-index: 60; pointer-events: none; background: var(--text); color: var(--bg);
  font: 600 13px var(--font); padding: 6px 10px; border-radius: 8px; white-space: nowrap; box-shadow: var(--shadow);
}
.meters { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.meters li { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(60px, 1fr) auto; gap: 12px; align-items: center; }
.m-name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.m-extra { display: block; font-weight: 500; font-size: 12px; color: var(--good); }
.m-track { height: 8px; border-radius: 4px; background: var(--accent-soft); overflow: hidden; }
.m-fill { height: 100%; border-radius: 4px; background: var(--accent); width: 0; }
.m-val { text-align: right; font-weight: 700; white-space: nowrap; }
@media (max-width: 820px) {
  .meters li { grid-template-columns: minmax(0, 1fr) auto; row-gap: 4px; }
  .m-track { grid-column: 1 / -1; grid-row: 2; }
}

/* ---------- marketing: Instagram posts ---------- */
.post { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 14px; padding: 14px 0; border-top: 1px solid var(--border); }
.post:first-of-type { border-top: 0; padding-top: 4px; }
.thumb { width: 76px; height: 95px; border-radius: 10px; object-fit: cover; background: var(--surface-2); }
.post-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 2px; }
.post-main .title { font-weight: 600; margin: 2px 0 6px; }
.pstats { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 6px 0; }
.pstat { display: grid; line-height: 1.2; }
.pstat b { font-size: 17px; }
.pstat span { font-size: 12px; color: var(--muted); }
@media (max-width: 820px) {
  .post { grid-template-columns: 60px minmax(0, 1fr); gap: 10px; }
  .thumb { width: 60px; height: 75px; }
  .pstats { gap: 6px 12px; }
}

/* ---------- content: planned posts ---------- */
.content-grid { display: grid; grid-template-columns: minmax(0, 260px) minmax(0, 1fr); gap: 18px; align-items: start; }
.content-grid > div:only-child { grid-column: 1 / -1; }
.preview { width: 100%; max-width: 260px; aspect-ratio: 9 / 16; object-fit: cover; border-radius: 12px; background: #000; display: block; }
textarea.caption { width: 100%; font: 14px/1.5 var(--font); color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; resize: vertical; margin: 4px 0 10px; }
.when { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.when label { display: grid; gap: 4px; }
.when input { font: 14px var(--font); color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; color-scheme: inherit; }
.content-post h2 { margin: 4px 0 10px; }
.content-post .msg { white-space: pre-wrap; background: var(--surface-2); border-radius: 10px; padding: 12px 14px; font-size: 14px; margin: 6px 0 10px; }
label.btn { cursor: pointer; }
@media (max-width: 820px) { .content-grid { grid-template-columns: 1fr; } .preview { max-width: 100%; max-height: 70vh; margin: 0 auto; } }
