:root {
  --ink: #eef5ff;
  --muted: #91a4bb;
  --faint: #60738c;
  --canvas: #050b13;
  --surface: #091523;
  --surface-2: #0d1c2d;
  --surface-3: #13263a;
  --line: #1c344b;
  --line-bright: #2d4f6b;
  --mint: #58f0c2;
  --mint-soft: rgba(88, 240, 194, 0.12);
  --amber: #ffb45c;
  --amber-soft: rgba(255, 180, 92, 0.12);
  --red: #ff6b72;
  --red-soft: rgba(255, 107, 114, 0.12);
  --blue: #6da8ff;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.3);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 75% 0%, #10253c 0, transparent 30rem), var(--canvas); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

.auth-view { min-height: 100vh; display: grid; place-items: center; padding: 2rem; }
.auth-view::before { content: ""; position: fixed; inset: 0; pointer-events: none; background-image: linear-gradient(rgba(109,168,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(109,168,255,.035) 1px, transparent 1px); background-size: 42px 42px; mask-image: linear-gradient(to bottom, black, transparent 80%); }
.auth-card { width: min(100%, 34rem); position: relative; padding: clamp(2rem, 7vw, 4.5rem); border: 1px solid var(--line); border-radius: 1.75rem; background: linear-gradient(145deg, rgba(15, 33, 52, .95), rgba(7, 17, 31, .98)); box-shadow: var(--shadow); }
.auth-card h1 { margin: .75rem 0 1rem; font-size: clamp(2.5rem, 8vw, 4.4rem); line-height: .92; letter-spacing: -.07em; }
.auth-card h1 em { color: var(--mint); font-style: normal; }
.auth-copy { color: var(--muted); line-height: 1.65; font-size: 1.02rem; margin-bottom: 2rem; }
.eyebrow { color: var(--mint); font-size: .75rem; font-weight: 800; letter-spacing: .16em; margin: 0 0 .45rem; }
.brand-mark { width: 3.2rem; height: 3.2rem; display: flex; align-items: end; gap: .28rem; padding: .62rem; background: var(--mint-soft); border: 1px solid rgba(88,240,194,.25); border-radius: 1rem; }
.brand-mark span { display: block; width: 100%; border-radius: 10px 10px 2px 2px; background: var(--mint); }
.brand-mark span:nth-child(1) { height: 44%; opacity: .55; }
.brand-mark span:nth-child(2) { height: 70%; opacity: .75; }
.brand-mark span:nth-child(3) { height: 100%; }
.brand-mark.small { width: 2.5rem; height: 2.5rem; padding: .5rem; border-radius: .75rem; flex: 0 0 auto; }

.stack-form { display: grid; gap: .55rem; }
label { color: #c3d1e1; font-size: .87rem; font-weight: 700; }
.input-action { display: flex; gap: .65rem; }
input, select, textarea { width: 100%; min-height: 2.8rem; border: 1px solid var(--line-bright); border-radius: .75rem; background: #07121f; color: var(--ink); padding: .7rem .8rem; outline: none; }
textarea { min-height: 6rem; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--mint); box-shadow: 0 0 0 3px rgba(88,240,194,.12); }
input[type="checkbox"] { width: 1.1rem; min-height: auto; accent-color: var(--mint); }
input[type="range"] { padding: 0; accent-color: var(--mint); }
.form-message { min-height: 1.25rem; color: var(--red); margin: .15rem 0 0; font-size: .88rem; }
.microcopy { color: var(--faint); font-size: .78rem; line-height: 1.5; margin: 1.35rem 0 0; }

.button { min-height: 2.65rem; border: 1px solid var(--line-bright); border-radius: .72rem; padding: .62rem .95rem; background: var(--surface-2); cursor: pointer; font-weight: 800; font-size: .86rem; transition: transform .16s ease, border-color .16s ease, background .16s ease; }
.button:hover { transform: translateY(-1px); border-color: #47769a; }
.button:focus-visible { outline: 3px solid rgba(88,240,194,.35); outline-offset: 2px; }
.button.primary { background: var(--mint); color: #03120d; border-color: var(--mint); }
.button.secondary { background: var(--blue); color: #06111f; border-color: var(--blue); }
.button.danger { background: var(--red-soft); color: #ffb7ba; border-color: rgba(255,107,114,.4); }
.button.ghost { background: transparent; }
.button.small { min-height: 2.2rem; padding: .4rem .7rem; font-size: .78rem; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 15.5rem minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--line); background: rgba(5,11,19,.94); backdrop-filter: blur(18px); padding: 1.4rem 1.1rem; display: flex; flex-direction: column; z-index: 10; }
.brand { display: flex; align-items: center; gap: .8rem; text-decoration: none; font-size: .78rem; letter-spacing: .12em; line-height: 1.25; margin: .15rem .35rem 2rem; }
.brand strong { color: var(--mint); font-size: 1.02rem; }
.main-nav { display: grid; gap: .35rem; }
.main-nav a { text-decoration: none; color: var(--muted); display: flex; align-items: center; gap: .75rem; min-height: 2.9rem; padding: .65rem .75rem; border-radius: .8rem; font-size: .91rem; font-weight: 700; }
.main-nav a span { width: 1.2rem; text-align: center; color: var(--faint); font-size: 1.15rem; }
.main-nav a:hover { background: var(--surface); color: var(--ink); }
.main-nav a.active { background: var(--mint-soft); color: var(--mint); }
.main-nav a.active span { color: var(--mint); }
.scope-card { margin-top: auto; padding: 1rem; border: 1px solid var(--line); border-radius: .9rem; background: var(--surface); }
.scope-card strong { font-size: .82rem; }
.scope-card p { color: var(--faint); font-size: .74rem; line-height: 1.45; margin: .5rem 0 0; }
.status-dot { display: inline-block; width: .48rem; height: .48rem; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 5px rgba(88,240,194,.08); margin-right: .45rem; }
.logout { width: 100%; margin-top: .8rem; color: var(--muted); }

.workspace { min-width: 0; padding: 0 clamp(1rem, 3.2vw, 3.2rem) 4rem; }
.topbar { min-height: 6.7rem; display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; border-bottom: 1px solid var(--line); }
.topbar h2 { margin: 0; font-size: clamp(1.65rem, 3vw, 2.25rem); letter-spacing: -.045em; }
.topbar-actions { display: flex; align-items: center; gap: .75rem; }
.assisted-badge { color: var(--muted); border: 1px solid var(--line); background: var(--surface); border-radius: 99rem; padding: .55rem .75rem; font-size: .76rem; font-weight: 700; white-space: nowrap; }
.assisted-badge i { display: inline-block; width: .45rem; height: .45rem; border-radius: 50%; background: var(--mint); margin-right: .35rem; }
.notice { margin: 1.25rem 0; border-left: 3px solid var(--amber); background: var(--amber-soft); color: #c9b48f; padding: .8rem 1rem; font-size: .84rem; line-height: 1.5; }
.notice strong { color: var(--amber); }

.section-head { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin: 1.9rem 0 1rem; }
.section-head h3 { margin: 0; font-size: 1.15rem; letter-spacing: -.02em; }
.section-head p { color: var(--muted); font-size: .83rem; margin: .35rem 0 0; }
.grid { display: grid; gap: 1rem; }
.kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { border: 1px solid var(--line); border-radius: 1rem; background: linear-gradient(145deg, var(--surface-2), var(--surface)); padding: 1.15rem; min-height: 8.2rem; display: flex; flex-direction: column; justify-content: space-between; }
.kpi .label { color: var(--muted); font-size: .77rem; font-weight: 700; }
.kpi strong { display: block; font-size: 2.3rem; letter-spacing: -.07em; }
.kpi small { color: var(--faint); font-size: .72rem; }
.kpi.accent { border-color: rgba(88,240,194,.4); background: linear-gradient(145deg, rgba(88,240,194,.13), var(--surface)); }
.kpi.accent strong { color: var(--mint); }

.dashboard-grid { grid-template-columns: minmax(0, 1.6fr) minmax(18rem, .8fr); align-items: start; }
.panel { border: 1px solid var(--line); border-radius: 1rem; background: rgba(9,21,35,.8); overflow: hidden; }
.panel-body { padding: 1rem; }
.offer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.offer-card { border: 1px solid var(--line); background: var(--surface); border-radius: 1rem; overflow: hidden; cursor: pointer; transition: transform .18s ease, border-color .18s ease; }
.offer-card:hover { transform: translateY(-2px); border-color: var(--line-bright); }
.offer-visual { height: 8rem; position: relative; display: flex; align-items: flex-end; padding: .9rem; background: linear-gradient(125deg, #102f43, #0b1d32 58%, #172a33); overflow: hidden; }
.offer-visual::after { content: ""; position: absolute; inset: auto -15% -65% 20%; aspect-ratio: 1; border: 1px solid rgba(88,240,194,.35); border-radius: 50%; box-shadow: 0 0 0 2rem rgba(88,240,194,.04), 0 0 0 4rem rgba(109,168,255,.035); }
.offer-visual img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.offer-visual .demo-flag { position: relative; z-index: 1; background: rgba(5,11,19,.82); border: 1px solid var(--line-bright); border-radius: 99rem; padding: .35rem .55rem; font-size: .68rem; font-weight: 900; letter-spacing: .08em; }
.offer-card-content { padding: .95rem; }
.offer-card h4 { margin: 0 0 .4rem; font-size: 1rem; line-height: 1.3; }
.offer-card p { color: var(--muted); margin: 0; font-size: .78rem; }
.chip-row { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .8rem; }
.chip { display: inline-flex; align-items: center; gap: .3rem; border: 1px solid var(--line); background: var(--surface-2); border-radius: 99rem; padding: .33rem .52rem; color: #afbdd0; font-size: .68rem; font-weight: 800; }
.chip.good { color: var(--mint); border-color: rgba(88,240,194,.3); background: var(--mint-soft); }
.chip.warn { color: var(--amber); border-color: rgba(255,180,92,.3); background: var(--amber-soft); }
.chip.bad { color: #ff9ca1; border-color: rgba(255,107,114,.3); background: var(--red-soft); }
.score-ring { margin-left: auto; width: 2.45rem; height: 2.45rem; display: grid; place-items: center; border: 3px solid var(--line-bright); border-top-color: var(--mint); border-radius: 50%; font-size: .72rem; font-weight: 900; }
.card-title-row { display: flex; align-items: start; gap: .65rem; }

.alert-list, .decision-list, .timeline-list { display: grid; gap: .55rem; }
.alert-item { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .7rem; padding: .75rem; border-bottom: 1px solid var(--line); }
.alert-item:last-child { border-bottom: 0; }
.alert-icon { width: 2rem; height: 2rem; display: grid; place-items: center; border-radius: .6rem; background: var(--amber-soft); color: var(--amber); font-weight: 900; }
.alert-item strong { display: block; font-size: .8rem; }
.alert-item small { color: var(--faint); font-size: .7rem; }
.country-bars { display: grid; gap: .75rem; }
.bar-row { display: grid; grid-template-columns: 2rem 1fr 2rem; align-items: center; gap: .55rem; font-size: .75rem; }
.bar-track { height: .55rem; border-radius: 99rem; background: #05101b; overflow: hidden; }
.bar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--mint)); }

.research-hero { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(17rem, .6fr); gap: 1rem; margin: 1.5rem 0 1rem; }
.research-intro { padding: 1.25rem; border: 1px solid rgba(88,240,194,.35); border-radius: 1rem; background: linear-gradient(145deg, rgba(88,240,194,.11), var(--surface)); }
.research-intro h3 { margin: 0 0 .5rem; font-size: 1.3rem; }
.research-intro p { color: var(--muted); margin: 0; line-height: 1.6; font-size: .86rem; }
.research-steps { display: grid; gap: .55rem; padding: 1rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); }
.research-step { display: grid; grid-template-columns: 1.8rem 1fr; align-items: start; gap: .6rem; color: var(--muted); font-size: .78rem; line-height: 1.45; }
.research-step strong { width: 1.8rem; height: 1.8rem; display: grid; place-items: center; border-radius: .55rem; color: var(--mint); background: var(--mint-soft); }
.research-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.search-card { display: grid; gap: .9rem; padding: 1rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); }
.search-card.disabled { opacity: .62; }
.search-card-head { display: flex; align-items: start; justify-content: space-between; gap: .7rem; }
.search-card h4 { margin: 0; font-size: 1rem; line-height: 1.35; }
.search-card p { color: var(--muted); margin: .25rem 0 0; font-size: .78rem; }
.search-terms { min-height: 3.4rem; padding: .7rem; border: 1px solid var(--line); border-radius: .7rem; color: #c4d2e2; background: #07121f; font-size: .78rem; line-height: 1.45; word-break: break-word; }
.search-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.search-actions .button:first-child { flex: 1 1 12rem; }
.capture-summary { display: grid; gap: .6rem; margin-top: 1rem; padding: .85rem; border: 1px solid var(--line); border-radius: .8rem; background: var(--surface-2); }
.capture-summary p { color: var(--muted); margin: 0; font-size: .8rem; line-height: 1.5; }

.toolbar { display: flex; gap: .65rem; flex-wrap: wrap; margin: 1.5rem 0 1rem; }
.toolbar input { flex: 1 1 15rem; }
.toolbar select { width: auto; min-width: 8rem; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 1rem; }
table { width: 100%; border-collapse: collapse; min-width: 48rem; background: rgba(9,21,35,.8); }
th, td { text-align: left; padding: .8rem .9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--faint); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; }
td { color: #c8d4e2; font-size: .82rem; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }

.empty-state { text-align: center; padding: 3.5rem 1.5rem; border: 1px dashed var(--line-bright); border-radius: 1rem; color: var(--muted); }
.empty-state strong { display: block; color: var(--ink); margin-bottom: .4rem; }
.loading-state { min-height: 16rem; display: grid; place-content: center; gap: .7rem; color: var(--muted); font-size: .85rem; text-align: center; }
.loading-state span { width: 2rem; height: 2rem; border: 3px solid var(--line); border-top-color: var(--mint); border-radius: 50%; animation: spin .8s linear infinite; margin: auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.modal { width: min(94vw, 66rem); max-height: 92vh; color: var(--ink); background: var(--surface); border: 1px solid var(--line-bright); border-radius: 1.25rem; padding: 0; box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(1,6,12,.8); backdrop-filter: blur(7px); }
.modal-close { position: sticky; float: right; top: .85rem; right: .85rem; z-index: 4; width: 2.2rem; height: 2.2rem; border: 1px solid var(--line-bright); border-radius: 50%; background: var(--surface-2); cursor: pointer; font-size: 1.35rem; }
#modalContent { padding: clamp(1.2rem, 4vw, 2.2rem); }
.modal-head { margin-bottom: 1.4rem; padding-right: 2.5rem; }
.modal-head h3 { margin: .25rem 0 .5rem; font-size: 1.65rem; letter-spacing: -.04em; }
.modal-head p { color: var(--muted); margin: 0; line-height: 1.5; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; }
.form-field { display: grid; gap: .4rem; }
.form-field.full { grid-column: 1 / -1; }
.checkbox-field { display: flex; align-items: start; gap: .55rem; color: var(--muted); line-height: 1.45; }
.form-actions { display: flex; justify-content: flex-end; gap: .7rem; margin-top: 1.3rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.bump-list { display: grid; gap: .65rem; }
.bump-row { display: grid; grid-template-columns: minmax(10rem, 1fr) 7rem 7rem 2.4rem; gap: .55rem; align-items: end; }
.icon-button { width: 2.4rem; height: 2.8rem; border: 1px solid var(--line); border-radius: .65rem; background: var(--red-soft); color: var(--red); cursor: pointer; }

.dossier-hero { display: grid; grid-template-columns: minmax(11rem, 16rem) 1fr; gap: 1.4rem; padding-bottom: 1.4rem; border-bottom: 1px solid var(--line); }
.dossier-visual { min-height: 12rem; border-radius: 1rem; background: linear-gradient(135deg, #143449, #0b1a2d); overflow: hidden; display: grid; place-items: center; color: var(--faint); }
.dossier-visual img { width: 100%; height: 100%; object-fit: cover; }
.dossier-title h3 { margin: .4rem 0 .65rem; font-size: 1.8rem; letter-spacing: -.045em; }
.dossier-title p { color: var(--muted); line-height: 1.5; }
.dossier-actions { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: 1rem; }
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; margin: 1.2rem 0; }
.detail { border: 1px solid var(--line); border-radius: .75rem; padding: .75rem; }
.detail small { display: block; color: var(--faint); font-size: .67rem; text-transform: uppercase; letter-spacing: .08em; margin-bottom: .3rem; }
.detail strong { font-size: .83rem; word-break: break-word; }
.dossier-section { margin-top: 1.5rem; }
.dossier-section h4 { font-size: .92rem; color: var(--mint); margin: 0 0 .75rem; }
.record-list { display: grid; gap: .6rem; }
.record { border-left: 2px solid var(--line-bright); background: var(--surface-2); padding: .75rem .9rem; }
.record strong { font-size: .82rem; }
.record p { color: var(--muted); font-size: .78rem; margin: .35rem 0 0; line-height: 1.5; }
.record a { color: var(--blue); }
.gate-list { display: grid; gap: .4rem; margin: .7rem 0 0; padding: 0; list-style: none; }
.gate-list li { color: #ffb0b4; background: var(--red-soft); border-radius: .55rem; padding: .5rem .65rem; font-size: .75rem; }
.timeline-item { display: grid; grid-template-columns: 4.2rem 1fr; gap: .8rem; }
.timeline-marker { color: var(--mint); font-weight: 900; border-right: 1px solid var(--line-bright); }
.timeline-body { padding-bottom: 1rem; }

.settings-grid { grid-template-columns: minmax(0, 1fr) minmax(18rem, .6fr); }
.setting-card { padding: 1.1rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); }
.setting-card h3 { margin-top: 0; }
.integration-off { display: flex; gap: .8rem; align-items: start; padding: 1rem; border: 1px dashed var(--line-bright); border-radius: .8rem; }
.integration-off span { width: .7rem; height: .7rem; border-radius: 50%; background: var(--faint); margin-top: .35rem; flex: 0 0 auto; }
.integration-off p { color: var(--muted); margin: .25rem 0 0; font-size: .82rem; line-height: 1.5; }
.weight-row { display: grid; grid-template-columns: minmax(10rem, 1fr) minmax(8rem, 1fr) 3rem; gap: .7rem; align-items: center; margin: .7rem 0; }
.weight-row output { color: var(--mint); text-align: right; font-weight: 900; }
.toast-region { position: fixed; right: 1rem; bottom: 1rem; z-index: 50; display: grid; gap: .5rem; }
.toast { max-width: 24rem; background: #12283b; border: 1px solid var(--line-bright); border-left: 3px solid var(--mint); border-radius: .75rem; padding: .8rem 1rem; box-shadow: var(--shadow); font-size: .82rem; animation: toast-in .2s ease-out; }
.toast.error { border-left-color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(.5rem); } }

@media (max-width: 1050px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid, .settings-grid, .research-hero { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  .app-shell { display: block; }
  .sidebar { position: sticky; height: auto; padding: .7rem; border-right: 0; border-bottom: 1px solid var(--line); flex-direction: row; align-items: center; overflow-x: auto; }
  .brand { margin: 0 .7rem 0 0; }
  .brand > span:last-child, .scope-card, .logout { display: none; }
  .main-nav { display: flex; gap: .25rem; }
  .main-nav a { min-height: 2.45rem; white-space: nowrap; padding: .5rem .65rem; font-size: .78rem; }
  .main-nav a span { display: none; }
  .workspace { padding: 0 .9rem 3rem; }
  .topbar { min-height: 5.6rem; }
  .assisted-badge { display: none; }
  .offer-grid { grid-template-columns: 1fr; }
  .research-grid { grid-template-columns: 1fr; }
  .dossier-hero { grid-template-columns: 1fr; }
  .dossier-visual { min-height: 10rem; }
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
  .auth-view { padding: .7rem; }
  .auth-card { padding: 1.5rem; border-radius: 1.1rem; }
  .input-action { flex-direction: column; }
  .topbar { align-items: center; }
  .topbar-actions .button { font-size: 0; width: 2.8rem; padding: .5rem; }
  .topbar-actions .button::after { content: "+"; font-size: 1.2rem; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: .65rem; }
  .kpi { min-height: 7.2rem; padding: .85rem; }
  .kpi strong { font-size: 1.8rem; }
  .form-grid { grid-template-columns: 1fr; }
  .form-field.full { grid-column: auto; }
  .bump-row { grid-template-columns: 1fr 6rem 2.4rem; }
  .bump-row .bump-currency { display: none; }
  .detail-grid { grid-template-columns: 1fr; }
  .modal { width: 100vw; max-height: 96vh; margin: auto 0 0; border-radius: 1.15rem 1.15rem 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
