:root {
  --blue: #0757e8;
  --blue-2: #0646c7;
  --blue-3: #0d6bff;
  --cyan: #27b6e9;
  --ink: #0d1424;
  --muted: #71809c;
  --line: #e5eaf2;
  --surface: #ffffff;
  --canvas: #f7f9fc;
  --green: #08b94e;
  --red: #f20d1b;
  --orange: #ff7200;
  --shadow: 0 12px 34px rgba(32, 65, 120, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}
button, select, input { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: flex; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 228px;
  padding: 20px 15px;
  color: #fff;
  background: linear-gradient(160deg, #0757e8 0%, #0053ec 58%, #043fc4 100%);
  display: flex;
  flex-direction: column;
  z-index: 20;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 4px 21px; }
.brand strong { display: block; font-size: 18px; letter-spacing: -.3px; }
.brand small { display: block; margin-top: 1px; opacity: .88; }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: #fff; position: relative; display: block; }
.brand-mark i { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); }
.brand-mark i:nth-child(1) { left: 9px; top: 21px; }
.brand-mark i:nth-child(2) { left: 18px; top: 12px; }
.brand-mark i:nth-child(3) { right: 7px; top: 9px; }
.brand-mark:before, .brand-mark:after { content: ""; position: absolute; height: 2px; background: var(--blue); transform-origin: left center; }
.brand-mark:before { width: 14px; left: 13px; top: 20px; transform: rotate(-43deg); }
.brand-mark:after { width: 10px; left: 21px; top: 13px; transform: rotate(-18deg); }

.profile-mini { display: flex; align-items: center; gap: 11px; padding: 11px 2px 19px; border-top: 1px solid rgba(255,255,255,.14); }
.profile-mini strong, .profile-mini small { display: block; }
.profile-mini small { font-size: 11px; opacity: .85; margin-top: 3px; }
.initials { width: 38px; height: 38px; border-radius: 11px; background: rgba(255,255,255,.16); display: grid; place-items: center; font-weight: 800; }
.nav-kicker { margin: 10px 2px 8px; font-size: 10px; font-weight: 800; letter-spacing: 1.1px; opacity: .83; }
#main-nav { display: flex; flex-direction: column; }
.nav-item {
  width: 100%;
  border: 0;
  color: rgba(255,255,255,.94);
  background: transparent;
  border-radius: 9px;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  transition: .18s ease;
}
.nav-item span { width: 18px; text-align: center; font-size: 17px; }
.nav-item:hover, .nav-item:focus-visible { background: rgba(255,255,255,.12); outline: none; }
.nav-item.active { background: rgba(117, 180, 255, .34); box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
.sidebar-bottom { margin-top: auto; padding: 18px 7px 2px; display: grid; gap: 8px; }
.sidebar-bottom small { opacity: .75; font-size: 10px; }
.system-state { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #54ef8d; box-shadow: 0 0 0 5px rgba(84,239,141,.15); }

.workspace { margin-left: 228px; width: calc(100% - 228px); min-width: 0; }
.topbar { height: 58px; padding: 0 22px; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 15; backdrop-filter: blur(12px); }
.crumb { display: flex; align-items: center; gap: 12px; }
.crumb span { color: var(--muted); }
.crumb b { color: #a0abc0; }
.top-actions { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 11px; }
.top-actions strong { color: var(--blue); }
.icon-button { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); color: var(--blue); background: white; font-size: 18px; }
.avatar-top { width: 34px; height: 34px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; font-weight: 800; }
.menu-toggle { display: none; border: 0; background: none; font-size: 22px; color: var(--ink); }

.content-grid { display: grid; grid-template-columns: minmax(0, 1fr) 305px; gap: 16px; padding: 16px 18px 22px; align-items: start; }
#view-root { min-width: 0; outline: none; }
.view-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 0 4px 16px; }
.view-title h1 { margin: 0; font-size: clamp(26px, 2.4vw, 38px); letter-spacing: -1.3px; line-height: 1; }
.view-title p { margin: 7px 0 0; color: var(--muted); }
.status-pill { display: inline-flex; align-items: center; gap: 7px; border: 1px solid #cfe4ff; color: var(--blue); background: #eef6ff; padding: 8px 11px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.status-pill:before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); background: white; border: 1px solid var(--line); border-radius: 13px; margin-bottom: 14px; box-shadow: var(--shadow); }
.kpi { min-width: 0; padding: 16px 17px; position: relative; }
.kpi + .kpi:before { content: ""; position: absolute; left: 0; top: 18px; bottom: 18px; width: 1px; background: var(--line); }
.kpi-label { display: flex; align-items: center; gap: 8px; color: #465069; font-size: 10px; font-weight: 800; letter-spacing: .3px; text-transform: uppercase; }
.kpi-icon { font-size: 18px; color: var(--ink); }
.kpi-value { margin: 8px 0 4px; font-size: clamp(24px, 2.1vw, 34px); line-height: 1; font-weight: 800; letter-spacing: -.8px; }
.delta { font-weight: 800; color: var(--green); }
.delta.negative { color: var(--red); }
.delta.neutral { color: var(--blue); }
.kpi small { color: var(--muted); margin-left: 6px; }

.priority-banner { background: linear-gradient(120deg, var(--blue), var(--blue-2)); color: white; border-radius: 13px; padding: 16px 18px; margin-bottom: 14px; display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; box-shadow: 0 12px 30px rgba(7,87,232,.23); }
.priority-icon { width: 36px; height: 36px; border-radius: 9px; background: rgba(255,255,255,.12); display: grid; place-items: center; font-size: 21px; }
.priority-banner .eyebrow { color: #40d4ff; }
.priority-banner h2 { margin: 4px 0; font-size: 19px; }
.priority-banner p { margin: 0; color: rgba(255,255,255,.86); font-size: 12px; }
.action-button { border: 1px solid rgba(255,255,255,.9); background: transparent; color: white; border-radius: 9px; padding: 10px 14px; font-weight: 700; }
.action-button:hover { background: rgba(255,255,255,.13); }

.dashboard-grid { display: grid; grid-template-columns: 1.07fr 1fr; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 16px; box-shadow: 0 5px 18px rgba(32,65,120,.035); min-width: 0; }
.card.full { grid-column: 1 / -1; }
.card-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card h2, .card h3 { margin: 0; }
.card h2 { font-size: 17px; }
.card h3 { font-size: 15px; }
.card-subtitle { color: var(--muted); margin: 5px 0 0; font-size: 11px; }
.chip, .filter-button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 9px; color: var(--muted); font-size: 11px; }
.filters { display: flex; flex-wrap: wrap; gap: 7px; }
.filter-button.active { color: var(--blue); border-color: #bcd6ff; background: #edf5ff; font-weight: 700; }

.bar-list { display: grid; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 132px 1fr 55px; gap: 10px; align-items: center; }
.bar-row .name { font-weight: 650; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 11px; background: #e9eef7; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; width: var(--w); border-radius: inherit; background: #9badcf; transition: width .45s ease; }
.bar-row.primary .bar-fill { background: linear-gradient(90deg, #0b67ff, #0757e8); }
.bar-row.warning .bar-fill { background: var(--orange); }
.bar-row .value { font-weight: 800; text-align: right; }
.bar-note { margin-top: 14px; color: var(--muted); font-size: 11px; }

.split-stat { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 13px; }
.split-stat > div { padding: 11px; border-radius: 10px; background: #f6f8fc; }
.split-stat strong { display: block; font-size: 24px; color: var(--blue); }
.split-stat span { color: var(--muted); font-size: 11px; }
.split-stat .green strong { color: var(--green); }
.split-stat .red strong { color: var(--red); }
.stacked { height: 28px; display: flex; border-radius: 8px; overflow: hidden; color: white; font-size: 10px; font-weight: 800; }
.stacked span { display: grid; place-items: center; }

.territory-board { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; min-height: 266px; }
.zone { position: relative; border: 0; border-radius: 14px; color: white; padding: 17px; text-align: left; overflow: hidden; transition: transform .2s ease, box-shadow .2s ease; }
.zone:hover, .zone.active { transform: translateY(-2px); box-shadow: 0 14px 24px rgba(7,87,232,.17); }
.zone strong { display: block; font-size: 17px; }
.zone span { display: block; margin-top: 4px; font-size: 11px; opacity: .85; }
.zone em { position: absolute; right: 12px; bottom: 9px; font-style: normal; font-size: 27px; font-weight: 800; opacity: .28; }
.zone.tepic { background: linear-gradient(135deg, #0757e8, #0842bd); }
.zone.bahia { background: linear-gradient(135deg, #12aee9, #057bcf); }
.zone.costa { background: linear-gradient(135deg, #2f7cef, #0757e8); }
.zone.interior { background: linear-gradient(135deg, #7686a5, #53627e); }
.zone-detail { grid-column: 1 / -1; padding: 12px 14px; border: 1px solid var(--line); background: #f8faff; border-radius: 10px; color: #44516b; }
.zone-detail strong { color: var(--ink); }

.timeline { display: grid; gap: 0; }
.timeline-row { display: grid; grid-template-columns: 72px 1fr auto; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.timeline-row:last-child { border-bottom: 0; }
.timeline-row time { font-weight: 800; color: #4e5870; }
.timeline-row strong { display: block; font-size: 12px; }
.timeline-row small { color: var(--muted); }
.agent-tag { border-radius: 999px; background: #f2f5fa; padding: 5px 8px; color: var(--muted); font-size: 9px; }

.decision-rail { position: sticky; top: 74px; min-height: calc(100vh - 96px); border-radius: 13px; color: white; background: linear-gradient(165deg, #0757e8 0%, #0349ca 72%, #063bac 100%); padding: 16px 19px; display: flex; flex-direction: column; box-shadow: 0 18px 38px rgba(7,87,232,.2); overflow: hidden; }
.candidate-card { display: grid; grid-template-columns: 76px 1fr; gap: 12px; align-items: center; padding-bottom: 15px; margin-bottom: 16px; border-bottom: 1px solid rgba(255,255,255,.23); }
.candidate-card img { width: 76px; height: 82px; object-fit: cover; object-position: 50% 25%; border-radius: 12px; border: 2px solid rgba(255,255,255,.65); }
.candidate-card h2 { margin: 4px 0; font-size: 18px; }
.candidate-card p { margin: 0; font-size: 10px; color: rgba(255,255,255,.78); line-height: 1.35; }
.eyebrow { font-size: 9px; letter-spacing: 1px; font-weight: 800; }
.report-meta { display: flex; justify-content: space-between; font-size: 9px; letter-spacing: .7px; font-weight: 800; }
.decision-rail > h3 { font-size: 21px; line-height: 1.22; margin: 24px 0 10px; }
.decision-rail > p { color: rgba(255,255,255,.86); line-height: 1.55; margin: 0; font-size: 12px; }
.rail-list { margin: 22px 0; padding-left: 18px; color: rgba(255,255,255,.88); line-height: 1.55; font-size: 11px; }
.rail-list li { margin-bottom: 10px; }
.rail-spacer { flex: 1; min-height: 18px; }
.recommendation { border-top: 1px solid rgba(255,255,255,.42); padding-top: 16px; }
.recommendation span { display: block; font-size: 9px; letter-spacing: 1px; font-weight: 800; margin-bottom: 12px; }
.recommendation strong { display: block; border-radius: 10px; padding: 14px; background: rgba(93,165,255,.28); font-size: 12px; line-height: 1.5; }
.rail-sources { margin-top: 25px; font-size: 9px; color: rgba(255,255,255,.75); }

.metric-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.metric-box { border: 1px solid var(--line); border-radius: 11px; padding: 14px; background: #fafcff; }
.metric-box strong { display: block; font-size: 27px; }
.metric-box span { color: var(--muted); font-size: 11px; }
.callout { padding: 14px; border-radius: 10px; border-left: 4px solid var(--blue); background: #eef5ff; color: #274063; line-height: 1.5; }
.callout.warning { border-color: var(--orange); background: #fff7ed; }
.callout.danger { border-color: var(--red); background: #fff0f1; }
.callout.success { border-color: var(--green); background: #effbf4; }

.evidence-table { width: 100%; border-collapse: collapse; }
.evidence-table th { color: var(--muted); font-size: 9px; letter-spacing: .6px; text-transform: uppercase; text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); }
.evidence-table td { padding: 11px 8px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 11px; line-height: 1.4; }
.evidence-table tr:last-child td { border-bottom: 0; }
.level { display: inline-grid; place-items: center; min-width: 25px; height: 25px; padding: 0 7px; border-radius: 999px; font-weight: 800; }
.level.a { background: #e4f8ec; color: #07853a; }
.level.b { background: #eaf2ff; color: var(--blue); }
.level.c { background: #fff2df; color: #b85b00; }
.level.d { background: #ffe9eb; color: #cc0f21; }

.risk-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 11px; }
.risk-card { border: 1px solid var(--line); border-radius: 11px; padding: 14px; position: relative; }
.risk-card h3 { padding-right: 70px; }
.risk-card p { color: var(--muted); line-height: 1.45; font-size: 11px; }
.risk-state { position: absolute; right: 11px; top: 11px; border-radius: 999px; padding: 5px 8px; font-size: 9px; font-weight: 800; }
.risk-state.high { background: #ffe9eb; color: var(--red); }
.risk-state.medium { background: #fff2df; color: #bd5e00; }
.risk-state.blocked { background: #f0f2f6; color: #69758c; }
.risk-source { display: flex; align-items: center; justify-content: space-between; color: #5e6a82; font-size: 10px; }

.actor-network { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.actor { border: 1px solid var(--line); border-radius: 11px; padding: 13px; background: #fff; }
.actor-head { display: flex; gap: 9px; align-items: center; }
.actor-avatar { width: 35px; height: 35px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; font-weight: 800; }
.actor h3 { font-size: 12px; }
.actor p { color: var(--muted); line-height: 1.4; font-size: 10px; }
.relationship { font-size: 9px; color: var(--green); font-weight: 800; }
.relationship.rival { color: var(--orange); }
.relationship.watch { color: var(--red); }

.roadmap { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.phase { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.phase-head { padding: 13px; background: #f3f7fd; border-bottom: 1px solid var(--line); }
.phase-head span { color: var(--blue); font-size: 10px; font-weight: 800; }
.phase-head h3 { margin: 4px 0 0; font-size: 15px; }
.phase-body { padding: 12px; }
.phase-body label { display: flex; gap: 8px; align-items: flex-start; margin: 9px 0; color: #465069; font-size: 11px; line-height: 1.35; }
.phase-body input { accent-color: var(--blue); margin-top: 1px; }
.progress { height: 7px; border-radius: 99px; background: #e8edf6; overflow: hidden; margin-top: 12px; }
.progress span { display: block; height: 100%; background: var(--blue); width: var(--progress); transition: width .3s ease; }
.phase-progress { color: var(--muted); font-size: 9px; margin-top: 6px; }

.source-list { display: grid; gap: 8px; }
.source-item { display: grid; grid-template-columns: 42px 1fr auto; gap: 10px; align-items: start; border: 1px solid var(--line); border-radius: 9px; padding: 11px; }
.source-item h3 { font-size: 12px; margin: 0 0 4px; }
.source-item p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.4; }
.source-item a { color: var(--blue); text-decoration: none; font-weight: 700; font-size: 10px; }

.toast { position: fixed; right: 22px; bottom: 22px; background: var(--ink); color: white; border-radius: 10px; padding: 12px 15px; font-size: 11px; box-shadow: var(--shadow); transform: translateY(80px); opacity: 0; transition: .25s ease; z-index: 50; }
.toast.show { transform: none; opacity: 1; }

@media (max-width: 1180px) {
  .content-grid { grid-template-columns: minmax(0, 1fr); }
  .decision-rail { position: static; min-height: auto; }
  .rail-spacer { display: none; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: .25s ease; }
  .sidebar.open { transform: none; }
  .workspace { margin-left: 0; width: 100%; }
  .menu-toggle { display: block; }
  .crumb { margin-right: auto; }
  .top-actions > span:first-child { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi:nth-child(3):before { display: none; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .card.full { grid-column: auto; }
  .actor-network, .roadmap { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 620px) {
  .content-grid { padding: 12px; }
  .topbar { padding: 0 12px; }
  .crumb span, .crumb b { display: none; }
  .view-header { align-items: flex-start; flex-direction: column; }
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi + .kpi:before { left: 16px; right: 16px; top: 0; bottom: auto; width: auto; height: 1px; }
  .priority-banner { grid-template-columns: auto 1fr; }
  .priority-banner .action-button { grid-column: 1 / -1; }
  .bar-row { grid-template-columns: 95px 1fr 45px; }
  .risk-grid, .actor-network, .roadmap, .metric-pair { grid-template-columns: 1fr; }
  .evidence-table { display: block; overflow-x: auto; }
  .source-item { grid-template-columns: 36px 1fr; }
  .source-item a { grid-column: 2; }
}

@media print {
  .sidebar, .topbar, .decision-rail, .action-button, .filters, .menu-toggle { display: none !important; }
  .workspace { margin: 0; width: 100%; }
  .content-grid { display: block; padding: 0; }
  .card, .kpi-grid { box-shadow: none; break-inside: avoid; }
}
