:root {
  --navy: #12344b;
  --navy-2: #0a2639;
  --teal: #18788b;
  --teal-soft: #e5f4f6;
  --paper: #f4f6f5;
  --surface: #ffffff;
  --ink: #17232b;
  --muted: #60717c;
  --line: #d5dee2;
  --yellow: #f5cf48;
  --yellow-soft: #fff8d7;
  --red: #cb3347;
  --red-soft: #fde8eb;
  --green: #16835a;
  --green-soft: #e4f5ed;
  --orange: #d56b27;
  --shadow: 0 10px 30px rgba(20, 48, 65, .08);
  --radius: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--paper); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .6; }
.disabled-link { pointer-events: none; opacity: .55; }

.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 100; padding: .75rem 1rem; background: white; color: var(--navy); border-radius: 8px; }
.skip-link:focus { top: 1rem; }
.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.site-header { display: flex; align-items: center; gap: 1rem; padding: 1.1rem max(1.25rem, calc((100vw - 1180px) / 2)); color: white; background: var(--navy-2); border-bottom: 4px solid var(--teal); }
.brand-mark { display: grid; place-items: center; width: 52px; height: 52px; flex: 0 0 52px; border: 2px solid rgba(255,255,255,.65); border-radius: 50%; font-weight: 900; letter-spacing: -.06em; }
.eyebrow, .section-kicker { margin: 0 0 .25rem; font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.site-header .eyebrow { color: #aad4dc; }
.site-header h1 { margin: 0; font-size: clamp(1.3rem, 3vw, 1.8rem); letter-spacing: -.02em; }
.header-actions { display: flex; gap: .6rem; margin-left: auto; }

.app-shell { width: min(1180px, calc(100% - 2rem)); margin: 1.25rem auto 3rem; }
.panel { padding: clamp(1.1rem, 3vw, 1.65rem); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel + .panel, .workspace + .panel, .panel + .workspace { margin-top: 1rem; }

.status-strip { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; padding: .85rem 1rem; background: var(--navy); color: white; border-radius: 12px; }
.status-main, .status-actions { display: flex; align-items: center; gap: .75rem; }
.status-main strong, .status-main span { display: block; }
.status-main span { margin-top: .1rem; color: #bed0d9; font-size: .82rem; }
.status-dot { width: 12px; height: 12px; flex: 0 0 12px; border-radius: 50%; box-shadow: 0 0 0 4px rgba(255,255,255,.1); }
.status-dot.live { background: #48dc97; }
.status-dot.checking { background: var(--yellow); animation: pulse 1.3s infinite; }
.status-dot.stale { background: #ff6477; }
@keyframes pulse { 50% { opacity: .45; } }
.count-badge { padding: .3rem .65rem; background: rgba(255,255,255,.12); border-radius: 999px; font-size: .8rem; font-weight: 800; }

.notice { margin-bottom: 1rem; padding: .9rem 1rem; border-radius: 10px; font-weight: 650; }
.notice.danger { color: #7f1827; background: var(--red-soft); border: 1px solid #efb8c0; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.section-heading.small { margin-bottom: 1.2rem; }
.section-actions { display: flex; align-items: center; gap: .75rem; }
.section-heading h2 { margin: 0; color: var(--navy); font-size: clamp(1.2rem, 2vw, 1.55rem); letter-spacing: -.02em; }
.section-kicker { color: var(--teal); }
.section-intro { margin: -.35rem 0 1.15rem; color: var(--muted); }

.button, .log-button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: .68rem 1rem; color: var(--navy); background: white; border: 1px solid #b7c7ce; border-radius: 9px; font-weight: 800; text-decoration: none; transition: transform .1s, background .1s, border-color .1s; }
.button:hover, .log-button:hover { background: #f2f7f8; border-color: #7595a2; }
.button:active, .log-button:active { transform: translateY(1px); }
.button.primary { color: white; background: var(--teal); border-color: var(--teal); }
.button.secondary { color: inherit; background: transparent; }
.site-header .button.secondary { color: white; border-color: rgba(255,255,255,.4); }
.button.compact { min-height: 34px; padding: .42rem .75rem; font-size: .82rem; }
.button.tiny { min-height: 30px; padding: .3rem .55rem; font-size: .75rem; white-space: nowrap; }
.text-button { padding: .25rem 0; color: var(--teal); background: none; border: 0; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }

.alerts-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: .8rem; }
.alert-card { width: 100%; padding: 1rem; text-align: left; color: var(--ink); background: var(--yellow-soft); border: 1px solid #d8bd52; border-left: 7px solid var(--yellow); border-radius: 12px; }
.alert-card.storm-warning, .alert-card.tornado-warning, .alert-card.cancel { background: var(--red-soft); border-color: #e49aa5; border-left-color: var(--red); }
.alert-card.storm-watch, .alert-card.tornado-watch { background: var(--yellow-soft); border-color: #d8bd52; border-left-color: var(--yellow); }
.alert-card.warning { background: var(--red-soft); border-color: #e49aa5; border-left-color: var(--red); }
.alert-card.watch { background: var(--yellow-soft); border-color: #d8bd52; border-left-color: var(--yellow); }
.alert-card:hover { box-shadow: 0 6px 16px rgba(20,48,65,.12); }
.alert-card.included { box-shadow: inset 0 0 0 2px var(--teal); }
.alert-card-top { display: flex; justify-content: space-between; gap: .75rem; margin-bottom: .65rem; }
.alert-event { color: var(--navy); font-weight: 900; }
.alert-until { color: var(--muted); font-size: .8rem; font-weight: 750; white-space: nowrap; }
.alert-area, .alert-headline { display: block; }
.alert-area { margin-bottom: .25rem; }
.alert-headline { color: var(--muted); font-size: .83rem; line-height: 1.4; }
.included-label { display: inline-block; margin-top: .65rem; padding: .22rem .5rem; color: #07586a; background: #d7f1f4; border-radius: 999px; font-size: .68rem; font-weight: 850; text-transform: uppercase; letter-spacing: .04em; }
.empty-state { display: flex; flex-direction: column; gap: .25rem; padding: 1.5rem; color: var(--muted); text-align: center; background: #f7f9f9; border: 1px dashed #bac8ce; border-radius: 12px; }
.compact-empty { padding: 1rem; }

.workspace { display: grid; grid-template-columns: minmax(0, 2fr) minmax(250px, .8fr); gap: 1rem; margin-top: 1rem; scroll-margin-top: 1rem; }
.training-banner { margin: -1.65rem -1.65rem 1.25rem; padding: .65rem 1rem; color: #5d3f00; background: #ffe69a; border-radius: var(--radius) var(--radius) 0 0; font-weight: 900; text-align: center; text-transform: uppercase; letter-spacing: .06em; }
.event-badge { padding: .35rem .65rem; color: #6b4e00; background: var(--yellow-soft); border-radius: 999px; font-size: .75rem; font-weight: 900; }
.event-badge.storm-warning, .event-badge.tornado-warning, .event-badge.cancel { color: #8b1a2a; background: var(--red-soft); }
.event-badge.warning { color: #8b1a2a; background: var(--red-soft); }
.event-badge.watch { color: #635000; background: var(--yellow-soft); }
.alert-facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; margin: 0 0 1.25rem; }
.fact { padding: .65rem .7rem; background: #f3f6f7; border-radius: 8px; }
.fact dt { margin-bottom: .2rem; color: var(--muted); font-size: .68rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.fact dd { margin: 0; font-size: .86rem; font-weight: 750; }
.field-label { display: block; margin: 1rem 0 .4rem; color: var(--navy); font-size: .82rem; font-weight: 850; }
input, textarea, select { width: 100%; color: var(--ink); background: white; border: 1px solid #b8c7ce; border-radius: 9px; outline: none; }
input, select { min-height: 42px; padding: .65rem .75rem; }
textarea { padding: .85rem; line-height: 1.55; resize: vertical; }
input:focus, textarea:focus, select:focus, button:focus-visible, a:focus-visible { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(24,120,139,.18); }
.field-help { margin: .4rem 0 0; color: var(--muted); font-size: .76rem; }
.print-message { display: none; }
.message-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }
.nixle-box { margin-top: 1.5rem; padding: 1rem; background: var(--teal-soft); border: 1px solid #b9dce2; border-radius: 12px; }
.facebook-box { margin-top: 1rem; padding: 1rem; background: #eef3ff; border: 1px solid #c6d4f2; border-radius: 12px; }
.nixle-heading-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: .7rem; }
.nixle-heading-row h3 { margin: 0; color: var(--navy); font-size: 1.05rem; }
.character-count { color: var(--green); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; white-space: nowrap; }
.character-count.near-limit { color: #9a4d00; }
#nixle-message { background: white; }
#facebook-message { background: white; }
.incident-meta { margin-top: 1.25rem; border-top: 1px solid var(--line); }
.incident-alert-count { margin: -.45rem 0 .8rem; color: var(--teal); font-size: .78rem; font-weight: 850; }
.incident-meta div { padding: .7rem 0; border-bottom: 1px solid var(--line); }
.incident-meta dt { color: var(--muted); font-size: .72rem; font-weight: 800; text-transform: uppercase; }
.incident-meta dd { margin: .2rem 0 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .76rem; overflow-wrap: anywhere; }

.save-state { color: var(--green); font-size: .78rem; font-weight: 800; }
.channel-list { display: grid; gap: .8rem; }
.channel-row { display: grid; grid-template-columns: 160px minmax(330px, .8fr) 1fr; align-items: start; gap: 1rem; padding: 1rem; background: #f8faf9; border: 1px solid var(--line); border-radius: 11px; }
.channel-name { margin: .7rem 0 0; color: var(--navy); font-size: .95rem; }
.channel-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: .45rem; }
.log-button { min-height: 38px; padding: .55rem .6rem; font-size: .78rem; }
.log-button.issued { color: #085c3e; border-color: #75b99c; background: var(--green-soft); }
.log-button.update { color: #675000; border-color: #d8bd52; background: var(--yellow-soft); }
.log-button.clear { color: #7d2431; border-color: #e1a5ae; background: var(--red-soft); }
.log-entries { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; min-height: 38px; }
.no-entries { color: #88969d; font-size: .78rem; font-style: italic; }
.log-chip { display: inline-flex; align-items: center; gap: .3rem; padding: .35rem .35rem .35rem .55rem; background: white; border: 1px solid var(--line); border-radius: 999px; font-size: .72rem; }
.log-chip.issued { border-color: #a6d5c1; }
.log-chip.update { border-color: #ead985; }
.log-chip.clear { border-color: #edbdc4; }
.remove-log, .icon-button { display: grid; place-items: center; width: 25px; height: 25px; padding: 0; color: var(--muted); background: transparent; border: 0; border-radius: 50%; font-size: 1rem; }
.remove-log:hover, .icon-button:hover { color: var(--red); background: var(--red-soft); }

.table-scroll { overflow-x: auto; }
.staff-table { width: 100%; border-collapse: collapse; }
.staff-table th { padding: .55rem; color: var(--muted); font-size: .7rem; text-align: left; text-transform: uppercase; letter-spacing: .06em; border-bottom: 2px solid var(--line); }
.staff-table td { padding: .55rem; border-bottom: 1px solid var(--line); }
.staff-table input { min-width: 140px; }
.time-entry { display: flex; align-items: center; gap: .5rem; min-width: 145px; }
.time-entry span { min-width: 68px; font-size: .78rem; font-weight: 700; }
.empty-table { color: var(--muted); text-align: center; }

.incident-history { display: grid; gap: .55rem; }
.history-item { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem; background: #f7f9f9; border-radius: 9px; }
.history-info strong, .history-info span { display: block; }
.history-info span { margin-top: .18rem; color: var(--muted); font-size: .76rem; }
.history-count { flex: 0 0 auto; color: var(--teal); font-size: .78rem; font-weight: 800; }
.history-actions { display: flex; align-items: center; gap: .7rem; }

footer { width: min(1180px, calc(100% - 2rem)); margin: 0 auto 2rem; color: var(--muted); font-size: .75rem; text-align: center; }
footer p { margin: .3rem; }
.safety-note { font-weight: 650; }
.noscript { position: fixed; inset: auto 0 0; padding: 1rem; color: white; background: var(--red); text-align: center; }
.sr-status { position: absolute; width: 1px; height: 1px; overflow: hidden; }

.app-dialog { width: min(1080px, calc(100% - 2rem)); max-height: calc(100vh - 2rem); padding: 0; color: var(--ink); background: white; border: 0; border-radius: 16px; box-shadow: 0 24px 70px rgba(0,0,0,.3); overflow: auto; }
.app-dialog::backdrop { background: rgba(6, 23, 34, .72); backdrop-filter: blur(3px); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.25rem 1.4rem .75rem; }
.dialog-heading h2 { margin: 0; color: var(--navy); font-size: 1.45rem; }
.dialog-close { width: 36px; height: 36px; font-size: 1.5rem; }
.dialog-note { margin: 0 1.4rem 1rem; color: var(--muted); font-size: .82rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .6rem; padding: 1rem 1.4rem 1.35rem; }
.training-dialog { width: min(680px, calc(100% - 2rem)); }
.training-form { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; padding: .3rem 1.4rem .6rem; }
.training-form label span { display: block; margin-bottom: .4rem; color: var(--navy); font-size: .78rem; font-weight: 850; }
.canvas-wrap { margin: 0 1.4rem; background: #172b34; border-radius: 10px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
#alert-graphic { display: block; width: 100%; height: auto; }

.report-dialog { width: min(900px, calc(100% - 2rem)); }
.completed-report { padding: clamp(1.25rem, 4vw, 2.5rem); background: white; }
.report-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; padding-bottom: 1rem; border-bottom: 4px solid var(--navy); }
.report-header p { margin: 0 0 .25rem; color: var(--teal); font-size: .72rem; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.report-header h2 { margin: 0; color: var(--navy); font-size: clamp(1.4rem, 3vw, 2rem); }
.report-generated { text-align: right; }
.report-generated span, .report-generated strong { display: block; }
.report-generated span { color: var(--muted); font-size: .68rem; font-weight: 800; text-transform: uppercase; }
.report-generated strong { margin-top: .2rem; font-size: .78rem; }
.report-summary { padding: 1.15rem 0; }
.report-summary h3 { margin: 0 0 .75rem; color: var(--navy); font-size: 1.25rem; }
.report-summary dl { display: grid; grid-template-columns: repeat(2, 1fr); gap: .55rem; margin: 0; }
.report-summary dl div { padding: .6rem .7rem; background: #f3f6f7; border-radius: 7px; }
.report-summary dt { color: var(--muted); font-size: .66rem; font-weight: 850; text-transform: uppercase; }
.report-summary dd { margin: .2rem 0 0; font-size: .82rem; font-weight: 750; overflow-wrap: anywhere; }
.report-section { margin-top: 1rem; break-inside: avoid; }
.report-section h3 { margin: 0 0 .5rem; padding-bottom: .35rem; color: var(--navy); font-size: .95rem; border-bottom: 2px solid var(--line); }
.report-message { margin: 0; padding: .8rem; line-height: 1.5; white-space: pre-wrap; background: #f8faf9; border: 1px solid var(--line); border-radius: 7px; }
.report-messages { display: grid; gap: .8rem; }
.report-alert-message { padding: .8rem; border: 1px solid var(--line); border-radius: 8px; break-inside: avoid; }
.report-alert-message h4 { margin: 0; color: var(--navy); }
.report-alert-meta { margin: .25rem 0 .7rem; color: var(--muted); font-size: .72rem; }
.report-message-label { display: block; margin: .6rem 0 .3rem; color: var(--teal); font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; }
.report-table { width: 100%; border-collapse: collapse; }
.report-table th, .report-table td { padding: .55rem .6rem; text-align: left; border: 1px solid var(--line); }
.report-table th { color: var(--navy); background: #edf3f4; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; }
.report-table td { font-size: .8rem; }
.report-empty { color: var(--muted); font-style: italic; text-align: center !important; }
.report-notes-section p { margin: 0; white-space: pre-wrap; }
.report-footer { width: auto; margin: 1.5rem 0 0; padding-top: .7rem; color: var(--muted); font-size: .68rem; text-align: left; border-top: 1px solid var(--line); }
.report-controls { background: #edf2f3; border-top: 1px solid var(--line); }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .alert-facts { grid-template-columns: repeat(2, 1fr); }
  .channel-row { grid-template-columns: 130px 1fr; }
  .log-entries { grid-column: 1 / -1; }
}

@media (max-width: 650px) {
  .site-header { align-items: flex-start; flex-wrap: wrap; }
  .brand-mark { width: 44px; height: 44px; flex-basis: 44px; }
  .header-actions { width: 100%; margin-left: 0; }
  .header-actions .button { flex: 1; }
  .app-shell { width: min(100% - 1rem, 1180px); margin-top: .5rem; }
  .status-strip, .section-heading { align-items: stretch; flex-direction: column; }
  .section-actions { justify-content: space-between; }
  .status-actions { justify-content: space-between; }
  .alerts-panel, .message-panel, .operator-panel, #channel-section, #staffing-section, .history-panel { padding: 1rem; }
  .training-banner { margin: -1rem -1rem 1rem; }
  .alert-facts { grid-template-columns: 1fr 1fr; }
  .channel-row { grid-template-columns: 1fr; gap: .7rem; }
  .channel-name { margin: 0; }
  .channel-actions { min-width: 0; }
  .log-entries { grid-column: auto; }
  .message-actions .button { width: 100%; }
  .nixle-heading-row { align-items: flex-start; }
  .history-item { align-items: flex-start; flex-direction: column; }
  .history-actions { width: 100%; justify-content: space-between; }
  .app-dialog { width: calc(100% - 1rem); max-height: calc(100vh - 1rem); }
  .dialog-heading { padding: 1rem 1rem .6rem; }
  .dialog-note, .canvas-wrap { margin-left: 1rem; margin-right: 1rem; }
  .dialog-actions { padding: .8rem 1rem 1rem; }
  .dialog-actions .button { flex: 1; }
  .training-form { grid-template-columns: 1fr; padding-left: 1rem; padding-right: 1rem; }
  .report-header { align-items: flex-start; flex-direction: column; }
  .report-generated { text-align: left; }
  .report-summary dl { grid-template-columns: 1fr; }
}

@media print {
  :root { background: white; }
  body { background: white; font-size: 10pt; }
  .site-header { padding: 0 0 12pt; color: black; background: white; border-bottom: 2pt solid black; }
  .brand-mark, .header-actions, .status-strip, .alerts-panel, .notice, footer, .message-actions, .section-kicker, .save-state, .section-intro, .log-button, #add-staff, .history-panel, .field-help, .training-banner { display: none !important; }
  .app-shell { width: 100%; margin: 12pt 0 0; }
  .workspace { display: block; margin: 0; }
  .panel { padding: 10pt 0; border: 0; border-radius: 0; box-shadow: none; }
  .operator-panel { border-top: 1pt solid #777; }
  textarea, input { border: 0; padding: 0; resize: none; }
  #radio-message { display: none; }
  .print-message { display: block; min-height: 110pt; padding: 8pt; line-height: 1.5; white-space: pre-wrap; border: 1pt solid #777; }
  .alert-facts { grid-template-columns: repeat(4, 1fr); }
  .fact { padding: 5pt; border: 1pt solid #aaa; }
  .channel-row { grid-template-columns: 110pt 1fr; padding: 6pt 0; break-inside: avoid; background: white; border: 0; border-bottom: 1pt solid #aaa; }
  .channel-actions { display: none; }
  .log-entries { min-height: 0; }
  .no-entries { font-style: normal; }
  .remove-log, .icon-button, .button { display: none !important; }
  .log-chip { border: 0; padding: 0 8pt 0 0; }
  .staff-table input { border: 0; }

  body.report-printing > .site-header,
  body.report-printing > .app-shell,
  body.report-printing > footer,
  body.report-printing > noscript,
  body.report-printing > #graphic-dialog,
  body.report-printing > #training-dialog { display: none !important; }
  body.report-printing #report-dialog { position: static; display: block; width: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; box-shadow: none; overflow: visible; }
  body.report-printing .completed-report { padding: 0; }
  body.report-printing .report-controls { display: none !important; }
  body.report-printing .report-header { display: flex !important; padding-bottom: 8pt; color: black; background: white; border-bottom: 3pt solid black; }
  body.report-printing .report-header h2 { font-size: 18pt; }
  body.report-printing .report-summary { padding: 8pt 0; }
  body.report-printing .report-summary dl { grid-template-columns: repeat(2, 1fr); }
  body.report-printing .report-section { margin-top: 9pt; }
  body.report-printing .report-table th,
  body.report-printing .report-table td { padding: 4pt 5pt; border-color: #777; }
  body.report-printing .report-footer { display: block !important; width: auto; margin-top: 12pt; }
}
