/* AvoMail2Graph dashboard. Look taken from avo-davbook (AVONON design policy): accent #3c4858,
   glass surfaces, Barlow, Material Symbols Rounded, light and dark tokens, own phone layout. */

@font-face { font-family: Barlow; font-weight: 500; font-display: swap; src: url(fonts/barlow-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Barlow; font-weight: 500; font-display: swap; src: url(fonts/barlow-latin-ext-500-normal.woff2) format('woff2'); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: Barlow; font-weight: 600; font-display: swap; src: url(fonts/barlow-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Barlow; font-weight: 600; font-display: swap; src: url(fonts/barlow-latin-ext-600-normal.woff2) format('woff2'); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Barlow Condensed'; font-weight: 600; font-display: swap; src: url(fonts/barlow-condensed-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Barlow Condensed'; font-weight: 600; font-display: swap; src: url(fonts/barlow-condensed-latin-ext-600-normal.woff2) format('woff2'); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  color-scheme: light;
  --bg: #e6ebf1;
  --bg-tint-a: rgba(60, 72, 88, 0.16);
  --bg-tint-b: rgba(120, 146, 176, 0.22);
  --glass: rgba(255, 255, 255, 0.64);
  --glass-strong: rgba(255, 255, 255, 0.84);
  --glass-edge: rgba(255, 255, 255, 0.75);
  --line: rgba(45, 55, 68, 0.12);
  --line-strong: rgba(45, 55, 68, 0.22);
  --text: #1c242e;
  --muted: #586373;
  --accent: #3c4858;
  --accent-hover: #2d3744;
  --accent-text: #3c4858;
  --on-accent: #ffffff;
  --accent-soft: rgba(60, 72, 88, 0.09);
  --input: rgba(255, 255, 255, 0.82);
  --ok: #2b6f4f;
  --ok-soft: rgba(43, 111, 79, 0.12);
  --warn: #8e5b12;
  --warn-soft: rgba(176, 120, 30, 0.14);
  --danger: #a8392f;
  --danger-soft: rgba(168, 57, 47, 0.1);
  --shadow: 0 1px 2px rgba(20, 28, 38, 0.06), 0 12px 32px rgba(20, 28, 38, 0.08);
  --focus: 0 0 0 3px rgba(60, 72, 88, 0.38);
  --radius-dialog: 18px;
  --radius-control: 10px;
  --radius-card: 14px;
  --sidebar: 248px;
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #10141a;
  --bg-tint-a: rgba(76, 92, 114, 0.3);
  --bg-tint-b: rgba(40, 52, 70, 0.45);
  --glass: rgba(27, 33, 42, 0.66);
  --glass-strong: rgba(31, 38, 48, 0.9);
  --glass-edge: rgba(255, 255, 255, 0.06);
  --line: rgba(220, 228, 238, 0.1);
  --line-strong: rgba(220, 228, 238, 0.2);
  --text: #e3e8ef;
  --muted: #9ca8b8;
  /* Lightened only as far as contrast on the dark background requires. */
  --accent: #4f5e73;
  --accent-hover: #5d6d84;
  --accent-text: #b2c0d3;
  --on-accent: #ffffff;
  --accent-soft: rgba(143, 160, 184, 0.14);
  --input: rgba(14, 18, 24, 0.6);
  --ok: #7cc6a0;
  --ok-soft: rgba(124, 198, 160, 0.14);
  --warn: #e0b46a;
  --warn-soft: rgba(224, 180, 106, 0.14);
  --danger: #ee8d84;
  --danger-soft: rgba(238, 141, 132, 0.13);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 14px 36px rgba(0, 0, 0, 0.32);
  --focus: 0 0 0 3px rgba(178, 192, 211, 0.45);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font: 500 15px/1.5 Barlow, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--text);
  background:
    radial-gradient(60rem 40rem at 8% -10%, var(--bg-tint-b), transparent 70%),
    radial-gradient(50rem 36rem at 105% 10%, var(--bg-tint-a), transparent 70%),
    radial-gradient(40rem 30rem at 50% 120%, var(--bg-tint-b), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}
h1, h2, h3 { font-family: 'Barlow Condensed', Barlow, sans-serif; font-weight: 600; line-height: 1.15; margin: 0; letter-spacing: 0.005em; }
h1 { font-size: 30px; }
h2 { font-size: 19px; display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
h2 .icon { color: var(--accent-text); }
h3 { font-size: 16px; margin: 22px 0 10px; }
p { margin: 0 0 12px; }
a { color: var(--accent-text); text-decoration-thickness: 1px; text-underline-offset: 3px; }
code { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 0.88em; }
strong { font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.count { font-family: 'Barlow Condensed', sans-serif; font-weight: 600; font-size: 22px; line-height: 1; }
.right { text-align: right; }
.break { word-break: break-all; }
.text-danger { color: var(--danger); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 12px; top: 12px; z-index: 50; background: var(--glass-strong); padding: 8px 12px; border-radius: var(--radius-control); }
:focus-visible { outline: none; box-shadow: var(--focus); }

.icon { width: 20px; height: 20px; fill: currentColor; flex: none; }

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow), inset 0 0 0 1px var(--line);
}

/* ------------------------------------------------------------------ layout */

.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 14px auto 14px 14px; width: var(--sidebar);
  border-radius: var(--radius-dialog); padding: 18px 12px; display: flex; flex-direction: column; gap: 18px; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; padding: 0 6px; }
.brand-mark {
  width: 38px; height: 38px; flex: none; border-radius: 11px; overflow: hidden; background: #3c4858;
}
.brand-mark img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-family: 'Barlow Condensed', sans-serif; font-size: 21px; }
.brand-text small { color: var(--muted); font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: var(--radius-control);
  color: var(--text); text-decoration: none;
}
.nav-link .icon { color: var(--muted); }
.nav-link:hover { background: var(--accent-soft); }
.nav-link.is-active { background: var(--accent); color: var(--on-accent); }
.nav-link.is-active .icon { color: var(--on-accent); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.sidebar-tools { display: flex; gap: 6px; padding: 0 4px; }
.topbar, .tabbar { display: none; }
.main { margin-left: calc(var(--sidebar) + 28px); padding: 28px 32px 64px 12px; max-width: calc(1180px + var(--sidebar)); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.page-title h1 { overflow-wrap: anywhere; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.page-actions form { margin: 0; }
.back-link { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: 14px; }
.back-link:hover { color: var(--text); }
.lead { color: var(--muted); max-width: 75ch; margin-bottom: 18px; }

.panel { border-radius: var(--radius-dialog); padding: 20px 22px; margin-bottom: 18px; }
.panel.highlight { box-shadow: var(--shadow), inset 0 0 0 1px var(--line), inset 4px 0 0 var(--accent); }
.danger-zone h2 .icon { color: var(--danger); }
.grid { display: grid; gap: 14px 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: 1 / -1; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack.narrow { max-width: 420px; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }

/* ---------------------------------------------------------------- controls */

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: var(--radius-control); border: 1px solid var(--line-strong); background: var(--glass-strong);
  color: var(--text); font: inherit; font-weight: 600; font-size: 14px; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.button .icon { width: 18px; height: 18px; }
.button:hover { border-color: var(--accent); }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.button.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.button.ghost { background: transparent; }
.button.small { height: 30px; padding: 0 10px; font-size: 13px; }
.button.wide { width: 100%; }
.button[disabled] { opacity: 0.5; cursor: not-allowed; }
.icon-button {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius-control);
  border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; padding: 0;
}
.icon-button:hover { background: var(--accent-soft); color: var(--text); }
.icon-button.danger:hover { color: var(--danger); background: var(--danger-soft); }
.icon-button.subtle { width: 30px; height: 30px; }
.theme-toggle .icon:last-of-type { display: none; }
:root[data-theme='dark'] .theme-toggle .icon:first-of-type { display: none; }
:root[data-theme='dark'] .theme-toggle .icon:last-of-type { display: block; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span:first-child, .field > label { font-size: 13px; color: var(--muted); }
.field.inline { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
.req { color: var(--warn); font-size: 12px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--input); border: 1px solid var(--line-strong);
  border-radius: var(--radius-control); padding: 0 11px; height: 38px; width: 100%; min-width: 0;
}
textarea { padding: 9px 11px; height: auto; resize: vertical; line-height: 1.45; }
input[type='file'] { padding: 6px; height: auto; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
input:disabled { opacity: 0.6; }
input[type='radio'], input[type='checkbox'] { width: auto; height: auto; accent-color: var(--accent); }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { width: 36px; height: 20px; border-radius: 999px; background: var(--line-strong); position: relative; transition: background 0.15s; flex: none; }
.switch-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: transform 0.15s; }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { box-shadow: var(--focus); }

.choice { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.choice legend { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.radio { display: flex; gap: 10px; align-items: flex-start; }
.radio input { margin-top: 4px; }

.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin: 0; }
.inline-form input { width: auto; min-width: 140px; }
.inline-form select { width: auto; }
td .inline-form { align-items: center; }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 13px; background: var(--accent-soft); color: var(--text); white-space: nowrap; }
.chip .icon { width: 16px; height: 16px; }
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-error { background: var(--danger-soft); color: var(--danger); }
.chip-muted { color: var(--muted); }

.flash { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--radius-card); margin: 0 0 16px; }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-error { background: var(--danger-soft); color: var(--danger); }
.flash-warn { background: var(--warn-soft); color: var(--warn); margin-top: 10px; }
.flash span { color: var(--text); }
.flash a { color: inherit; }

.empty { display: flex; gap: 12px; align-items: center; border-radius: var(--radius-dialog); padding: 22px; color: var(--muted); margin-bottom: 18px; }
.empty .icon { width: 28px; height: 28px; color: var(--accent-text); }

/* ------------------------------------------------------------------ data */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0; border-radius: var(--radius-dialog); margin: 0 0 18px; overflow: hidden; }
.stats > div { padding: 16px 20px; border-left: 1px solid var(--line); }
.stats > div:first-child { border-left: 0; }
.stats dt { color: var(--muted); font-size: 13px; }
.stats dd { margin: 2px 0 0; font-family: 'Barlow Condensed', sans-serif; font-weight: 600; font-size: 30px; line-height: 1.1; }
.stats dd small { font-family: Barlow, sans-serif; font-size: 14px; color: var(--muted); font-weight: 500; }
.panel .stats { box-shadow: none; border: 1px solid var(--line); }

.table-wrap { border-radius: var(--radius-dialog); overflow-x: auto; margin-bottom: 18px; }
.panel .table-wrap { border: 1px solid var(--line); border-radius: var(--radius-card); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.is-muted td { color: var(--muted); }
.table td.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 10px 18px; margin: 0 0 14px; align-items: start; }
.kv dt { color: var(--muted); font-size: 14px; padding-top: 6px; }
.kv dd { margin: 0; min-width: 0; }

.copy-field { display: flex; align-items: center; gap: 4px; background: var(--input); border: 1px solid var(--line-strong); border-radius: var(--radius-control); padding: 3px 3px 3px 11px; }
.copy-field code { flex: 1; overflow-wrap: anywhere; user-select: all; padding: 4px 0; }
.copy-field.is-secret { border-color: var(--accent); }
.copy-field .is-copied { color: var(--ok); }

.tabs { display: flex; gap: 4px; margin: -4px 0 18px; border-bottom: 1px solid var(--line-strong); overflow-x: auto; }
.tabs a { display: inline-flex; gap: 7px; align-items: center; padding: 9px 12px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.is-active { color: var(--text); border-color: var(--accent-text); }

.search { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; border-radius: var(--radius-card); margin-bottom: 14px; }
.search .icon { color: var(--muted); }
.search input { border: 0; background: transparent; box-shadow: none; padding: 0; }
.search input:focus { box-shadow: none; }
.pager { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; margin: 0 0 18px; }
.pager .button { min-width: 30px; justify-content: center; }
.pager .is-disabled { opacity: 0.45; pointer-events: none; }
.pager-gap { color: var(--muted); padding: 0 2px; }
.pager-info { text-align: center; font-size: 13px; margin: 0 0 8px; }
@media (max-width: 760px) {
  .pager .button span:not(.icon) { display: none; }
}

/* ------------------------------------------------------------- sign in */

.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; border-radius: var(--radius-dialog); overflow: hidden; padding: 0 0 22px; }
.auth-card > :not(.auth-head) { margin-left: 24px; margin-right: 24px; }
.auth-head {
  display: flex; align-items: center; gap: 12px; padding: 18px 20px; margin-bottom: 20px; color: #fff;
  background: linear-gradient(135deg, #2d3744, #3c4858);
}
.auth-head h1 { font-size: 24px; }
.auth-head p { margin: 0; color: rgba(255, 255, 255, 0.72); font-size: 13px; }
.auth-head > div { flex: 1; }
.auth-head .icon-button { color: rgba(255, 255, 255, 0.8); }
.auth-head .icon-button:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }


.table th.right, .table td.right { text-align: right; }
.table tr.is-clickable { cursor: pointer; }
.table tr.is-clickable:hover td { background: var(--accent-soft); }
.table td .sub { display: block; font-size: 13px; color: var(--muted); }
.table td.wrap { max-width: 320px; overflow-wrap: anywhere; }
.table-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.table-foot .pager { margin: 0; }

/* ---------------------------------------------------------------- filters */

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px; border-radius: var(--radius-card); margin-bottom: 14px; }
.filters .search { flex: 1 1 240px; margin: 0; padding: 0 4px 0 10px; background: var(--input); border: 1px solid var(--line-strong); border-radius: var(--radius-control); height: 38px; gap: 8px; }
.filters .search:focus-within { border-color: var(--accent); box-shadow: var(--focus); }
.filters select, .filters input[type='date'] { width: auto; flex: 0 1 auto; min-width: 130px; }
.filters .date-range { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.filters .result-count { margin-left: auto; color: var(--muted); font-size: 13px; padding: 0 6px; white-space: nowrap; }
.filters .is-set { border-color: var(--accent); background: var(--accent-soft); }
.empty-filter { padding: 22px 14px; text-align: center; color: var(--muted); }

/* --------------------------------------------------------- page sections */

.nav-badge { margin-left: auto; min-width: 22px; padding: 0 7px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); font-size: 12px; font-weight: 600; text-align: center; line-height: 20px; }
.nav-link.is-active .nav-badge { background: rgba(255, 255, 255, 0.2); color: var(--on-accent); }
.tab { position: relative; }
.tab .nav-badge { position: absolute; top: 0; right: 6px; min-width: 16px; padding: 0 4px; line-height: 16px; font-size: 10px; }
.version-tag { color: var(--muted); font-size: 12px; padding: 0 10px; }

.stats a { color: inherit; text-decoration: none; display: block; }
.stats a:hover dt { color: var(--accent-text); text-decoration: underline; }
.stats dd.is-ok { color: var(--ok); }
.stats dd.is-warn { color: var(--warn); }
.stats dd.is-error { color: var(--danger); }
.section-title { font-family: 'Barlow Condensed', sans-serif; font-weight: 600; font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 4px 0 8px; }

.status-list { list-style: none; margin: 0; padding: 0; }
.status-list li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--line); }
.status-list li:last-child { border-bottom: 0; }
.status-list .icon { margin-top: 1px; }
.status-list .is-ok .icon { color: var(--ok); }
.status-list .is-warn .icon { color: var(--warn); }

.note { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; color: var(--muted); margin: 0 0 12px; }
.note .icon { width: 18px; height: 18px; margin-top: 2px; }
.note.is-warn { color: var(--warn); }
.note.is-error { color: var(--danger); }
.note.is-ok { color: var(--ok); }
.note.is-warn span, .note.is-error span, .note.is-ok span { color: var(--text); }
.hint { font-size: 13px; color: var(--muted); }
.field > .hint { margin-top: -1px; }
.input-row { display: flex; gap: 6px; align-items: center; }
.input-row input { flex: 1; }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.switches { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.port-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 18px; }
.port { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-card); }
pre.code { margin: 0 0 12px; padding: 10px 12px; border-radius: var(--radius-control); background: var(--input); border: 1px solid var(--line-strong); overflow-x: auto; user-select: all; font-size: 13px; }
textarea.mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 13px; min-height: 110px; }
.list-plain { margin: 6px 0 0; padding-left: 20px; font-size: 14px; }
.list-plain li { margin-bottom: 4px; }

.steps-list { list-style: none; padding: 0; margin: 0 0 14px; }
.steps-list li { display: flex; gap: 12px; padding: 8px 0; align-items: flex-start; }
.steps-list .n { flex: 0 0 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 13px; background: var(--accent-soft); color: var(--accent-text); }
.steps-list li.is-done .n { background: var(--ok-soft); color: var(--ok); }
.steps-list li.is-active .n { background: var(--accent); color: var(--on-accent); }
.steps-list .n .icon { width: 16px; height: 16px; }

.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent-text); display: inline-block; animation: spin 0.7s linear infinite; vertical-align: -3px; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; gap: 10px; align-items: center; color: var(--muted); }

.sticky-actions { position: sticky; bottom: 14px; display: flex; justify-content: flex-end; padding: 10px; border-radius: var(--radius-card); z-index: 5; }

/* ----------------------------------------------------------------- dialog */

dialog.modal { border: 0; padding: 0; border-radius: var(--radius-dialog); max-width: 640px; width: calc(100% - 32px); max-height: calc(100vh - 48px); color: var(--text); background: var(--glass-strong); -webkit-backdrop-filter: blur(18px) saturate(140%); backdrop-filter: blur(18px) saturate(140%); box-shadow: var(--shadow); overflow: hidden; }
dialog.modal[open] { display: flex; flex-direction: column; }
dialog.modal.narrow { max-width: 440px; }
dialog.modal::backdrop { background: rgba(16, 20, 26, 0.45); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
dialog.modal > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: linear-gradient(135deg, #2d3744, #3c4858); color: #fff; padding: 12px 12px 12px 18px; }
dialog.modal > header h2 { margin: 0; font-size: 19px; color: #fff; overflow-wrap: anywhere; }
dialog.modal > header .icon-button { color: rgba(255, 255, 255, 0.8); }
dialog.modal > header .icon-button:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
dialog.modal .modal-body { padding: 18px; overflow: auto; }
dialog.modal .modal-body > .stack { gap: 14px; }
dialog.modal > footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--line); }

/* ------------------------------------------------------------------ toast */

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 36px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--radius-card); background: var(--glass-strong); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); box-shadow: var(--shadow), inset 0 0 0 1px var(--line); font-size: 14px; }
.toast .icon { color: var(--ok); }
.toast.is-error .icon { color: var(--danger); }
.toast.is-info .icon { color: var(--accent-text); }

.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card .note { margin: 0 0 14px; }

/* ------------------------------------------------------------------ phone */

@media (max-width: 1080px) {
  .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  body { font-size: 15px; }
  .sidebar { display: none; }
  .topbar {
    display: flex; position: sticky; top: 0; z-index: 20; align-items: center; justify-content: space-between;
    padding: 8px 12px; border-radius: 0; border-width: 0 0 1px; padding-top: max(8px, env(safe-area-inset-top));
  }
  .topbar .brand strong { font-family: 'Barlow Condensed', sans-serif; font-size: 20px; }
  .topbar .brand-mark { width: 32px; height: 32px; border-radius: 9px; }
  .topbar-tools { display: flex; gap: 2px; }
  .main { margin: 0; padding: 16px 14px calc(96px + env(safe-area-inset-bottom)); }
  h1 { font-size: 26px; }
  .page-head { align-items: flex-start; margin-bottom: 14px; }
  .panel { padding: 16px; }
  .grid.two, .grid.three, .grid.four, .port-grid { grid-template-columns: 1fr; }
  .span-2, .span-3, .span-4 { grid-column: auto; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats > div:nth-child(odd) { border-left: 0; }
  .stats > div:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .tabbar {
    display: flex; position: fixed; left: 10px; right: 10px; bottom: max(10px, env(safe-area-inset-bottom)); z-index: 20;
    border-radius: var(--radius-dialog); padding: 6px; justify-content: space-around;
  }
  .tab { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 8px; border-radius: 12px; color: var(--muted); text-decoration: none; font-size: 11px; min-width: 56px; cursor: pointer; list-style: none; }
  .tab::-webkit-details-marker { display: none; }
  .tab.is-active { color: var(--on-accent); background: var(--accent); }
  .more { position: relative; }
  .more .sheet { position: absolute; right: 0; bottom: calc(100% + 10px); width: 220px; border-radius: var(--radius-dialog); padding: 8px; display: flex; flex-direction: column; background: var(--glass-strong); }
  .sheet-link { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 10px; color: var(--text); text-decoration: none; }
  .sheet-link:hover { background: var(--accent-soft); }
  .table { font-size: 13px; }
  .table th, .table td { padding: 9px 10px; }
  .table .hide-phone { display: none; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters select, .filters input[type='date'], .filters .search { width: 100%; flex: none; }
  .filters .date-range { display: grid; grid-template-columns: 1fr auto 1fr; }
  .filters .result-count { margin: 0; text-align: right; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dt { padding-top: 8px; }
  .field.inline { flex-direction: column; align-items: stretch; }
  .toasts { left: 12px; right: 12px; bottom: calc(86px + env(safe-area-inset-bottom)); max-width: none; }
  .sticky-actions { bottom: calc(86px + env(safe-area-inset-bottom)); }
  dialog.modal { width: calc(100% - 20px); max-height: calc(100vh - 20px); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
.kv.compact { gap: 8px 18px; }
.kv.compact dt { padding-top: 0; }
.main.health { margin: 0 auto; padding: 28px 20px 48px; max-width: 980px; }
