/* Shared styles for the Admin and Control Tower apps. Palette follows info.alertaa.app. */
:root {
  --red01: #a20d32; --red02: #cd2b2c; --accent: #fa9379; --dark: #4a1225;
  --bg: #ffffff; --surface: #f6f5f2; --text: #1f1416; --muted: #5e5254; --line: #dddad3;
  --link: var(--red01); --focus: #1a6fd1;
  --ok: #2e7d4f; --warn: #b26a00; --info: #2f5f9e; --bad: var(--red02);
  --phase-active: #cd2b2c; --phase-upcoming: #e0a020; --phase-pending: #2f5f9e;
  --phase-done: #8a7f81;
  --radius: 10px; --shadow: 0 1px 3px rgba(31, 20, 22, .12);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a0b10; --surface: #2a1219; --text: #f4eeee; --muted: #c9b9bc; --line: #4a2a33; --link: var(--accent);
    --ok: #6cc28f; --warn: #f0b04a; --info: #8db4ea; --phase-pending: #6f9fe0; --phase-done: #a59a9c;
    --shadow: 0 1px 3px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 Arial, Helvetica, sans-serif; }
a { color: var(--link); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

/* App shell */
.topbar { display: flex; align-items: center; gap: 12px; padding: 0 16px; height: 56px; background: var(--dark); color: #fff; border-bottom: 3px solid var(--red02); }
.topbar .brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; min-width: 0; }
.topbar .brand img { height: 42px; width: auto; display: block; }
.topbar .brand small { font-size: 14px; opacity: .85; padding-left: 10px; border-left: 1px solid rgba(255,255,255,.35); }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 13px; opacity: .9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
.topbar .short { display: none; }
.topbar button { white-space: nowrap; background: transparent; border: 1px solid rgba(255,255,255,.5); color: #fff; border-radius: 999px; padding: 4px 12px; cursor: pointer; }

.tabs { display: flex; gap: 4px; padding: 0 12px; border-bottom: 1px solid var(--line); background: var(--surface); overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 12px 14px; cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; color: var(--muted); font-weight: 700; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--red02); }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--red02); color: #fff; font-size: 12px; line-height: 20px; text-align: center; margin-left: 6px; }

/* Split view: list + map */
.split { display: grid; grid-template-columns: minmax(300px, 420px) 1fr; height: calc(100vh - 56px - 47px); }
.split.full { height: calc(100vh - 56px); }
.split .list { overflow-y: auto; border-right: 1px solid var(--line); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.split .map { position: relative; min-height: 300px; }
@media (max-width: 760px) {
  .split, .split.full { grid-template-columns: 1fr; grid-template-rows: 45vh auto; height: auto; }
  .split .map { order: -1; }
  .split .list { border-right: 0; }
}
.page { padding: 16px; max-width: 1100px; }

/* Cards */
.card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); cursor: pointer; }
.card.selected { border-color: var(--red02); box-shadow: 0 0 0 2px var(--red02); }
.card h3 { margin: 0 0 4px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.card .meta { color: var(--muted); font-size: 13px; }
.card .info { margin: 6px 0 0; font-size: 14px; white-space: pre-wrap; }
.card .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.card textarea { width: 100%; margin-top: 8px; }
.empty { color: var(--muted); text-align: center; padding: 32px 12px; }

.phase { display: inline-block; font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 999px; color: #fff; background: var(--phase-done); white-space: nowrap; }
.phase.active { background: var(--phase-active); }
.phase.upcoming { background: var(--phase-upcoming); color: #1f1416; }
.phase.pending { background: var(--phase-pending); }
.tag { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; }

/* Buttons and forms */
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px 14px; cursor: pointer; font-weight: 700; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn.primary { background: var(--red02); border-color: var(--red02); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn:disabled { opacity: .55; cursor: default; }
input[type=text], input[type=email], input[type=number], input[type=date], input[type=datetime-local], input[type=search], select, textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: var(--bg); min-width: 0;
}
label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.msg { font-size: 14px; margin: 8px 0 0; }
.msg.error { color: var(--bad); }
.msg.ok { color: var(--ok); }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--surface); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface); }
code.secret { display: block; padding: 10px; background: var(--surface); border: 1px dashed var(--red02); border-radius: 8px; word-break: break-all; margin: 8px 0; }

section.block { margin-bottom: 28px; }
section.block h2 { font-size: 18px; margin: 0 0 4px; }
section.block p.lead { color: var(--muted); margin: 0 0 12px; font-size: 14px; }

/* Login */
.login { max-width: 380px; margin: 10vh auto; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); box-shadow: var(--shadow); }
.login-logo img { display: block; width: 100%; max-width: 260px; height: auto; margin: 0 auto 16px; }
.login h1 { font-size: 20px; margin: 0 0 4px; }
.login p { color: var(--muted); margin: 0 0 16px; font-size: 14px; }
.login form { display: flex; flex-direction: column; gap: 12px; }
.login input { width: 100%; }
.login .code { font-size: 22px; letter-spacing: .3em; text-align: center; }

/* Video modal */
.video-modal { width: min(960px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 0; border-radius: var(--radius); background: var(--bg); color: var(--text); box-shadow: 0 8px 32px rgba(0, 0, 0, .4); }
.video-modal::backdrop { background: rgba(20, 8, 12, .7); }
.video-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.video-head h2 { margin: 0; font-size: 16px; }
.video-modal video { display: block; width: 100%; max-height: calc(100vh - 120px); background: #000; }
.video-modal .msg { padding: 24px 14px; margin: 0; }
@media (max-width: 560px) {
  .topbar .who, .topbar .brand small, .topbar .long { display: none; }
  .topbar .short { display: inline; }
  .topbar .brand img { height: 34px; }
  /* iOS Safari zooms into any focused field under 16px. */
  input, select, textarea { font-size: 16px; }
}

/* Toast */
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 50; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.toast.error { background: var(--bad); color: #fff; }

/* Map overlays */
.map-legend { position: absolute; left: 10px; bottom: 28px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 12px; display: flex; gap: 10px; z-index: 2; }
.map-legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; background: var(--c); vertical-align: -1px; }
.maplibregl-popup-content { color: #1f1416; font: 13px/1.4 Arial, sans-serif; }
