/* Engine app styles. Mobile first: the base rules are for a phone, wider screens add columns. All touch targets are at least 44px.
   No inline styles are used anywhere in the app (the content security policy forbids them). */
:root {
    --bg: #020e1c;
    --panel: #0a1c30;
    --panel-2: #10263f;
    --line: #234160;
    --text: #f5efe0;
    --muted: #a9b6c6;
    --accent: #c9a24b;
    --accent-text: #1a1204;
    --warn: #e0a23a;
    --radius: 8px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body { margin: 0; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, "Segoe UI", sans-serif; line-height: 1.5; }

a { color: var(--accent); }

h1 { font-size: 1.5rem; margin: 0 0 .5rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .5rem; color: var(--muted); }

.boot { padding: 2rem; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- shell ---------- */
.shell__bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding: .5rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.shell__brand { font-weight: 700; letter-spacing: .08em; text-transform: uppercase; text-decoration: none; color: var(--text); min-height: 44px; display: inline-flex; align-items: center; }
.shell__nav { display: flex; gap: .25rem; flex: 1 1 auto; }
.shell__nav a { color: var(--muted); text-decoration: none; padding: 0 .75rem; min-height: 44px; display: inline-flex; align-items: center; border-radius: var(--radius); }
.shell__nav a.active { color: var(--text); background: var(--panel-2); }
.shell__user { display: flex; align-items: center; gap: .5rem; margin-left: auto; flex-wrap: wrap; }
.shell__who { color: var(--muted); max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shell__main { max-width: 80rem; margin: 0 auto; padding: 1rem; }

/* ---------- pieces ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.badge { border: 1px solid var(--accent); color: var(--accent); border-radius: 999px; padding: .1rem .6rem; font-size: .8rem; }
.badge--preview { color: var(--text); border-color: var(--muted); }
.notice { background: var(--panel-2); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: .6rem .8rem; margin: 0 0 1rem; }
.notice--warn { border-left-color: var(--warn); }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 1rem; border-radius: var(--radius); border: 1px solid var(--line); background: transparent; color: var(--text); text-decoration: none; font: inherit; cursor: pointer; }
.btn--primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.btn--quiet { color: var(--muted); }

/* ---------- lock screen ---------- */
.lock { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.lock__card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; max-width: 26rem; width: 100%; }
.lock__actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0; }
.lock__note { color: var(--muted); font-size: .9rem; margin: 0; }

/* ---------- overview ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin: 1rem 0; }
.tile { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; }
.tile dt { color: var(--muted); font-size: .85rem; }
.tile dd { margin: 0; font-size: 1.5rem; font-weight: 700; }

.bars { width: 100%; border-collapse: collapse; }
.bars th, .bars td { text-align: left; padding: .3rem .25rem; border-bottom: 1px solid var(--line); font-weight: 400; }
.bars thead th { color: var(--muted); font-size: .85rem; }
.bars meter { width: min(60%, 18rem); height: 1rem; vertical-align: middle; }

@media (min-width: 40rem) {
    .tiles { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 64rem) {
    .tiles { grid-template-columns: repeat(5, 1fr); }
}

/* ---------- lists, records and boards (E2) ---------- */
.muted { color: var(--muted); }
.field { display: grid; gap: .25rem; color: var(--muted); font-size: .85rem; }
.field input, .field select { min-height: 44px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel-2); color: var(--text); padding: 0 .6rem; font: inherit; }
.filters { display: grid; gap: .75rem; margin: 1rem 0; }
.table-wrap { overflow-x: auto; }
.data { width: 100%; border-collapse: collapse; min-width: 40rem; }
.data th, .data td { text-align: left; padding: .5rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; font-weight: 400; }
.data thead th { color: var(--muted); font-size: .85rem; }
.pager { display: flex; gap: .5rem; margin-top: 1rem; }
.facts { display: grid; grid-template-columns: 1fr; gap: .5rem; margin: .5rem 0 1rem; }
.facts dt { color: var(--muted); font-size: .85rem; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.plain { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .4rem; }
.board { display: grid; grid-template-columns: 1fr; gap: .75rem; margin-bottom: 1rem; }
.stage { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; }
.stage h3 { margin: 0; font-size: 1rem; }

@media (min-width: 40rem) {
    .filters { grid-template-columns: 1fr 14rem auto; align-items: end; }
    .facts { grid-template-columns: repeat(2, 1fr); }
    .board { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 64rem) {
    .facts { grid-template-columns: repeat(3, 1fr); }
    .board { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- Mail Flow (E3) ---------- */
.subnav { display: flex; flex-wrap: wrap; gap: .25rem; margin: .5rem 0 1rem; border-bottom: 1px solid var(--line); padding-bottom: .5rem; }
.subnav a { color: var(--muted); text-decoration: none; padding: 0 .75rem; min-height: 44px; display: inline-flex; align-items: center; border-radius: var(--radius); }
.subnav a.active { color: var(--text); background: var(--panel-2); }
.pill { border-radius: 999px; padding: .05rem .6rem; font-size: .8rem; border: 1px solid var(--line); }
.pill--good { color: #4fae7c; border-color: #4fae7c; }
.pill--bad { color: #d65c5c; border-color: #d65c5c; }
.pill--neutral { color: var(--muted); }
.wrap { overflow-wrap: anywhere; word-break: break-all; }
.compose { display: grid; gap: .75rem; max-width: 40rem; }
.compose textarea { border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel-2); color: var(--text); padding: .6rem; font: inherit; resize: vertical; }

/* ---------- Broadcasts (E4) ---------- */
input[type="radio"], input[type="checkbox"] { min-height: auto; width: auto; margin-right: .5rem; }
fieldset.field { border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem .75rem; }
fieldset.field label { display: flex; align-items: center; gap: .25rem; min-height: 44px; color: var(--text); font-size: 1rem; }
label:has(> input[type="checkbox"]) { display: flex; align-items: center; min-height: 44px; gap: .25rem; }
code { background: var(--panel-2); padding: 0 .3rem; border-radius: 4px; }

/* Text campaigns: the opening text shown as it will be sent, and one waiting reply as a card */
.sms-preview { white-space: pre-wrap; background: var(--panel-2); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: .6rem .8rem; margin: .5rem 0; }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; margin: .75rem 0; }
.card h3 { margin: 0 0 .25rem; }
