:root {
  --bg: #0a0e15;
  --panel: #101725;
  --panel-2: #0d1420;
  --border: #1d2739;
  --text: #e8ecf4;
  --muted: #8a94a8;
  --dhl-yellow: #ffcc00;
  --dhl-red: #d40511;
  --s2-purple: #a06bff;
  --ok: #3ddc84;
  --warn: #ffb020;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  display: grid;
  grid-template-rows: 58px 1fr 236px;
  grid-template-columns: 1fr;
  overflow: hidden;
}

/* ---------------- top bar ---------------- */
#topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 0 16px;
  background: linear-gradient(180deg, #121a2b, #0e1523);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; position: relative; cursor: pointer; user-select: none; }
.brand-mark {
  background: var(--dhl-yellow); color: var(--dhl-red);
  font-weight: 900; font-style: italic; letter-spacing: -1px;
  padding: 4px 10px; border-radius: 4px; font-size: 16px; white-space: nowrap;
}
.brand-caret { color: var(--muted); font-size: 9px; margin-left: -2px; }
.brand:hover .brand-caret { color: var(--text); }
#brand-menu {
  position: absolute; top: 46px; left: 0; z-index: 60; list-style: none;
  min-width: 230px; padding: 5px;
  background: #131b2af8; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 36px rgba(0, 0, 0, .55); backdrop-filter: blur(8px);
}
#brand-menu li {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: 7px; font-size: 12.5px; color: #cfd6e4;
}
#brand-menu li:hover { background: #1a2436; color: #fff; }
#brand-menu li.on { color: #fff; font-weight: 700; }
#brand-menu li i { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
#brand-menu li small { color: var(--muted); font-size: 10px; margin-left: auto; font-style: italic; }
.brand-title { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title span { font-size: 9.5px; letter-spacing: 2.5px; color: var(--muted); }
.brand-title strong { font-size: 14px; letter-spacing: 1.5px; }

#kpis { display: flex; gap: 8px; flex: 1; justify-content: center; }
.kpi {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 5px 14px; min-width: 104px; text-align: center;
}
.kpi label { display: block; font-size: 9.5px; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); }
.kpi b { font-size: 17px; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); margin-left: 3px; }
.kpi.alert b { color: var(--dhl-red); }
.kpi.alert { border-color: #3a1520; }

.top-actions { display: flex; align-items: center; gap: 14px; }
.ctl-btn {
  background: transparent; color: #b9c2d4;
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px;
  font-weight: 600; cursor: pointer; font-size: 12px; transition: all .15s;
  white-space: nowrap;
}
.ctl-btn:hover { background: #1a2436; color: #fff; }
.ctl-btn.on { color: var(--ok); border-color: #1d4030; }
.ctl-btn:disabled { opacity: .45; cursor: default; }

.storm-btn {
  background: transparent; color: var(--dhl-yellow);
  border: 1px solid #4a3f10; border-radius: 8px; padding: 8px 14px;
  font-weight: 600; cursor: pointer; font-size: 12.5px; transition: all .15s;
  white-space: nowrap;
}
.storm-btn:hover { background: #2a2408; }
.storm-btn.active {
  background: var(--dhl-red); border-color: var(--dhl-red); color: #fff;
  animation: pulse-red 1.6s infinite;
}
@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212, 5, 17, .5); }
  50% { box-shadow: 0 0 0 8px rgba(212, 5, 17, 0); }
}

.powered { font-size: 11px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.powered .s2 { color: var(--s2-purple); font-weight: 700; }
.powered .cf { color: #4cc9f0; font-weight: 700; }
.powered .x { opacity: .5; }

/* ---------------- main ---------------- */
main { display: grid; grid-template-columns: 1fr 392px; min-height: 0; }

#map-wrap { position: relative; border-right: 1px solid var(--border); }
#map { position: absolute; inset: 0; background: var(--bg); }

#map-overlay { position: absolute; top: 12px; left: 12px; right: 12px; z-index: 5; pointer-events: none; }
#storm-banner {
  pointer-events: auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: rgba(60, 8, 14, .92); border: 1px solid var(--dhl-red);
  border-radius: 10px; padding: 9px 14px; font-size: 13px;
  backdrop-filter: blur(4px);
}
#storm-banner button {
  background: var(--dhl-red); border: 0; color: #fff; font-weight: 700;
  border-radius: 6px; padding: 6px 12px; cursor: pointer;
}
#impact-card {
  pointer-events: auto; margin-top: 8px;
  background: rgba(13, 20, 32, .95); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 16px; max-width: 460px;
  backdrop-filter: blur(4px);
}
#impact-card h4 { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
#impact-card .impact-nums { display: flex; gap: 22px; margin-bottom: 6px; }
#impact-card .impact-nums b { font-size: 22px; display: block; }
#impact-card .impact-nums span { font-size: 10.5px; color: var(--muted); }
#impact-card .geo-note { font-size: 11px; color: var(--s2-purple); }

.map-legend {
  position: absolute; bottom: 10px; left: 12px; z-index: 5;
  display: flex; gap: 14px; font-size: 11px; color: var(--muted);
  background: rgba(10, 14, 21, .75); padding: 5px 10px; border-radius: 6px;
}
.map-legend .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.map-legend .dot.hub { background: var(--dhl-yellow); }
.map-legend .dot.global { background: var(--dhl-yellow); box-shadow: 0 0 0 3px rgba(255, 204, 0, .25); }
.map-legend .dot.risk { background: var(--dhl-red); }
.map-legend .plane-ico { color: #dfe6f3; margin-right: 4px; font-style: normal; }

/* hub + flight markers */
.hub-marker { display: flex; flex-direction: column; align-items: center; cursor: default; }
.hub-marker .pt {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--dhl-yellow); border: 1.5px solid #7d6600;
}
.hub-marker.global .pt {
  width: 13px; height: 13px;
  box-shadow: 0 0 0 4px rgba(255, 204, 0, .18), 0 0 14px rgba(255, 204, 0, .5);
}
.hub-marker .lbl {
  margin-top: 3px; font-size: 9.5px; font-weight: 700; letter-spacing: .5px;
  color: #cfd6e4; text-shadow: 0 1px 3px #000;
}
.hub-marker.stormy .pt { background: var(--dhl-red); border-color: #5f0208; }

.flight-marker {
  font-size: 17px; color: #eef4ff;
  text-shadow: 0 0 7px rgba(76, 201, 240, .95), 0 0 2px rgba(255, 255, 255, .6);
  will-change: transform; transition: opacity .8s;
}
.flight-marker.holding { color: var(--warn); text-shadow: 0 0 8px rgba(255, 176, 32, .9); }
.flight-marker.landed { opacity: .3; }

.ping {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--dhl-yellow);
  animation: ping 2.4s ease-out forwards;
}
.ping.exc { background: rgba(212, 5, 17, .95); }
@keyframes ping {
  0% { box-shadow: 0 0 0 0 rgba(255, 204, 0, .5); opacity: 1; }
  100% { box-shadow: 0 0 0 16px rgba(255, 204, 0, 0); opacity: 0; }
}

/* ---------------- side column ---------------- */
#side { display: flex; flex-direction: column; min-height: 0; background: var(--panel-2); }
.panel { display: flex; flex-direction: column; min-height: 0; border-bottom: 1px solid var(--border); background: var(--panel-2); }
#side .panel:last-child { border-bottom: 0; }
#feed-panel { flex: 1.25; }
#side .panel:nth-child(2) { flex: 1; }
#side .panel:nth-child(3) { flex: .95; }

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px 6px;
}
.panel-head h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: 1.2px; color: #b9c2d4; }
.panel-head h3 small { color: var(--muted); text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: 6px; }
.ms-badge {
  font-size: 10px; color: var(--s2-purple); border: 1px solid #372a55;
  padding: 1px 7px; border-radius: 20px; font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#feed { list-style: none; overflow: hidden; padding: 0 12px; flex: 1; }
#feed li {
  display: flex; gap: 8px; align-items: baseline;
  padding: 3.5px 0; border-bottom: 1px solid #131c2c; font-size: 11.5px;
  animation: fadein .4s;
}
@keyframes fadein { from { opacity: 0; transform: translateY(-4px); } }
#feed .t { color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
#feed .code {
  font-weight: 700; width: 26px; text-align: center; border-radius: 4px;
  background: #1a2436; color: var(--dhl-yellow); font-size: 10px; padding: 1px 0; flex-shrink: 0;
}
#feed li.exc .code { background: #3a0d13; color: #ff6b74; }
#feed .desc { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#feed .hub { color: var(--muted); margin-left: auto; flex-shrink: 0; }

.chart { flex: 1; min-height: 0; }

/* ---------------- bottom ---------------- */
#bottom { display: grid; grid-template-columns: 1fr 392px; border-top: 1px solid var(--border); min-height: 0; }
#risk-panel { border-right: 1px solid var(--border); border-bottom: 0; }
.tbl-wrap { overflow-y: auto; flex: 1; }
table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
th {
  text-align: left; font-size: 9.5px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted); padding: 4px 10px; position: sticky; top: 0; background: var(--panel-2);
}
td { padding: 4px 10px; border-top: 1px solid #131c2c; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.wb { font-family: ui-monospace, Menlo, monospace; font-size: 10.5px; color: #b9c2d4; }
.risk-badge {
  font-size: 9.5px; font-weight: 700; padding: 2px 8px; border-radius: 20px; letter-spacing: .4px;
}
.risk-badge.CUSTOMS { background: #3a2a08; color: var(--warn); }
.risk-badge.WEATHER { background: #3a0d13; color: #ff6b74; }
.risk-badge.SLARISK { background: #3a2408; color: #ff9f43; }
.risk-badge.SLABREACHED { background: #2b060b; color: #ff4757; }

#lanes-panel { border-bottom: 0; }
#lanes { list-style: none; padding: 2px 12px; overflow-y: auto; flex: 1; }
#lanes li { display: flex; align-items: center; gap: 10px; padding: 4.5px 0; border-bottom: 1px solid #131c2c; font-size: 12px; }
#lanes .lane { width: 86px; font-weight: 600; font-variant-numeric: tabular-nums; }
#lanes .bar { flex: 1; height: 5px; background: #1a2436; border-radius: 3px; overflow: hidden; }
#lanes .bar i { display: block; height: 100%; border-radius: 3px; }
#lanes .pct { width: 48px; text-align: right; font-variant-numeric: tabular-nums; }

.pipeline-strip {
  padding: 6px 12px; font-size: 10.5px; color: var(--muted);
  border-top: 1px solid var(--border); font-variant-numeric: tabular-nums;
}
.pipeline-strip b { color: var(--ok); font-weight: 600; }

/* ---------------- Aura drawer ---------------- */
#aura-fab {
  position: fixed; right: 20px; bottom: 256px; z-index: 30;
  background: linear-gradient(135deg, #7b2ff7, #a06bff);
  color: #fff; border: 0; border-radius: 24px; padding: 10px 18px;
  font-size: 13px; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 24px rgba(123, 47, 247, .45);
}
#aura-fab:hover { filter: brightness(1.1); }

#aura-drawer {
  position: fixed; right: 16px; bottom: 250px; top: 70px; width: 430px; z-index: 40;
  background: #0e1422f2; border: 1px solid #372a55; border-radius: 14px;
  display: flex; flex-direction: column;
  box-shadow: 0 12px 48px rgba(0, 0, 0, .6);
  backdrop-filter: blur(8px);
}
.aura-head { border-bottom: 1px solid #241b3a; }
.aura-head h3 { color: var(--s2-purple); }
#aura-close { background: none; border: 0; color: var(--muted); font-size: 14px; cursor: pointer; }

#aura-chat { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.aura-hello { color: var(--muted); font-size: 12.5px; }
.aura-chips { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.chip {
  background: #171f31; color: #b9c2d4; border: 1px solid var(--border);
  text-align: left; border-radius: 8px; padding: 7px 10px; font-size: 12px; cursor: pointer;
}
.chip:hover { border-color: var(--s2-purple); color: #fff; }

.msg { max-width: 92%; border-radius: 10px; padding: 8px 12px; font-size: 12.5px; }
.msg.user { align-self: flex-end; background: #241b3a; }
.msg.bot { align-self: flex-start; background: #131b2a; border: 1px solid var(--border); width: 92%; }
.msg.bot .meta { font-size: 10px; color: var(--s2-purple); margin-bottom: 5px; }
.msg.bot pre {
  background: #0a0f19; border: 1px solid #1a2436; border-radius: 6px;
  padding: 7px 9px; font-size: 10.5px; overflow-x: auto; margin: 6px 0;
  font-family: ui-monospace, Menlo, monospace; color: #9fd3ff; white-space: pre-wrap;
}
.msg.bot table { font-size: 10.5px; margin-top: 4px; }
.msg.bot td, .msg.bot th { padding: 2.5px 7px; }
.msg.bot .err { color: #ff6b74; }
.typing { color: var(--muted); font-style: italic; }

/* Aura streaming steps + results */
.aura-step { font-size: 11px; color: var(--muted); padding: 2.5px 0; display: flex; align-items: baseline; gap: 6px; }
.aura-step b { color: #b9c2d4; font-weight: 600; flex-shrink: 0; }
.aura-step i {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; align-self: center;
  background: var(--ok);
}
.aura-step.live i { background: var(--s2-purple); animation: pulse-step 1s infinite; }
@keyframes pulse-step { 50% { opacity: .3; } }
.aura-step .step-body { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aura-title { font-weight: 700; font-size: 13px; margin: 8px 0 4px; color: #fff; }
.aura-text { margin: 4px 0; }
.aura-text code { background: #0a0f19; padding: 0 4px; border-radius: 4px; font-size: 11px; }
.aura-chart {
  height: 235px; margin: 8px 0 2px;
  background: #0c121e; border: 1px solid #1a2436; border-radius: 8px;
}
.sqlbox { margin-top: 6px; }
.sqlbox summary { font-size: 10.5px; color: var(--s2-purple); cursor: pointer; }
.aura-follow { display: flex; flex-direction: column; gap: 5px; margin-top: 8px; }
.chip.mini { font-size: 11px; padding: 5px 9px; }

#aura-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid #241b3a; }
#aura-input {
  flex: 1; background: #131b2a; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: 9px 12px; font-size: 13px; outline: none;
}
#aura-input:focus { border-color: var(--s2-purple); }
#aura-form button {
  background: var(--s2-purple); border: 0; border-radius: 8px; color: #fff;
  width: 42px; font-size: 16px; cursor: pointer;
}

.hidden { display: none !important; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #223048; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }
