:root,
.mini {
  --paper: #f3ecdf;
  --paper-2: #fffaf2;
  --ink: #241c15;
  --muted: #6f6256;
  --line: #e2d5c3;
  --rail: #14241e;
  --rail-soft: #1d332b;
  --rail-text: #edf3ee;
  --rail-muted: #c9d5ce;
  --rail-line: rgba(237, 243, 238, 0.4);
  --leaf: #d7f09a;
  --on-accent: #14241e;
  --green: #1d6b45;
  --bad: #8d3b24;
  --bad-bg: #f6ddd4;
  --ok-bg: #dcead9;
  --wait: #8a5a16;
  --wait-bg: #f4e6c4;
  --shadow: 0 16px 40px rgba(36, 28, 21, 0.06);
  --track: #efe4d4;
  --input-bg: #fff;
  --selected: #f7f1e3;
  --story: #fffdf8;
  --radius: 16px;
  --radius-sm: 10px;
  --pill: 999px;
  --sidebar: 280px;
  --h1: 42px;
  --h2: 34px;
  --h3: 22px;
  --stat: 28px;
  --display: Palatino, "Palatino Linotype", "Times New Roman", serif;
  --sans: "Segoe UI", "Helvetica Neue", sans-serif;
  --scheme: light;
  color: var(--ink);
  font-family: var(--sans);
  background: var(--paper);
  color-scheme: var(--scheme);
}

html[data-theme="primer"],
.mini[data-preview="primer"] {
  --paper: #f6f8fa;
  --paper-2: #ffffff;
  --ink: #1f2328;
  --muted: #656d76;
  --line: #d1d9e0;
  --rail: #f6f8fa;
  --rail-soft: #ffffff;
  --rail-text: #1f2328;
  --rail-muted: #656d76;
  --rail-line: #d1d9e0;
  --leaf: #0969da;
  --on-accent: #ffffff;
  --green: #1a7f37;
  --bad: #cf222e;
  --bad-bg: #ffebe9;
  --ok-bg: #dafbe1;
  --wait: #9a6700;
  --wait-bg: #fff8c5;
  --shadow: none;
  --track: #eaeef2;
  --selected: #ddf4ff;
  --story: #ffffff;
  --radius: 6px;
  --radius-sm: 6px;
  --pill: 6px;
  --sidebar: 232px;
  --h1: 26px;
  --h2: 22px;
  --h3: 16px;
  --stat: 22px;
  --display: var(--sans);
}

html[data-theme="linear"],
.mini[data-preview="linear"] {
  --paper: #101114;
  --paper-2: #191a1f;
  --ink: #f3f4f6;
  --muted: #9b9ca3;
  --line: #2a2b31;
  --rail: #0c0c0e;
  --rail-soft: #1c1d22;
  --rail-text: #ececee;
  --rail-muted: #9b9ca3;
  --rail-line: #2e2f36;
  --leaf: #8b93e8;
  --on-accent: #0c0c0e;
  --green: #8b93e8;
  --bad: #ff8b8b;
  --bad-bg: #3a1d22;
  --ok-bg: #173126;
  --wait: #e2b340;
  --wait-bg: #2c2616;
  --shadow: none;
  --track: #2a2b31;
  --input-bg: #101114;
  --selected: #23242b;
  --story: #14151a;
  --radius: 8px;
  --radius-sm: 6px;
  --pill: 6px;
  --sidebar: 232px;
  --h1: 26px;
  --h2: 20px;
  --h3: 16px;
  --stat: 22px;
  --display: var(--sans);
  --scheme: dark;
}

html[data-theme="desk"],
.mini[data-preview="desk"] {
  --paper: #0b0d0c;
  --paper-2: #101412;
  --ink: #d7e6d4;
  --muted: #7d8f80;
  --line: #243028;
  --rail: #070908;
  --rail-soft: #152019;
  --rail-text: #d7e6d4;
  --rail-muted: #7d8f80;
  --rail-line: #243028;
  --leaf: #e2b340;
  --on-accent: #070908;
  --green: #3dd68c;
  --bad: #ff7b72;
  --bad-bg: #3a1d1c;
  --ok-bg: #123024;
  --wait: #e2b340;
  --wait-bg: #2c2616;
  --shadow: none;
  --track: #243028;
  --input-bg: #0b0d0c;
  --selected: #18211b;
  --story: #101412;
  --radius: 2px;
  --radius-sm: 2px;
  --pill: 2px;
  --sidebar: 220px;
  --h1: 22px;
  --h2: 18px;
  --h3: 15px;
  --stat: 22px;
  --display: Consolas, "Cascadia Mono", ui-monospace, monospace;
  --scheme: dark;
}

html[data-theme="carbon"],
.mini[data-preview="carbon"] {
  --paper: #f4f4f4;
  --paper-2: #ffffff;
  --ink: #161616;
  --muted: #525252;
  --line: #e0e0e0;
  --rail: #161616;
  --rail-soft: #262626;
  --rail-text: #f4f4f4;
  --rail-muted: #c6c6c6;
  --rail-line: #393939;
  --leaf: #78a9ff;
  --on-accent: #161616;
  --green: #0f62fe;
  --bad: #da1e28;
  --bad-bg: #fff1f1;
  --ok-bg: #defbe6;
  --wait: #8a3800;
  --wait-bg: #fff2e8;
  --shadow: none;
  --track: #e0e0e0;
  --selected: #e8f0ff;
  --story: #ffffff;
  --radius: 0;
  --radius-sm: 0;
  --pill: 0;
  --sidebar: 220px;
  --h1: 24px;
  --h2: 20px;
  --h3: 16px;
  --stat: 22px;
  --display: var(--sans);
}

html[data-theme="stripe"],
.mini[data-preview="stripe"] {
  --paper: #f6f9fc;
  --paper-2: #ffffff;
  --ink: #0a2540;
  --muted: #425466;
  --line: #e3e8ee;
  --rail: #0a2540;
  --rail-soft: #123052;
  --rail-text: #f6f9fc;
  --rail-muted: #adbdcc;
  --rail-line: #23405f;
  --leaf: #80e9ff;
  --on-accent: #0a2540;
  --green: #635bff;
  --bad: #df1b41;
  --bad-bg: #fde8ec;
  --ok-bg: #e6f4ea;
  --wait: #b76e00;
  --wait-bg: #fff4d6;
  --shadow: 0 2px 5px rgba(50, 50, 93, 0.08);
  --track: #e3e8ee;
  --selected: #f0f4ff;
  --story: #ffffff;
  --radius: 8px;
  --radius-sm: 8px;
  --pill: 999px;
  --sidebar: 240px;
  --h1: 28px;
  --h2: 22px;
  --h3: 16px;
  --stat: 24px;
  --display: var(--sans);
}

html[data-theme="paper"],
.mini[data-preview="paper"] {
  --paper: #ffffff;
  --paper-2: #ffffff;
  --ink: #37352f;
  --muted: #787774;
  --line: #ebebea;
  --rail: #f7f6f3;
  --rail-soft: #efeeea;
  --rail-text: #37352f;
  --rail-muted: #787774;
  --rail-line: #e3e2de;
  --leaf: #37352f;
  --on-accent: #ffffff;
  --green: #2e7d4f;
  --bad: #9f2f2d;
  --bad-bg: #fdebec;
  --ok-bg: #e7f5ee;
  --wait: #956400;
  --wait-bg: #fbf3db;
  --shadow: none;
  --track: #efeeea;
  --selected: #f1f1ef;
  --story: #ffffff;
  --radius: 4px;
  --radius-sm: 4px;
  --pill: 4px;
  --sidebar: 220px;
  --h1: 24px;
  --h2: 20px;
  --h3: 16px;
  --stat: 22px;
  --display: var(--sans);
}

html[data-theme="epi"],
.mini[data-preview="epi"] {
  --paper: #edf3f3;
  --paper-2: #f7fbfb;
  --ink: #163c43;
  --muted: #526b71;
  --line: #cbdada;
  --rail: #163c43;
  --rail-soft: #1e4e56;
  --rail-text: #edf3f3;
  --rail-muted: #b8cccc;
  --rail-line: #3d6a72;
  --leaf: #dbcda8;
  --on-accent: #163c43;
  --green: #163c43;
  --bad: #8d3b24;
  --bad-bg: #f6ddd4;
  --ok-bg: #d7e2df;
  --wait: #7a6240;
  --wait-bg: #f7f2e8;
  --shadow: none;
  --track: #dce5e5;
  --selected: #e4eeed;
  --story: #f7f2e8;
  --radius: 2px;
  --radius-sm: 2px;
  --pill: 2px;
  --sidebar: 248px;
  --h1: 30px;
  --h2: 26px;
  --h3: 18px;
  --stat: 26px;
  --display: Georgia, "Times New Roman", serif;
}

html[data-theme="epi-night"],
.mini[data-preview="epi-night"] {
  --paper: #0e2428;
  --paper-2: #163238;
  --ink: #edf3f3;
  --muted: #9fb4b6;
  --line: #2a555c;
  --rail: #0a1c1f;
  --rail-soft: #163c43;
  --rail-text: #edf3f3;
  --rail-muted: #9fb4b6;
  --rail-line: #2a555c;
  --leaf: #dbcda8;
  --on-accent: #0a1c1f;
  --green: #dbcda8;
  --bad: #ffb4a8;
  --bad-bg: #3a2420;
  --ok-bg: #1a3330;
  --wait: #dbcda8;
  --wait-bg: #2c281c;
  --shadow: none;
  --track: #2a555c;
  --input-bg: #0e2428;
  --selected: #1e4c54;
  --story: #163c43;
  --radius: 2px;
  --radius-sm: 2px;
  --pill: 2px;
  --sidebar: 240px;
  --h1: 28px;
  --h2: 22px;
  --h3: 16px;
  --stat: 24px;
  --display: Georgia, "Times New Roman", serif;
  --scheme: dark;
}

/* Іконки: однаковий набір для всіх тем, а товщина лінії, кінці ліній і підкладка в меню — свої в кожній. */
:root, .mini {
  --icon-stroke: 1.75;
  --icon-cap: round;
  --icon-join: round;
  --nav-icon-bg: var(--rail-soft);
  --nav-icon-radius: 50%;
  --nav-icon-color: var(--leaf);
  --icon-accent: var(--green);
}
html[data-theme="primer"], .mini[data-preview="primer"] {
  --nav-icon-bg: transparent;
  --nav-icon-radius: 6px;
  --nav-icon-color: var(--muted);
  --icon-accent: var(--leaf);
}
html[data-theme="linear"], .mini[data-preview="linear"] {
  --icon-stroke: 1.5;
  --nav-icon-bg: transparent;
  --nav-icon-radius: 6px;
  --nav-icon-color: var(--rail-muted);
  --icon-accent: var(--leaf);
}
html[data-theme="desk"], .mini[data-preview="desk"] {
  --icon-stroke: 1.5;
  --nav-icon-radius: 4px;
  --icon-accent: var(--leaf);
}
html[data-theme="carbon"], .mini[data-preview="carbon"] {
  --icon-stroke: 1.5;
  --icon-cap: square;
  --icon-join: miter;
  --nav-icon-bg: transparent;
  --nav-icon-radius: 0;
  --nav-icon-color: var(--rail-muted);
  --icon-accent: var(--leaf);
}
html[data-theme="stripe"], .mini[data-preview="stripe"] {
  --nav-icon-radius: 8px;
  --icon-accent: var(--leaf);
}
html[data-theme="paper"], .mini[data-preview="paper"] {
  --icon-stroke: 1.5;
  --nav-icon-bg: transparent;
  --nav-icon-radius: 4px;
  --nav-icon-color: var(--muted);
}
html[data-theme="epi"], .mini[data-preview="epi"],
html[data-theme="epi-night"], .mini[data-preview="epi-night"] {
  --icon-stroke: 1.5;
  --icon-accent: var(--leaf);
}

/* Brightness modes repaint any theme on body from the theme's values captured on html.
   Mini previews reset their own palette, so they always show the theme as designed. */
html {
  --t-green: var(--green);
  --t-leaf: var(--leaf);
  --t-rail: var(--rail);
  --t-icon: var(--icon-accent);
  --t-nav-icon: var(--nav-icon-color);
}
html[data-mode="light"] body {
  --paper: color-mix(in srgb, var(--t-green) 4%, #f5f6f7);
  --paper-2: #ffffff;
  --ink: #1d2024;
  --muted: #5d646d;
  --line: color-mix(in srgb, var(--t-green) 8%, #dde0e4);
  --track: color-mix(in srgb, var(--t-green) 6%, #eceef1);
  --input-bg: #ffffff;
  --selected: color-mix(in srgb, var(--t-green) 9%, #ffffff);
  --story: #ffffff;
  --green: color-mix(in srgb, var(--t-green) 82%, #000);
  --ok-bg: color-mix(in srgb, var(--t-green) 14%, #ffffff);
  --bad: #b42318;
  --bad-bg: #fde8e5;
  --wait: #8a5a00;
  --wait-bg: #fbefd2;
  --shadow: 0 12px 32px rgba(20, 24, 30, 0.06);
  --icon-accent: color-mix(in srgb, var(--t-icon) 80%, #000);
  --scheme: light;
}
html[data-mode="dim"] body,
html[data-mode="dark"] body {
  --ink: #e6e8eb;
  --rail-text: #e9ebee;
  --rail-muted: #aab0b8;
  --rail-line: rgba(233, 235, 238, 0.2);
  --leaf: color-mix(in srgb, var(--t-leaf) 70%, #fff);
  --on-accent: #111316;
  --green: color-mix(in srgb, var(--t-green) 58%, #fff);
  --bad: #ff8f80;
  --wait: #f0c26a;
  --shadow: none;
  --icon-accent: color-mix(in srgb, var(--t-icon) 62%, #fff);
  --nav-icon-color: color-mix(in srgb, var(--t-nav-icon) 45%, #e9ebee);
  --nav-icon-bg: var(--rail-soft);
  --scheme: dark;
}
html[data-mode="dim"] body {
  --paper: color-mix(in srgb, var(--t-green) 7%, #2a2d33);
  --paper-2: color-mix(in srgb, var(--t-green) 6%, #33363d);
  --muted: #b0b5bd;
  --line: #4a4e57;
  --track: #3d4148;
  --input-bg: #2b2e34;
  --selected: color-mix(in srgb, var(--t-green) 18%, #33363d);
  --story: #30333a;
  --rail: color-mix(in srgb, var(--t-rail) 25%, #202227);
  --rail-soft: color-mix(in srgb, var(--t-rail) 20%, #2d3037);
  --ok-bg: color-mix(in srgb, var(--t-green) 26%, #33363d);
  --bad-bg: #4b3030;
  --wait-bg: #4a3f26;
}
html[data-mode="dark"] body {
  --paper: color-mix(in srgb, var(--t-green) 5%, #0f1113);
  --paper-2: color-mix(in srgb, var(--t-green) 6%, #171a1d);
  --muted: #98a0a8;
  --line: #2b3036;
  --track: #22262b;
  --input-bg: #121518;
  --selected: color-mix(in srgb, var(--t-green) 18%, #171a1d);
  --story: #15181b;
  --rail: color-mix(in srgb, var(--t-rail) 22%, #0a0b0d);
  --rail-soft: color-mix(in srgb, var(--t-rail) 18%, #1a1d21);
  --ok-bg: color-mix(in srgb, var(--t-green) 22%, #171a1d);
  --bad-bg: #3a1f1c;
  --wait-bg: #3a2f17;
}
html[data-mode] body { color-scheme: var(--scheme); }

* { box-sizing: border-box; }
.icon {
  width: 1.15em;
  height: 1.15em;
  flex: 0 0 auto;
  vertical-align: -0.2em;
  stroke-width: var(--icon-stroke);
  stroke-linecap: var(--icon-cap);
  stroke-linejoin: var(--icon-join);
}
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); }
button, input, select { font: inherit; color: inherit; background: transparent; }
a { color: var(--green); }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 600; letter-spacing: -0.03em; }
h1 { margin: 0; font-size: var(--h1); }
h2 { margin: 0; font-size: var(--h2); }
h3 { margin: 0 0 12px; font-size: var(--h3); }
h4 { margin: 0 0 6px; }

.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
aside {
  background: var(--rail);
  color: var(--rail-text);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.eyebrow { margin: 0 0 6px; text-transform: uppercase; letter-spacing: 0.14em; font-size: 11px; color: var(--leaf); }
.tagline, .patrol-note { color: var(--rail-muted); line-height: 1.45; }
.brand .tagline { margin-bottom: 0; }
.countries { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 12px 0 4px; }
.countries button,
html[data-density] .countries button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  color: var(--rail-muted);
  text-align: center;
  cursor: pointer;
}
.countries .code { border: 1px solid var(--rail-line); color: var(--rail-text); border-radius: var(--pill); padding: 4px 12px; }
.countries small { color: inherit; font-size: 11px; line-height: 1.2; }
.countries button.active { color: var(--leaf); }
.countries button.active .code { background: var(--leaf); color: var(--on-accent); border-color: var(--leaf); }
nav { display: flex; flex-direction: column; gap: 4px; }
nav a, nav button, button, .slim {
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  cursor: pointer;
}
nav a, nav button { color: var(--rail-text); display: flex; gap: 10px; align-items: center; text-decoration: none; }
nav .nav-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--nav-icon-radius);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: var(--nav-icon-bg);
  color: var(--nav-icon-color);
}
nav .nav-icon .icon { width: 17px; height: 17px; }
nav a.active, nav button.active { background: var(--rail-soft); }
nav a.active .nav-icon { color: var(--leaf); }
nav a:hover .nav-icon { color: var(--leaf); }
.patrol-note { margin-top: auto; }
main { padding: 22px 28px 48px; }
.top { display: flex; justify-content: space-between; gap: 16px; align-items: end; margin-bottom: 16px; }
.top-actions { display: flex; gap: 10px; align-items: center; }
.lang { display: flex; border: 1px solid var(--line); border-radius: var(--pill); overflow: hidden; background: var(--paper-2); }
.lang button { border: 0; background: transparent; padding: 8px 12px; cursor: pointer; }
.lang button.active { background: var(--ink); color: var(--paper); }
.primary, a.primary {
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  border-radius: var(--pill);
  padding: 10px 16px;
  display: inline-flex;
}
.primary:disabled { opacity: 0.6; cursor: wait; }
button, .primary, a.primary, .slim { display: inline-flex; align-items: center; gap: 0.45em; }
button .icon, .primary .icon, .slim .icon { width: 1.05em; height: 1.05em; }
.primary.spinning .icon { animation: kontur-spin 1s linear infinite; }
@keyframes kontur-spin { to { transform: rotate(360deg); } }
.lang { align-items: center; }
.lang-icon { display: grid; place-items: center; padding: 0 2px 0 10px; color: var(--muted); }
.banner { display: flex; gap: 8px; align-items: flex-start; }
.banner .icon { margin-top: 0.1em; }
.with-icon { display: flex; align-items: center; gap: 0.5em; }
.with-icon > .icon { color: var(--icon-accent); }
p.with-icon > .icon, .muted.with-icon > .icon { color: var(--muted); width: 1em; height: 1em; }
.icon-link { display: inline-flex; align-items: center; gap: 0.3em; white-space: nowrap; }
.chip { white-space: nowrap; }
a.slim { text-decoration: none; }
a.slim:not(.primary) { color: var(--ink); }
.settings .check { display: flex; align-items: center; gap: 8px; }
.icon-link .icon { width: 0.95em; height: 0.95em; }
.place-line { display: inline-flex; align-items: center; gap: 0.3em; }
.place-line .icon { width: 0.95em; height: 0.95em; color: var(--muted); }
dt { display: flex; align-items: center; gap: 0.4em; }
dt .icon { width: 1.05em; height: 1.05em; color: var(--icon-accent); }
.search-field { position: relative; display: flex; align-items: center; flex: 1 1 220px; min-width: 0; }
.search-field > .icon { position: absolute; left: 10px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search-field input, html[data-density] .filters .search-field input { width: 100%; min-width: 0; padding-left: 32px; }
.cards article { position: relative; }
.card-icon {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--selected);
  color: var(--icon-accent);
}
.card-icon .icon { width: 17px; height: 17px; }
.card-icon.bad { background: var(--bad-bg); color: var(--bad); }
.card-icon.wait { background: var(--wait-bg); color: var(--wait); }
.card-icon.ok { background: var(--ok-bg); color: var(--green); }
.slim { border: 1px solid var(--ink); }
a.slim, button.slim { border-radius: var(--pill); }
.banner { padding: 10px 12px; border-radius: var(--radius-sm); }
.banner.bad { background: var(--bad-bg); color: var(--bad); }
.banner.ok { background: var(--ok-bg); color: var(--green); }
.cards { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 12px; }
.cards article, .panel {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.cards article { padding: 12px; }
.cards b { display: block; font-size: var(--stat); font-variant-numeric: tabular-nums; font-family: var(--display); }
.cards span, .muted, small { color: var(--muted); }
.panel { padding: 16px; margin-bottom: 12px; }
.split { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 12px; }
.bar { display: grid; grid-template-columns: 140px 1fr 32px; gap: 8px; align-items: center; margin: 8px 0; }
.track { height: 8px; background: var(--track); border-radius: 99px; overflow: hidden; }
.fill { height: 100%; background: var(--green); }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; }
.row-head, .filters, .source, .settings, .actions { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.filters input, .filters select, .settings input, .source-controls input {
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.filters > input { min-width: 220px; }
table { width: 100%; border-collapse: collapse; margin-top: 8px; }
th { text-align: left; font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
th, td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr { cursor: pointer; }
tbody tr.selected { background: var(--selected); }
td strong, td small { display: block; }
td strong { max-width: 36rem; }
td, .stories h4 { overflow-wrap: anywhere; }
td small { margin-top: 3px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; font-family: var(--display); }
.chip { display: inline-flex; border-radius: 999px; padding: 3px 8px; font-size: 12px; background: var(--wait-bg); color: var(--wait); }
.chip.ok { background: var(--ok-bg); color: var(--green); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.detail { margin-top: 16px; padding-top: 8px; }
.detail header { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
dl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; }
dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
dd { margin: 0; }
.chain { margin: 0; padding-left: 18px; }
.chain li { margin: 8px 0; }
.stories { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stories li { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; background: var(--story); }
.source { align-items: start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.source p { max-width: 640px; }
.source-controls { display: grid; gap: 8px; min-width: 180px; }
.tiny { width: 72px; }
.settings { align-items: end; }
.settings label, .check { display: grid; gap: 6px; }
.note { padding: 8px 0; border-bottom: 1px solid var(--line); }
code { font-family: Consolas, monospace; font-size: 0.95em; }

.photo-col { width: 92px; }
.thumb {
  position: relative;
  display: block;
  width: 84px;
  height: 60px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--track);
  border: 1px solid var(--line);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.empty img { display: none; }
.thumb.empty::after { content: ""; position: absolute; inset: 30% 32%; border: 2px solid var(--line); border-radius: 3px; }
.thumb b { position: absolute; right: 4px; bottom: 4px; padding: 0 5px; border-radius: 999px; font-size: 11px; background: rgba(0, 0, 0, 0.6); color: #fff; }
.gallery { margin: 12px 0; }
.gallery-main { display: block; border-radius: var(--radius-sm); overflow: hidden; background: var(--track); border: 1px solid var(--line); }
.gallery-main img { display: block; width: 100%; max-height: 420px; object-fit: contain; }
.gallery-strip { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; }
.gallery-strip button { padding: 0; border: 2px solid transparent; border-radius: var(--radius-sm); overflow: hidden; flex: 0 0 auto; }
.gallery-strip button.active { border-color: var(--green); }
.gallery-strip img { display: block; width: 72px; height: 52px; object-fit: cover; }
.gallery .muted { margin: 6px 0 0; }
.story-photo { display: block; width: 100%; height: 140px; object-fit: cover; border-radius: var(--radius-sm); margin-bottom: 8px; background: var(--track); }
html[data-density] .gallery-strip button { padding: 0; }
html[data-density="compact"] .thumb { width: 64px; height: 46px; }
html[data-density="compact"] .photo-col { width: 70px; }

.themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
button.theme {
  display: grid;
  gap: 6px;
  align-content: start;
  min-height: 132px;
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 12px;
}
button.theme.active { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
button.theme { position: relative; }
.theme-check {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 1;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
  color: var(--paper-2);
}
.theme-check .icon { width: 14px; height: 14px; stroke-width: 2.5; }
.mini .icon { width: 9px; height: 9px; stroke-width: 2; vertical-align: -1px; margin-right: 3px; }
.mini-nav { display: flex; align-items: center; }
.mini-primary, .mini-slim { display: inline-flex; align-items: center; }
.density button { gap: 0.4em; justify-content: center; }
button.theme strong { font-family: var(--display); }

.mini {
  display: grid;
  grid-template-columns: 34% 1fr;
  height: 112px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 9px;
  line-height: 1.3;
  pointer-events: none;
}
.mini-rail { display: flex; flex-direction: column; gap: 3px; padding: 7px 6px; background: var(--rail); color: var(--rail-text); }
.mini-rail b { font-family: var(--display); font-size: 12px; margin-bottom: 3px; }
.mini-nav { padding: 2px 4px; border-radius: min(var(--radius-sm), 5px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--rail-text); }
.mini-nav.on { background: var(--rail-soft); color: var(--leaf); }
.mini-main { padding: 7px; background: var(--paper); }
.mini-panel {
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: 100%;
  padding: 6px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: min(var(--radius), 8px);
  overflow: hidden;
}
.mini-title { font-family: var(--display); font-size: 11px; font-weight: 600; color: var(--ink); }
.mini-text { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-row { display: flex; gap: 4px; flex-wrap: nowrap; overflow: hidden; }
.mini-chip { padding: 1px 5px; border-radius: 999px; white-space: nowrap; }
.mini-chip.ok { background: var(--ok-bg); color: var(--green); }
.mini-chip.bad { background: var(--bad-bg); color: var(--bad); }
.mini-primary, .mini-slim { padding: 2px 7px; border-radius: min(var(--pill), 999px); white-space: nowrap; }
.mini-primary { background: var(--ink); color: var(--paper); }
.mini-slim { border: 1px solid var(--ink); color: var(--ink); }
button.theme small { color: var(--muted); line-height: 1.35; }

.density { display: inline-flex; max-width: 100%; border: 1px solid var(--line); border-radius: var(--pill); overflow-x: auto; scrollbar-width: none; background: var(--paper-2); margin: 4px 0 18px; }
.density button { border: 0; border-radius: 0; padding: 8px 14px; color: var(--ink); }
.density button.active { background: var(--ink); color: var(--paper); }

html[data-density="compact"] body { font-size: 13px; }
html[data-density="compact"] aside { padding: 14px 12px; gap: 14px; }
html[data-density="compact"] nav { gap: 2px; }
html[data-density="compact"] nav a,
html[data-density="compact"] nav button,
html[data-density="compact"] button,
html[data-density="compact"] .slim { padding: 5px 8px; }
html[data-density="compact"] main { padding: 14px 18px 32px; }
html[data-density="compact"] .top { margin-bottom: 10px; }
html[data-density="compact"] .primary,
html[data-density="compact"] a.primary { padding: 6px 12px; }
html[data-density="compact"] .cards { gap: 6px; margin-bottom: 8px; }
html[data-density="compact"] .cards article { padding: 8px 10px; }
html[data-density="compact"] .cards b { font-size: calc(var(--stat) * 0.8); }
html[data-density="compact"] .panel { padding: 10px 12px; margin-bottom: 8px; }
html[data-density="compact"] .split { gap: 8px; }
html[data-density="compact"] h3 { margin-bottom: 8px; }
html[data-density="compact"] th,
html[data-density="compact"] td { padding: 4px 6px; }
html[data-density="compact"] .plain li { padding: 3px 0; }
html[data-density="compact"] .bar { margin: 4px 0; }
html[data-density="compact"] .source { padding: 6px 0; }
html[data-density="compact"] .filters input,
html[data-density="compact"] .filters select,
html[data-density="compact"] .settings input,
html[data-density="compact"] .source-controls input { padding: 4px 8px; }
html[data-density="compact"] .banner { padding: 6px 10px; }
html[data-density="compact"] button.theme { min-height: 104px; padding: 8px; }

html[data-density="spacious"] body { font-size: 17px; }
html[data-density="spacious"] aside { padding: 30px 24px; gap: 30px; }
html[data-density="spacious"] nav { gap: 8px; }
html[data-density="spacious"] nav a,
html[data-density="spacious"] nav button,
html[data-density="spacious"] button,
html[data-density="spacious"] .slim { padding: 11px 14px; }
html[data-density="spacious"] main { padding: 32px 40px 64px; }
html[data-density="spacious"] .top { margin-bottom: 24px; }
html[data-density="spacious"] .primary,
html[data-density="spacious"] a.primary { padding: 13px 20px; }
html[data-density="spacious"] .cards { gap: 14px; margin-bottom: 18px; }
html[data-density="spacious"] .cards article { padding: 18px; }
html[data-density="spacious"] .cards b { font-size: calc(var(--stat) * 1.2); }
html[data-density="spacious"] .panel { padding: 24px; margin-bottom: 18px; }
html[data-density="spacious"] .split { gap: 18px; }
html[data-density="spacious"] h3 { margin-bottom: 16px; }
html[data-density="spacious"] th,
html[data-density="spacious"] td { padding: 13px 10px; }
html[data-density="spacious"] .plain li { padding: 10px 0; }
html[data-density="spacious"] .bar { margin: 12px 0; }
html[data-density="spacious"] .source { padding: 18px 0; }
html[data-density="spacious"] .filters input,
html[data-density="spacious"] .filters select,
html[data-density="spacious"] .settings input,
html[data-density="spacious"] .source-controls input { padding: 11px 12px; }
html[data-density="spacious"] .banner { padding: 14px 16px; }
html[data-density="spacious"] button.theme { min-height: 150px; padding: 16px; }

.shell > main, .shell > aside, nav { min-width: 0; }
.panel { min-width: 0; }
img { max-width: 100%; }

/* Планшет: вужча бічна панель, сітки у дві колонки. */
@media (max-width: 1100px) {
  .shell { grid-template-columns: min(var(--sidebar), 230px) 1fr; }
  .cards { grid-template-columns: repeat(3, 1fr); }
  .split, dl { grid-template-columns: 1fr; }
  .stories, .themes { grid-template-columns: 1fr 1fr; }
  .filters input { min-width: 0; flex: 1 1 200px; }
  .filters { justify-content: flex-start; }
}

/* Таблиці лотів і журналу стають картками. */
@media (max-width: 900px) {
  .lot-table thead, .run-table thead { display: none; }
  .lot-table, .lot-table tbody, .run-table, .run-table tbody { display: block; }
  .lot-table tr {
    display: grid;
    grid-template-columns: 96px 1fr auto;
    grid-template-areas:
      "photo name name"
      "photo status link"
      "photo place place"
      "photo price round";
    gap: 4px 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
  }
  .lot-table td, html[data-density] .lot-table td { display: block; padding: 0; border: 0; }
  .lot-table .photo-col { grid-area: photo; width: auto; }
  .lot-table .thumb, html[data-density] .lot-table .thumb { width: 96px; height: 72px; }
  .lot-table .lot-name { grid-area: name; }
  .lot-table .lot-status { grid-area: status; }
  .lot-table .lot-link { grid-area: link; text-align: right; }
  .lot-table .lot-place { grid-area: place; }
  .lot-table .lot-place small { display: inline; margin-left: 6px; }
  .lot-table td.num { white-space: normal; }
  .lot-table td.num:nth-of-type(5) { grid-area: price; }
  .lot-table td.num:nth-of-type(6) { grid-area: round; text-align: right; }
  .lot-table td[data-label]::before,
  .run-table td[data-label]::before {
    content: attr(data-label) " ";
    color: var(--muted);
    font-family: var(--sans);
    font-size: 12px;
  }
  .lot-table td.lot-place::before { display: none; }
  .run-table tr {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
  }
  .run-table td, html[data-density] .run-table td { display: block; padding: 0; border: 0; }
  .run-table .run-when { flex: 1 1 auto; }
  .run-table .run-source { flex: 1 1 100%; order: -1; font-weight: 600; }
  .run-table .run-status { flex: 0 0 auto; }
}

/* Телефон: компактна верхня панель з горизонтальним меню. */
@media (max-width: 800px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  aside, html[data-density] aside {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 10px 12px 8px;
    gap: 8px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  }
  .brand { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 12px; }
  .brand .eyebrow { grid-column: 1 / -1; margin-bottom: 2px; font-size: 10px; }
  .brand h1 { font-size: min(var(--h1), 28px); }
  .countries { margin: 0; gap: 4px; }
  .countries .code { padding: 3px 9px; }
  .countries small { font-size: 10px; }
  .brand .tagline, .patrol-note { display: none; }
  nav, html[data-density] nav {
    flex-direction: row;
    gap: 4px;
    overflow-x: auto;
    margin: 0 -12px;
    padding: 0 12px 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  nav::-webkit-scrollbar { display: none; }
  nav a, html[data-density] nav a { flex: 0 0 auto; white-space: nowrap; padding: 7px 10px; }
  main, html[data-density] main { padding: 14px 12px 40px; }
  .top, html[data-density] .top { align-items: stretch; flex-direction: column; gap: 10px; margin-bottom: 12px; }
  .top h2 { font-size: min(var(--h2), 26px); }
  .top-actions { justify-content: space-between; }
  .cards, html[data-density] .cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .cards b { font-size: min(var(--stat), 24px); }
  .panel, html[data-density] .panel { padding: 12px; }
  h3 { font-size: min(var(--h3), 19px); }
  .bar { grid-template-columns: minmax(80px, 34%) 1fr 32px; }
  .row-head { align-items: stretch; flex-direction: column; }
  .filters, .settings, .actions { align-items: stretch; }
  .filters > *, .filters input, .filters select { flex: 1 1 140px; min-width: 0; }
  .settings > label, .settings > button { flex: 1 1 100%; }
  .settings input { width: 100%; }
  .settings .check, .source-controls label:has(input[type="checkbox"]) { display: flex; align-items: center; gap: 8px; }
  .settings input[type="checkbox"], .source-controls input[type="checkbox"] { width: 20px; height: 20px; flex: 0 0 auto; }
  .source { flex-direction: column; }
  .source-controls { min-width: 0; width: 100%; grid-template-columns: 1fr 1fr; }
  .source-controls label, .source-controls p { grid-column: 1 / -1; }
  .detail header { flex-direction: column; }
  .detail header .primary { align-self: flex-start; }
  .gallery-main img { max-height: 300px; }
  .stories { grid-template-columns: 1fr; }
  .plain li { flex-wrap: wrap; }
  .density { display: flex; width: 100%; }
  .density button { flex: 1; text-align: center; }
  input, select, textarea { font-size: 16px; }
  button, .primary, .slim, .lang button { min-height: 38px; }
  .countries button, .gallery-strip button { min-height: 0; }
}

@media (max-width: 560px) {
  .themes { grid-template-columns: 1fr; }
  .lot-table tr { grid-template-columns: 76px 1fr auto; }
  .lot-table .thumb, html[data-density] .lot-table .thumb { width: 76px; height: 60px; }
  .cards b { font-size: 20px; }
  .brand h1 { font-size: 24px; }
}
@media print {
  aside, .top button, .filters, .actions { display: none; }
  .shell { display: block; }
  body { background: white; color: black; }
}
