:root {
  color-scheme: light;
  --canvas: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #f0f5f8;
  --ink: #0b1e3f;
  --ink-2: #43536c;
  --ink-3: #738097;
  --teal: #006678;
  --teal-dark: #004c5c;
  --teal-soft: #e7f3f5;
  --danger: #bb2428;
  --danger-soft: #fff1f1;
  --line: #d6dee8;
  --line-strong: #b9c5d3;
  --shadow: 0 22px 60px rgba(9, 30, 63, .12);
  --font: "Manrope", "Segoe UI", sans-serif;
  --display: "IBM Plex Sans Condensed", "Arial Narrow", sans-serif;
  --mono: "IBM Plex Mono", Consolas, monospace;
  --header-h: 76px;
  --source-w: 256px;
  --panel-w: 420px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #0d1624;
  --surface: #121e2d;
  --surface-soft: #182737;
  --ink: #edf4fa;
  --ink-2: #b1c0cf;
  --ink-3: #8194a7;
  --teal: #55bdc7;
  --teal-dark: #83d4da;
  --teal-soft: #16343d;
  --danger: #ff777a;
  --danger-soft: #382126;
  --line: #293c50;
  --line-strong: #3e5368;
  --shadow: 0 22px 60px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
}
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button, input, select, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--teal) 35%, transparent);
  outline-offset: 2px;
}
[hidden] { display: none !important; }
svg { display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: -5rem; left: 1rem; z-index: 200; padding: .7rem 1rem; background: var(--ink); color: var(--surface); text-decoration: none; }
.skip-link:focus { top: 1rem; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1.5rem;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: blur(14px);
}
.brand { display: inline-flex; align-items: center; gap: 13px; width: max-content; color: var(--ink); text-decoration: none; }
.brand > span:last-child { min-width: 0; }
.brand strong { display: block; font-family: var(--display); font-size: 1.42rem; font-weight: 700; line-height: 1; letter-spacing: -.015em; }
.brand small { display: block; margin-top: 5px; color: var(--ink-3); font-size: .62rem; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; }
.brand-mark, .empty-mark { position: relative; display: block; width: 42px; height: 42px; border: 5px solid var(--ink); }
.brand-mark i, .brand-mark b, .empty-mark i, .empty-mark b { position: absolute; display: block; background: var(--surface); }
.brand-mark i, .empty-mark i { right: -8px; bottom: -7px; width: 18px; height: 18px; }
.brand-mark b, .empty-mark b { right: -8px; bottom: -7px; width: 8px; height: 8px; background: var(--teal); }
.scope-tabs { display: flex; align-items: center; border: 1px solid var(--line); background: var(--canvas); }
.scope-tabs button { min-width: 142px; height: 40px; border: 0; border-right: 1px solid var(--line); background: transparent; color: var(--ink-2); font-size: .76rem; font-weight: 700; }
.scope-tabs button:last-child { border-right: 0; }
.scope-tabs button.active { background: var(--surface); color: var(--ink); box-shadow: inset 0 -3px 0 var(--teal); }
.scope-tabs .customs-tab { color: var(--teal); }
.scope-tabs .customs-tab.active { background: var(--teal); color: #fff; box-shadow: inset 0 -3px 0 var(--ink); }
.topbar-tools { justify-self: end; display: flex; align-items: center; gap: 10px; }
.live-state { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-2); font-size: .68rem; white-space: nowrap; }
.live-state i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.live-state.online i { background: var(--teal); box-shadow: 0 0 0 4px color-mix(in srgb, var(--teal) 12%, transparent); }
.live-state.error i { background: var(--danger); }
.mcp-button { height: 36px; display: inline-flex; align-items: center; padding: 0; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.mcp-button span { height: 100%; display: grid; place-items: center; padding: 0 10px; background: var(--ink); color: var(--surface); font-size: .6rem; font-weight: 700; letter-spacing: .08em; }
.mcp-button code { padding: 0 9px; color: var(--ink-2); font-family: var(--mono); font-size: .6rem; }
.icon-button, .panel-close { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.icon-button svg { width: 17px; height: 17px; }

.app-shell { display: grid; grid-template-columns: var(--source-w) minmax(520px, 1fr) var(--panel-w); max-width: 1800px; min-height: calc(100vh - var(--header-h)); margin: 0 auto; }
.app-shell.general-layout { grid-template-columns: minmax(520px,1fr) var(--panel-w); }
.source-sidebar, .document-panel { position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h)); overflow: auto; background: var(--surface); }
.source-sidebar { display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.source-sidebar > h2 { margin: 0; padding: 28px 24px 13px; color: var(--ink-3); font-family: var(--mono); font-size: .63rem; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; }
.source-list { display: grid; gap: 3px; padding: 0 12px; }
.source-link { position: relative; display: grid; grid-template-columns: 25px minmax(0,1fr); align-items: center; gap: 12px; min-height: 54px; width: 100%; padding: 8px 12px; border: 0; background: transparent; color: var(--ink); text-align: left; }
.source-link::before { content: ""; position: absolute; left: -12px; top: 0; bottom: 0; width: 4px; background: var(--teal); transform: scaleY(0); }
.source-link:hover { background: var(--surface-soft); }
.source-link.active { background: var(--teal); color: #fff; }
.source-link.active::before { transform: scaleY(1); }
.source-link svg { width: 22px; height: 22px; }
.source-link b { display: block; font-size: .78rem; font-weight: 700; }
.source-link small { display: block; margin-top: 2px; color: var(--ink-3); font-size: .57rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source-link.active small { color: rgba(255,255,255,.72); }
.coverage { margin: auto 16px 12px; padding: 14px; border: 1px solid var(--line); background: var(--canvas); }
.coverage > div:first-child { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.coverage h3 { margin: 0; font-family: var(--display); font-size: .82rem; }
.coverage > div > span { color: var(--teal); font-family: var(--mono); font-size: .55rem; font-weight: 500; text-transform: uppercase; }
.coverage dl { margin: 10px 0; }
.coverage dl div { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--line); }
.coverage dt { color: var(--ink-3); font-size: .61rem; }
.coverage dd { margin: 0; font-family: var(--mono); font-size: .62rem; }
.coverage p { margin: 8px 0 0; color: var(--ink-3); font-size: .56rem; line-height: 1.35; }
.official-domain { display: grid; grid-template-columns: 23px minmax(0,1fr) 18px; align-items: center; gap: 10px; margin: 0 16px 18px; padding: 12px; border: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.official-domain > svg:first-child { width: 22px; height: 22px; color: var(--teal); }
.official-domain > svg:last-child { width: 16px; height: 16px; color: var(--teal); }
.official-domain small { display: block; color: var(--ink-3); font-size: .57rem; }
.official-domain b { display: block; margin-top: 2px; font-family: var(--mono); font-size: .62rem; font-weight: 500; }

.main-workspace { min-width: 0; padding: 34px clamp(24px, 3vw, 46px) 24px; }
.search-area { max-width: 980px; margin: 0 auto; }
.search-box { display: grid; grid-template-columns: 50px minmax(0,1fr) 124px; height: 64px; border: 1px solid var(--line-strong); background: var(--surface); }
.search-box > svg { align-self: center; justify-self: center; width: 22px; height: 22px; color: var(--ink-2); }
.search-box input { min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 1rem; font-weight: 500; }
.search-box input::placeholder { color: var(--ink-3); }
.search-box button { margin: -1px; border: 0; background: var(--teal); color: #fff; font-family: var(--display); font-size: 1.05rem; font-weight: 700; }
.search-box button:hover { background: var(--teal-dark); }
.filter-bar { display: grid; grid-template-columns: 1.15fr 1.15fr .82fr 1fr; gap: 8px; margin-top: 18px; }
.filter-bar > label, .repealed-filter, .search-mode { min-width: 0; min-height: 64px; margin: 0; padding: 10px 13px; border: 1px solid var(--line); background: var(--surface); }
.filter-bar label > span, .search-mode legend { display: block; margin-bottom: 4px; color: var(--ink-3); font-size: .58rem; font-weight: 600; letter-spacing: .03em; }
.filter-bar select, .filter-bar input[type="number"], .filter-bar input[type="date"] { width: 100%; height: 28px; padding: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: .76rem; font-weight: 600; }
.repealed-filter { display: flex; align-items: center; gap: 10px; }
.repealed-filter input { width: 16px; height: 16px; accent-color: var(--teal); }
.repealed-filter > span { margin: 0 !important; }
.repealed-filter b { display: block; color: var(--ink); font-size: .69rem; }
.repealed-filter small { display: block; margin-top: 3px; color: var(--ink-3); font-size: .58rem; }
.general-filters { grid-template-columns: 1.35fr 1.2fr 1fr 1fr; }
.search-mode { display: flex; align-items: flex-end; gap: 2px; border: 0; padding: 0; background: transparent; }
.search-mode legend { position: absolute; transform: translate(12px, 8px); }
.search-mode label { flex: 1; position: relative; }
.search-mode input { position: absolute; opacity: 0; pointer-events: none; }
.search-mode label span { display: grid; place-items: center; height: 64px; margin: 0; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: .67rem; }
.search-mode label + label span { border-left: 0; }
.search-mode input:checked + span { background: var(--ink); color: var(--surface); }

.results { max-width: 980px; margin: 32px auto 0; }
.results-header { display: flex; align-items: end; justify-content: space-between; gap: 18px; min-height: 49px; padding: 0 2px 12px; border-bottom: 1px solid var(--line-strong); }
.results-header h2 { margin: 0; font-family: var(--display); font-size: 1.28rem; font-weight: 700; }
.results-header p { margin: 0; color: var(--ink-3); font-size: .65rem; }
.results-header strong { color: var(--ink); font-family: var(--mono); font-size: .85rem; font-weight: 500; }
.result-columns { display: grid; grid-template-columns: minmax(0,1fr) 145px 105px 24px; gap: 12px; padding: 10px 13px 7px 63px; color: var(--ink-3); font-family: var(--mono); font-size: .54rem; letter-spacing: .05em; text-transform: uppercase; }
.status-note { display: grid; grid-template-columns: 40px 1fr; align-items: center; gap: 10px; padding: 20px 14px; border: 1px dashed var(--line-strong); background: var(--surface); }
.status-note > span { color: var(--teal); font-family: var(--mono); font-size: .7rem; }
.status-note strong { font-family: var(--display); font-size: .88rem; }
.status-note p { margin: 3px 0 0; color: var(--ink-3); font-size: .67rem; }
.status-note.error > span { color: var(--danger); }
.result-list { position: relative; border: 1px solid var(--line); background: var(--surface); }
.result-list::before { content: ""; position: absolute; z-index: 2; left: 25px; top: 29px; bottom: 29px; width: 1px; background: var(--teal); }
.result-item { position: relative; display: grid; grid-template-columns: 38px minmax(0,1fr) 145px 105px 24px; gap: 12px; align-items: center; width: 100%; min-height: 84px; padding: 12px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--ink); text-align: left; }
.result-item:last-child { border-bottom: 0; }
.result-item:hover { background: var(--surface-soft); }
.result-item.selected { background: var(--teal-soft); box-shadow: inset 4px 0 0 var(--teal), inset 0 0 0 1px var(--teal); }
.result-node { position: relative; z-index: 3; display: grid; place-items: center; width: 16px; height: 16px; margin-left: 5px; border: 1px solid var(--teal); background: var(--surface); color: transparent; }
.result-item.selected .result-node { background: var(--teal); box-shadow: 0 0 0 5px var(--teal-soft); }
.result-item.repealed .result-node { border-color: var(--danger); }
.result-title { display: block; font-size: .8rem; font-weight: 700; line-height: 1.3; }
.result-subline { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 5px; color: var(--ink-2); font-size: .65rem; }
.result-subline span + span::before { content: "·"; margin-right: 7px; color: var(--ink-3); }
.result-context { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; margin-top: 4px; color: var(--ink-3); font-size: .59rem; }
.result-source, .result-date { color: var(--ink-2); font-size: .64rem; }
.result-date { font-family: var(--mono); font-size: .58rem; }
.result-arrow { width: 18px; height: 18px; color: var(--ink); }
.result-arrow svg { width: 100%; height: 100%; }
.skeleton { height: 84px; border-bottom: 1px solid var(--line); background: var(--surface); animation: pulse 1s ease-in-out infinite alternate; }
@keyframes pulse { to { background: var(--surface-soft); } }
.pagination { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 18px; }
.pagination button { width: 38px; height: 38px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.pagination button:disabled { opacity: .35; cursor: not-allowed; }
.pagination span { color: var(--ink-2); font-family: var(--mono); font-size: .62rem; }
.legal-note { max-width: 980px; margin: 34px auto 0; padding-top: 14px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: .59rem; }

.document-panel { border-left: 1px solid var(--line); }
.panel-empty { height: 100%; display: flex; flex-direction: column; justify-content: center; padding: 42px; }
.empty-mark { width: 54px; height: 54px; margin-bottom: 28px; border-width: 6px; color: var(--line-strong); }
.panel-empty h2 { margin: 0; font-family: var(--display); font-size: 1.4rem; }
.panel-empty p { max-width: 28ch; margin: 9px 0 0; color: var(--ink-2); font-size: .72rem; }
.panel-document { min-height: 100%; padding: 26px 28px 22px; }
.sheet-handle { display: none; }
.panel-header { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.panel-header span { display: block; margin-bottom: 6px; color: var(--teal); font-family: var(--mono); font-size: .58rem; font-weight: 500; letter-spacing: .05em; text-transform: uppercase; }
.panel-header h2 { margin: 0; font-family: var(--display); font-size: 1.42rem; font-weight: 700; line-height: 1.12; }
.panel-close { flex: 0 0 auto; font-size: 1.35rem; }
.citation-spine { position: relative; display: grid; margin: 24px 0 20px; padding-left: 25px; }
.citation-spine::before { content: ""; position: absolute; left: 6px; top: 9px; bottom: 9px; width: 1px; background: var(--teal); }
.citation-line { position: relative; display: grid; grid-template-columns: 94px minmax(0,1fr); gap: 10px; padding: 8px 0; }
.citation-line::before { content: ""; position: absolute; left: -25px; top: 13px; width: 12px; height: 12px; border: 1px solid var(--teal); background: var(--surface); }
.citation-line:first-child::before { background: var(--teal); }
.citation-line span { color: var(--ink-3); font-family: var(--mono); font-size: .55rem; letter-spacing: .04em; text-transform: uppercase; }
.citation-line b { overflow-wrap: anywhere; font-size: .65rem; font-weight: 600; }
.citation-line.warning b { color: var(--danger); }
.panel-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; padding: 14px 0; border-top: 1px solid var(--line); }
.panel-actions a, .panel-actions button { min-height: 44px; display: flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); text-decoration: none; font-size: .64rem; font-weight: 700; }
.panel-actions a { border-color: var(--teal); background: var(--teal); color: #fff; }
.panel-actions svg { width: 17px; height: 17px; }
.document-search { display: grid; grid-template-columns: 32px minmax(0,1fr) auto; align-items: center; min-height: 45px; border: 1px solid var(--line); background: var(--surface); }
.document-search > svg { justify-self: end; width: 17px; height: 17px; color: var(--ink-2); }
.document-search input { min-width: 0; height: 43px; padding: 0 10px; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: .66rem; }
.document-search > span { padding-right: 10px; color: var(--ink-3); font-family: var(--mono); font-size: .5rem; white-space: nowrap; }
.reader-warning { margin-top: 10px; padding: 9px 11px; background: var(--danger-soft); color: var(--danger); font-size: .58rem; }
.reader-content { height: calc(100vh - 410px); min-height: 250px; margin: 10px 0 0; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 18px; font-family: var(--font); font-size: .67rem; line-height: 1.65; }
.reader-content mark { background: #ffe487; color: #211c0b; }
.load-more { width: 100%; min-height: 42px; margin-top: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--teal); font-size: .64rem; font-weight: 700; }
.panel-backdrop { display: none; }
.toast { position: fixed; left: 50%; bottom: 20px; z-index: 110; transform: translate(-50%, 12px); opacity: 0; pointer-events: none; padding: 10px 14px; background: var(--ink); color: var(--surface); box-shadow: var(--shadow); font-size: .66rem; transition: opacity .15s ease, transform .15s ease; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

/* Gümrükçe evidence-first intake */
.app-shell.customs-layout { grid-template-columns: minmax(0,1fr); max-width: 1600px; }
.app-shell.customs-layout .main-workspace { padding: 0; }
.customs-workspace { max-width: 1320px; margin: 0 auto; padding: 38px clamp(24px,4vw,64px) 70px; }
.customs-hero { display: flex; align-items: end; justify-content: space-between; gap: 40px; padding-bottom: 26px; border-bottom: 1px solid var(--line-strong); }
.customs-hero > div:first-child { max-width: 780px; }
.eyebrow { display: block; color: var(--teal); font-family: var(--mono); font-size: .62rem; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; }
.customs-hero h1 { margin: 7px 0 10px; font-family: var(--display); font-size: clamp(2.3rem,4.5vw,4.8rem); line-height: .9; letter-spacing: -.035em; }
.customs-hero p { max-width: 74ch; margin: 0; color: var(--ink-2); font-size: .82rem; line-height: 1.7; }
.safety-seal { flex: 0 0 118px; width: 118px; height: 118px; display: grid; place-items: center; align-content: center; border: 1px solid var(--danger); color: var(--danger); text-align: center; }
.safety-seal b { font-family: var(--display); font-size: 2.2rem; line-height: 1; }
.safety-seal span { max-width: 75px; margin-top: 7px; font-size: .53rem; font-weight: 700; line-height: 1.25; text-transform: uppercase; }
.customs-flow { display: grid; grid-template-columns: auto 1fr auto 1fr auto; align-items: center; gap: 14px; margin: 20px 0 28px; color: var(--ink-3); font-family: var(--mono); font-size: .58rem; }
.customs-flow span { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.customs-flow i { width: 24px; height: 24px; display: grid; place-items: center; border: 1px solid var(--line-strong); font-style: normal; }
.customs-flow span.active { color: var(--ink); }
.customs-flow span.active i { border-color: var(--teal); background: var(--teal); color: #fff; }
.customs-flow b { height: 1px; background: var(--line); }
.customs-form { display: grid; grid-template-columns: minmax(0,1fr) 270px; gap: 20px; align-items: start; }
.intake-card, .readiness-card { border: 1px solid var(--line); background: var(--surface); }
.intake-card { padding: clamp(22px,3vw,38px); }
.section-heading { display: flex; align-items: center; gap: 15px; margin-bottom: 24px; }
.section-heading > span { flex: 0 0 auto; width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--teal); color: var(--teal); font-family: var(--mono); font-size: .65rem; }
.section-heading h2 { margin: 0; font-family: var(--display); font-size: 1.45rem; }
.section-heading p { margin: 2px 0 0; color: var(--ink-3); font-size: .62rem; }
.field { display: block; min-width: 0; }
.field > span { display: block; margin-bottom: 7px; color: var(--ink-2); font-size: .61rem; font-weight: 700; }
.field > span b { color: var(--danger); }
.field input, .field textarea, .field select { width: 100%; border: 1px solid var(--line); border-radius: 0; outline: 0; background: var(--canvas); color: var(--ink); font-size: .72rem; }
.field input, .field select { height: 46px; padding: 0 12px; }
.field textarea { min-height: 88px; padding: 12px; resize: vertical; line-height: 1.55; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--teal); box-shadow: inset 3px 0 0 var(--teal); }
.field-wide { margin-bottom: 20px; }
.field-wide textarea { min-height: 78px; }
.product-input-grid { display: grid; grid-template-columns: 240px minmax(0,1fr); gap: 18px; }
.upload-zone { position: relative; min-height: 260px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 18px; overflow: hidden; border: 1px dashed var(--line-strong); background: var(--canvas); text-align: center; cursor: pointer; }
.upload-zone.dragging { border-color: var(--teal); background: var(--teal-soft); }
.upload-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-icon { width: 46px; height: 46px; display: grid; place-items: center; margin-bottom: 14px; border: 1px solid var(--teal); color: var(--teal); }
.upload-icon svg { width: 22px; height: 22px; }
.upload-zone b { font-family: var(--display); font-size: .95rem; }
.upload-zone small { max-width: 175px; margin-top: 6px; color: var(--ink-3); font-size: .57rem; }
.upload-zone img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.upload-zone.has-image::after { content: "Değiştir"; position: absolute; right: 8px; bottom: 8px; padding: 6px 9px; background: rgba(11,30,63,.9); color: #fff; font-size: .56rem; font-weight: 700; }
.product-fields { display: grid; gap: 13px; }
.product-fields > .field textarea { min-height: 102px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.advanced-fields { margin-top: 18px; border: 1px solid var(--line); background: var(--canvas); }
.advanced-fields summary { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 16px; cursor: pointer; list-style: none; }
.advanced-fields summary::-webkit-details-marker { display: none; }
.advanced-fields summary::after { content: "+"; color: var(--teal); font-family: var(--mono); font-size: 1rem; }
.advanced-fields[open] summary::after { content: "−"; }
.advanced-fields summary span { font-size: .69rem; font-weight: 700; }
.advanced-fields summary small { margin-left: auto; color: var(--ink-3); font-size: .57rem; }
.advanced-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 13px; padding: 18px 16px; border-top: 1px solid var(--line); background: var(--surface); }
.cost-grid { grid-template-columns: repeat(4,minmax(0,1fr)); }
.verified-rate input { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.rate-warning { margin: 0; padding: 0 16px 16px; background: var(--surface); color: var(--danger); font-size: .56rem; }
.consent-line { display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: center; margin-top: 18px; padding: 12px; background: var(--danger-soft); color: var(--danger); }
.consent-line > span { width: 26px; height: 26px; display: grid; place-items: center; border: 1px solid currentColor; font-family: var(--mono); }
.consent-line p { margin: 0; font-size: .58rem; line-height: 1.5; }
.analyse-button { width: 100%; min-height: 58px; display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; border: 0; background: var(--teal); color: #fff; font-family: var(--display); font-size: 1rem; font-weight: 700; }
.analyse-button:hover { background: var(--teal-dark); }
.analyse-button:disabled { opacity: .6; cursor: wait; }
.analyse-button svg { width: 20px; height: 20px; }
.readiness-card { position: sticky; top: calc(var(--header-h) + 20px); padding: 23px 20px; }
.readiness-card h2 { margin: 7px 0 18px; font-family: var(--display); font-size: 1.24rem; }
.readiness-card ul { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.readiness-card li { display: grid; grid-template-columns: 19px 1fr; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.readiness-card li i { width: 15px; height: 15px; margin-top: 2px; border: 1px solid var(--line-strong); }
.readiness-card li.ready i { border-color: var(--teal); background: var(--teal); box-shadow: inset 0 0 0 3px var(--surface); }
.readiness-card li b { display: block; font-size: .66rem; }
.readiness-card li small { display: block; margin-top: 2px; color: var(--ink-3); font-size: .55rem; }
.source-stack { display: grid; gap: 7px; margin-top: 22px; padding-top: 17px; border-top: 1px solid var(--line-strong); }
.source-stack > span { color: var(--ink-3); font-family: var(--mono); font-size: .54rem; text-transform: uppercase; }
.source-stack > div { display: grid; grid-template-columns: 31px 1fr; align-items: center; gap: 8px; }
.source-stack > div b { width: 29px; height: 29px; display: grid; place-items: center; background: var(--ink); color: var(--surface); font-family: var(--mono); font-size: .55rem; }
.source-stack p { margin: 0; color: var(--ink-2); font-size: .54rem; }
.source-stack > small { color: var(--danger); font-size: .52rem; line-height: 1.45; }
.customs-result { margin-top: 26px; }
.analysis-loading { display: flex; align-items: center; gap: 17px; padding: 24px; border: 1px solid var(--line); background: var(--surface); }
.analysis-loading i { width: 28px; height: 28px; border: 2px solid var(--line); border-top-color: var(--teal); border-radius: 50%; animation: spin .75s linear infinite; }
.analysis-loading b, .analysis-loading span { display: block; }
.analysis-loading b { font-family: var(--display); font-size: 1rem; }
.analysis-loading span { margin-top: 3px; color: var(--ink-3); font-size: .62rem; }
@keyframes spin { to { transform: rotate(360deg); } }
.answer-sheet { border: 1px solid var(--line); background: var(--surface); }
.answer-head { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 16px; align-items: start; padding: 24px; border-bottom: 1px solid var(--line); }
.answer-status { padding: 6px 8px; background: var(--teal-soft); color: var(--teal); font-family: var(--mono); font-size: .55rem; text-transform: uppercase; }
.answer-status.warning { background: var(--danger-soft); color: var(--danger); }
.answer-head h2 { margin: 0; font-family: var(--display); font-size: 1.45rem; }
.answer-head p { margin: 7px 0 0; color: var(--ink-2); font-size: .7rem; line-height: 1.6; }
.answer-head time { color: var(--ink-3); font-family: var(--mono); font-size: .53rem; white-space: nowrap; }
.answer-section { padding: 22px 24px; border-bottom: 1px solid var(--line); }
.answer-section > h3 { margin: 0 0 13px; color: var(--ink-3); font-family: var(--mono); font-size: .58rem; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; }
.candidate-grid, .finding-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.candidate-card, .finding-card { padding: 15px; border: 1px solid var(--line); background: var(--canvas); }
.candidate-card code { color: var(--teal); font-family: var(--mono); font-size: .9rem; }
.candidate-card b, .finding-card b { display: block; margin-top: 8px; font-size: .67rem; }
.candidate-card p, .finding-card p { margin: 5px 0 0; color: var(--ink-2); font-size: .59rem; line-height: 1.55; }
.finding-card > span { display: inline-block; padding: 3px 6px; background: var(--teal-soft); color: var(--teal); font-family: var(--mono); font-size: .5rem; text-transform: uppercase; }
.finding-card.unknown > span, .finding-card.conditional > span { background: var(--danger-soft); color: var(--danger); }
.citation-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.citation-chips a { padding: 3px 6px; border: 1px solid var(--line); color: var(--teal); font-family: var(--mono); font-size: .48rem; text-decoration: none; }
.missing-list, .next-list { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: .65rem; line-height: 1.8; }
.cost-table { width: 100%; border-collapse: collapse; font-size: .65rem; }
.cost-table td { padding: 9px 0; border-bottom: 1px solid var(--line); }
.cost-table td:last-child { text-align: right; font-family: var(--mono); }
.source-ledger { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }
.source-ledger a { display: grid; grid-template-columns: 36px 1fr; gap: 10px; padding: 11px; border: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.source-ledger code { color: var(--teal); font-family: var(--mono); font-size: .52rem; }
.source-ledger b { display: block; font-size: .61rem; }
.source-ledger small { display: block; margin-top: 2px; color: var(--ink-3); font-size: .51rem; }
.legal-banner { padding: 18px 24px; border-left: 5px solid var(--danger); background: var(--danger-soft); color: var(--danger); font-size: .61rem; line-height: 1.65; }
.answer-error { padding: 22px; border: 1px solid var(--danger); background: var(--danger-soft); color: var(--danger); }
.answer-error h2 { margin: 0; font-family: var(--display); }
.answer-error p { margin: 7px 0 0; font-size: .65rem; }
.followup-box { display: grid; grid-template-columns: minmax(0,1fr) 250px; gap: 10px; margin-top: 14px; padding: 16px; border: 1px solid var(--line); background: var(--surface); }
.followup-box .analyse-button { min-height: 46px; margin: 24px 0 0; font-size: .86rem; }

@media (max-width: 1260px) {
  .app-shell { grid-template-columns: 224px minmax(0,1fr); }
  .app-shell.general-layout { grid-template-columns: minmax(0,1fr); }
  .app-shell.customs-layout { grid-template-columns: minmax(0,1fr); }
  .document-panel { position: fixed; top: var(--header-h); right: 0; z-index: 70; width: min(var(--panel-w), 94vw); transform: translateX(105%); box-shadow: var(--shadow); transition: transform .18s ease; }
  .document-panel.open { transform: translateX(0); }
  .panel-backdrop { position: fixed; inset: var(--header-h) 0 0; z-index: 65; width: 100%; height: auto; border: 0; background: rgba(5,16,33,.46); opacity: 0; pointer-events: none; }
  body.reader-open .panel-backdrop { display: block; opacity: 1; pointer-events: auto; }
}

@media (max-width: 840px) {
  :root { --header-h: 64px; }
  .topbar { grid-template-columns: 1fr auto; gap: 10px; padding: 0 14px; }
  .brand strong { font-size: 1.05rem; }
  .brand small, .live-state, .mcp-button { display: none; }
  .brand-mark { width: 34px; height: 34px; border-width: 4px; }
  .scope-tabs { position: fixed; top: var(--header-h); left: 0; right: 0; z-index: 45; }
  .scope-tabs button { flex: 1; min-width: 0; height: 46px; }
  .app-shell { display: block; padding-top: 46px; }
  .source-sidebar { position: static; height: auto; display: block; overflow: visible; border-right: 0; border-bottom: 1px solid var(--line); }
  .source-sidebar > h2, .coverage, .official-domain { display: none; }
  .source-list { display: flex; gap: 0; padding: 0; overflow-x: auto; scrollbar-width: thin; }
  .source-link { flex: 0 0 auto; width: auto; min-height: 54px; grid-template-columns: 16px auto; gap: 8px; padding: 8px 14px; border-right: 1px solid var(--line); }
  .source-link::before { left: 0; right: 0; top: auto; bottom: 0; width: auto; height: 3px; transform: scaleX(0); }
  .source-link.active::before { transform: scaleX(1); }
  .source-link svg { width: 16px; height: 16px; }
  .source-link small { display: none; }
  .source-link b { font-size: .68rem; white-space: nowrap; }
  .main-workspace { padding: 18px 14px 30px; }
  .search-box { grid-template-columns: 42px minmax(0,1fr) 74px; height: 58px; }
  .search-box input { font-size: .84rem; }
  .search-box button { font-size: .9rem; }
  .filter-bar { grid-template-columns: 1fr 1fr; margin-top: 10px; }
  .filter-bar > label, .repealed-filter, .search-mode { min-height: 58px; }
  .general-filters { grid-template-columns: 1fr 1fr; }
  .search-mode { grid-column: 1 / -1; }
  .results { margin-top: 24px; }
  .results-header { align-items: center; }
  .result-columns { display: none; }
  .result-list { margin-top: 10px; border-left: 0; border-right: 0; }
  .result-item { grid-template-columns: 34px minmax(0,1fr) 22px; gap: 8px; min-height: 96px; padding: 14px 7px; }
  .result-list::before { left: 18px; }
  .result-node { margin-left: 3px; }
  .result-source, .result-date { display: none; }
  .result-context { -webkit-line-clamp: 2; }
  .legal-note { margin-top: 26px; }
  .document-panel { top: auto; bottom: 0; width: 100%; height: min(82vh, 720px); border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0; transform: translateY(105%); }
  .document-panel.open { transform: translateY(0); }
  .panel-backdrop { inset: calc(var(--header-h) + 46px) 0 0; }
  .panel-document { padding: 14px 18px 18px; }
  .sheet-handle { display: block; width: 50px; height: 5px; margin: 0 auto 15px; border-radius: 5px; background: var(--line-strong); }
  .panel-header h2 { font-size: 1.35rem; }
  .citation-spine { grid-template-columns: 1fr 1fr; gap: 0 10px; margin: 18px 0 10px; padding-left: 0; border-top: 1px solid var(--line); }
  .citation-spine::before, .citation-line::before { display: none; }
  .citation-line { display: block; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .citation-line span { display: block; margin-bottom: 3px; }
  .reader-content { height: calc(82vh - 355px); min-height: 190px; }
  .customs-workspace { padding: 24px 14px 48px; }
  .customs-hero { align-items: start; }
  .customs-hero h1 { font-size: 3rem; }
  .safety-seal { width: 86px; height: 86px; flex-basis: 86px; }
  .safety-seal b { font-size: 1.5rem; }
  .safety-seal span { font-size: .45rem; }
  .customs-flow { grid-template-columns: 1fr 1fr 1fr; }
  .customs-flow b { display: none; }
  .customs-flow span { white-space: normal; font-size: .5rem; }
  .customs-form { grid-template-columns: 1fr; }
  .readiness-card { position: static; }
  .readiness-card ul { grid-template-columns: 1fr 1fr; }
  .product-input-grid { grid-template-columns: 190px minmax(0,1fr); }
  .advanced-grid, .cost-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 500px) {
  .filter-bar { grid-template-columns: 1fr; }
  .repealed-filter { min-height: 52px; }
  .general-filters { grid-template-columns: 1fr; }
  .results-header h2 { font-size: 1.12rem; }
  .result-title { font-size: .76rem; }
  .panel-actions { grid-template-columns: 1fr 1fr; }
  .panel-actions a, .panel-actions button { padding: 6px; font-size: .59rem; }
  .customs-hero { display: block; }
  .safety-seal { display: none; }
  .customs-flow { overflow-x: auto; }
  .product-input-grid { grid-template-columns: 1fr; }
  .upload-zone { min-height: 190px; }
  .field-row, .advanced-grid, .cost-grid, .candidate-grid, .finding-grid, .source-ledger { grid-template-columns: 1fr; }
  .readiness-card ul { grid-template-columns: 1fr; }
  .answer-head { grid-template-columns: 1fr; }
  .followup-box { grid-template-columns: 1fr; }
  .followup-box .analyse-button { margin-top: 0; }
}

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