/* Hajde4EU Donor Mapping – data-entry app
   Palette taken from the TACSO / TAMIS-WBT logo: navy + sky blue. */
:root {
  --navy: #26307a;
  --navy-700: #1d2563;
  --navy-900: #141a47;
  --sky: #3d9be9;
  --sky-50: #eef6fd;
  --sky-100: #dcecfb;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --ink: #161b2e;
  --ink-2: #424a63;
  --muted: #6b7390;
  --line: #e3e7ef;
  --line-2: #eef1f6;
  --green: #127a4a;   --green-bg: #e3f5ec;
  --teal: #0f6f7c;    --teal-bg: #def3f5;
  --amber: #8a5a00;   --amber-bg: #fdf1d8;
  --red: #b42318;     --red-bg: #fde8e6;
  --grey: #4a5168;    --grey-bg: #eceff4;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(20, 26, 71, .06), 0 1px 1px rgba(20, 26, 71, .04);
  --shadow-lg: 0 8px 24px rgba(20, 26, 71, .10);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--navy); text-decoration: none; }
a:hover { color: var(--sky); }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 650; }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }

/* ---------- sidebar ---------- */
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--navy-900);
  color: #c9cfe8;
  display: flex; flex-direction: column;
  padding: 18px 14px;
}
.brand { display: block; background: #fff; border-radius: var(--radius); padding: 12px 12px 10px; margin-bottom: 18px; }
.brand img { width: 100%; display: block; }
.brand span { display: block; margin-top: 8px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--navy); }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: #c9cfe8; font-weight: 500;
}
.sidebar nav a svg { width: 17px; height: 17px; flex: none; opacity: .8; }
.sidebar nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar nav a.active { background: var(--sky); color: #fff; }
.sidebar nav a.active svg { opacity: 1; }
.sidebar nav .sep { height: 1px; background: rgba(255, 255, 255, .08); margin: 10px 4px; }
.sidebar-foot { margin-top: auto; font-size: 11.5px; color: #8790b8; padding: 10px 6px 0; display: flex; gap: 8px; align-items: flex-start; }
.sidebar-foot svg { width: 14px; height: 14px; flex: none; margin-top: 2px; }

/* ---------- main ---------- */
main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 32px;
  background: rgba(244, 246, 250, .88);
  backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.crumbs { color: var(--muted); font-size: 13px; display: flex; gap: 6px; align-items: center; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--navy); }
.crumbs .cur { color: var(--ink); font-weight: 600; }
.whoami { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.whoami input { width: 74px; text-transform: uppercase; text-align: center; font-weight: 600; padding: 5px 8px; }
.whoami .avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.whoami.missing input { border-color: #f0b44c; background: var(--amber-bg); }
.content { padding: 26px 32px 80px; max-width: 1360px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-head .actions { display: flex; gap: 8px; }

/* ---------- flashes ---------- */
.flashes { padding: 16px 32px 0; display: flex; flex-direction: column; gap: 8px; max-width: 1360px; }
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid; font-size: 13.5px; }
.flash::before { content: ""; width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; background: currentColor; }
.flash.success { background: var(--green-bg); border-color: #b8e3cc; color: var(--green); }
.flash.info { background: var(--sky-50); border-color: var(--sky-100); color: var(--navy); }
.flash.warning { background: var(--amber-bg); border-color: #f3d79c; color: var(--amber); }
.flash.error { background: var(--red-bg); border-color: #f6c3be; color: var(--red); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow); transition: background .12s, border-color .12s;
}
.btn:hover { border-color: #c9d0de; color: var(--ink); background: #fafbfd; }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-700); }
.btn.sky { background: var(--sky); border-color: var(--sky); color: #fff; }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--line-2); color: var(--ink); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.danger { color: var(--red); }
.btn.lg { padding: 10px 20px; font-size: 14.5px; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.card-body { padding: 18px; }
.card + .card { margin-top: 16px; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stat { padding: 16px 18px; position: relative; overflow: hidden; }
.stat .k { font-size: 12px; color: var(--muted); font-weight: 550; text-transform: uppercase; letter-spacing: .05em; }
.stat .v { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; color: var(--navy-900); }
.stat .s { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.stat .s b { color: var(--ink-2); }
.stat::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--sky); }
.stat.warn::after { background: #e9a23b; }
.stat.bad::after { background: var(--red); }
.stat.good::after { background: #22a06b; }

.grid-2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafbfd; white-space: nowrap;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background .1s; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr:hover { background: #f8fafd; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .primary-cell a { font-weight: 600; color: var(--ink); }
table.data .primary-cell a:hover { color: var(--sky); }
table.data .sub { color: var(--muted); font-size: 12.5px; }
table.compact td { padding: 8px 14px; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty svg { width: 40px; height: 40px; color: #c3cad9; margin-bottom: 8px; }
.empty h3 { color: var(--ink-2); font-size: 15px; margin-bottom: 4px; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--grey-bg); color: var(--grey);
}
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-public, .b-confirmed, .b-A, .b-open, .b-yes { background: var(--green-bg); color: var(--green); }
.b-B, .b-rolling, .b-recurring { background: var(--teal-bg); color: var(--teal); }
.b-restricted, .b-to_verify, .b-C, .b-expected, .b-warning { background: var(--amber-bg); color: var(--amber); }
.b-confidential, .b-rejected, .b-D, .b-error { background: var(--red-bg); color: var(--red); }
.b-closed, .b-ended, .b-no { background: var(--grey-bg); color: var(--grey); }
.code-chip { display: inline-block; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11.5px; font-weight: 600; padding: 1px 6px; border-radius: 5px; background: var(--sky-50); color: var(--navy); border: 1px solid var(--sky-100); }
.conf { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; font-weight: 700; font-size: 12px; }

/* ---------- filters ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--line-2); }
.toolbar .search { position: relative; flex: 1 1 240px; max-width: 360px; }
.toolbar .search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); }
.toolbar .search input { padding-left: 32px; width: 100%; }
.toolbar select { width: auto; min-width: 140px; }
.toolbar .count { margin-left: auto; color: var(--muted); font-size: 12.5px; }

/* ---------- forms ---------- */
input[type=text], input[type=number], input[type=date], input[type=datetime-local], input[type=url], select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  padding: 8px 10px; border: 1px solid #d5dbe6; border-radius: var(--radius-sm); background: #fff;
  transition: border-color .12s, box-shadow .12s;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 3px rgba(61, 155, 233, .18); }
input[readonly] { background: var(--line-2); color: var(--muted); }
select { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7390' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }

.record-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.record-side { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 16px; }
.section-nav { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; }
.section-nav a { padding: 5px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 550; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); }
.section-nav a:hover { border-color: var(--sky); color: var(--navy); }

.form-section { scroll-margin-top: 80px; }
.form-section .card-head h2 { display: flex; align-items: center; gap: 8px; }
.form-section .card-head h2 .num { width: 22px; height: 22px; border-radius: 6px; background: var(--sky-50); color: var(--navy); display: grid; place-items: center; font-size: 11.5px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field > label, .field > .lbl { font-size: 12.5px; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.req { color: var(--red); font-weight: 700; }
.cond { font-size: 10.5px; font-weight: 600; color: var(--amber); background: var(--amber-bg); padding: 0 6px; border-radius: 4px; text-transform: uppercase; letter-spacing: .04em; }
.help { color: var(--muted); font-size: 12px; line-height: 1.4; }

.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid #d5dbe6; border-radius: var(--radius-sm); overflow: hidden; background: #fff; width: fit-content; max-width: 100%; }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 7px 13px; font-size: 13px; font-weight: 550; color: var(--ink-2); border-right: 1px solid #e5e9f1; transition: background .1s; }
.seg label:last-child span { border-right: none; }
.seg label:hover span { background: var(--sky-50); }
.seg input:checked + span { background: var(--navy); color: #fff; }
.seg input:focus-visible + span { box-shadow: inset 0 0 0 2px var(--sky); }
.seg.conf-seg input:checked + span.c-A { background: var(--green); }
.seg.conf-seg input:checked + span.c-B { background: var(--teal); }
.seg.conf-seg input:checked + span.c-C { background: #b7791f; }
.seg.conf-seg input:checked + span.c-D { background: var(--red); }
.seg.pub-seg input:checked + span.p-public { background: var(--green); }
.seg.pub-seg input:checked + span.p-restricted { background: #b7791f; }
.seg.pub-seg input:checked + span.p-confidential { background: var(--red); }
.seg .clear span { color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border: 1px solid #d5dbe6; border-radius: 999px; font-size: 12.5px; font-weight: 550; color: var(--ink-2); background: #fff; transition: all .1s; }
.chip span b { font-family: ui-monospace, Menlo, monospace; font-size: 11px; color: var(--muted); }
.chip:hover span { border-color: var(--sky); }
.chip input:checked + span { background: var(--sky-50); border-color: var(--sky); color: var(--navy); }
.chip input:checked + span b { color: var(--navy); }
.chip input:checked + span::before { content: "✓"; font-weight: 700; color: var(--sky); }
.chip input:focus-visible + span { box-shadow: 0 0 0 3px rgba(61, 155, 233, .25); }

.country-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.country-card { border: 1px solid #d5dbe6; border-radius: var(--radius-sm); padding: 10px 12px; background: #fff; transition: all .1s; }
.country-card.on { border-color: var(--sky); background: var(--sky-50); }
.country-card label { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; font-size: 13px; }
.country-card label b { font-family: ui-monospace, Menlo, monospace; font-size: 11px; color: var(--muted); margin-left: auto; }
.country-card input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--navy); }
.country-card .alloc { margin-top: 8px; display: none; }
.country-card.on .alloc { display: block; }
.country-card .alloc input { padding: 5px 8px; font-size: 12.5px; }
.sub-head { font-size: 12.5px; font-weight: 650; color: var(--ink-2); margin: 18px 0 8px; display: flex; gap: 6px; align-items: center; }
.sub-head:first-child { margin-top: 0; }

.savebar {
  position: sticky; bottom: 0; z-index: 15; margin-top: 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 18px; background: rgba(255, 255, 255, .94); backdrop-filter: blur(6px);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.savebar .hint { color: var(--muted); font-size: 12.5px; }
.error-box { background: var(--red-bg); border: 1px solid #f6c3be; color: var(--red); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; font-weight: 550; display: flex; gap: 10px; }
.error-box svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }

/* side panel */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 550; text-align: right; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 9px 0; border-bottom: 1px solid var(--line-2); display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; font-size: 13px; }
.list-plain li:last-child { border-bottom: none; }
.list-plain .meta { color: var(--muted); font-size: 12px; }
.ev-title { font-weight: 600; }
.mini-form { display: grid; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.mini-form .row { display: grid; grid-template-columns: 1fr 86px; gap: 8px; }
.history { max-height: 320px; overflow-y: auto; }
.history li { display: block; }
.history .chg { font-size: 12.5px; }
.history .chg del { color: var(--red); text-decoration: line-through; background: var(--red-bg); padding: 0 3px; border-radius: 3px; }
.history .chg ins { color: var(--green); text-decoration: none; background: var(--green-bg); padding: 0 3px; border-radius: 3px; }
.qa-item { display: flex; gap: 8px; font-size: 12.5px; padding: 6px 0; }
.qa-item .badge { flex: none; align-self: flex-start; }

/* ---------- matrix ---------- */
.matrix { border-collapse: separate; border-spacing: 4px; width: 100%; font-size: 12.5px; }
.matrix th { font-weight: 600; color: var(--ink-2); padding: 6px; }
.matrix thead th { text-align: center; font-size: 12px; }
.matrix thead th small { display: block; font-weight: 500; color: var(--muted); font-size: 10.5px; }
.matrix tbody th { text-align: left; font-weight: 550; max-width: 300px; }
.matrix tbody th .code-chip { margin-right: 6px; }
.matrix td { text-align: center; border-radius: 7px; padding: 7px 4px; min-width: 76px; background: var(--line-2); color: var(--muted); }
.matrix td a { display: block; color: inherit; }
.matrix td .n { font-weight: 700; font-size: 14px; color: var(--ink); }
.matrix td .e { font-size: 11px; }
.matrix td.score-1 { background: #e8f2fc; }
.matrix td.score-2 { background: #c9e1f8; }
.matrix td.score-3 { background: #8fc0ef; color: var(--navy-900); }
.matrix td.score-3 .n { color: var(--navy-900); }
.matrix td.empty-cell { background: #f7f8fb; border: 1px dashed #dde2ec; }
.matrix td:hover { outline: 2px solid var(--sky); }
.cls-critical_gap { background: #fde3e0 !important; box-shadow: inset 0 0 0 2px #e5675c; }
.cls-emerging_gap { background: #fdf0d5 !important; box-shadow: inset 0 0 0 2px #e9a23b; }
.cls-overlap { background: #e6e3fb !important; box-shadow: inset 0 0 0 2px #7b6fe0; }
.cls-adequate { background: #e2f4ea !important; box-shadow: inset 0 0 0 2px #4fb37f; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs a { padding: 9px 14px; font-weight: 550; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--navy); border-bottom-color: var(--navy); }

.bar { height: 8px; background: var(--line-2); border-radius: 99px; overflow: hidden; min-width: 80px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--navy), var(--sky)); border-radius: 99px; }

.dir-card { padding: 16px 18px; }
.dir-card h3 { font-size: 15px; margin-bottom: 4px; }
.dir-card .meta { color: var(--muted); font-size: 12.5px; display: flex; gap: 10px; flex-wrap: wrap; }
.dir-card p { margin: 10px 0 0; color: var(--ink-2); font-size: 13px; }
.notice { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--sky-50); border: 1px solid var(--sky-100); color: var(--navy); font-size: 13px; }
.notice svg { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.right { text-align: right; }
.mt { margin-top: 16px; }
.files { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }

@media (max-width: 1180px) {
  .record-layout { grid-template-columns: 1fr; }
  .record-side { position: static; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .country-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  body { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .fields { grid-template-columns: 1fr; }
  .content, .topbar, .flashes { padding-left: 16px; padding-right: 16px; }
}

table.data td.mono { white-space: nowrap; }
table.data td.mono.wrap { white-space: normal; }

/* ---------- import ---------- */
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 34px 20px; border: 2px dashed #c8d1e0; border-radius: var(--radius); background: #fafbfd; cursor: pointer; text-align: center; transition: all .12s; position: relative; }
.dropzone:hover, .dropzone.over { border-color: var(--sky); background: var(--sky-50); }
.dropzone.has-file { border-style: solid; border-color: var(--sky); background: var(--sky-50); }
.dropzone svg { width: 34px; height: 34px; color: var(--sky); }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.portal-settings { grid-template-columns: repeat(4, minmax(0, 1fr)); }
table.data .code-chip { white-space: nowrap; }
@media (max-width: 1180px) { .portal-settings { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 820px) { .portal-settings { grid-template-columns: 1fr; } }

/* ---------- map ---------- */
.presets { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.chip-link { padding: 5px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 550; border: 1px solid var(--line); background: #fff; color: var(--ink-2); }
.chip-link:hover { border-color: var(--sky); color: var(--navy); }
.chip-link.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.map-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.map-filters select { width: auto; min-width: 150px; max-width: 260px; padding-top: 6px; padding-bottom: 6px; font-size: 13px; }
.map-filters .check { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); }
.filter-chip { display: inline-flex; gap: 6px; align-items: center; padding: 6px 10px; border-radius: var(--radius-sm); background: var(--sky-50); border: 1px solid var(--sky-100); font-size: 13px; }
.filter-chip a { color: var(--muted); }
.map-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.map-side { display: flex; flex-direction: column; gap: 16px; }
.map-card .card-head { padding: 10px 16px; }
.region-map { display: block; width: 100%; height: auto; border-radius: 0 0 var(--radius) var(--radius); }
.region-map .sea { fill: #eef4fb; }
.region-map .land { stroke: #fff; stroke-width: .8; stroke-linejoin: round; }
.region-map .land.other { fill: #e3e7ee; }
.region-map .land.focus { cursor: pointer; transition: fill .15s; stroke-width: 1.1; }
.region-map .land.focus.xk { stroke-dasharray: 3 2; }
.region-map a:hover .land.focus { fill: #ffd98a; }
.region-map .land.selected { stroke: var(--navy-900); stroke-width: 2.2; }
.lvl-0 { fill: #cfdcec; background: #cfdcec; }
.lvl-1 { fill: #a9cbef; background: #a9cbef; }
.lvl-2 { fill: #74ace6; background: #74ace6; }
.lvl-3 { fill: #3d86d6; background: #3d86d6; color: #fff !important; }
.lvl-4 { fill: #26307a; background: #26307a; color: #fff !important; }
.region-map .pin circle { fill: #fff; stroke: var(--navy); stroke-width: 2.2; filter: drop-shadow(0 1px 2px rgba(20, 26, 71, .35)); transition: transform .12s; }
.region-map .pin text { font: 700 13px var(--font); fill: var(--navy-900); text-anchor: middle; pointer-events: none; }
.region-map .pin .pin-label { font: 700 10.5px var(--font); fill: var(--navy-900); paint-order: stroke; stroke: rgba(255,255,255,.85); stroke-width: 3px; }
.region-map .pin.empty circle { stroke: #9aa6bd; stroke-dasharray: 2 2; }
.region-map .pin.empty text { fill: #7a849c; font-size: 11px; }
.region-map .pin.selected circle { fill: var(--sky); stroke: var(--navy-900); }
.region-map .pin.selected text:not(.pin-label) { fill: #fff; }
.region-map .pin:hover circle { fill: #fff6df; }
.reg-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; color: var(--ink); }
.reg-card:hover { border-color: var(--sky); color: var(--ink); }
.reg-card.selected { border-color: var(--navy); box-shadow: 0 0 0 2px var(--sky-100); }
.reg-pin { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 16px; border: 2.2px solid var(--navy); color: var(--navy-900); background: #fff; flex: none; box-shadow: var(--shadow); }
.reg-pin.empty { border-style: dashed; border-color: #9aa6bd; color: #7a849c; }
.legend i.lvl-0, .legend i.lvl-1, .legend i.lvl-2, .legend i.lvl-3, .legend i.lvl-4 { width: 22px; }
.theme-summary { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; max-width: 60%; }
.ct-table th a { color: inherit; }
.ct-n { display: inline-block; min-width: 26px; padding: 1px 6px; border-radius: 5px; font-weight: 650; text-align: center; color: var(--navy-900); }
@media (max-width: 1180px) { .map-layout { grid-template-columns: 1fr; } }

/* ---------- call document import ---------- */
.import-grid { align-items: start; }
.field.from-doc input, .field.from-doc select, .field.from-doc textarea { background: #fff9e6; border-color: #f0c96a; }
.field.from-doc > label::after, .field.from-doc > .lbl::after { content: "from document"; font-size: 10px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: #8a5a00; background: #fdf1d8; padding: 0 6px; border-radius: 4px; }
.field.from-doc .seg { box-shadow: 0 0 0 2px #f0c96a; }
.from-doc-block { background: #fffcf2; }
.doc-meta { display: flex; flex-direction: column; gap: 2px; padding: 6px 0 10px; border-bottom: 1px solid var(--line-2); margin-bottom: 4px; font-size: 13px; }
.doc-meta .muted { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
.doc-found li { font-size: 13px; }
.doc-snip { font-style: italic; margin-top: 3px; line-height: 1.4; }
.doc-urls { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.doc-urls .btn { font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; padding: 3px 6px; }
.chip-tools { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.link-btn { background: none; border: none; padding: 0; font: inherit; color: var(--navy); cursor: pointer; font-weight: 600; }
.link-btn:hover { color: var(--sky); text-decoration: underline; }
.url-card { margin-bottom: 0; border-color: var(--sky-100); background: linear-gradient(180deg, #fff, #f7fbff); }
.url-form { display: flex; flex-direction: column; gap: 10px; }
.url-intro { display: flex; gap: 12px; align-items: flex-start; }
.url-intro > svg { width: 22px; height: 22px; color: var(--sky); flex: none; margin-top: 2px; }
.url-row { display: flex; gap: 8px; }
.url-row input { flex: 1; font-size: 14.5px; padding: 10px 12px; }
.btn.busy { opacity: .7; pointer-events: none; }

/* ---------- login & accounts ---------- */
body.login-body { display: block; min-height: 100vh; background: linear-gradient(160deg, var(--navy-900), var(--navy) 60%, #2f5fb0); }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 400px; padding: 28px 28px 22px; }
.login-brand img { width: 100%; max-width: 300px; display: block; margin-bottom: 18px; }
.login-card h1 { font-size: 20px; }
.login-card .flash { margin-top: 12px; }
.login-form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.acct-actions { display: inline-block; position: relative; text-align: left; }
.acct-actions summary { list-style: none; }
.acct-actions summary::-webkit-details-marker { display: none; }
.acct-menu { position: absolute; right: 0; top: 34px; z-index: 30; width: 280px; padding: 12px; box-shadow: var(--shadow-lg); }
