/* ─────────────────────────── design tokens ───────────────────────────
   Palette from the official e-gov.uz brand guide (design_fyles/COLORS.jpg):
     PANTONE 2945 C  #005AA5   PANTONE 2995 C  #00A5DC   PANTONE 361 C  #0DAF2D
     neutrals        #1E1E1E / #6E6E6E / #A8A8A8
   White-on-#00A5DC fails contrast, so 2995 is used for fills and accents only;
   text and primary buttons use 2945.
   ------------------------------------------------------------------- */
:root {
  --brand-700: #005AA5;  /* PANTONE 2945 C */
  --brand-600: #0079BE;  /* midpoint of the official 2995 → 2945 gradient */
  --brand-500: #00A5DC;  /* PANTONE 2995 C */
  --brand-050: #E7F5FC;
  --brand-100: #CDEAF8;

  --green-600: #0A8F24;
  --green-500: #0DAF2D;  /* PANTONE 361 C */
  --green-050: #E4F7E8;

  --ink:       #1E1E1E;  /* CMYK 0.0.0.100 */
  --ink-2:     #6E6E6E;  /* CMYK 0.0.0.70  */
  --ink-3:     #A8A8A8;  /* CMYK 0.0.0.40  */

  --bg:        #EEF6FB;
  --surface:   #ffffff;
  --surface-2: #F4F8FB;
  /* Support thread — see .msg. Neutral for the citizen, green for us. */
  --msg-user-bg:      #FFFFFF;
  --msg-user-line:    #E3E9EE;
  --msg-user-accent:  #8FA3B2;
  --msg-staff-bg:     #E9F7EE;
  --msg-staff-line:   #C3E6D0;
  --msg-staff-accent: #17924F;
  --msg-bot-bg:       #F3F1FB;
  --msg-bot-line:     #CFC7EC;
  --msg-bot-accent:   #6B51C4;
  --text:      var(--ink);
  --text-2:    var(--ink-2);
  --hint:      var(--ink-3);
  --line:      #DCE7EF;

  --success:   var(--green-600);
  --success-bg: var(--green-050);
  --danger:    #C62839;
  --danger-bg: #FBEAEC;
  --warn:      #C2540F;
  --warn-bg:   #FDF0E7;

  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 9px;

  --shadow-1: 0 1px 2px rgba(0, 90, 165, .07);
  --shadow-2: 0 8px 24px rgba(0, 90, 165, .12);

  --tabbar-h: 62px;
  --topbar-h: 52px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;

  /* Portrait crop keeps the artwork's rounded-square cascade on a phone screen;
     the landscape original is used when the viewport is wider than it is tall. */
  --page-bg-image: url("/assets/bg-portrait.jpg");
}

@media (min-aspect-ratio: 1 / 1) {
  :root { --page-bg-image: url("/assets/bg.jpg"); }
}

:root[data-theme="dark"] {
  --brand-050: #0E2B41;
  --brand-100: #143954;

  --bg:        #0B1520;
  --surface:   #13202D;
  --surface-2: #1A2937;
  --msg-user-bg:      #1C2530;
  --msg-user-line:    #2C3A47;
  --msg-user-accent:  #6E8496;
  --msg-staff-bg:     #12301F;
  --msg-staff-line:   #1E4A31;
  --msg-staff-accent: #35B06B;
  --msg-bot-bg:       #211C33;
  --msg-bot-line:     #3A3054;
  --msg-bot-accent:   #9B84E8;
  --text:      #EAF2F8;
  --text-2:    #9FB3C4;
  --hint:      #74889B;
  --line:      #24384980;

  --success-bg: #10321A;
  --danger-bg:  #37191D;
  --warn-bg:    #35240F;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, .4);

  --page-bg-image: none;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html {
  background: var(--bg);
}

html, body {
  margin: 0;
  padding: 0;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}

body {
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  position: relative;
  background: transparent;
}

/* The corner artwork from the brand kit, fixed behind the content. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--page-bg-image) center center / cover no-repeat;
  pointer-events: none;
}

button, input, textarea, select { font: inherit; color: inherit; }
/* UA buttons come with a grey ButtonFace background in dark mode — reset once, here. */
button { background: none; border: 0; }
/* Inline icons default to a sane box; component rules below override where needed. */
svg { width: 18px; height: 18px; flex: none; }
a { color: var(--brand-700); text-decoration: none; }

/* ────────────────────────────── splash ─────────────────────────────── */
.splash {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  background: var(--page-bg-image) center center / cover no-repeat, var(--bg);
}
.splash__logo { width: 190px; max-width: 62vw; animation: pop .5s ease; }
.splash__spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2.5px solid var(--line); border-top-color: var(--brand-700);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }

/* ────────────────────────────── topbar ─────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar__brand { display: flex; align-items: center; }
.topbar__brand img { height: 25px; width: auto; display: block; }
/* The wordmark is brand blue; lift it slightly so it reads on the dark surface. */
:root[data-theme="dark"] .topbar__brand img,
:root[data-theme="dark"] .splash__logo { filter: brightness(1.28) saturate(1.05); }
.topbar__actions { display: flex; gap: 6px; }

.iconbtn {
  display: inline-flex; align-items: center; gap: 3px;
  height: 34px; min-width: 34px; padding: 0 9px;
  border: 0; border-radius: 999px;
  background: var(--surface-2); color: var(--text);
  font-size: 15px; cursor: pointer;
  transition: transform .12s ease, background .15s ease;
}
.iconbtn:active { transform: scale(.94); }
.iconbtn__code { font-size: 12px; font-weight: 700; letter-spacing: .3px; }
.iconbtn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.chev { opacity: .55; }

/* ─────────────────────────────── layout ────────────────────────────── */
.view { padding: 14px 14px 24px; animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

.section { margin-top: 22px; }
.section:first-child { margin-top: 0; }
.section__head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; padding: 0 2px; }
.section__title { font-size: 17px; font-weight: 700; letter-spacing: -.3px; margin: 0; }
.section__link { border: 0; background: none; padding: 0; cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--brand-700); display: inline-flex; align-items: center; gap: 4px; }
.section__link svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* ──────────────────────────────── hero ────────────────────────────── */
.hero {
  position: relative; overflow: hidden;
  border-radius: var(--radius-xl);
  padding: 26px 20px 22px;
  background: linear-gradient(158deg, var(--brand-500), var(--brand-700));
  color: #fff;
  box-shadow: var(--shadow-2);
  text-align: center;
}
.hero::after {
  content: ""; position: absolute; width: 240px; height: 240px; right: -80px; top: -110px;
  background: radial-gradient(circle, rgba(255,255,255,.22), transparent 65%);
}
.hero__logo {
  width: 78px; height: 78px; margin: 0 auto 16px;
  display: grid; place-items: center;
  background: #fff; border-radius: 22px;
  box-shadow: 0 6px 18px rgba(0, 40, 80, .22);
}
.hero__logo img { width: 52px; height: 52px; display: block; }
.hero__title { margin: 0 0 8px; font-size: 25px; font-weight: 800; line-height: 1.2; letter-spacing: -.6px; }
.hero__subtitle { margin: 0; font-size: 14.5px; opacity: .88; }
.hero__row { display: flex; gap: 8px; margin-top: 18px; }
.hero__btn {
  flex: 1; border: 0; cursor: pointer;
  padding: 11px 12px; border-radius: 13px;
  background: rgba(255,255,255,.18); color: #fff; font-weight: 650; font-size: 14px;
  border: 1px solid rgba(255,255,255,.2);
  transition: transform .12s ease, background .15s;
}
.hero__btn:active { transform: scale(.97); background: rgba(255,255,255,.28); }
.hero__btn--solid { background: #fff; color: var(--brand-700); border-color: #fff; }
.hero__logo + .hero__title { margin-top: 0; }

/* ─────────────────────────────── search ───────────────────────────── */
.search { position: relative; margin-top: 16px; }
.search input {
  width: 100%; height: 46px; padding: 0 14px 0 42px;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--text);
  outline: none; font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
.search input:focus { border-color: var(--brand-500); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-500) 18%, transparent); }
.search svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; stroke: var(--hint); fill: none; stroke-width: 2.2; stroke-linecap: round;
}

/* ──────────────────────────────── cards ───────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-1);
}
.card + .card { margin-top: 10px; }

.list { display: flex; flex-direction: column; gap: 8px; }

.row {
  display: flex; align-items: center; gap: 12px;
  font: inherit; color: inherit;
  width: 100%; text-align: left; cursor: pointer;
  padding: 13px 14px; border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: var(--shadow-1);
  transition: transform .12s ease, border-color .15s;
}
.row:active { transform: scale(.985); border-color: color-mix(in srgb, var(--brand-500) 45%, var(--line)); }
.row__icon {
  flex: none; width: 42px; height: 42px; border-radius: 13px;
  display: grid; place-items: center; font-size: 20px;
  background: var(--brand-050);
}
.row__body { flex: 1; min-width: 0; }
.row__title { font-weight: 620; font-size: 14.8px; letter-spacing: -.2px; margin: 0 0 2px; }
.row__sub { color: var(--text-2); font-size: 12.8px; margin: 0; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row__chev { flex: none; width: 16px; height: 16px; stroke: var(--hint); fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* categories grid */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile {
  cursor: pointer; text-align: left; font: inherit; color: inherit;
  padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: var(--shadow-1);
  transition: transform .12s ease;
}
.tile:active { transform: scale(.97); }
.tile__icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; margin-bottom: 10px; }
.tile__title { font-weight: 620; font-size: 14px; letter-spacing: -.2px; }
.tile__meta { color: var(--hint); font-size: 12px; margin-top: 3px; }

/* quick actions */
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick__btn {
  font: inherit; color: inherit;
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 13px 14px; border-radius: var(--radius-lg);
  border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-1);
  font-weight: 600; font-size: 13.6px; text-align: left;
  transition: transform .12s ease;
}
.quick__btn:active { transform: scale(.97); }
.quick__ic { width: 34px; height: 34px; flex: none; border-radius: 11px; display: grid; place-items: center; font-size: 17px; background: var(--brand-050); }

/* ──────────────────────────────── rates ───────────────────────────── */
.rates { padding: 4px 0; }
.rate {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.rate:last-child { border-bottom: 0; }
.rate__flag { font-size: 22px; }
.rate__code { font-weight: 700; font-size: 14.5px; flex: none; width: 42px; }
.rate__value { flex: 1; font-weight: 650; font-size: 15px; font-variant-numeric: tabular-nums; }
.pill {
  font-size: 12.2px; font-weight: 700; padding: 4px 9px; border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.pill--up { color: var(--success); background: var(--success-bg); }
.pill--down { color: var(--danger); background: var(--danger-bg); }
.pill--flat { color: var(--text-2); background: var(--surface-2); }

/* ──────────────────────────────── badges ──────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 650; padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2);
  /* A badge is a short label; a ticket number broken over three lines is not one. */
  white-space: nowrap;
}
.badge--new { background: var(--brand-050); color: var(--brand-700); }
.badge--in_progress { background: var(--warn-bg); color: var(--warn); }
.badge--answered { background: var(--success-bg); color: var(--success); }
.badge--rejected { background: var(--danger-bg); color: var(--danger); }
.badge--closed { background: var(--surface-2); color: var(--text-2); }

/* ─────────────────────────────── details ──────────────────────────── */
.page-head { margin-bottom: 14px; }
.page-head h1 { font-size: 21px; font-weight: 800; letter-spacing: -.5px; margin: 0 0 6px; line-height: 1.25; }
.page-head p { color: var(--text-2); margin: 0; font-size: 14px; }

.kv { padding: 4px 0; }
.kv__row { display: flex; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.kv__row:last-child { border-bottom: 0; }
.kv__k { color: var(--text-2); font-size: 13px; flex: none; width: 40%; }
.kv__v { font-size: 13.6px; font-weight: 550; flex: 1; }

.bullets { margin: 0; padding: 12px 14px 12px 30px; }
.bullets li { margin: 5px 0; font-size: 13.8px; }

/* ────────────────────────────── timeline ──────────────────────────── */
/*
 * Who said it, told three ways over.
 *
 * The citizen's message and ours used to be #E7F5FC against #F4F8FB in light
 * and #0E2B41 against #1A2937 in dark — two blues a shade apart, which read as
 * one long undifferentiated thread. Specialists said so.
 *
 * Colour now separates them by hue rather than by shade, and never carries the
 * distinction alone: the citizen's messages sit left against a neutral ground,
 * ours sit right in green with an accent down the edge, and each keeps its
 * 👤 / 👨‍💼 marker. Any one of the three would be enough on its own.
 */
.msg {
  padding: 11px 13px; border-radius: var(--radius-md); font-size: 14px;
  max-width: 86%; width: fit-content; white-space: pre-line; overflow-wrap: anywhere;
}
.msg--user {
  background: var(--msg-user-bg); border: 1px solid var(--msg-user-line);
  border-left: 3px solid var(--msg-user-accent);
  margin-right: auto; border-top-left-radius: 5px;
}
.msg--staff {
  background: var(--msg-staff-bg); border: 1px solid var(--msg-staff-line);
  border-right: 3px solid var(--msg-staff-accent);
  margin-left: auto; border-top-right-radius: 5px; text-align: left;
}
/* The bot's own answer: on our side of the thread, because it went out in our
   name, but dashed and paler so nobody mistakes it for something a person wrote. */
.msg--bot {
  background: var(--msg-bot-bg); border: 1px dashed var(--msg-bot-line);
  border-right: 3px solid var(--msg-bot-accent);
  margin-left: auto; border-top-right-radius: 5px;
}
.msg__file { margin-top: 6px; }
.msg__file-open {
  display: inline-block; font: inherit; font-size: 12.5px; cursor: pointer;
  background: transparent; color: var(--link); border: 1px dashed var(--line);
  border-radius: 8px; padding: 5px 9px; text-decoration: none;
}
.msg__file-open:disabled { opacity: .6; cursor: default; }
.msg__img { display: block; margin-top: 6px; max-width: 100%; border-radius: 10px; }
.msg__img--zoom { cursor: zoom-in; }

/* One image, as large as the screen allows. Above everything, including the
   sticky reply bar, because a half-covered screenshot is the problem itself. */
.lightbox {
  position: fixed; inset: 0; z-index: 900; background: rgba(0, 0, 0, .92);
  display: flex; align-items: center; justify-content: center; padding: 12px;
  overscroll-behavior: contain;
}
.lightbox img {
  max-width: 100%; max-height: 100%;
  object-fit: contain; border-radius: 6px;
}
.lightbox__close {
  position: absolute; top: 10px; right: 12px;
  width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, .15); color: #fff; font-size: 17px; line-height: 1;
}

.msg--system {
  background: transparent; color: var(--hint); font-size: 12.5px;
  text-align: center; padding: 4px; max-width: 100%; margin: 0 auto;
}
.msg__meta { font-size: 11.5px; color: var(--hint); margin-top: 6px; }
.msg--staff .msg__meta { text-align: right; }

/* ──────────────────────────────── forms ───────────────────────────── */
.field { margin-bottom: 14px; }
.field__label { display: block; font-size: 13px; font-weight: 620; color: var(--text-2); margin-bottom: 6px; padding-left: 2px; }
.field__control, .field select, .field textarea, .field input {
  width: 100%; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--surface); color: var(--text); outline: none;
  font-size: 15px; transition: border-color .15s, box-shadow .15s;
}
.field textarea { min-height: 130px; resize: vertical; line-height: 1.5; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--brand-500); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-500) 18%, transparent);
}
.field--error input, .field--error textarea, .field--error select { border-color: var(--danger); }
.field__error { color: var(--danger); font-size: 12.2px; margin-top: 5px; padding-left: 2px; }
.field__hint { color: var(--hint); font-size: 12px; margin-top: 5px; padding-left: 2px; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px; cursor: pointer;
  border: 0; border-radius: 14px;
  background: var(--brand-700); color: #fff; font-weight: 680; font-size: 15px;
  transition: transform .12s ease, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; }
.btn--ghost { background: var(--surface); color: var(--brand-700); border: 1px solid var(--line); }
.btn--danger { background: var(--danger); }

.field input[type="file"] { padding: 0; }

.attachments { display: flex; flex-wrap: wrap; gap: 8px; }
.attachment {
  padding: 0; border: 1px solid var(--line); border-radius: var(--radius-md);
  overflow: hidden; cursor: pointer; line-height: 0; background: var(--surface-2);
  transition: transform .12s ease;
}
.attachment:active { transform: scale(.97); }
.attachment img { width: 104px; height: 104px; object-fit: cover; display: block; }
.filechip__size { color: var(--hint); font-size: 11.5px; margin-left: 2px; }

.filechip {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  padding: 8px 12px; margin: 6px 6px 0 0;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; font-size: 12.6px;
}
.filechip button { border: 0; background: none; color: var(--danger); cursor: pointer; font-size: 15px; line-height: 1; }
button.filechip { cursor: pointer; text-align: left; }

/* ────────────────────────────── settings ──────────────────────────── */
.settings { padding: 2px 0; }
.settings__row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.settings__row:last-child { border-bottom: 0; }
.settings__row--stack { flex-direction: column; align-items: stretch; gap: 10px; }
.settings__ic { width: 32px; height: 32px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); font-size: 16px; }
.settings__label { flex: 1; font-size: 14.4px; font-weight: 550; }
.settings__value { color: var(--hint); font-size: 13.4px; }

.switch { position: relative; width: 46px; height: 27px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0; border-radius: 999px; background: var(--line);
  transition: background .2s; cursor: pointer;
}
.switch span::before {
  content: ""; position: absolute; width: 21px; height: 21px; left: 3px; top: 3px;
  border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: var(--shadow-1);
}
.switch input:checked + span { background: var(--brand-700); }
.switch input:checked + span::before { transform: translateX(19px); }

.segmented { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 12px; }
.segmented button {
  flex: 1; border: 0; background: none; cursor: pointer;
  padding: 8px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--text-2);
  transition: background .15s, color .15s;
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

.profile-head { display: flex; align-items: center; gap: 14px; padding: 16px; }
.avatar {
  width: 58px; height: 58px; flex: none; border-radius: 20px;
  display: grid; place-items: center; font-size: 24px; font-weight: 700; color: #fff;
  background: linear-gradient(150deg, var(--brand-500), var(--brand-700));
}
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { padding: 14px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.stat__n { font-size: 21px; font-weight: 800; letter-spacing: -.5px; }
.stat__l { font-size: 11.6px; color: var(--hint); margin-top: 2px; }

/* ────────────────────────────── tab bar ───────────────────────────── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--line);
}
.tab {
  border: 0; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--hint); font-size: 10.6px; font-weight: 600;
  transition: color .15s;
}
.tab svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-selected="true"] { color: var(--brand-700); }
.tab[aria-selected="true"] svg { stroke-width: 2.3; }
.tab__badge {
  position: absolute; transform: translate(13px, -10px);
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 999px; display: grid; place-items: center;
}

/* ───────────────────────────── bottom sheet ───────────────────────── */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(2, 6, 23, .45); z-index: 40; animation: fade .2s ease; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  background: var(--surface); border-radius: 22px 22px 0 0;
  padding: 10px 14px calc(18px + var(--safe-bottom));
  max-height: 78vh; overflow-y: auto;
  animation: slideup .26s cubic-bezier(.2, .8, .3, 1);
}
@keyframes slideup { from { transform: translateY(100%); } }
.sheet__grip { width: 38px; height: 4px; border-radius: 999px; background: var(--line); margin: 4px auto 14px; }
.sheet__title { font-size: 16px; font-weight: 700; margin: 0 0 12px; padding: 0 2px; }
.sheet__option {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 13px 12px; border: 0; border-radius: 12px; background: none; cursor: pointer;
  font-size: 15px; text-align: left;
}
.sheet__option[aria-selected="true"] { background: var(--brand-050); color: var(--brand-700); font-weight: 650; }

/* ─────────────────────────────── toast ────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  transform: translateX(-50%); z-index: 50;
  padding: 11px 18px; border-radius: 999px;
  background: rgba(15, 23, 42, .92); color: #fff; font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow-2); animation: toastin .25s ease;
  max-width: 88vw; text-align: center;
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ───────────────────────────── empty / skeleton ───────────────────── */
.empty { text-align: center; padding: 46px 20px; }
.empty__ic { font-size: 44px; margin-bottom: 12px; }
.empty__title { font-weight: 700; font-size: 16px; margin-bottom: 6px; }
.empty__text { color: var(--text-2); font-size: 13.6px; margin-bottom: 18px; }

.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius: var(--radius-md); }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
.skeleton--row { height: 68px; margin-bottom: 8px; }

[hidden] { display: none !important; }

/* ─────────────────────── announcement composer ──────────────────────── */

.langtabs { display: flex; gap: 6px; margin-bottom: 8px; overflow-x: auto; padding-bottom: 2px; }
.langtab {
  position: relative; flex: none; cursor: pointer;
  padding: 7px 13px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2);
  font-size: 12.5px; font-weight: 700; letter-spacing: .3px;
  transition: background .15s, color .15s;
}
.langtab[aria-selected="true"] { background: var(--brand-700); color: #fff; }
.langtab__dot {
  position: absolute; top: 5px; right: 6px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--green-500);
}

.toolbar { display: flex; gap: 5px; flex-wrap: wrap; }
.toolbar button {
  cursor: pointer; min-width: 34px; height: 32px; padding: 0 9px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); color: var(--text); font-size: 13.5px;
  transition: transform .1s ease, border-color .15s;
}
.toolbar button:active { transform: scale(.94); border-color: var(--brand-500); }

/* A rough stand-in for a Telegram bubble — the real check is the test send. */
.tg-preview {
  background: var(--brand-050); border: 1px solid var(--line);
  border-radius: 14px 14px 14px 4px; padding: 12px 14px; overflow: hidden;
  font-size: 14.5px; line-height: 1.5; word-break: break-word;
}
.tg-preview__img { width: 100%; border-radius: 10px; margin: -4px 0 10px; display: block; }
.tg-preview__text blockquote {
  margin: 6px 0; padding: 4px 0 4px 10px;
  border-left: 3px solid var(--brand-500); color: var(--text-2);
}
.tg-preview__text code { font-family: ui-monospace, SFMono-Regular, monospace; font-size: 13px; }
.tg-preview__text tg-spoiler { background: var(--text-2); border-radius: 3px; color: transparent; }
.tg-preview__btn {
  margin: 10px -14px -12px; padding: 11px;
  border-top: 1px solid var(--line); text-align: center;
  color: var(--brand-700); font-weight: 650; font-size: 14px;
}

.badge--draft { background: var(--surface-2); color: var(--text-2); }
.badge--scheduled { background: var(--warn-bg); color: var(--warn); }
.badge--sending { background: var(--brand-050); color: var(--brand-700); }
.badge--sent { background: var(--success-bg); color: var(--success); }
.badge--cancelled { background: var(--danger-bg); color: var(--danger); }

/* ─────────────────────── site-wide notices ─────────────────────────── */
/* A strip at the top of home: a state of the world, not a one-off message. */
.notice {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; margin-bottom: 12px;
  border-radius: var(--radius-md);
  border-left: 3px solid var(--brand-500);
  background: var(--brand-050); color: var(--text);
}
.notice--warning { border-left-color: var(--warn); background: var(--warn-bg); }
.notice--urgent  { border-left-color: var(--danger); background: var(--danger-bg); }
.notice__body { flex: 1; min-width: 0; }
.notice__title { font-weight: 700; font-size: 14px; }
.notice__text { margin-top: 3px; font-size: 13px; color: var(--text-2); white-space: pre-line; }
.notice__close {
  flex: none; border: 0; background: none; cursor: pointer;
  color: var(--hint); font-size: 15px; line-height: 1; padding: 2px 4px;
}
.notice__close:hover { color: var(--text); }

/* ────────────────────── portal statistics card ─────────────────────── */
/* Four figures side by side on a phone: two columns, not three. */
.stats--4 { grid-template-columns: repeat(2, 1fr); }
.stats--4 .stat__n { font-size: 19px; }
.stats__note { margin-top: 8px; font-size: 11.5px; color: var(--hint); text-align: center; }
.section__link[disabled] { opacity: .45; cursor: default; }
.stats__note a { color: var(--brand-600, var(--brand-500)); text-decoration: none; }
.stats__note a:hover { text-decoration: underline; }

/* ───────────────────────────── dashboard ─────────────────────────────── */
/* Chart colours are the validated categorical slots 1–4, stepped separately
   for the dark surface rather than flipped. Two of the light steps sit below
   3:1 against white, so every chart here also ships its numbers as a table —
   identity is never carried by colour alone. */
.viz {
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --grid: var(--line);
}
:root[data-theme="dark"] .viz {
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
}

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px; margin: 0 -2px 14px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--surface); color: var(--text-2);
  border-radius: 999px; padding: 7px 13px; font-size: 13px; font-weight: 600; cursor: pointer;
  font-family: inherit; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--brand-700); border-color: var(--brand-700); color: #fff; }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 560px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 13px 14px; box-shadow: var(--shadow-1);
}
.tile__v { font-size: 23px; font-weight: 750; letter-spacing: -.6px; line-height: 1.15; }
.tile__k { font-size: 12.2px; color: var(--text-2); margin-top: 3px; }
.tile__sub { font-size: 11.5px; color: var(--hint); margin-top: 2px; }
.tile--live .tile__v { color: var(--brand-700); }
.tile--alert .tile__v { color: var(--warn); }

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart__grid { stroke: var(--grid); stroke-width: 1; }
.chart__axis { fill: var(--hint); font-size: 10.5px; }
.chart__line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart__dot { r: 3.2; stroke: var(--surface); stroke-width: 2; }
.chart__hit { fill: transparent; cursor: pointer; }
.chart__cursor { stroke: var(--hint); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0; }
.chart__tip {
  position: absolute; pointer-events: none; opacity: 0; transform: translate(-50%, -108%);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-2); padding: 8px 10px; font-size: 12px; white-space: nowrap; z-index: 3;
}
.chart__tip b { display: block; margin-bottom: 4px; font-size: 11.5px; color: var(--text-2); font-weight: 600; }
.chart__tip span { display: flex; align-items: center; gap: 6px; }
.chart__tip i { width: 8px; height: 8px; border-radius: 2px; flex: none; }

.legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.legend button {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line);
  background: var(--surface); border-radius: 999px; padding: 5px 11px; font-size: 12.4px;
  font-weight: 600; color: var(--text); cursor: pointer; font-family: inherit;
}
.legend button[aria-pressed="false"] { color: var(--hint); }
.legend button[aria-pressed="false"] i { opacity: .28; }
.legend i { width: 9px; height: 9px; border-radius: 3px; flex: none; }

.bars { display: flex; flex-direction: column; gap: 9px; }
.bar__head { display: flex; justify-content: space-between; gap: 10px; font-size: 13.2px; margin-bottom: 4px; }
.bar__head span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar__head b { font-variant-numeric: tabular-nums; }
.bar__track { height: 7px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar__fill { height: 100%; border-radius: 99px; background: var(--brand-600); }

.dtable { width: 100%; border-collapse: collapse; font-size: 13px; }
.dtable th, .dtable td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: right; }
.dtable th:first-child, .dtable td:first-child { text-align: left; }
.dtable th { color: var(--text-2); font-weight: 600; font-size: 11.8px; white-space: nowrap; }
.dtable td { font-variant-numeric: tabular-nums; }
.dtable tr:last-child td { border-bottom: 0; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* News kinds. A reader scanning the list should be able to tell "the portal is
   down this weekend" from "a new service has launched" without reading either. */
.badge--news-service      { background: var(--success-bg); color: var(--success); }
.badge--news-maintenance  { background: var(--warn-bg);    color: var(--warn); }
.badge--news-greeting     { background: var(--brand-050);  color: var(--brand-700); }
.badge--news-announcement { background: var(--surface-2);  color: var(--text-2); }

/* The activity trail: a sequence to read, not a table to scan. */
.trail__row { display: flex; gap: 11px; padding: 10px 14px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.trail__row:last-child { border-bottom: 0; }
.trail__icon { flex: none; width: 22px; text-align: center; font-size: 15px; line-height: 1.4; }
.trail__body { min-width: 0; flex: 1; }
.trail__what { display: block; font-size: 13.8px; line-height: 1.35; word-break: break-word; }
.trail__meta { display: block; margin-top: 2px; font-size: 11.5px; color: var(--hint); }

/* The in-app prompt: Telegram's WebView answers neither window.prompt nor
   window.confirm, so asking for a name has to happen inside the page. */
.sheet__hint { margin: 0 0 10px; font-size: 13px; color: var(--hint); }
.sheet__input {
  width: 100%; box-sizing: border-box; font: inherit; font-size: 16px;
  padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text);
}
.sheet__actions { display: flex; gap: 8px; margin-top: 12px; }
.sheet__actions .btn { flex: 1; }
.btn--ghost { background: transparent; color: var(--text-2); border: 1px solid var(--line); }
