@charset "UTF-8";

/*
 * Постотека (Postoteka) — production CSS
 * Visual system adapted from the Arena prototype styles.
 * No React/Vite/Tailwind. Plain CSS. Compatible with existing Jinja templates and app.js.
 */

:root {
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
  --green: #168363;
  --green-dark: #106b50;
  --green-soft: #eaf5ef;
  --bg: #f7f9fa;
  --surface: #fff;
  --surface-hover: #f4f7f5;
  --ink: #25332d;
  --muted: #84908a;
  --line: #e7ebe8;
  --input-border: #cbd5cf;
  --toast-bg: #23352c;
  --toast-color: #ffffff;
  --toast-error-bg: #922f2a;
  --backdrop: #17231f88;
  --banner-bg: #fff7f6;
  --banner-color: #922f2b;
  --banner-border: #ffd9d5;
  --sidebar: 244px;
}

/* ---- Theme: dark mode (light is the :root defaults above) ----
   Priority: an explicit server-rendered / cookie `data-theme` attribute wins.
   When absent, CSS follows the OS prefers-color-scheme (no JS, no FOUC).
   The server bakes `data-theme` from the postoteka_theme cookie on first
   paint; app.js only mirrors the OS default into the attribute so ECharts
   and the toggle icon agree with the already-painted page. ---- */
html[data-theme="dark"] {
  --bg: #0d100e;
  --surface: #141a17;
  --surface-hover: #1a211d;
  --ink: #e8f0ee;
  --muted: #a3b3a8;
  --line: #2a3a33;
  --input-border: #3a4a42;
  --toast-bg: #e8f0ee;
  --toast-color: #0f1512;
  --toast-error-bg: #b95d57;
  --backdrop: #060908cc;
  --banner-bg: #2e1a18;
  --banner-color: #fbb3ac;
  --banner-border: #5a2d29;
  --green: #2fb881;
  --green-dark: #14c99a;
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) {
    --bg: #0d100e;
    --surface: #141a17;
    --surface-hover: #1a211d;
    --ink: #e8f0ee;
    --muted: #a3b3a8;
    --line: #2a3a33;
    --input-border: #3a4a42;
    --toast-bg: #e8f0ee;
    --toast-color: #0f1512;
    --toast-error-bg: #b95d57;
    --backdrop: #060908cc;
    --banner-bg: #2e1a18;
    --banner-color: #fbb3ac;
    --banner-border: #5a2d29;
    --green: #2fb881;
    --green-dark: #14c99a;
  }
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-size: 13px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button { color: inherit; }
button:disabled { cursor: not-allowed; opacity: .55; }
button, input, select, textarea { outline: none; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid #7dc3ad; outline-offset: 3px; }
input:focus, select:focus, textarea:focus { border-color: #55a88c !important; box-shadow: 0 0 0 3px #16836312; }
a { color: inherit; text-decoration: none; }
svg { display: inline-block; vertical-align: middle; flex-shrink: 0; }

/* ---- Icon system (scoped & bounded) — Arena shell fix ----
   Inline <svg> icons render symbols from the hidden .icon-sprite via <use>.
   Without an explicit bounded size, an inline <svg> with a viewBox falls back
   to its intrinsic 300x150 viewport, and monochrome paths (no fill) render as
   huge black shapes — the Arena shell regression. Each icon role is sized
   explicitly below; there is intentionally NO global "svg { width/height }" rule
   that could over-reach, and .icon-sprite stays zero-size/invisible. ---- */
.nav-icon svg { width: 20px; height: 20px; flex: 0 0 auto; flex-shrink: 0; fill: currentColor; }
svg.brand-icon { width: 52px; height: 52px; flex: 0 0 auto; flex-shrink: 0; }
.empty-state svg { width: 40px; height: 40px; flex: 0 0 auto; flex-shrink: 0; fill: currentColor; }
svg.empty-icon { width: 40px; height: 40px; flex: 0 0 auto; flex-shrink: 0; fill: currentColor; }
.badge svg { width: 12px; height: 12px; flex: 0 0 auto; flex-shrink: 0; fill: currentColor; }

h1, h2, h3, p { margin: 0; }
button { border: 0; background: none; }
input[type='checkbox'], input[type='radio'] { accent-color: var(--green); }
::selection { background: #d0eddf; }

/* ---- Layout: shell / sidebar / workspace ---- */
.shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 29px 18px 0; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 7px 0 0; }
.brand-link { color: var(--green); font-weight: 700; font-size: 17px; text-decoration: none; }
.brand-link:hover { text-decoration: none; }
.nav-heading { padding: 0 13px; margin: 33px 0 13px; font-size: 9px; font-weight: 650; letter-spacing: 1.2px; color: var(--muted); }
.nav-list { display: flex; flex-direction: column; gap: 5px; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 12px 13px; min-height: 45px; border-radius: 7px; font-size: 13px; font-weight: 500; color: var(--muted); position: relative; text-align: left; transition: background .18s, color .18s; }
.nav-link:hover { background: var(--surface-hover); color: var(--ink); }
.nav-link.active { color: #148263; background: var(--surface-hover); font-weight: 650; }
html[data-theme="dark"] .nav-link.active { color: #3abfa0; }
.nav-link.active::before { content: ''; position: absolute; left: -18px; width: 3px; height: 24px; border-radius: 0 3px 3px 0; background: var(--green); }
.workspace { min-width: 0; }
.main-content { max-width: 1440px; margin: 0 auto; padding: 28px 30px 48px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-heading h1 { font-size: 26px; margin-bottom: 0; color: var(--ink); }
.eyebrow { font-size: 11px; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-heading h2 { font-size: 17px; margin-bottom: 0; color: var(--ink); }
.muted { color: var(--muted); font-size: 13px; line-height: 1.5; }

/* ---- Topbar ---- */
.topbar { min-height: 62px; padding: 0 30px; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-right { display: flex; align-items: center; flex-shrink: 0; }
.connection { display: flex; align-items: center; gap: 9px; font-size: 14px; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #87928c; }
.dot.success { background: #20834e; }
.dot.warning { background: #bf8418; }
.dot.error { background: #c43b36; }
.dot.neutral { background: #78858f; }
html[data-theme="dark"] .dot.success { background: #4ade80; }
html[data-theme="dark"] .dot.warning { background: #fbbf24; }
html[data-theme="dark"] .dot.error { background: #f87171; }
html[data-theme="dark"] .dot.neutral { background: #9ca3af; }

/* ---- Buttons ---- */
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 8px 13px; border: 1px solid var(--input-border); border-radius: 4px; background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .18s; }
.button:hover:not(:disabled) { background: var(--surface-hover); text-decoration: none; }
.button.primary { background: #176b54; border-color: #176b54; color: #fff; }
.button.primary:hover:not(:disabled) { background: #155e44; }
.button.quiet { background: transparent; }
.button.danger { border-color: #ba423d; color: #a92f2a; }
.button.danger:hover:not(:disabled) { background: #fdf0ef; }
.button:disabled { opacity: .48; cursor: not-allowed; }

/* ---- Forms / inputs / labels ---- */
input, select { min-height: 38px; padding: 7px 9px; border: 1px solid var(--input-border); border-radius: 4px; background: var(--surface); color: var(--ink); max-width: 100%; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.helper { color: var(--muted); font-size: 12px; line-height: 1.5; }

/* ---- Stack form (used by settings.html) ---- */
.stack-form { display: grid; gap: 10px; max-width: 560px; }
.stack-form select { width: 100%; }

/* ---- Panels / cards ---- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 5px; padding: 20px; margin-bottom: 18px; }

/* ---- Stats grid ---- */
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 18px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); padding: 18px; border-radius: 5px; }
.stat strong { display: block; font-size: 26px; margin-top: 6px; color: var(--ink); }

/* ---- Lists ---- */
.list-panel { display: grid; }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }

/* ---- Badges ---- */
.badge { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 12px; background: var(--surface-hover); font-size: 12px; }
.badge.success { background: #e7f4eb; color: #21653b; }
.badge.warning { background: #fff3dc; color: #825500; }
.badge.error { background: #fdebea; color: #9f302b; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); padding: 10px 9px; }
th { font-weight: 600; color: var(--muted); white-space: nowrap; }
td .muted { display: block; }
tbody tr:last-child td { border-bottom: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 5px; }
.actions .button { min-height: 31px; padding: 5px 8px; font-size: 12px; }

/* ---- Filters ---- */
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.filters label { min-width: 140px; }
.filters label input, .filters label select { width: 100%; }
.filters .check-label { display: flex; align-items: center; min-height: 38px; }
.filters .check-label input { min-height: auto; }
.filter-actions { display: flex; gap: 7px; }

/* ---- Toolbar ---- */
.toolbar { margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.toolbar p { margin: 0; }
.button-row { display: flex; gap: 7px; flex-wrap: wrap; }
.quick-actions { display: flex; align-items: center; justify-content: flex-start; gap: 12px; margin-top: 18px; flex-wrap: wrap; }

/* ---- Pagination ---- */
.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; padding-top: 16px; }
#page-prev, #page-next { min-height: 31px; }
#page-label { font-size: 13px; color: var(--ink); }

/* ---- Empty state ---- */
.empty-state { padding: 24px; text-align: center; color: var(--muted); }

/* ---- Toasts ---- */
.toast-region { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 20; }
.toast { max-width: min(440px, calc(100vw - 36px)); padding: 12px 16px; background: var(--toast-bg); color: var(--toast-color); border-radius: 4px; box-shadow: 0 5px 22px #0002; font-size: 13px; }
.toast.error { background: var(--toast-error-bg); }

/* ---- Modals ---- */
.modal-backdrop { position: fixed; inset: 0; background: var(--backdrop); display: grid; place-items: center; padding: 18px; z-index: 30; }
.modal { background: var(--surface); width: min(680px, 100%); max-height: 85vh; overflow: auto; border-radius: 5px; padding: 22px; }
.modal pre { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; line-height: 1.55; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ---- Spinner ---- */
.spinner { display: inline-block; width: 15px; height: 15px; border: 2px solid #cbd5cf; border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Screen-reader only ---- */
.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; }

/* ---- Login page ---- */
.login-page { min-height: 100vh; display: grid; place-items: center; background: var(--bg); }
.login-wrap { width: min(440px, calc(100% - 32px)); }
.login-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 5px; padding: 20px; }
.login-panel .button.primary { width: 100%; }
.notice { padding: 12px 14px; background: #f0f5f2; border-left: 3px solid #398365; color: #42584c; font-size: 14px; line-height: 1.5; border-radius: 4px; }
.notice.error { background: #fff2f1; border-color: #c43b36; color: #922f2a; }
.notice.warning { background: #fffbf2; border-color: #f2e9d7; color: #9a7942; }

/* ---- Telegram-specific helpers (settings.html) ---- */
.telegram-help-hidden { display: none; }
.telegram-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.telegram-actions .button { min-width: 220px; }
.bullets { list-style: disc inside; margin: 12px 0; padding-left: 4px; }
.bullets li { margin: 4px 0; }
.intro-text { margin: 12px 0; }
.helper-small { color: var(--muted); font-size: 12px; line-height: 1.5; }
.telegram-connected-card .connected-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.telegram-details { margin-top: 18px; }
.telegram-details summary { cursor: pointer; }
.modal-steps { margin: 14px 0; padding-left: 18px; line-height: 1.6; }
.modal-steps li { margin: 6px 0; }
.security-notice { background: #fff7f6; border: 1px solid #ffd9d5; border-radius: 4px; padding: 10px 12px; font-size: 13px; margin: 14px 0; }
.modal-footer { font-size: 13px; color: var(--muted); margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }

/* ---- Responsive: tablet ---- */
@media (max-width: 850px) {
  .shell { grid-template-columns: 180px minmax(0, 1fr); }
  .sidebar { padding: 12px; height: auto; position: relative; background: var(--surface); }
  .brand { padding: 0; margin-bottom: 10px; }
  .nav-link { padding: 10px 12px; font-size: 12px; }
  .nav-heading { display: none; }
  .topbar { padding: 0 18px; }
  .main-content { padding: 22px 18px 48px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .filters label { flex: 1 1 42%; min-width: 0; }
  .filters .filter-actions { width: 100%; }
  .button-row { flex-wrap: wrap; justify-content: flex-start; }
  .list-row { align-items: flex-start; flex-direction: column; }
  .login-page { display: block; }
  .login-wrap { margin: 15vh auto; }
}

/* ---- Responsive: mobile ---- */
@media (max-width: 600px) {
  .shell { display: block; }
  .sidebar { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; border-right: none; border-bottom: 1px solid var(--line); position: relative; height: auto; background: var(--surface); }
  .brand { padding: 0; margin-bottom: 8px; }
  .nav-list { display: flex; flex-wrap: wrap; gap: 5px; width: 100%; }
  .nav-link { white-space: nowrap; padding: 8px; font-size: 11px; min-height: 36px; }
  .topbar { min-height: 54px; padding: 0 12px; }
  .connection { font-size: 12px; }
  .main-content { padding: 18px 12px 32px; }
  .panel { padding: 15px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .toolbar, .quick-actions { align-items: flex-start; flex-wrap: wrap; gap: 12px; }
  .login-page { display: block; }
}

/* ---- Utility ---- */
[hidden] { display: none; }

/*
 * Arena visual system — extension to production CSS.
 * Plain CSS (no React/Vite/Tailwind). Ported from the Arena prototype
 * styles to fill classes the Jinja templates
 * and app.js rely on. Deliberately avoids re-declaring already-covered rules.
 */

.app-shell { min-height: 100vh; }

/* ---- Heading / intro ---- */
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 27px; }
.page-heading h1 { font-size: 29px; line-height: 1.3; font-weight: 700; letter-spacing: -.9px; color: var(--ink); }
.page-heading > .btn { flex-shrink: 0; }
.page-intro { color: var(--muted); font-size: 12px; margin-top: 8px; line-height: 1.7; }
.eyebrow { font-size: 11px; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; letter-spacing: .5px; }

/* ---- Buttons (.btn family used by hand-written templates) ---- */
.btn { display: inline-flex; justify-content: center; align-items: center; gap: 7px; min-height: 38px; border-radius: 6px; padding: 9px 14px; font-size: 11.5px; line-height: 1.5; font-weight: 550; white-space: nowrap; border: 1px solid var(--input-border); background: var(--surface); transition: background .18s, border-color .18s, transform .18s, box-shadow .18s; }
.btn:hover { background: var(--surface-hover); border-color: var(--input-border); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; }
.btn-primary { color: #fff; background: var(--green); border-color: var(--green); box-shadow: 0 2px 3px #125c4110; }
.btn-primary:hover { background: var(--green-dark); border-color: var(--green-dark); box-shadow: 0 3px 8px #16836320; }
html[data-theme="dark"] .btn-primary { background: #106b50; border-color: #106b50; }
html[data-theme="dark"] .btn-primary:hover { background: #0d5c46; border-color: #0d5c46; }
.btn-lg { min-height: 41px; padding: 10px 17px; }
.btn-sm { min-height: 31px; padding: 5px 11px; font-size: 10.5px; border-radius: 5px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { border-color: transparent; background: var(--surface-hover); }
.btn-danger { color: #c24b46; border-color: #f0d8d5; background: var(--surface); }
.btn-danger:hover { background: var(--surface-hover); border-color: #e9b9b4; }
.btn-success { color: #338665; background: var(--surface); border-color: var(--input-border); }

.text-link { color: var(--green); font-size: 11px; display: inline-flex; align-items: center; gap: 5px; font-weight: 550; padding: 3px 0; }
.text-link:hover { color: var(--green-dark); text-decoration: underline; }
.text-link svg { width: 13px; height: 13px; }

.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 29px; height: 29px; border-radius: 5px; color: var(--muted); background: transparent; flex-shrink: 0; }
.icon-button svg { fill: currentColor; }
.icon-button:hover { color: var(--green); background: var(--surface-hover); }
.icon-button svg { width: 16px; height: 16px; }
.lang-switch { display: inline-flex; align-items: center; gap: 6px; min-height: 29px; padding: 0 8px; border-radius: 5px; color: var(--muted); background: transparent; font-size: 13px; font-weight: 500; flex-shrink: 0; cursor: pointer; }
.lang-switch:hover { color: var(--ink); background: var(--surface-hover); }
.lang-switch .lang-current { font-weight: 700; color: var(--ink); }
.lang-switch .lang-other,
.lang-switch .lang-sep { opacity: 0.5; }

.mobile-toggle { display: none; }

/* ---- Panels ---- */
.panel { border-radius: 10px; overflow: hidden; }

.page-heading-alt .section-title { font-size: 15px; font-weight: 650; }
.section-title { font-size: 15px; font-weight: 650; letter-spacing: -.3px; }
.section-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-subtitle { font-size: 11px; color: var(--muted); margin-top: 5px; }
.available-note { display: flex; gap: 6px; align-items: center; font-size: 10px; color: var(--muted); }
.available-note svg { width: 12px; height: 12px; }

/* ---- Search / discovery ---- */
.search-panel { margin-bottom: 27px; }
.panel-top { padding: 20px 23px 0; }
.panel-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.search-form { display: flex; gap: 10px; margin: 17px 0 19px; }
.search-input-wrap { position: relative; flex: 1; min-width: 0; }
.search-input-wrap > svg { position: absolute; left: 13px; top: 13px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search-form .btn { min-height: 41px; font-size: 11px; padding-inline: 16px; }
.input { width: 100%; min-width: 0; height: 41px; padding: 10px 12px; color: var(--ink); font-size: 11.5px; border: 1px solid var(--input-border); border-radius: 6px; background: var(--surface); transition: border-color .2s, box-shadow .2s; }
.input::placeholder { color: var(--muted); opacity: 1; }
.search-input-wrap .input { padding-left: 38px; }
select.input { appearance: auto; padding-right: 12px; cursor: pointer; }

/* ---- Tables (Arena look) ---- */
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 11px; }
th { color: var(--muted); font-size: 9px; font-weight: 550; letter-spacing: .65px; background: var(--surface-hover); padding: 11px 22px; white-space: nowrap; border-block: 1px solid var(--line); }
td { border-bottom: 1px solid var(--line); padding: 14px 22px; color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: var(--surface-hover); }
.count-badge { min-width: 21px; height: 21px; display: inline-grid; place-items: center; border-radius: 5px; background: var(--surface-hover); color: var(--muted); font-size: 10px; font-weight: 500; }
.sources-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.sources-heading h2 { display: flex; align-items: center; gap: 9px; font-size: 17px; font-weight: 650; letter-spacing: -.4px; }
.sources-heading .btn { font-size: 10px; }
.table-note { display: flex; align-items: center; gap: 7px; padding: 11px 22px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; background: var(--surface-hover); }
.table-note svg { width: 13px; height: 13px; }

/* ---- Forms / fields ---- */
.field { display: block; min-width: 0; margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field-label { display: block; color: var(--muted); font-size: 11px; font-weight: 550; margin-bottom: 7px; }
.field-label .optional { color: var(--muted); font-size: 10px; font-weight: 400; margin-left: 6px; }
.field-hint { font-size: 10.5px; color: var(--muted); line-height: 1.65; margin-top: 8px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-row .field { margin-bottom: 0; }

/* ---- Info / notices ---- */
.info-box { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 14px 16px; display: flex; align-items: flex-start; gap: 10px; color: var(--muted); font-size: 11px; line-height: 1.8; }
.info-box > svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 2px; }
.info-box strong { font-weight: 600; }
.warning-box { color: #9a7942; background: var(--surface); border-color: var(--line); }
.error-box { color: #ba554d; background: var(--surface); border-color: var(--line); }
.mt-18 { margin-top: 18px; }
.mb-18 { margin-bottom: 18px; }
.full-width { width: 100%; }

/* ---- Layout helpers ---- */
.split-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(285px, 1fr); align-items: start; gap: 22px; }
.form-panel { padding: 24px; }
.form-section + .form-section { margin-top: 25px; padding-top: 23px; border-top: 1px solid var(--line); }
.form-section-title { font-size: 13px; font-weight: 650; margin-bottom: 14px; display: flex; gap: 8px; align-items: center; }
.step-number { width: 19px; height: 19px; display: grid; place-items: center; background: var(--surface-hover); color: var(--muted); border-radius: 50%; font-size: 9px; font-weight: 600; }
.collect-submit { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-top: 20px; }
.collect-submit-note { color: var(--muted); font-size: 10px; display: flex; align-items: center; gap: 5px; }
.collect-submit-note svg { width: 12px; height: 12px; }
.side-explanation { padding: 19px 4px; color: var(--muted); font-size: 10px; line-height: 1.85; }
.side-explanation h3 { font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.progress-panel { padding: 22px; }
.progress-title { font-size: 14px; font-weight: 650; }

/* ---- Messages filters / export toolbar ---- */
.filters-panel { padding: 19px 22px; margin-bottom: 18px; }
.filters-grid { display: grid; grid-template-columns: 1.1fr .8fr .8fr 1.25fr; gap: 13px; }
.filters-grid .field { margin-bottom: 0; }
.filters-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.checkbox-label { display: flex; align-items: center; gap: 7px; cursor: pointer; color: var(--muted); font-size: 11px; }
.checkbox-label input { width: 13px; height: 13px; margin: 0; }
.checkbox { width: 13px; height: 13px; }
.export-toolbar { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin: 20px 0 16px; }

/* ---- Charts (dashboard) ---- */
.chart-panel { padding: 22px; }
.chart-header { display: flex; align-items: center; justify-content: space-between; }
.chart { position: relative; height: 280px; width: 100%; margin-top: 26px; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; background: var(--surface); z-index: 2; }
/* [hidden] must actually hide chart overlays. The generic [hidden]{display:none}
   (0,1,0) is defeated by .chart-empty's display:grid (same specificity, declared
   later in the cascade) — leaving the loading/empty/error overlay visible as an
   opaque (z-index:2) sheet that smothers the rendered ECharts canvas, even though
   the JS correctly set the hidden attribute. This double-class selector (0,2,0)
   restores the hidden contract; mirrors the .license-banner[hidden] rule below. */
.chart-empty[hidden] {
  display: none;
}

/* ---- Saved-message activity chart (dashboard, Apache ECharts) ---- */
.chart-toolbar { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.chart-toolbar .field-small { flex: 1 1 120px; min-width: 120px; margin-bottom: 0; }
.field-small { display: block; min-width: 0; margin-bottom: 0; }
.field-small .input { height: 34px; font-size: 11px; }
.activity-presets { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.activity-meta { font-size: 10px; color: var(--muted); margin: 8px 0; word-break: break-word; }
.activity-meta .available-note { white-space: normal; }
.activity-error-text { color: #c0392b; font-size: 11px; white-space: normal; }
/* ECharts renders into this div; overlays (.chart-empty) sit on top during
   loading/empty/error via document order + [hidden]. No hand-rolled bars. */
.activity-echarts { width: 100%; height: 100%; display: block; }
.mt-12 { margin-top: 12px; }

/* ---- Overview metrics ---- */
.overview-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 25px; padding: 5px 0 25px; margin-bottom: 24px; border-bottom: 1px solid var(--line); }
.metric-card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 18px; }
.metric-label { font-size: 10px; color: var(--muted); line-height: 1.5; }
.metric-value { font-size: 28px; font-weight: 650; color: var(--ink); letter-spacing: -.8px; font-variant-numeric: tabular-nums; }
.metric-change { font-size: 10px; color: #5f9c77; margin-top: 4px; }
.overview-bottom { display: grid; grid-template-columns: 1.1fr 1fr; gap: 30px; margin-top: 27px; }
.getting-started { padding-top: 3px; }
.getting-started p { color: var(--muted); font-size: 11px; line-height: 1.9; margin: 10px 0 18px; }

/* ---- Empty state extras ---- */
.empty-state h3 { font-size: 14px; color: var(--ink); margin-bottom: 6px; }
.empty-state p { max-width: 400px; margin-inline: auto; font-size: 11px; line-height: 1.8; }
.empty-state .btn { margin-top: 18px; }

/* ---- Badges (extras) ---- */
.badge-soft { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); background: var(--surface-hover); border-radius: 4px; padding: 2px 7px; font-size: 9px; font-weight: 500; }
.badge-success { display: inline-flex; align-items: center; gap: 5px; color: #21653b; background: var(--surface-hover); border-radius: 4px; padding: 2px 7px; font-size: 9px; font-weight: 500; }

/* ---- Integrations ---- */
.integration-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.integration-card { padding: 26px; display: flex; flex-direction: column; align-items: flex-start; }
.integration-icon { width: 50px; height: 50px; display: grid; place-items: center; background: var(--surface-hover); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 20px; }
.integration-icon svg { width: 30px; height: 30px; }
.integration-card h2 { font-size: 19px; font-weight: 650; letter-spacing: -.4px; }
.integration-description { color: var(--muted); font-size: 11px; line-height: 1.85; margin-top: 8px; max-width: 355px; }
.integration-card > .btn { margin-top: 25px; }
.integration-connection { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 18px; width: 100%; }
.account-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.account-text { font-size: 11px; color: var(--muted); margin-top: 8px; }
.folder-box { display: flex; align-items: center; gap: 8px; padding: 11px; border: 1px solid var(--line); border-radius: 6px; font-size: 11px; color: var(--muted); width: 100%; }
.folder-box > svg { width: 15px; height: 15px; }
.folder-box .text-link { margin-left: auto; font-size: 10px; }
.integration-actions { margin-top: 17px; display: flex; gap: 7px; flex-wrap: wrap; }
.integration-actions .btn { font-size: 10px; min-height: 32px; }
.integration-grid + .info-box { margin-top: 24px; }

/* ---- Settings tabs ---- */
.settings-tabs { display: flex; gap: 25px; border-bottom: 1px solid var(--line); margin-bottom: 26px; }
.tab { font-size: 12px; padding: 0 3px 13px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; }
.tab.active { border-bottom-color: var(--green); color: #2b7f56; font-weight: 550; }
.tab-panel { padding: 0 0 20px; }
.tab:not(.active) { opacity: .6 }

/* ---- Settings body ---- */
.intro-text { margin: 12px 0; color: var(--muted); font-size: 12px; }
.bullets { list-style: disc inside; margin: 12px 0; padding-left: 4px; }
.bullets li { margin: 4px 0; color: var(--muted); }
.telegram-status-root { margin-top: 18px; }
.connected-details { display: grid; grid-template-columns: 1fr 1fr; gap: 21px; padding: 20px 0; margin-bottom: 20px; border-block: 1px solid var(--line); }
.connected-details dt { color: var(--muted); font-size: 10px; }
.connected-details dd { margin: 5px 0 0; font-size: 12px; color: var(--muted); }

/* ---- Export ---- */
.export-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(300px, 1fr); gap: 23px; align-items: start; }
.format-options { display: flex; gap: 9px; margin-top: 8px; }
.format-option { flex: 1; cursor: pointer; border: 1px solid var(--line); border-radius: 7px; padding: 13px 14px; color: var(--muted); font-size: 11px; }
.format-option.selected { border-color: #8bbf9d; background: var(--surface-hover); color: #36794d; }
.format-option input { margin-right: 7px; }
.format-description { font-size: 9px; color: var(--muted); display: block; margin-top: 5px; padding-left: 23px; }
.export-summary { padding: 14px 0; margin-top: 18px; border-top: 1px solid var(--line); font-size: 11px; color: #849a8c; }
.export-summary strong { color: #4d785b; font-weight: 600; }

/* ---- Sidebar backdrop (mobile) ---- */
.sidebar-backdrop { position: fixed; inset: 0; z-index: 35; background: var(--backdrop); }

/* ---- Responsive: tablet/laptop (hide desktop-only, prep mobile) ---- */
@media (max-width: 1280px) {
  .filters-grid { grid-template-columns: 1fr 1fr; }
  .split-layout { grid-template-columns: 1.35fr 260px; }
  .overview-metrics { grid-template-columns: 1fr 1fr; }
}

/* ---- Responsive: mobile (off-canvas sidebar + hamburger) ---- */
@media (max-width: 800px) {
  .shell { display: block; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar); transform: translateX(-100%); transition: transform .23s ease; display: block; z-index: 40; background: var(--surface); border-right: 1px solid var(--line); padding: 29px 18px 0; overflow-y: auto; }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-backdrop { display: block; }
  .mobile-toggle { display: inline-flex; margin-right: 10px; }
  .workspace { width: 100%; }
  .topbar { min-height: 65px; padding: 0 22px; }
  .topbar-right { gap: 14px; }
  .topbar-left { gap: 8px; }
  .main-content { padding: 27px 22px 20px; }
  .page-heading { align-items: flex-start; flex-wrap: wrap; gap: 16px; margin-bottom: 22px; }
  .page-heading h1 { font-size: 27px; }
  .page-heading p { max-width: 440px; }
  .page-heading > .btn { min-height: 36px; font-size: 11px; }
  .split-layout { grid-template-columns: 1fr; }
  .filters-grid { grid-template-columns: 1fr 1fr; }
  .filters-grid .field:first-child, .filters-grid .field:last-child { grid-column: 1 / -1; }
  .integration-grid { grid-template-columns: 1fr; }
  .chart-panel { padding: 18px; }
  .chart { height: 200px; }
  .overview-bottom { grid-template-columns: 1fr; gap: 20px; }
  .export-layout { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .topbar { min-height: 54px; padding: 0 16px; }
  .topbar-right { gap: 12px; flex-wrap: wrap; }
  .topbar-left { gap: 6px; }
  .main-content { padding: 24px 16px 19px; }
  .page-heading h1 { font-size: 24px; }
  .page-heading p { font-size: 11px; }
  .panel { padding: 18px; }
  .search-form { flex-wrap: wrap; }
  .search-form > .btn { width: 100%; }
  .section-title { font-size: 14px; }
  .available-note { font-size: 9px; }
  .integration-card { padding: 23px; }
}

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

/* ---- License banner (non-dismissable, full-width across all pages) ---- */
.license-banner {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 10px 14px;
  margin: 0 0 8px 0;
  border-radius: 6px;
  background: var(--banner-bg);
  border: 1px solid var(--banner-border);
  color: var(--banner-color);
  font-size: 14px;
  line-height: 1.4;
}
.license-banner svg { width: 18px; height: 18px; flex: 0 0 auto; fill: currentColor; }
.license-banner .banner-text { flex: 1 1 auto; }
.license-banner a.license-banner-link {
  flex: 0 0 auto;
  text-decoration: underline;
  font-weight: 600;
}
/* [hidden] must actually hide the banner. The generic [hidden]{display:none}
   rule (higher in the file) and .license-banner{display:flex} below share
   specificity (0,1,0) and the later .license-banner wins the cascade — leaving
   the banner visible (with an empty .banner-text) even after
   renderLicenseBanner sets hidden. This double-class selector (0,2,0)
   restores the hidden contract so the banner is shown only for blocked modes. */
.license-banner[hidden] {
  display: none;
}

/* ---- License card on Settings ---- */
.license-card .page-subheading { color: var(--muted); margin: 4px 0 12px; }
.license-state { margin: 8px 0; font-size: 15px; }
.license-state .muted { color: #6b7280; }
.license-state .active { color: #2e7d32; font-weight: 600; }
.license-state .warn { color: #b95a00; font-weight: 600; }
.license-instance { margin-top: 14px; }
.request-code-row {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: var(--surface-hover);
  border-radius: 6px;
  padding: 8px 10px;
  word-break: break-all;
  margin: 6px 0 10px;
}
.request-code-row .mono { font-family: ui-monospace, monospace; font-size: 13px; }
.request-code-row .btn-icon { width: 16px; height: 16px; }
.license-card .info-box { margin-top: 14px; }
.license-details { margin: 8px 0 4px; font-size: 14px; line-height: 1.5; }
.license-details .muted { color: #6b7280; }
.license-countdown { margin-top: 6px; font-weight: 600; color: #b95a00; }
