:root {
  --ink: #102f2e;
  --ink-soft: #315755;
  --forest: #123c3a;
  --forest-deep: #0a2928;
  --paper: #f2f5f4;
  --white: #ffffff;
  --mist: #dfe8e5;
  --line: #c9d7d3;
  --signal: #f4c95d;
  --signal-deep: #9a7311;
  --risk: #d95d50;
  --success: #2f816f;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(12, 48, 45, .08);
  font-family: "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid rgba(244, 201, 93, .75); outline-offset: 2px;
}
.skip-link { position: fixed; left: 1rem; top: -4rem; z-index: 100; padding: .7rem 1rem; background: var(--signal); color: var(--forest-deep); }
.skip-link:focus { top: 1rem; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 27px 17px 22px; background: var(--forest-deep); color: white; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 9px 29px; }
.brand svg { width: 38px; height: 38px; fill: none; stroke: var(--signal); stroke-width: 1.7; }
.brand strong { display: block; font-size: 1.25rem; letter-spacing: -.03em; }
.brand span { display: block; margin-top: -2px; color: #a9c2bd; font-size: .78rem; letter-spacing: .04em; }
.nav-list { display: grid; gap: 4px; }
.nav-item { width: 100%; border: 0; border-radius: 9px; background: transparent; color: #b8cbc7; padding: 10px 12px; text-align: left; display: flex; align-items: center; gap: 11px; font-size: .87rem; }
.nav-item span { width: 18px; color: #779b95; text-align: center; }
.nav-item:hover { background: rgba(255,255,255,.055); color: white; }
.nav-item.active { color: var(--forest-deep); background: var(--signal); font-weight: 700; }
.nav-item.active span { color: inherit; }
.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.12); padding: 18px 9px 0; }
.sidebar-foot small { display: block; color: #7d9f9a; margin-top: 6px; }
.network-state { font-size: .8rem; color: #c9d8d5; }
.network-state i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--signal); margin-right: 7px; }
.workspace { min-width: 0; padding: 34px clamp(22px, 4vw, 58px) 60px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 28px; }
.topbar p { margin: 0 0 3px; color: var(--ink-soft); font-size: .82rem; }
.topbar h1 { margin: 0; font-size: clamp(1.55rem, 3vw, 2.45rem); line-height: 1.08; letter-spacing: -.045em; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.operator { color: var(--ink-soft); font-size: .8rem; padding-right: 7px; }
.logout-form { margin: 0; }
.logout-button { padding: 9px 6px; }
.btn { border: 1px solid transparent; border-radius: 9px; padding: 10px 15px; font-weight: 700; font-size: .82rem; }
.btn.primary { background: var(--forest); color: white; }
.btn.primary:hover { background: var(--forest-deep); }
.btn.secondary { background: var(--white); border-color: var(--line); color: var(--ink); }
.btn.small { padding: 7px 10px; font-size: .74rem; }
.text-button { border: 0; background: transparent; color: var(--success); font-weight: 700; }
.view { display: none; }
.view.active { display: block; }
.journey { padding: 25px 27px 17px; color: white; background: var(--forest); border-radius: 18px; overflow: hidden; position: relative; box-shadow: var(--shadow); }
.journey::after { content: ""; position: absolute; width: 260px; height: 260px; right: -100px; top: -150px; border: 38px solid rgba(244,201,93,.13); border-radius: 50%; }
.journey-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; position: relative; z-index: 1; }
.journey h2 { margin: 3px 0 0; font-size: 1.45rem; letter-spacing: -.03em; }
.section-label { display: block; color: var(--ink-soft); font-size: .72rem; font-weight: 700; }
.journey .section-label { color: #9ec0ba; }
.status-pill { display: inline-flex; border-radius: 99px; padding: 5px 9px; background: #d9eee8; color: #1b6a5b; font-size: .7rem; font-weight: 800; }
.status-pill.neutral { background: rgba(255,255,255,.13); color: #e4efed; }
.route { list-style: none; display: grid; grid-template-columns: repeat(5, 1fr); margin: 29px 0 0; padding: 0; position: relative; z-index: 1; }
.route::before { content: ""; position: absolute; left: 9px; right: calc(10% - 9px); top: 8px; height: 1px; background: rgba(255,255,255,.25); }
.route li { position: relative; padding: 24px 20px 0 0; }
.route i { position: absolute; top: 0; left: 0; width: 17px; height: 17px; background: var(--forest); border: 3px solid #6f9992; border-radius: 50%; }
.route li.done i { border-color: var(--signal); background: var(--signal); box-shadow: 0 0 0 4px rgba(244,201,93,.12); }
.route strong, .route span { display: block; }
.route strong { font-size: .82rem; }
.route span { margin-top: 3px; color: #9fbab5; font-size: .7rem; }
.metric-strip { display: grid; grid-template-columns: repeat(5, 1fr); background: var(--white); border: 1px solid var(--line); border-radius: 14px; margin: 17px 0; }
.metric-strip article { padding: 18px 20px; border-right: 1px solid var(--line); }
.metric-strip article:last-child { border: 0; }
.metric-strip span, .metric-strip small, .metric-strip strong { display: block; }
.metric-strip span { color: var(--ink-soft); font-size: .7rem; }
.metric-strip strong { font-size: 1.75rem; letter-spacing: -.05em; margin: 2px 0; }
.metric-strip small { color: #6e8985; font-size: .65rem; }
.metric-strip .budget strong { color: var(--signal-deep); }
.overview-grid, .monitor-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, .9fr); gap: 17px; }
.panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 21px; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 17px; }
.panel-head h2 { margin: 2px 0 0; font-size: 1rem; letter-spacing: -.02em; }
.empty-state { padding: 35px; text-align: center; color: var(--ink-soft); border: 1px dashed var(--line); border-radius: 10px; }
.empty-state strong { color: var(--ink); }
.empty-state p { max-width: 52ch; margin: 7px auto 0; font-size: .82rem; line-height: 1.55; }
.lead-row { display: grid; grid-template-columns: 54px minmax(130px,1fr) 1.1fr 90px; gap: 13px; align-items: center; padding: 13px 0; border-top: 1px solid var(--mist); text-align: left; }
.lead-row:first-child { border-top: 0; }
.priority-ring { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; border: 4px solid var(--signal); font-weight: 800; }
.lead-row strong, .lead-row small { display: block; }
.lead-row small { color: var(--ink-soft); margin-top: 2px; }
.channel-list { display: flex; gap: 5px; flex-wrap: wrap; }
.channel { padding: 4px 7px; border-radius: 5px; background: var(--mist); font-size: .66rem; color: var(--forest); }
.guardrails { list-style: none; margin: 0; padding: 0; }
.guardrails li { display: grid; grid-template-columns: 88px 1fr; gap: 11px; padding: 12px 0; border-top: 1px solid var(--mist); }
.guardrails li:first-child { border-top: 0; }
.guardrails b { font-size: .74rem; color: var(--risk); }
.guardrails span { font-size: .74rem; line-height: 1.45; color: var(--ink-soft); }
.notice { padding: 11px 14px; border-radius: 9px; margin: -12px 0 18px; background: #e0f0eb; border-left: 4px solid var(--success); font-size: .82rem; }
.notice.error { background: #fae8e5; border-color: var(--risk); }
.section-intro { display: flex; justify-content: space-between; align-items: center; margin-bottom: 17px; }
.campaign-list { display: grid; gap: 12px; }
.campaign-card { display: grid; grid-template-columns: minmax(180px, 1.5fr) 1fr auto; align-items: center; gap: 20px; padding: 19px 21px; background: white; border: 1px solid var(--line); border-radius: 12px; }
.campaign-card h3 { margin: 0 0 4px; font-size: 1rem; }
.campaign-card p { margin: 0; font-size: .72rem; color: var(--ink-soft); }
.campaign-meta { display: flex; gap: 22px; }
.campaign-meta span { font-size: .7rem; color: var(--ink-soft); }
.campaign-meta b { display: block; margin-top: 2px; color: var(--ink); }
.campaign-actions { display: flex; gap: 6px; }
.table-wrap { overflow-x: auto; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .78rem; }
th { padding: 12px 16px; text-align: left; color: var(--ink-soft); background: #e9efed; font-size: .68rem; }
td { padding: 14px 16px; border-top: 1px solid var(--mist); vertical-align: middle; }
tbody tr { cursor: default; }
#leads-body tr { cursor: pointer; }
tbody tr:hover { background: #f7f9f8; }
.score { font-weight: 800; font-size: .95rem; }
.filterbar { display: flex; align-items: end; gap: 12px; margin-bottom: 14px; }
label { display: grid; gap: 6px; color: var(--ink-soft); font-size: .74rem; font-weight: 700; }
input, select, textarea { width: 100%; padding: 10px 11px; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 8px; }
textarea { resize: vertical; }
.map-board { display: grid; grid-template-columns: .8fr 1.2fr; gap: 25px; background: white; padding: 26px; border: 1px solid var(--line); border-radius: var(--radius); }
.map-copy h2 { font-size: 1.6rem; line-height: 1.1; letter-spacing: -.04em; max-width: 14ch; }
.map-copy p { max-width: 52ch; color: var(--ink-soft); line-height: 1.6; font-size: .82rem; }
.schematic-map { min-height: 420px; position: relative; overflow: hidden; border-radius: 10px; background-color: #dce9e2; background-image: linear-gradient(rgba(18,60,58,.07) 1px, transparent 1px), linear-gradient(90deg, rgba(18,60,58,.07) 1px, transparent 1px); background-size: 34px 34px; }
.schematic-map::before, .schematic-map::after { content: ""; position: absolute; border: 1px solid rgba(18,60,58,.25); border-radius: 45% 55% 65% 35%; }
.schematic-map::before { inset: 19% 17% 24% 25%; transform: rotate(-8deg); }
.schematic-map::after { inset: 31% 28% 11% 38%; transform: rotate(9deg); }
.schematic-map .coast { position: absolute; left: -18%; top: -10%; width: 42%; height: 130%; background: #9ecbd1; transform: rotate(10deg); border-right: 5px solid rgba(255,255,255,.6); }
.schematic-map button { position: absolute; left: var(--x); top: var(--y); z-index: 2; transform: translate(-50%,-50%); border: 1px solid var(--forest); border-radius: 99px; padding: 8px 11px; background: white; color: var(--forest); font-size: .7rem; box-shadow: 0 6px 20px rgba(18,60,58,.12); }
.schematic-map button:nth-of-type(1) { --x: 32%; --y: 28%; }
.schematic-map button:nth-of-type(2) { --x: 46%; --y: 52%; }
.schematic-map button:nth-of-type(3) { --x: 62%; --y: 72%; }
.event-list { display: grid; gap: 8px; }
.event { display: flex; justify-content: space-between; gap: 14px; padding: 10px 0; border-top: 1px solid var(--mist); font-size: .75rem; }
.event:first-child { border-top: 0; }
.event span { color: var(--ink-soft); }
.export-sheet { display: grid; grid-template-columns: 1.2fr .8fr; gap: 40px; padding: clamp(24px,4vw,46px); background: white; border: 1px solid var(--line); border-radius: var(--radius); }
.export-sheet h2 { margin: 5px 0 13px; font-size: 1.8rem; letter-spacing: -.045em; }
.export-sheet p { color: var(--ink-soft); max-width: 60ch; line-height: 1.6; }
.warning-box { padding: 13px; background: #fff7de; border-left: 4px solid var(--signal); font-size: .76rem; line-height: 1.5; }
.export-sheet form { display: grid; gap: 14px; align-content: start; padding: 20px; background: var(--paper); border-radius: 11px; }
.export-result { font-size: .74rem; line-height: 1.5; }
.export-result a { color: var(--success); font-weight: 800; }
dialog { width: min(680px, calc(100vw - 30px)); padding: 0; border: 0; border-radius: 16px; box-shadow: 0 30px 90px rgba(5,33,31,.28); }
dialog::backdrop { background: rgba(7,35,33,.58); backdrop-filter: blur(3px); }
.dialog-form { padding: 25px; }
.dialog-form.wide { width: 100%; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; }
.dialog-head h2 { margin: 3px 0 0; letter-spacing: -.035em; }
.icon-button { border: 0; background: var(--paper); border-radius: 50%; width: 34px; height: 34px; font-size: 1.3rem; color: var(--ink-soft); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.span-2 { grid-column: span 2; }
.form-note { color: var(--ink-soft); font-size: .72rem; line-height: 1.5; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 19px; }
.lead-dialog { width: min(800px, calc(100vw - 30px)); }
.detail-grid { display: grid; grid-template-columns: 220px 1fr; gap: 20px; }
.score-stack { display: grid; gap: 8px; }
.score-box { padding: 12px; background: var(--paper); border-radius: 8px; }
.score-box strong { display: block; font-size: 1.4rem; }
.score-box strong.compact-value { font-size: .85rem; }
.evidence-item { padding: 12px 0; border-top: 1px solid var(--mist); }
.evidence-item:first-child { border-top: 0; }
.evidence-item blockquote { margin: 7px 0; padding-left: 10px; border-left: 3px solid var(--signal); color: var(--ink-soft); font-size: .75rem; }
.evidence-item a { color: var(--success); word-break: break-all; font-size: .7rem; }

.login-page { min-height: 100vh; background: var(--forest-deep); }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(420px, .95fr); }
.login-brand { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center; padding: clamp(40px, 8vw, 112px); color: white; background: var(--forest-deep); }
.login-brand::after { content: ""; position: absolute; width: 440px; height: 440px; right: -240px; bottom: -210px; border: 68px solid rgba(244,201,93,.1); border-radius: 50%; }
.login-mark { width: 58px; height: 58px; display: grid; place-items: center; margin-bottom: 42px; border: 1px solid rgba(244,201,93,.35); border-radius: 16px; background: rgba(255,255,255,.035); }
.login-mark svg { width: 40px; height: 40px; fill: none; stroke: var(--signal); stroke-width: 1.7; }
.login-eyebrow { color: var(--signal); font-size: .76rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.login-brand h1 { max-width: 700px; margin: 14px 0 20px; font-size: clamp(2.25rem, 4vw, 4.1rem); line-height: .98; letter-spacing: -.055em; text-wrap: balance; }
.login-brand > p { max-width: 590px; margin: 0; color: #b8d0cc; font-size: clamp(.95rem, 1.4vw, 1.15rem); line-height: 1.65; }
.login-guardrails { display: grid; gap: 11px; margin: 38px 0 0; padding: 0; list-style: none; color: #d8e5e2; font-size: .82rem; }
.login-guardrails li { display: flex; align-items: center; gap: 10px; }
.login-guardrails i { width: 8px; height: 8px; border-radius: 50%; background: var(--signal); box-shadow: 0 0 0 4px rgba(244,201,93,.1); }
.login-panel { display: grid; place-items: center; padding: clamp(22px, 5vw, 70px); background: var(--paper); }
.login-card { width: min(430px, 100%); padding: clamp(25px, 5vw, 42px); background: white; border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); }
.login-card h2 { margin: 7px 0 8px; font-size: clamp(1.75rem, 3vw, 2.3rem); letter-spacing: -.045em; }
.login-intro { margin: 0 0 27px; color: var(--ink-soft); font-size: .86rem; line-height: 1.5; }
.login-form { display: grid; gap: 9px; }
.login-form label { margin-top: 7px; }
.login-form input { min-height: 48px; font-size: 1rem; }
.login-form input:focus { border-color: var(--success); box-shadow: 0 0 0 3px rgba(47,129,111,.13); }
.login-submit { min-height: 48px; margin-top: 14px; font-size: .9rem; }
.login-error { display: grid; gap: 3px; margin: 0 0 18px; padding: 13px 14px; color: #7d2720; background: #fae8e5; border-left: 4px solid var(--risk); border-radius: 7px; font-size: .8rem; line-height: 1.4; }
.login-error strong { font-size: .76rem; }
.login-meta { margin: 22px 0 0; color: #6e8985; font-size: .7rem; line-height: 1.5; text-align: center; }

@media (max-width: 980px) {
  .login-shell { grid-template-columns: 1fr 440px; }
  .login-brand { padding: 50px; }
  .app-shell { grid-template-columns: 72px minmax(0,1fr); }
  .sidebar { padding-inline: 10px; }
  .brand div, .nav-item:not(.active)::after, .nav-item { font-size: 0; }
  .brand { padding-inline: 7px; }
  .brand svg { min-width: 38px; }
  .nav-item { justify-content: center; padding: 11px; }
  .nav-item span { width: auto; font-size: 1rem; }
  .sidebar-foot { display: none; }
  .metric-strip { grid-template-columns: repeat(3,1fr); }
  .metric-strip article:nth-child(3) { border-right: 0; }
  .metric-strip article:nth-child(n+4) { border-top: 1px solid var(--line); }
  .overview-grid, .monitor-grid, .map-board, .export-sheet { grid-template-columns: 1fr; }
}

@media (max-width: 690px) {
  .login-shell { display: block; min-height: 100vh; background: var(--paper); }
  .login-brand { min-height: auto; padding: 31px 24px 44px; }
  .login-mark { width: 48px; height: 48px; margin-bottom: 27px; }
  .login-mark svg { width: 34px; height: 34px; }
  .login-brand h1 { font-size: clamp(2rem, 8.5vw, 2.7rem); }
  .login-brand > p, .login-intro { font-size: 1rem; }
  .login-guardrails { display: none; }
  .login-panel { padding: 0 15px 35px; background: linear-gradient(var(--forest-deep) 32px, var(--paper) 32px); }
  .login-card { position: relative; border-radius: 17px; padding: 25px 21px; }
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 20; left: 0; right: 0; top: auto; bottom: 0; width: auto; height: 66px; padding: 8px; }
  .brand, .sidebar-foot { display: none; }
  .nav-list { display: flex; overflow-x: auto; gap: 2px; }
  .nav-item { min-width: 50px; }
  .workspace { padding: 23px 15px 90px; }
  .topbar { display: block; }
  .topbar-actions { margin-top: 15px; flex-wrap: wrap; }
  .operator { display: none; }
  .route { grid-template-columns: 1fr; gap: 13px; padding-left: 4px; }
  .route::before { left: 12px; top: 8px; bottom: 20px; right: auto; width: 1px; height: auto; }
  .route li { padding: 0 0 0 32px; }
  .route i { top: 1px; }
  .metric-strip { grid-template-columns: repeat(2,1fr); }
  .metric-strip article { border-top: 1px solid var(--line); }
  .metric-strip article:nth-child(-n+2) { border-top: 0; }
  .metric-strip article:nth-child(even) { border-right: 0; }
  .lead-row { grid-template-columns: 48px 1fr; }
  .lead-row > :nth-child(n+3) { grid-column: 2; }
  .campaign-card { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .filterbar { align-items: stretch; flex-direction: column; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: no-preference) {
  dialog[open] { animation: reveal .18s ease-out; }
  @keyframes reveal { from { opacity: 0; transform: translateY(8px) scale(.985); } }
}

