:root {
  --bg: #050506;
  --bg-soft: #09080a;
  --panel: #0d0b0d;
  --panel-2: #111014;
  --panel-3: #151116;
  --line: #3a241b;
  --line-soft: #211719;
  --text: #f5e8e8;
  --muted: #9e8588;
  --dim: #6e5b5f;
  --magenta: #db1559;
  --magenta-bright: #ff2f73;
  --rose: #ff6d8f;
  --rose-soft: #d54c70;
  --pink: #f7a0b6;
  --gold: #e89a36;
  --gold-soft: #b96c25;
  --red: #ee3038;
  --green: #35d0b0;
  --shadow: 0 20px 55px rgba(0, 0, 0, .48);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 76% 2%, rgba(219, 21, 89, .075), transparent 28%),
    radial-gradient(circle at 30% 110%, rgba(232, 154, 54, .035), transparent 34%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .22;
  background-image:
    linear-gradient(rgba(255,255,255,.012) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.012) 1px, transparent 1px);
  background-size: 44px 44px;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.app-shell { display: grid; grid-template-columns: 138px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 10;
  border: 1px solid rgba(185,108,37,.32);
  border-top: 0;
  border-bottom: 0;
  background: linear-gradient(180deg, rgba(12,9,10,.98), rgba(6,6,7,.99));
  display: flex;
  flex-direction: column;
  padding: 8px 7px 14px;
}
.pheme-logo { height: 104px; display: grid; place-items: center; border-bottom: 1px solid rgba(185,108,37,.22); }
.logo-hex {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  position: relative;
  color: var(--pink);
  font-family: Georgia, serif;
  font-size: 34px;
  clip-path: polygon(50% 0, 91% 22%, 91% 78%, 50% 100%, 9% 78%, 9% 22%);
  background: linear-gradient(145deg, rgba(219,21,89,.33), rgba(89,8,39,.7));
  border: 1px solid var(--rose);
  filter: drop-shadow(0 0 12px rgba(219,21,89,.35));
}
.logo-hex::before,
.logo-hex::after {
  content: "";
  position: absolute;
  inset: 7px;
  clip-path: inherit;
  border: 1px solid rgba(255,109,143,.62);
}
.logo-hex::after { inset: 14px; border-color: rgba(232,154,54,.28); }

.primary-nav { display: flex; flex-direction: column; gap: 2px; padding-top: 6px; }
.nav-item {
  min-height: 43px;
  padding: 0 11px;
  display: flex;
  align-items: center;
  gap: 11px;
  color: #c8b6b8;
  font-size: 12px;
  border-left: 2px solid transparent;
  transition: .16s ease;
}
.nav-item span { width: 18px; text-align: center; font-size: 16px; color: #cab9bc; }
.nav-item:hover { background: rgba(219,21,89,.07); color: #fff; }
.nav-item.active {
  color: #fff;
  border-left-color: var(--rose);
  background: linear-gradient(90deg, rgba(219,21,89,.34), rgba(219,21,89,.08));
  box-shadow: inset 0 0 22px rgba(219,21,89,.06);
}
.nav-item.active span { color: var(--pink); }

.persona-card { margin-top: auto; text-align: center; padding: 18px 5px 12px; }
.persona-medallion {
  width: 82px;
  height: 82px;
  margin: 0 auto 12px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: Georgia, serif;
  font-size: 34px;
  color: #f2b58e;
  border: 1px solid rgba(232,154,54,.5);
  background:
    radial-gradient(circle at 50% 48%, rgba(219,21,89,.35), transparent 42%),
    conic-gradient(from 20deg, rgba(232,154,54,.18), rgba(219,21,89,.32), rgba(232,154,54,.14));
  box-shadow: inset 0 0 0 5px #0d0a0b, 0 0 25px rgba(219,21,89,.2);
}
.persona-card strong { display: block; font-family: Georgia, serif; letter-spacing: .12em; color: var(--pink); font-size: 17px; font-weight: 500; }
.persona-card small { display: block; margin-top: 8px; color: #d4a259; font-family: Georgia, serif; font-size: 9px; letter-spacing: .1em; line-height: 1.5; }
.system-card {
  border: 1px solid rgba(185,108,37,.28);
  border-radius: 9px;
  min-height: 170px;
  padding: 14px 10px;
  text-align: center;
  background: linear-gradient(180deg, rgba(219,21,89,.025), transparent), #0a090a;
}
.system-label { text-align: left; color: #c5aaad; font-size: 8px; letter-spacing: .1em; }
.heartbeat { width: 66px; height: 66px; margin: 14px auto 8px; border-radius: 50%; border: 1px solid rgba(219,21,89,.45); position: relative; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 24px rgba(219,21,89,.14); }
.heartbeat i { width: 43px; height: 1px; background: linear-gradient(90deg, transparent, var(--rose), transparent); position: relative; }
.heartbeat i::before { content:""; position:absolute; left:17px; top:-7px; width:8px; height:14px; border-left:1px solid var(--rose); border-bottom:1px solid var(--rose); transform:skewX(-22deg) rotate(-28deg); }
.nominal { color: var(--green); font-size: 10px; letter-spacing: .1em; margin-top: 2px; }
.system-card small { color: #9b8589; line-height: 1.45; font-size: 9px; }

.main { min-width: 0; padding: 18px 28px 26px 30px; }
.masthead { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 12px; }
.mast-title { min-width: 0; }
h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(21px, 2vw, 31px);
  letter-spacing: .055em;
  font-weight: 500;
  color: #e6a44e;
  white-space: nowrap;
}
h1 span { color: #ff97ac; }
h1 b { color: var(--rose); font-size: .7em; padding: 0 5px; }
.mast-rule { margin-top: 10px; width: 86%; height: 1px; background: linear-gradient(90deg, rgba(232,154,54,.7), rgba(232,154,54,.12), transparent); }
.mast-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.tenant-pill, .status-pill {
  min-height: 35px;
  border: 1px solid rgba(185,108,37,.35);
  border-radius: 9px;
  display: flex;
  align-items: center;
  color: #c9b7b9;
  background: #090809;
  font-size: 10px;
}
.tenant-pill { padding: 0 8px; gap: 5px; }
.tenant-pill input { width: 72px; border: 0; outline: 0; background: transparent; color: var(--pink); font-size: 10px; }
.status-pill { padding: 0 13px; }
.status-pill i, .hero-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--magenta); box-shadow: 0 0 10px var(--magenta-bright); margin-right: 8px; }
.bell-button, .profile-button {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #090809;
  color: #e9d6d9;
  border: 1px solid transparent;
}
.bell-button:hover { border-color: rgba(219,21,89,.35); color: var(--rose); }
.profile-button { border-color: rgba(232,154,54,.65); color: #e6a44e; font-family: Georgia, serif; font-size: 18px; }

.hero-grid { display: grid; grid-template-columns: minmax(0, 2.15fr) minmax(300px, .95fr); gap: 12px; margin-bottom: 12px; }
.hero-left { display: flex; flex-direction: column; gap: 10px; }
.command-panel, .workflow-panel, .hero-art, .metric-card, .panel, .mission-strip {
  border: 1px solid rgba(185,108,37,.34);
  background: linear-gradient(180deg, rgba(219,21,89,.025), transparent 38%), var(--panel);
  box-shadow: var(--shadow);
}
.command-panel { border-radius: 8px; padding: 13px 15px 11px; }
.section-kicker { font-size: 10px; color: #dfcbce; letter-spacing: .055em; margin-bottom: 10px; }
.command-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 9px; }
.command-row input {
  min-width: 0;
  border: 1px solid rgba(219,21,89,.33);
  border-radius: 6px;
  background: #070708;
  color: #f3e9ea;
  outline: none;
  padding: 12px 13px;
  box-shadow: inset 0 0 22px rgba(219,21,89,.025);
}
.command-row input:focus { border-color: rgba(255,109,143,.72); box-shadow: 0 0 0 2px rgba(219,21,89,.07); }
.command-row input::placeholder { color: #a79396; }
.command-secondary, .command-primary {
  min-width: 83px;
  border-radius: 6px;
  padding: 0 12px;
  color: #efdfe2;
  border: 1px solid rgba(219,21,89,.28);
  background: linear-gradient(180deg, rgba(219,21,89,.12), rgba(34,13,20,.6));
}
.command-secondary.active { color: var(--pink); border-color: var(--rose); box-shadow: 0 0 16px rgba(219,21,89,.16); }
.command-primary { min-width: 103px; border-color: rgba(255,47,115,.62); background: linear-gradient(135deg, #8a0c36, #b40f46 55%, #7d102f); box-shadow: inset 0 0 18px rgba(255,255,255,.045), 0 0 18px rgba(219,21,89,.12); }
.command-primary:hover { filter: brightness(1.12); }
.entity-strip { min-height: 26px; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding-top: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid rgba(255,109,143,.25); background: rgba(219,21,89,.07); border-radius: 999px; padding: 4px 8px; font-size: 9px; color: #e7d2d6; }
.chip button { border: 0; background: transparent; color: #b89098; padding: 0; }
.command-status { color: #7d696d; font-size: 9px; padding-top: 4px; text-align: right; }
.command-status.success { color: var(--green); }
.command-status.warn { color: var(--gold); }
.command-status.error { color: var(--rose); }

.workflow-panel { border-radius: 8px; padding: 10px 15px 13px; flex: 1; }
.workflow { display: grid; grid-template-columns: repeat(13, auto); align-items: center; justify-content: space-between; gap: 6px; padding: 3px 7px 0; }
.workflow > i { color: var(--magenta-bright); font-style: normal; font-size: 24px; font-weight: 200; }
.workflow-step { text-align: center; min-width: 74px; }
.workflow-icon { width: 47px; height: 47px; margin: 0 auto 7px; border-radius: 50%; border: 1px solid var(--magenta-bright); display: grid; place-items: center; font-size: 19px; color: #eee3e5; background: #0a090a; box-shadow: 0 0 14px rgba(219,21,89,.08); }
.workflow-step strong { display: block; font-weight: 500; font-size: 10px; color: #e9dddf; }
.workflow-step small { display: block; color: #998286; margin-top: 2px; font-size: 9px; }

.hero-art { border-radius: 8px; position: relative; overflow: hidden; min-height: 225px; background: radial-gradient(circle at 45% 52%, rgba(219,21,89,.13), transparent 43%), linear-gradient(125deg,#070708,#0c080b 65%,#12090d); }
.hero-art::before { content:""; position:absolute; inset:0; background: linear-gradient(90deg, transparent 72%, rgba(232,154,54,.04)), repeating-linear-gradient(90deg, transparent 0 41px, rgba(255,255,255,.01) 42px); pointer-events:none; }
.hero-art svg { width: 100%; height: 100%; min-height: 238px; display: block; }
.hero-status { position: absolute; top: 10px; right: 11px; z-index: 3; display:flex; align-items:center; font-size:9px; color:#c6afb3; border:1px solid rgba(185,108,37,.26); border-radius:999px; padding:6px 9px; background:rgba(5,5,6,.72); }
.signal-web path { stroke: rgba(219,21,89,.26); stroke-width: .7; fill:none; }
.signal-web circle { fill: var(--magenta-bright); filter: drop-shadow(0 0 5px #ff2f73); }
.pheme-figure { stroke-width: 2.1; filter: drop-shadow(0 0 7px rgba(219,21,89,.28)); }
.hero-waves path { stroke: rgba(219,21,89,.6); stroke-width: 1.2; filter: drop-shadow(0 0 5px rgba(219,21,89,.35)); }

.metric-grid { display: grid; grid-template-columns: 1fr 1fr 1.2fr 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.metric-card { min-height: 137px; border-radius: 7px; padding: 13px 15px; position: relative; overflow: hidden; }
.metric-card > span { color: var(--rose); font-size: 10px; letter-spacing: .06em; }
.metric-card > strong { display: block; margin-top: 10px; font-family: Georgia, serif; font-weight: 400; font-size: 27px; color: #eee1df; }
.metric-card > small { display: block; color: #b87983; font-size: 9px; margin-top: 8px; }
.sparkline { position: absolute; left: 10px; right: 10px; bottom: 8px; height: 38px; opacity: .9; }
.sparkline svg { width:100%; height:100%; overflow:visible; }
.sparkline polyline { fill:none; stroke:var(--rose); stroke-width:1.2; filter: drop-shadow(0 0 3px rgba(219,21,89,.4)); }
.sentiment-card { min-width: 0; }
.sentiment-summary { display:flex; align-items:center; gap:14px; margin-top:13px; }
.sentiment-donut, .source-donut { border-radius:50%; position:relative; flex:0 0 auto; background: conic-gradient(var(--rose) 0 0, var(--gold) 0 0, var(--red) 0 100%); }
.sentiment-donut { width:74px; height:74px; }
.sentiment-donut::after, .source-donut::after { content:""; position:absolute; inset:13px; border-radius:50%; background:#090809; box-shadow: inset 0 0 0 1px rgba(255,255,255,.025); }
.sentiment-legend { display:flex; flex-direction:column; gap:8px; min-width:0; }
.sentiment-legend b { display:flex; align-items:center; gap:7px; color:#d7c6c8; font-weight:400; font-size:9px; }
.sentiment-legend em { width:31px; color:#fff; font-style:normal; }
.sentiment-legend i, .micro-legend i { width:7px; height:7px; display:inline-block; border-radius:1px; }
i.positive { background: #cf285d; } i.neutral { background: var(--gold); } i.negative { background: var(--red); }

.analysis-grid { display:grid; grid-template-columns: 1.25fr 1.02fr 1.18fr; gap:10px; margin-bottom:10px; }
.operations-grid { display:grid; grid-template-columns: 1.45fr .75fr 1.08fr .82fr; gap:10px; margin-bottom:10px; }
.panel { border-radius:7px; padding:12px 15px; min-width:0; }
.panel-heading { display:flex; justify-content:space-between; align-items:center; gap:10px; margin-bottom:10px; }
.panel h2 { margin:0; color:var(--rose); font-weight:500; font-size:11px; letter-spacing:.06em; }
.panel h2 small { color:#b9838d; font-size:8px; font-weight:400; }
.micro-legend { display:flex; align-items:center; gap:13px; color:#b59da1; font-size:8px; }
.micro-legend span { display:flex; align-items:center; gap:5px; }

.trend-panel { min-height: 225px; }
.trend-chart { height: 175px; position:relative; }
.trend-chart svg { width:100%; height:100%; overflow:visible; }
.chart-grid line { stroke: rgba(255,255,255,.055); stroke-width:1; }
.chart-axis text { fill:#9c8589; font-size:8px; }
.trend-line { fill:none; stroke-width:1.8; }
.trend-dot { stroke:#0b090a; stroke-width:1; }
.trend-positive { stroke:#cc315e; fill:#cc315e; }
.trend-neutral { stroke:var(--gold); fill:var(--gold); }
.trend-negative { stroke:var(--red); fill:var(--red); }

.table-head, .table-row { display:grid; align-items:center; gap:8px; }
.table-head { color:#a98f93; font-size:8px; border-bottom:1px solid rgba(255,255,255,.09); padding:0 2px 7px; }
.table-row { min-height:29px; border-bottom:1px solid rgba(255,255,255,.065); color:#dcced0; font-size:9px; }
.table-row:last-child { border-bottom:0; }
.table-row .muted { color:#927b80; }
.table-row .truncate { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.narrative-head, .narrative-row { grid-template-columns: minmax(0,1fr) 62px 118px; }
.actor-head, .actor-row { grid-template-columns: minmax(80px,1fr) minmax(80px,.85fr) 70px 55px 40px; }
.risk-head, .risk-row { grid-template-columns: 86px minmax(0,1fr) 72px 42px 58px; }
.sentiment-meter { display:flex; align-items:center; gap:7px; }
.sentiment-meter-track { flex:1; height:7px; border-radius:3px; background:#21171a; overflow:hidden; min-width:45px; }
.sentiment-meter-track i { display:block; height:100%; background:linear-gradient(90deg,#a70e40,var(--rose)); }
.confidence-high { color:var(--gold); } .confidence-medium { color:#d79742; } .confidence-low { color:#a88a8e; }
.trend-mark { color:var(--red); font-size:14px; letter-spacing:-3px; }
.panel-link { text-align:right; color:var(--rose); font-size:8px; margin-top:8px; }
.empty-state { color:#79666a; font-size:9px; padding:24px 6px; text-align:center; }

.risk-panel { min-height: 216px; }
.risk-row .negative-score { color:var(--red); }
.risk-row .neutral-score { color:var(--gold); }
.risk-row .positive-score { color:var(--green); }
.risk-source { color:#dfd0d2; }
.risk-link { color:inherit; }
.risk-link:hover { color:var(--rose); }

.source-panel { min-height:216px; }
.source-layout { display:flex; align-items:center; gap:15px; padding:7px 2px 2px; }
.source-donut { width:93px; height:93px; background:conic-gradient(#cb1e52 0 38%,#9e123d 38% 60%,#dc7a25 60% 78%,#b43f66 78% 90%,#e43b3f 90% 100%); }
.source-donut::after { inset:20px; }
.source-legend { display:flex; flex-direction:column; gap:9px; flex:1; min-width:0; }
.source-item { display:grid; grid-template-columns:8px minmax(0,1fr) auto; align-items:center; gap:6px; color:#c5b2b5; font-size:8px; }
.source-item i { width:7px; height:7px; border-radius:1px; }
.frontier-mini { display:flex; justify-content:space-between; align-items:center; border-top:1px solid rgba(255,255,255,.065); margin-top:13px; padding-top:9px; color:#927b80; font-size:8px; }
.frontier-mini b { color:#dcbcc2; font-weight:500; }

.escalation-panel { min-height:216px; }
.escalation-flow { display:grid; grid-template-columns:1fr auto 1fr auto 1fr auto 1fr; align-items:start; gap:5px; padding-top:13px; }
.escalation-flow > i { color:var(--magenta-bright); font-style:normal; font-size:19px; margin-top:20px; }
.agent-step { text-align:center; min-width:0; }
.agent-step > div { width:48px; height:48px; margin:0 auto 7px; border-radius:50%; display:grid; place-items:center; border:1px solid var(--magenta-bright); background:#0b090a; font-size:18px; color:#f2dfe2; box-shadow:0 0 14px rgba(219,21,89,.08); }
.agent-step strong { display:block; font-size:9px; font-weight:500; }
.agent-step small { display:block; margin-top:3px; color:#8e777b; font-size:7px; line-height:1.3; }
.agent-step.hades > div { border-color:#8e4bb6; color:#c69adc; }
.agent-step.hephaestus > div { border-color:var(--gold); color:#edb25e; }
.agent-step.athena > div { border-color:#d99a6b; color:#f0c09e; }
.escalation-note { border-top:1px solid rgba(255,255,255,.06); margin-top:15px; padding-top:8px; color:#816d71; font-size:7px; text-align:center; }

.reports-panel { min-height:216px; }
.mini-button { border:1px solid rgba(219,21,89,.32); color:var(--rose); background:#0b090a; width:24px; height:24px; border-radius:5px; }
.reports-list { display:flex; flex-direction:column; }
.report-item { display:grid; grid-template-columns:22px minmax(0,1fr) auto; gap:7px; align-items:center; min-height:42px; border-bottom:1px solid rgba(255,255,255,.06); }
.report-item:last-child { border-bottom:0; }
.report-icon { color:#d8c5c8; font-size:14px; }
.report-title { font-size:8px; color:#d6c4c7; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.report-time { color:#8c7579; font-size:7px; }

.mission-strip { min-height:46px; border-radius:7px; display:flex; align-items:center; gap:12px; padding:0 15px; color:#ae9297; font-size:9px; }
.mission-strip span { color:var(--rose); font-size:15px; }

@media (max-width: 1320px) {
  .app-shell { grid-template-columns: 118px minmax(0,1fr); }
  .sidebar { padding-left:5px; padding-right:5px; }
  .nav-item { padding-left:8px; gap:7px; font-size:10px; }
  .hero-grid { grid-template-columns: 1fr; }
  .hero-art { min-height:190px; }
  .hero-art svg { min-height:190px; }
  .metric-grid { grid-template-columns: repeat(3,1fr); }
  .sentiment-card { grid-column:span 1; }
  .analysis-grid { grid-template-columns:1fr 1fr; }
  .actors-panel { grid-column:1 / -1; }
  .operations-grid { grid-template-columns:1fr 1fr; }
  .workflow { overflow-x:auto; justify-content:start; padding-bottom:4px; }
}

@media (max-width: 900px) {
  .app-shell { display:block; }
  .sidebar { position:relative; height:auto; width:100%; flex-direction:row; align-items:center; overflow-x:auto; border-right:0; border-bottom:1px solid rgba(185,108,37,.28); }
  .pheme-logo { width:70px; height:64px; border-bottom:0; flex:0 0 auto; }
  .logo-hex { width:48px; height:48px; font-size:22px; }
  .primary-nav { flex-direction:row; padding:0; }
  .nav-item { min-width:max-content; min-height:44px; border-left:0; border-bottom:2px solid transparent; }
  .nav-item.active { border-bottom-color:var(--rose); }
  .persona-card, .system-card { display:none; }
  .main { padding:14px; }
  .masthead { flex-direction:column; }
  h1 { white-space:normal; font-size:21px; }
  .command-row { grid-template-columns:1fr 1fr 1fr; }
  .command-row input { grid-column:1 / -1; }
  .metric-grid, .analysis-grid, .operations-grid { grid-template-columns:1fr; }
  .actors-panel { grid-column:auto; }
  .sentiment-card { grid-column:auto; }
  .table-head { display:none; }
  .narrative-row, .actor-row, .risk-row { grid-template-columns:1fr; gap:4px; padding:8px 0; }
  .entity-strip { flex-direction:column; }
  .command-status { text-align:left; }
}
