:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #eef5f4;
  --ink: #17212b;
  --muted: #667789;
  --line: #dbe4ec;
  --brand: #087f8c;
  --brand-2: #0f5f6b;
  --accent: #f6a623;
  --green: #168a5f;
  --red: #c94a4a;
  --blue: #266fd5;
  --shadow: 0 18px 50px rgba(30, 49, 70, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 28px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), #22a7a0);
  border-radius: var(--radius);
  font-weight: 800;
}

.brand strong {
  display: block;
  font-size: 17px;
  line-height: 1.1;
}

.brand span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.portal-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.portal-nav a {
  min-height: 36px;
  padding: 0 13px;
  color: var(--muted);
  text-decoration: none;
  background: transparent;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
}

.portal-nav a.active {
  color: var(--brand-2);
  background: #e9f6f5;
  border-color: #c5e7e4;
}

.nav button,
.role-switch button,
.tab-button {
  min-height: 36px;
  padding: 0 13px;
  color: var(--muted);
  background: transparent;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 650;
}

.nav button.active,
.role-switch button.active,
.tab-button.active {
  color: var(--brand-2);
  background: #e9f6f5;
  border-color: #c5e7e4;
}

.role-switch {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f9fbfd;
}
.offline-status {
  position: sticky;
  top: 67px;
  z-index: 19;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 16px;
  color: #6b3d00;
  background: #fff7df;
  border-bottom: 1px solid #f4d28d;
  font-size: 13px;
  font-weight: 700;
}

.offline-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #d97706;
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.14);
}

.system-notice-stack {
  position: sticky;
  top: 101px;
  z-index: 18;
  display: grid;
  gap: 8px;
  padding: 10px 16px 0;
}

.system-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: min(1320px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 12px 14px;
  border: 1px solid #c9e4e1;
  border-radius: var(--radius);
  color: #143f46;
  background: #f3fbfa;
  box-shadow: var(--shadow-soft);
}

.system-notice strong,
.system-notice span {
  display: block;
}

.system-notice span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.system-notice.warn {
  border-color: #efd083;
  color: #694600;
  background: #fff8e5;
}

.system-notice.critical {
  border-color: #f3b8b8;
  color: #7a1d1d;
  background: #fff1f1;
}

.notice-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.page {
  width: min(1320px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  gap: 24px;
  align-items: stretch;
  margin-bottom: 24px;
}

.hero-main {
  min-width: 0;
  padding: 34px;
  background:
    radial-gradient(circle at 74% 18%, rgba(246, 166, 35, 0.24), transparent 34%),
    linear-gradient(135deg, #0f5f6b 0%, #087f8c 56%, #2db0a4 100%);
  border-radius: var(--radius);
  color: #fff;
  box-shadow: var(--shadow);
}

.hero-main h1 {
  max-width: 720px;
  margin: 0;
  font-size: clamp(32px, 4vw, 56px);
  line-height: 1.04;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.hero-main p {
  max-width: 710px;
  margin: 18px 0 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 17px;
  line-height: 1.65;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 760;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 15px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 760;
  text-decoration: none;
}

.btn.primary {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}

.btn.dark {
  color: #fff;
  background: #17212b;
  border-color: #17212b;
}

.btn.ghost {
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.28);
}

.btn.warn {
  color: #402b00;
  background: #ffe8b5;
  border-color: #ffd27b;
}

.btn.danger {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(30, 49, 70, 0.08);
}

.metric b {
  display: block;
  font-size: 28px;
}

.metric span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin: 24px 0 14px;
}

.section-head h2,
.panel h2,
.panel h3 {
  margin: 0;
}

.section-head p {
  max-width: 660px;
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.panel,
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(30, 49, 70, 0.07);
}

.panel {
  padding: 20px;
}

.card {
  padding: 18px;
}

.card h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.agent-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.agent-card {
  min-height: 112px;
  padding: 14px;
  text-align: left;
  color: var(--ink);
  background: #f9fbfd;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.agent-card:hover,
.agent-card.active {
  transform: translateY(-1px);
  border-color: #91d7d1;
  box-shadow: 0 10px 28px rgba(30, 49, 70, 0.09);
}

.agent-card strong,
.agent-card span,
.agent-card em {
  display: block;
}

.agent-card strong {
  font-size: 14px;
  line-height: 1.3;
}

.agent-card span {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.agent-card em {
  width: fit-content;
  margin-top: 10px;
  padding: 4px 8px;
  color: var(--brand-2);
  background: #e9f6f5;
  border-radius: 999px;
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}

.detail-panel {
  margin-bottom: 18px;
}

.media-frame,
.wide-media {
  overflow: hidden;
  margin-bottom: 14px;
  background: #e8eef2;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.media-frame {
  aspect-ratio: 16 / 9;
}

.wide-media {
  aspect-ratio: 21 / 8;
}

.media-frame img,
.wide-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.quote-structure {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.quote-structure details {
  padding: 10px 12px;
  background: #f8fbfc;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.quote-structure summary {
  color: #23394d;
  cursor: pointer;
  font-weight: 760;
}

.quote-structure p {
  margin-top: 8px;
}

.timeline {
  display: grid;
  gap: 10px;
  padding-left: 12px;
  border-left: 3px solid #c5e7e4;
}

.timeline-stop {
  padding: 11px 12px;
  background: #f8fbfc;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.timeline-stop p {
  margin: 5px 0 0;
}

.compact-form {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.map-panel {
  margin-bottom: 16px;
}

.map-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
  align-items: stretch;
}

.osm-map {
  width: 100%;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #e8eef2;
}

.map-stop-list {
  display: grid;
  align-content: start;
  gap: 10px;
  max-height: 420px;
  overflow: auto;
}

.map-stop {
  display: grid;
  gap: 5px;
  width: 100%;
  padding: 12px;
  color: var(--ink);
  text-align: left;
  background: #f8fbfc;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.map-stop.active {
  background: #e9f6f5;
  border-color: #76c9c5;
}

.map-stop.live {
  text-decoration: none;
  border-color: #b7d3ff;
  background: #eef5ff;
}

.map-stop.live.fresh {
  border-color: #7cc8a8;
  background: #effaf4;
}

.map-stop.live.stale {
  border-color: #e3c56b;
  background: #fff9e8;
}
