/* FlightPlan Online palette, shared with the desktop apps. */
:root {
  --primary: #008b38;
  --primary-hover: #006e2d;
  --navy: #071747;
  --page: #edf9f2;
  --bar: #e4f4ea;
  --border: #dce5eb;
  --card-border: #e9ecef;
  --muted: #345b83;
  --success: #128c3c;
  --warning: #fd7e14;
  --danger: #dc3545;
  --selection: #d1ecdb;
  --sidebar: #0b4a26;
  --sidebar-text: #c4e0d7;
  --sidebar-line: #186c3c;
  --sidebar-accent: #a9f2b8;
  --wallpaper: #efeae2;
  --bubble-out: #d9fdd3;
  --nav-height: 58px;
  --faint: #5f7894;
  --grid: #edf0f2;
  --row-hover: #f5fbf7;
  /* Delivery outcome: one green ramp, light to dark = sent, delivered, read (checked for contrast and colour blindness). */
  --o-sent: #7cc596;
  --o-delivered: #2f9a59;
  --o-read: #0b6230;
  /* Contact states on the send page and the dashboard. */
  --s-ready: #008b38;   --s-ready-bg: #def4e6;
  --s-cooling: #b45f06; --s-cooling-bg: #fdf0e1;
  --s-done: #1b7fb0;    --s-done-bg: #dff1fb;
  --s-pending: #7a5af5; --s-pending-bg: #ece8fe;
  --s-failed: #c62f3e;  --s-failed-bg: #fde8e6;
  --s-talking: #0f7d86; --s-talking-bg: #ddf3f4;
  --s-optout: #5d6b7a;  --s-optout-bg: #eceff2;
  --s-never: #1b7fb0;
}

* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body { overflow: hidden; }
@supports (height: 100dvh) { html, body, #app { height: 100dvh; } }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 15px;
  color: var(--navy);
  background: var(--page);
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 18px; margin: 0 0 12px; }
h2 { font-size: 14px; margin: 18px 0 8px; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error { color: var(--danger); }
.hidden { display: none !important; }

/* ---- Controls ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 6px 14px; border-radius: 4px; cursor: pointer;
  border: 1px solid var(--border); background: #fff; color: var(--navy); white-space: nowrap; text-decoration: none;
}
.btn:hover { background: #e1f3e8; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], select, textarea {
  width: 100%; min-height: 38px; padding: 6px 10px; border: 1px solid #9aa7b4; border-radius: 4px; background: #fff;
}
textarea { resize: vertical; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--primary); flex: none; }
label.field { display: block; margin-bottom: 10px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 3px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .grow { flex: 1 1 180px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; background: var(--bar); color: var(--muted); }
.badge.sent, .badge.delivered { background: #def4e6; color: var(--success); }
.badge.read { background: #dff1fb; color: #1b7fb0; }
.badge.failed { background: #fde8e6; color: var(--danger); }
.badge.pending { background: #fff3e0; color: #b46900; }
.badge.optout { background: #fde8e6; color: var(--danger); }
.badge.optin { background: #dff1fb; color: #1b7fb0; }
.badge.count { background: var(--primary); color: #fff; }

/* ---- Login ---- */
.login { height: 100%; overflow-y: auto; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--sidebar); }
.login form { width: 100%; max-width: 360px; background: #fff; border-radius: 12px; padding: 24px; }
.login .brand { color: var(--navy); margin-bottom: 18px; }
.login .brand small { color: var(--primary); }

/* ---- Shell ---- */
.shell { display: flex; height: 100%; }
.sidebar { width: 208px; flex: none; background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.sidebar .brand { border-bottom: 1px solid var(--sidebar-line); margin-bottom: 14px; }
.brand .tile { width: 40px; height: 40px; border-radius: 10px; background: #fff; display: grid; place-items: center; flex: none; }
.brand .tile svg { width: 22px; height: 22px; stroke: var(--primary); }
.brand b { display: block; font-size: 19px; line-height: 1.1; color: #fff; letter-spacing: .3px; }
.brand small { display: block; font-size: 10.5px; font-weight: 700; color: var(--sidebar-accent); letter-spacing: .4px; }
.login .brand b { color: var(--navy); }
.nav a {
  display: flex; align-items: center; gap: 12px; margin: 2px 10px; padding: 9px 12px; border-radius: 9px;
  color: var(--sidebar-text); text-decoration: none; position: relative;
}
.nav a svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.7; flex: none; }
.nav a.active { background: var(--primary); color: #fff; font-weight: 700; }
.nav a .dot { margin-left: auto; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100%; }
.topbar { display: none; }
.page { flex: 1; min-height: 0; overflow-y: auto; padding: 20px; -webkit-overflow-scrolling: touch; }
.page.flush { padding: 0; overflow: hidden; }

/* ---- Cards and lists ---- */
.card { background: #fff; border: 1.4px solid var(--card-border); border-radius: 10px; padding: 16px; }
/* ---- Shared by the dashboard and the send page ---- */
.num { font-variant-numeric: tabular-nums; }
.faint { color: var(--faint); }
.warn-text { color: #b45f06; font-weight: 600; }
.ok-text { color: var(--success); font-weight: 600; }
.card > h2:first-child { margin-top: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card-head a { color: var(--primary); font-weight: 600; text-decoration: none; }
.card-head a:hover { text-decoration: underline; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.legend .line i { height: 0; width: 14px; border-top: 2px dashed var(--muted); border-radius: 0; vertical-align: 3px; }
.btn.slim { min-height: 30px; padding: 3px 10px; font-size: 13px; }
.scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 7px 8px; border-bottom: 1.4px solid var(--card-border); white-space: nowrap; }
table.data th.sort { cursor: pointer; }
table.data th.sort.on, table.data th.sort:hover { color: var(--navy); }
table.data td { padding: 8px; border-bottom: 1px solid var(--card-border); }
table.data .r { text-align: right; }
table.data tr:hover td { background: var(--row-hover); }

/* ---- Dashboard ---- */
.dash, .planner { max-width: 1240px; }
.dash-head, .plan-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; margin-bottom: 16px; }
.dash-head h1, .plan-head h1 { margin: 0; }
.dash-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; padding: 6px 14px; cursor: pointer; min-height: 36px; }
.seg button.on { background: var(--navy); color: #fff; }
.attention { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.act { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 10px; background: #fff; border: 1.4px solid var(--card-border); color: var(--navy); text-decoration: none; min-width: 0; }
.act:hover { background: var(--row-hover); }
.act .ico { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; }
.act .ico svg { width: 18px; height: 18px; }
.ico.info { background: #e3effb; color: #1b6fb0; }
.ico.warn { background: #fff2dc; color: #b45f06; }
.ico.bad { background: #fde8e6; color: var(--danger); }
.ico.good { background: #e2f5e2; color: var(--success); }
.act .txt { min-width: 0; }
.act b { display: block; font-size: 20px; line-height: 1.1; }
.act b.calm { color: var(--faint); }
.act .lbl { display: block; font-size: 13px; font-weight: 600; }
.act .sub { display: block; font-size: 11.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi .label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi .value { font-size: 28px; font-weight: 700; line-height: 1.15; margin: 4px 0 2px; }
.kpi .delta { font-size: 12px; display: flex; align-items: center; gap: 4px; }
.kpi .delta.good { color: var(--success); }
.kpi .delta.bad { color: var(--danger); }
.kpi .delta.flat { color: var(--faint); }
.kpi .explain { font-size: 11.5px; color: var(--faint); margin-top: 2px; }
.dash-row { display: grid; gap: 14px; margin-bottom: 14px; align-items: start; }
.dash-row.wide-side { grid-template-columns: minmax(0, 1fr) 320px; }
.dash-row.halves { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { fill: var(--faint); font-size: 11px; font-family: inherit; }
.tip { position: absolute; top: 6px; pointer-events: none; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; box-shadow: 0 6px 18px rgba(7, 23, 71, .14); opacity: 0; transition: opacity .1s; min-width: 170px; z-index: 5; }
.tip.show { opacity: 1; }
.tip .t { font-weight: 700; margin-bottom: 4px; }
.tip .r { display: flex; justify-content: space-between; gap: 14px; }
.tip .r i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }
.tip .sum { margin-top: 4px; border-top: 1px solid var(--card-border); padding-top: 4px; }
.big-line { margin-top: 10px; }
.big { font-size: 30px; font-weight: 700; line-height: 1.1; }
.meter { height: 12px; border-radius: 6px; background: var(--bar); overflow: hidden; margin: 10px 0 6px; }
.meter span { display: block; height: 100%; border-radius: 6px; }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; padding: 6px 0; border-top: 1px solid var(--card-border); }
.card > h2 + .kv { border-top: 0; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 10px; white-space: nowrap; }
.pill svg { width: 12px; height: 12px; }
.pill.good { background: #e2f5e2; color: var(--success); }
.pill.warn { background: #fff2dc; color: #b45f06; }
.pill.bad { background: #fde8e6; color: var(--danger); }
.fun { display: grid; grid-template-columns: 100px minmax(0, 1fr) 96px; gap: 10px; align-items: center; margin: 7px 0; font-size: 13px; }
.fun .track { height: 22px; background: var(--bar); border-radius: 4px; overflow: hidden; }
.fun .track span { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.fun .v { text-align: right; }
.fun .v small { display: block; color: var(--faint); font-size: 11.5px; }
.aud-bar, .dist { display: flex; gap: 2px; height: 14px; border-radius: 4px; overflow: hidden; background: var(--bar); margin: 10px 0 12px; }
.aud-bar span, .dist span { height: 100%; }
.aud { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 16px; }
.aud div { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 0; }
.aud-optin { display: flex; justify-content: space-between; align-items: center; font-size: 13px; padding: 8px 0 0; margin-top: 6px; border-top: 1px solid var(--card-border); }
.aud i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.rate { display: inline-flex; align-items: center; gap: 8px; }
.rate .mini { width: 56px; height: 6px; background: var(--bar); border-radius: 3px; overflow: hidden; }
.rate .mini span { display: block; height: 100%; background: var(--o-read); }

/* ---- Send campaign (planner) ---- */
.plan-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.plan-controls label.field { margin: 0; min-width: 240px; }
.plan-controls label.field.narrow { min-width: 0; width: 130px; }
.states { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.state { text-align: left; border: 1.4px solid var(--card-border); border-left: 5px solid var(--c); background: #fff; border-radius: 10px; padding: 10px 12px; cursor: pointer; min-width: 0; color: var(--navy); }
.state:hover { background: var(--row-hover); }
.state.active { outline: 2px solid var(--c); outline-offset: -1px; }
.state .n { font-size: 24px; font-weight: 700; color: var(--c); line-height: 1.1; }
.state .label { font-weight: 600; font-size: 13.5px; }
.state .hint { font-size: 11.5px; color: var(--faint); }
.plan-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 14px; align-items: start; }
.plan-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.chips { gap: 6px; }
.chip { border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 4px 12px; font-size: 13px; cursor: pointer; }
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.ptable { width: 100%; border-collapse: collapse; }
.ptable th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1.4px solid var(--card-border); white-space: nowrap; }
.ptable th.sort { cursor: pointer; }
.ptable th.sort:hover { color: var(--navy); }
.ptable td { padding: 9px 10px; border-bottom: 1px solid var(--card-border); vertical-align: middle; font-size: 14px; }
.ptable tr:hover td { background: var(--row-hover); }
.ptable tr.sel td { background: var(--selection); }
.ptable .cb { width: 34px; }
.ptable .name { font-weight: 600; }
.ptable .phone, .ptable .why { font-size: 12px; color: var(--faint); }
.ptable .phone { font-variant-numeric: tabular-nums; }
.sbadge { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; font-weight: 600; color: var(--c); background: var(--cb); white-space: nowrap; }
.more { text-align: center; padding: 12px 0 0; }
.rule { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--card-border); cursor: pointer; }
.card > h2 + .rule { border-top: 0; }
.rule input { margin-top: 2px; }
.rule b { display: block; font-weight: 600; font-size: 14px; }
.rule .small { display: block; color: var(--faint); }
.plan-row { display: grid; grid-template-columns: 76px minmax(0, 1fr) 40px; gap: 8px; align-items: center; font-size: 12.5px; margin: 4px 0; }
.plan-row .bar { height: 14px; background: var(--bar); border-radius: 4px; overflow: hidden; display: flex; }
.plan-row .bar i { display: block; height: 100%; }
.plan-row .num { text-align: right; }
.plan-row.today span:first-child { font-weight: 700; }
.planner .legend { margin-top: 10px; font-size: 11.5px; }
.plan-foot { position: sticky; bottom: -20px; margin: 14px -20px -20px; padding: 12px 20px; background: #fff; border-top: 1.4px solid var(--card-border); box-shadow: 0 -4px 18px rgba(7, 23, 71, .07); display: flex; gap: 12px; align-items: center; z-index: 4; }
.plan-foot .grow { flex: 1; }
.sel-count { font-size: 18px; font-weight: 700; }
ul.review { margin: 0 0 12px; padding-left: 18px; }
ul.review li { margin: 4px 0; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .attention { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .states { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .dash-row.wide-side, .dash-row.halves, .plan-grid { grid-template-columns: minmax(0, 1fr); }
}
.list { background: #fff; border: 1.4px solid var(--card-border); border-radius: 10px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--card-border); }
.row:last-child { border-bottom: 0; }
.row .body { flex: 1; min-width: 0; }
.row .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .side { text-align: right; font-size: 12.5px; color: var(--muted); flex: none; }
.row .side.row-actions { display: flex; align-items: center; gap: 10px; }
.row-actions .btn { min-width: 96px; }
.row-actions .btn.optin { color: #1b7fb0; }
.row.clickable { cursor: pointer; }
.row.clickable:hover, .row.selected { background: var(--selection); }
.empty-note { padding: 24px; text-align: center; color: var(--muted); }
.log { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 10px; font: 12.5px Consolas, monospace; white-space: pre-wrap; max-height: 260px; overflow-y: auto; }
progress { width: 100%; height: 10px; accent-color: var(--primary); }
.notice { background: #fff3e0; border: 1px solid #ffd9a8; color: #7a4a00; border-radius: 6px; padding: 10px 12px; margin-bottom: 12px; }

/* ---- WhatsApp-style message preview and chat ---- */
.wallpaper { background: var(--wallpaper); border-radius: 8px; padding: 16px; }
.bubble { background: #fff; border: 1px solid #ded8cf; border-radius: 8px; max-width: 330px; overflow: hidden; }
.bubble img { display: block; width: calc(100% - 8px); margin: 4px; border-radius: 6px; }
.bubble .media-missing { margin: 4px; border-radius: 6px; background: #d9dee0; color: #8696a0; height: 150px; display: grid; place-items: center; font-size: 13px; text-align: center; padding: 10px; }
.bubble .text { padding: 6px 10px 2px; white-space: pre-wrap; overflow-wrap: anywhere; color: #111b21; }
.bubble .head { font-weight: 700; }
.bubble .foot { display: flex; justify-content: space-between; gap: 10px; padding: 2px 10px 8px; font-size: 12.5px; color: #8696a0; }
.bubble .wa-button { border-top: 1px solid #e9edef; text-align: center; padding: 10px; color: #008069; }
.chat-layout { display: flex; height: 100%; }
.chat-list { width: 380px; flex: none; display: flex; flex-direction: column; border-right: 1px solid var(--border); background: #fff; }
.chat-list .toolbar { padding: 12px; margin: 0; border-bottom: 1px solid var(--card-border); }
.chat-list .scroll { flex: 1; overflow-y: auto; }
/* Archived chats: a tray pinned under the active ones, closed until opened; open, it scrolls on its own. */
.archive-tray { flex: none; max-height: 55%; overflow-y: auto; border-top: 1.4px solid var(--border); background: var(--page); box-shadow: 0 -4px 12px rgba(7, 23, 71, .06); }
.archive-tray > summary { position: sticky; top: 0; z-index: 1; background: var(--page); display: flex; align-items: center; gap: 8px; padding: 12px 14px; cursor: pointer; list-style: none; font-weight: 600; color: var(--muted); user-select: none; }
.archive-tray > summary::-webkit-details-marker { display: none; }
.archive-tray > summary::before { content: '\25B8'; transition: transform .15s; }
.archive-tray[open] > summary::before { transform: rotate(90deg); }
.archive-tray .archive-search { padding: 0 12px 10px; }
.archive-tray .row { background: #fff; }
.chat-list .match { font-style: italic; }
.chat-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #fff; border-bottom: 1px solid var(--border); }
.chat-head .who { flex: 1; min-width: 0; }
.chat-head .who .title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .who .sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .back { display: none; padding: 0; width: 38px; flex: none; }
.chat-head .back svg { width: 20px; height: 20px; stroke: currentColor; }
.chat-actions { display: flex; gap: 8px; flex: none; }
.thread { flex: 1; overflow-y: auto; background: var(--wallpaper); padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.day-pill { align-self: center; background: #e1f2fa; color: #8696a0; font-size: 12px; padding: 2px 10px; border-radius: 6px; margin: 6px 0; }
.msg { max-width: min(78%, 520px); padding: 6px 10px 4px; border-radius: 8px; border: 1px solid #ded8cf; background: #fff; align-self: flex-start; white-space: pre-wrap; overflow-wrap: anywhere; color: #111b21; }
.msg.out { align-self: flex-end; background: var(--bubble-out); }
.msg.template { font-style: italic; }
.msg.has-media { padding: 4px 4px 4px; }
.msg .media img, .msg .media video { display: block; max-width: min(320px, 100%); max-height: 360px; border-radius: 6px; background: #e9edef; }
.msg .media img.sticker { max-width: 160px; background: transparent; }
.msg .media audio { display: block; max-width: 280px; }
.msg .caption { padding: 4px 6px 0; }
.msg .media-doc { display: inline-block; padding: 6px 8px; color: var(--navy); font-weight: 600; text-decoration: none; }
.msg .media-doc:hover { text-decoration: underline; }
.msg .media-gone { padding: 6px 8px; color: var(--muted); font-style: italic; }
.msg.has-media .meta { padding: 0 6px; }
.msg .meta { display: block; text-align: right; font-size: 11.5px; color: #8696a0; font-style: normal; margin-top: 2px; }
.msg .meta .read { color: #53bdeb; }
.msg .meta .failed { color: var(--danger); }
.msg-note { font-size: 12px; color: var(--muted); }
.msg-note.out { align-self: flex-end; color: var(--danger); }
.compose { background: var(--bar); padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); }
.compose .hint { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.compose .line { display: flex; gap: 8px; align-items: flex-end; }
.compose textarea { min-height: 44px; max-height: 140px; }
.window { font-size: 12px; font-weight: 600; }
.window.ok { color: var(--success); } .window.soon { color: var(--warning); } .window.urgent { color: var(--danger); } .window.closed { color: var(--muted); font-weight: 400; }

/* ---- Dialog ---- */
.overlay { position: fixed; inset: 0; background: rgba(7, 23, 71, .45); display: grid; place-items: center; padding: 16px; z-index: 20; }
.dialog { background: #fff; border-radius: 12px; padding: 20px; width: 100%; max-width: 420px; max-height: 90vh; overflow-y: auto; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-height) + 20px); transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 30; max-width: 90vw; }

/* ---- Phones ---- */
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; order: 2; padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--sidebar-line); }
  .sidebar .brand { display: none; }
  .nav { display: flex; width: 100%; }
  .nav a { flex: 1; flex-direction: column; gap: 2px; margin: 0; padding: 7px 2px; border-radius: 0; font-size: 10.5px; min-height: var(--nav-height); justify-content: center; }
  .nav a.active { background: transparent; color: #fff; }
  .nav a.active svg { stroke: var(--sidebar-accent); }
  .nav a .dot { position: absolute; top: 4px; right: calc(50% - 22px); margin: 0; }
  .main { order: 1; min-height: 0; }
  .topbar { display: flex; background: var(--sidebar); padding-top: env(safe-area-inset-top); }
  .topbar .brand { padding: 8px 14px; }
  .topbar .brand .tile { width: 32px; height: 32px; border-radius: 8px; }
  .topbar .brand b { font-size: 16px; }
  .page { padding: 14px; }
  .chat-list { width: 100%; border-right: 0; }
  .chat-layout.open .chat-list { display: none; }
  .chat-layout:not(.open) .chat-pane { display: none; }
  .chat-head { flex-wrap: wrap; gap: 8px 10px; padding: 8px 10px; }
  .chat-head .back { display: inline-flex; }
  /* Name and number on the first line; the buttons drop to a line of their own underneath. */
  .chat-actions { flex-basis: 100%; }
  .chat-actions:empty { display: none; }
  .chat-actions .btn { flex: 1; min-height: 34px; }
  .toast { bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 16px); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .value { font-size: 23px; }
  .attention, .aud { grid-template-columns: minmax(0, 1fr); }
  .states { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .state .n { font-size: 20px; }
  .fun { grid-template-columns: 80px minmax(0, 1fr) 80px; }
  .hide-sm { display: none; }
  /* Contact rows: the buttons get the room; the last-sent date shows on wider screens only. */
  .row-actions { gap: 6px; }
  .row-actions .when { display: none; }
  .row-actions .btn { min-width: 0; padding: 3px 8px; }
  .plan-controls label.field { min-width: 0; flex: 1 1 100%; }
  .plan-controls label.field.narrow { flex: 1 1 40%; }
  .plan-foot { bottom: -14px; margin: 14px -14px -14px; padding: 10px 14px; }
  /* Contacts become cards: tick box on the left, details stacked. */
  .ptable thead { display: none; }
  .ptable, .ptable tbody, .ptable tr, .ptable td { display: block; width: 100%; }
  .ptable tr { position: relative; padding: 10px 0 10px 34px; border-bottom: 1px solid var(--card-border); }
  .ptable td { border: 0; padding: 2px 0; }
  .ptable td.cb { position: absolute; left: 0; top: 12px; width: auto; }
  .ptable td.col-last::before { content: "Last message: "; color: var(--faint); font-size: 12px; }
  .ptable td.col-this::before { content: "This template: "; color: var(--faint); font-size: 12px; }
  .ptable td.col-next::before { content: "Can send: "; color: var(--faint); font-size: 12px; }
  .ptable td.col-last .why { display: inline; margin-left: 6px; }
  .ptable tr:hover td, .ptable tr.sel td { background: transparent; }
  .ptable tr.sel { background: var(--selection); }
}
