/* ===== Receiver panel — dashboard design system ======================= */
:root {
  /* Lokka brand (dark + lime) applied with app-screen discipline:
     lime is a data/status/active accent + the brand mark, not chrome. */
  --bg: #0a0a0b;
  --sidebar: #0e0e10;
  --card: #141416;
  --raised: #1c1c20;          /* elevated fill (avatars, inert tiles) */
  --field: #101012;
  --active: #1e1e22;          /* selected nav / row fill */
  --line: #34343a;            /* control / interactive borders (stronger) */
  --line-soft: #262629;       /* card & row rules (quiet) */
  --text: #f2f3f5;
  --muted: #b4b6bc;           /* secondary text — >=4.5:1 */
  --faint: #8e9096;           /* meta text — reads apart from --muted */
  --accent: #c6f531;          /* lokka lime — brand; on data/status/active only */
  --accent-2: #d6ff4d;
  --accent-weak: rgba(198, 245, 49, .13);
  --ink: #0a0a0b;             /* black text on lime */
  --primary: #26262c;         /* near-black raised primary; light label */
  --primary-border: #3c3c44;
  --green: #35d07f; --green-bg: rgba(53, 208, 127, .15);
  --red: #f5566f;   --red-bg: rgba(245, 86, 111, .15);
  --grey: #b4b6bc;  --grey-bg: rgba(140, 150, 165, .14);
  --amber: #f5b53a; --amber-bg: rgba(245, 181, 58, .15);
  --display: "Oswald", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 10px;
  --radius-sm: 6px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14.5px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }

/* ---- App layout (with sidebar) --------------------------------------- */
body.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; flex: none; background: var(--sidebar);
  border-right: 1px solid var(--line-soft); padding: 20px 14px;
  display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px; font-family: var(--display);
  font-weight: 700; font-size: 20px; text-transform: uppercase; letter-spacing: .5px; padding: 4px 8px;
}
.brand .logo {
  width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 7px;
  background: var(--accent); color: var(--ink); font-size: 16px; font-weight: 700;
  box-shadow: 0 4px 16px var(--accent-weak);
}
.brand .logo svg { display: block; width: 18px; height: 18px; }
.sidebar nav { display: flex; flex-direction: column; gap: 3px; position: relative; }
/* Sliding hover pill (FLIP-style). JS updates transform/height to the hovered
   link's layout rect; CSS easing does the glide. On .navlink.active we hide the
   pill since the active state is already a stronger fill. */
.nav-pill {
  position: absolute; left: 0; right: 0; top: 0; height: 40px;
  background: var(--line-soft); border-radius: 10px; opacity: 0;
  pointer-events: none; z-index: 0;
  transform: translateY(0);
  transition: transform .28s cubic-bezier(.4, .15, 0, 1),
              height    .24s cubic-bezier(.4, .15, 0, 1),
              opacity   .15s linear;
}
.navlink {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-weight: 500;
  transition: color .15s; position: relative; z-index: 1;
}
.navlink:hover { color: var(--text); }
.navlink.active { background: var(--active); color: var(--text); font-weight: 600; }
@media (prefers-reduced-motion: reduce) {
  .nav-pill { transition: opacity .15s linear; }
}
.navlink.active::before {
  content: ""; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent);
}
.navlink.active .ic { color: var(--accent); }
.ic { flex: none; opacity: .95; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }

/* ---- Language switcher (RU/EN) ---- */
.lang-switch { display: inline-flex; align-items: center; gap: 4px; padding: 3px;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px; width: fit-content; }
.lang-switch form.inline { margin: 0; display: inline-flex; }
.lang-btn { appearance: none; border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 12px; font-weight: 700; letter-spacing: .5px;
  padding: 5px 10px; border-radius: 6px; cursor: pointer; min-width: 32px;
  transition: background .15s ease, color .15s ease; }
.lang-btn:hover { color: var(--text, #e8e8e8); background: rgba(255,255,255,.05); }
.lang-btn.active { background: var(--accent); color: #0a0a0b; cursor: default; }
.lang-btn.active:hover { background: var(--accent); color: #0a0a0b; }
.lang-switch.auth { position: fixed; top: 16px; right: 16px; }

.who { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.who .avatar {
  width: 32px; height: 32px; flex: none; border-radius: 7px; display: grid; place-items: center;
  background: var(--raised); color: var(--text); border: 1px solid var(--line-soft); font-weight: 600;
}
.who b { display: block; font-size: 13.5px; }
.who small { color: var(--faint); font-size: 12px; }
.who-link {
  display: flex; align-items: center; gap: 10px; padding: 8px;
  color: var(--text); text-decoration: none; border-radius: 10px;
  border: 1px solid transparent; transition: background .15s, border-color .15s;
}
.who-link:hover { background: var(--line-soft); border-color: var(--line-soft); }
.who-link.active { background: var(--line-soft); border-color: var(--accent); }
.who-link .who-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.who-link .who-text small { display: block; }
.who-link .sub-exp { color: var(--faint); font-size: 11.5px; margin-top: 1px; }
.who-link .sub-exp.warn { color: var(--red); }

/* ---- Content --------------------------------------------------------- */
.content { flex: 1; min-width: 0; padding: 26px 30px 40px; max-width: 1240px; margin-inline: auto; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-weight: 600; font-size: 24px; margin: 0 0 2px; letter-spacing: -.01em; line-height: 1.2; }
.page-head .sub { color: var(--muted); font-size: 13.5px; }

/* ---- Stat tiles ------------------------------------------------------ */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stat {
  background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 16px 18px;
}
.stat .label { color: var(--muted); font-size: 12.5px; }
.stat .value { font-size: 26px; font-weight: 600; margin-top: 4px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: 14px; font-weight: 500; color: var(--faint); }

/* ---- Cards ----------------------------------------------------------- */
.card {
  background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 20px;
}
.card > h1 { font-weight: 600; font-size: 16px; margin: 0 0 16px; }

/* ---- Filters bar ----------------------------------------------------- */
.filters {
  background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.filters .f-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
}
.filters .f-input {
  display: block; margin: 0; padding: 7px 10px; width: auto; min-width: 150px;
  font-size: 13px;
}
.filters .f-input.f-grow { flex: 1 1 260px; min-width: 220px; }
.filters .f-group {
  display: inline-flex; align-items: center; gap: 6px; margin: 0;
  font-size: 12px; color: var(--muted); white-space: nowrap;
}
.filters .f-group .f-input { min-width: 110px; }
.filters .f-spacer { flex: 1 1 auto; }

.owner-link { color: var(--text); border-bottom: 1px dotted var(--line); text-decoration: none; }
.owner-link:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* Click-to-copy inline code chip (e.g. the exe-archive password). */
.copy-code {
  display: inline-block;
  padding: 1px 8px; margin: 0 2px;
  background: rgba(198, 245, 49, .12);
  border: 1px solid rgba(198, 245, 49, .35);
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.95em; font-weight: 600; letter-spacing: .3px;
  border-radius: 6px; cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
  vertical-align: baseline;
}
.copy-code:hover { background: rgba(198, 245, 49, .22); border-color: var(--accent); }
.copy-code:active { transform: scale(.96); }
.copy-code.copied { background: var(--accent); color: var(--ink); border-color: var(--accent); }

/* ---- Bulk actions (checkboxes + sticky "all-matching" row + floating bar) */
th.col-check, td.col-check { width: 36px; padding-left: 10px; padding-right: 2px; text-align: center; }
th.col-check input, td.col-check input {
  width: 16px; height: 16px; margin: 0; padding: 0; display: inline-block;
  accent-color: var(--accent); cursor: pointer; vertical-align: middle;
}
.bulk-all {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: -4px 0 14px; padding: 10px 14px;
  background: var(--card); border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.bulk-all .inline { display: inline; margin: 0; }
.bulk-bar {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  z-index: 900;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--card); border: 1px solid var(--accent);
  border-radius: 999px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .55), 0 0 0 1px rgba(198, 245, 49, .15);
  animation: bulk-in .22s ease-out both;
}
.bulk-bar[hidden] { display: none; }
.bulk-bar .inline { display: inline; margin: 0; }
.bulk-bar .bulk-count { color: var(--muted); font-size: 13px; padding: 0 6px 0 2px; }
.bulk-bar .bulk-count b { color: var(--accent); }
@keyframes bulk-in { from { transform: translate(-50%, 10px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* ---- Profile page ---------------------------------------------------- */
.profile-grid { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr); gap: 20px; }
@media (max-width: 760px) { .profile-grid { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 10px 18px; margin: 0; }
.kv dt { color: var(--muted); font-size: 13px; padding-top: 2px; }
.kv dd { margin: 0; font-size: 14px; }
.kv dd .sub { font-size: 12px; margin-top: 4px; }

/* ---- Telegram-notifications card (full-width row on the profile grid) --- */
.tg-card { grid-column: 1 / -1; }
.sessions-card { grid-column: 1 / -1; }
.tg-card p.small { font-size: 13px; margin: 0 0 14px; }
.tg-kv { margin-bottom: 16px; }
.tg-kv dd .mono { margin-left: 8px; color: var(--muted); font-size: 13px; }
.tg-form { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.tg-form label { flex: 1 1 320px; display: flex; flex-direction: column; gap: 6px; margin: 0; }
.tg-form input[type="text"] { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.tg-form button { flex: none; }
.tg-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.tg-actions form { margin: 0; }

/* ---- Build-in-progress animation (lime gear + rotating phrase) -------- */
.build-anim {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--accent); font-weight: 500; font-size: 13px; letter-spacing: .2px;
  line-height: 1; white-space: nowrap;
}
.build-anim .gear {
  width: 16px; height: 16px; flex: none; color: var(--accent);
  animation: ba-spin 2.4s linear infinite;
  transform-origin: 50% 50%;
  filter: drop-shadow(0 0 6px rgba(198,245,49,.35));
}
/* Reserve width for the widest phrase so swapping text can't resize the column. */
.build-anim .phrase {
  display: inline-block; width: 15.5em; text-align: left;
  opacity: 1; transition: opacity .22s ease;
}
/* Final/stable states keep natural width — no need to reserve space. */
.build-anim .phrase.done { width: auto; }
.build-anim .icon { width: 16px; height: 16px; flex: none; }
.build-anim.ready  { color: var(--green); }
.build-anim.failed { color: var(--red); }
.build-anim.queued { color: var(--muted); font-weight: 500; }
.build-anim.queued .phrase { animation: ba-pulse 2.4s ease-in-out infinite; }
.build-anim.queued .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 8px rgba(198,245,49,.5);
  animation: ba-blink 1.1s ease-in-out infinite;
}
/* Pin the status and actions columns so the table geometry never shifts
   between rows / statuses / polls (otherwise the "building"→"готов"
   transition shrinks the column and the whole row slides). */
th.col-status, .status-cell { width: 280px; min-width: 280px; }
th.col-actions, .action-cell { width: 190px; min-width: 190px; }
@keyframes ba-spin  { to { transform: rotate(360deg); } }
@keyframes ba-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@keyframes ba-blink { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.6); opacity: .35; } }

/* ---- Forms ----------------------------------------------------------- */
label { display: block; margin-bottom: 12px; font-size: 12.5px; color: var(--muted); }
input, select {
  display: block; width: 100%; margin-top: 5px; padding: 9px 11px; background: var(--field);
  color: var(--text); border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
form.row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; }
form.row label { margin-bottom: 0; }
form.row input, form.row select { width: auto; min-width: 180px; }
form.inline { display: inline; }

/* ---- Buttons --------------------------------------------------------- */
button, .btn {
  display: inline-block; padding: 8px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--raised); color: var(--text); cursor: pointer; font-size: 13.5px; font-weight: 500;
  text-decoration: none; transition: background .15s, border-color .15s, color .15s, transform .08s ease-in;
  white-space: nowrap; line-height: 1.3;
}
button:hover, .btn:hover { border-color: var(--line); background: #232328; }
/* Tactile press — only when motion is allowed. */
@media (prefers-reduced-motion: no-preference) {
  button:active:not(.disabled), .btn:active:not(.disabled) { transform: scale(.97); }
}
/* Unified focus ring (keyboard only). Inputs keep their own look above. */
button:focus-visible, .btn:focus-visible, .lang-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--accent-weak);
}
button.primary, .btn.primary {
  background: var(--primary); color: var(--text);
  border-color: var(--primary-border); font-weight: 600;
}
button.primary:hover, .btn.primary:hover { background: #2f2f36; border-color: #4a4a52; }
button.danger, .btn.danger { color: var(--red); border-color: transparent; background: var(--red-bg); }
button.danger:hover, .btn.danger:hover { background: rgba(245, 50, 91, .26); border-color: transparent; }
.btn.ghost, button.ghost { background: transparent; }
.btn.ghost:hover { background: var(--line-soft); }
.btn.sm, button.sm { padding: 6px 11px; font-size: 12.5px; }
.btn.full { width: 100%; text-align: center; }
.btn.disabled { opacity: .4; pointer-events: none; }
button.link { background: none; border: none; color: var(--muted); padding: 0; font-weight: 500; text-transform: none; letter-spacing: 0; }

/* ---- Tables ---------------------------------------------------------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
thead th {
  color: var(--muted); font-weight: 500; font-size: 12px;
  border-bottom: 1px solid var(--line-soft); white-space: nowrap; position: sticky; top: 0; background: var(--card);
}
.num { font-variant-numeric: tabular-nums; }
th.num, td.num { text-align: right; }
th.col-center, td.col-center { text-align: center; font-variant-numeric: tabular-nums; }
thead th a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
thead th a:hover { color: var(--text); }
thead th.sorted a { color: var(--accent-2); }
.arrow { font-size: 11px; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(255, 255, 255, .025); }
tbody tr:last-child td { border-bottom: none; }
tr.inactive { opacity: .5; }
td.actions { white-space: nowrap; text-align: right; }
td.actions form { display: inline; margin-left: 6px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.sub-line { color: var(--faint); font-size: 12px; margin-top: 2px; }
.muted { color: var(--muted); }
.time-tag { font-size: 12px; margin-left: 6px; }
.cell-strong { font-weight: 600; }

/* ---- Badges / pills -------------------------------------------------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 5px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.green { color: var(--green); background: var(--green-bg); }
.badge.red { color: var(--red); background: var(--red-bg); }
.badge.grey { color: var(--grey); background: var(--grey-bg); }
.badge.amber { color: var(--amber); background: var(--amber-bg); }
.tag-pill { display: inline-block; padding: 3px 9px; border-radius: 5px; background: var(--accent-weak); color: var(--accent); font-size: 12px; font-weight: 600; white-space: nowrap; }
.msgr-list { display: inline-flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.tag-pill.ext { background: var(--raised); color: var(--muted); }
.wlogo { display: inline-flex; width: 26px; height: 26px; border-radius: 6px; align-items: center; justify-content: center; padding: 3px; box-sizing: border-box; background: #f4f4f6; border: 1px solid var(--line-soft); }
.wlogo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.wlogo.unknown { background: var(--raised); }
.mlogo { display: inline-flex; width: 24px; height: 24px; border-radius: 6px; align-items: center; justify-content: center; padding: 4px; box-sizing: border-box; }
.mlogo.unknown { background: var(--raised); border: 1px solid var(--line-soft); }
.mlogo img { width: 100%; height: 100%; object-fit: contain; display: block; }

/* ---- Source country (geo) -------------------------------------------- */
.src-line { margin-bottom: 2px; line-height: 1.5; }
.src-line .flag {
  display: inline-block; width: 18px; height: 13px; border-radius: 2px; object-fit: cover;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .12); vertical-align: middle; margin-right: 5px;
}
.src-line .cname { color: var(--text); font-size: 13px; }
.src-line .mono { font-size: 13px; }
.src-line .dot { color: var(--faint); margin: 0 4px; }
.geo-spin {
  width: 14px; height: 14px; border-radius: 50%; display: inline-block;
  vertical-align: middle; margin-right: 3px; position: relative;
  /* Conic progress ring: a 30% lime arc on a faint track. Rotated via transform
     so the "sweep" feels like real progress instead of a flat spinner. */
  background:
    conic-gradient(from 0deg, var(--accent) 0 30%, rgba(198,245,49,.14) 30% 100%);
  mask: radial-gradient(circle, transparent 42%, black 44%);
  -webkit-mask: radial-gradient(circle, transparent 42%, black 44%);
  animation: geospin .95s linear infinite;
  filter: drop-shadow(0 0 3px rgba(198,245,49,.35));
}
@keyframes geospin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .geo-spin { animation-duration: 2.8s; filter: none; }
}

/* ---- Icon buttons ---------------------------------------------------- */
.btn.icon { padding: 6px; display: inline-grid; place-items: center; line-height: 0; }
.btn.icon svg { display: block; }

/* ---- Pagination ------------------------------------------------------ */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; flex-wrap: wrap; }
.pagination .info { color: var(--muted); font-size: 13px; }

/* ---- Flash messages -------------------------------------------------- */
/* ---- Toast notifications (floating, auto-dismiss) -------------------- */
.toasts {
  position: fixed; top: 16px; right: 16px; z-index: 1000;
  display: flex; flex-direction: column; gap: 10px;
  max-width: 420px; width: calc(100vw - 32px); pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; padding-right: 10px;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45), 0 2px 8px rgba(0, 0, 0, .25);
  font-size: 13.5px; line-height: 1.4; color: var(--text);
  animation: toast-in .28s cubic-bezier(.22, .9, .3, 1.1) both;
}
.toast.out { animation: toast-out .22s ease-in forwards; }
.toast.success { border-left-color: var(--green); }
.toast.success .toast-icon { color: var(--green); }
.toast.error { border-left-color: var(--red); }
.toast.error .toast-icon { color: var(--red); }
.toast-icon { flex: none; display: inline-grid; place-items: center; padding-top: 1px; color: var(--accent); }
.toast-msg { flex: 1 1 auto; min-width: 0; word-break: break-word; }
.toast-x {
  flex: none; background: transparent; border: none; color: var(--faint);
  font-size: 20px; line-height: 1; padding: 0 4px; margin: -2px 0 0; cursor: pointer;
  transition: color .15s;
}
.toast-x:hover { color: var(--text); }
@keyframes toast-in  { from { transform: translateX(24px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toast-out { to { transform: translateX(24px); opacity: 0; } }

/* ---- Auth (login) screen --------------------------------------------- */
body.auth { display: grid; place-items: center; padding: 20px; background:
  radial-gradient(1200px 600px at 50% -10%, rgba(198,245,49,.10), transparent), var(--bg); }
.auth-wrap { width: 100%; max-width: 380px; }
.auth-brand { display: flex; align-items: center; gap: 11px; justify-content: center; margin-bottom: 20px;
  font-family: var(--display); font-weight: 700; font-size: 24px; text-transform: uppercase; letter-spacing: .5px; }
.auth-brand .logo { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 8px;
  background: var(--accent); color: var(--ink); font-weight: 700;
  font-size: 20px; line-height: 1; }
.auth-brand .logo svg { display: block; width: 22px; height: 22px; }
.card.narrow { max-width: 380px; margin: 0 auto; }

/* ---- 2FA code input (login_2fa.html) --------------------------------- */
.twofa-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 28px; letter-spacing: .5em;
  text-align: center; padding: 12px 10px; font-weight: 600;
}
/* Shift padding so the wide tracking doesn't clip the last glyph. */
.twofa-code { padding-right: calc(10px - .5em); }

/* Empty-state block with an inline illustration mark on top of the text. */
.empty {
  text-align: center; color: var(--muted); padding: 56px 16px 48px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.empty .empty-illus {
  width: 84px; height: 84px; display: grid; place-items: center;
  border-radius: 20px;
  background: linear-gradient(180deg, var(--raised), transparent 85%);
  border: 1px solid var(--line-soft);
  color: var(--accent);
  box-shadow: 0 10px 30px rgba(0,0,0,.35),
              inset 0 0 0 1px rgba(198,245,49,.08);
  animation: empty-float 4.5s ease-in-out infinite;
}
.empty .empty-illus svg { width: 42px; height: 42px; opacity: .92;
  filter: drop-shadow(0 0 10px rgba(198,245,49,.35)); }
.empty .empty-title { color: var(--text); font-size: 15px; font-weight: 500; margin-top: 4px; }
.empty .empty-hint  { font-size: 13px; max-width: 420px; line-height: 1.5; }
@keyframes empty-float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) { .empty .empty-illus { animation: none; } }

/* ---- View Transitions (cross-document page swaps) ------------------- */
/* Enables a crossfade when navigating between same-origin pages in Chromium
   111+, Safari 18, Firefox 129+. Older browsers simply ignore it. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-group(root) { animation-duration: 180ms; }
}

/* ---- Archives: «новых архивов» chip --------------------------------- */
/* Floating chip shown when the background poll finds fresh rows. Clicking
   reloads the current filtered view. Hidden by default. */
.newchip {
  position: fixed; right: 24px; bottom: 24px; z-index: 50;
  display: none; align-items: center; gap: 9px;
  padding: 10px 16px 10px 14px;
  background: var(--accent); color: var(--ink);
  border: none; border-radius: 999px;
  font: 600 13px/1 var(--display); letter-spacing: .4px; text-transform: uppercase;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  cursor: pointer;
}
.newchip.show { display: inline-flex; animation: newchip-in .22s ease-out; }
.newchip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink);
                animation: newchip-pulse 1.6s ease-in-out infinite; }
.newchip .num { font-variant-numeric: tabular-nums; display: inline-block; }
.newchip .num.bumped { animation: newchip-num 420ms ease-out; }
@keyframes newchip-num {
  0%   { transform: scale(1);    color: var(--ink); }
  40%  { transform: scale(1.35); color: #fff; text-shadow: 0 0 10px rgba(255,255,255,.7); }
  100% { transform: scale(1);    color: var(--ink); }
}
@keyframes newchip-in    { from { transform: translateY(14px); opacity: 0; }
                           to   { transform: translateY(0);     opacity: 1; } }
@keyframes newchip-pulse { 0%, 100% { transform: scale(1);   opacity: 1; }
                           50%      { transform: scale(.55); opacity: .4; } }
@media (prefers-reduced-motion: reduce) {
  .newchip.show { animation: none; }
  .newchip .dot { animation: none; }
}

/* ---- Inline confirm (replaces window.confirm on dangerous buttons) -- */
/* JS wraps a target button in an .inline-confirm span then flips `armed`.
   Two stacked mini-buttons appear in the same footprint; first click arms,
   second click submits the form. Auto-disarms after 4s. */
.inline-confirm { display: inline-flex; align-items: center; gap: 4px; }
.inline-confirm .confirm-body,
.inline-confirm .confirm-arm { transition: opacity .12s, transform .12s; }
.inline-confirm.armed .confirm-arm  { display: none; }
.inline-confirm:not(.armed) .confirm-body { display: none; }
.inline-confirm .confirm-body { display: inline-flex; gap: 4px; align-items: center;
  padding: 2px 4px; border-radius: 6px; background: var(--red-bg); }
.inline-confirm .confirm-yes { background: var(--red); color: #fff; border: none;
  padding: 4px 9px; border-radius: 5px; font: 600 11px/1 var(--display);
  letter-spacing: .4px; text-transform: uppercase; cursor: pointer; }
.inline-confirm .confirm-no  { background: transparent; color: var(--muted); border: none;
  padding: 4px 7px; font: 500 11px/1 var(--display); letter-spacing: .4px;
  text-transform: uppercase; cursor: pointer; }
.inline-confirm .confirm-no:hover { color: var(--text); }
@media (prefers-reduced-motion: reduce) {
  .inline-confirm .confirm-body,
  .inline-confirm .confirm-arm { transition: none; }
}

/* ---- Profile: active sessions ---------------------------------------- */
.sessions-table th, .sessions-table td { padding: 10px 12px; }
.sessions-table .row-current td:first-child { position: relative; padding-left: 16px; }
.sessions-table .row-current td:first-child::before {
  content: ""; position: absolute; left: 2px; top: 10px; bottom: 10px; width: 3px;
  background: var(--accent); border-radius: 2px;
}
.sessions-table { table-layout: auto; min-width: 0; }
.sessions-table .ua-cell { max-width: 520px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.sessions-card .table-wrap { margin-bottom: 14px; }

/* ---- Build agent heartbeat chip (on /builds) ------------------------- */
.agent-chip {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 7px 14px 7px 12px; margin-bottom: 14px;
  border: 1px solid var(--line-soft); border-radius: 999px;
  background: var(--card);
  font-size: 12.5px; color: var(--muted);
}
.agent-chip .pulse {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--grey); box-shadow: 0 0 0 0 transparent;
}
.agent-chip.online .agent-label { color: var(--green); font-weight: 600; }
.agent-chip.online .pulse {
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(53, 208, 127, .55);
  animation: agent-pulse 1.8s ease-out infinite;
}
.agent-chip.offline .agent-label { color: var(--faint); }
.agent-chip .small { font-size: 11.5px; }
@keyframes agent-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(53,208,127,.55); }
  70%  { box-shadow: 0 0 0 8px rgba(53,208,127,0);   }
  100% { box-shadow: 0 0 0 0   rgba(53,208,127,0);   }
}
@media (prefers-reduced-motion: reduce) {
  .agent-chip.online .pulse { animation: none; }
}

/* ---- Branded error screens (403 / 404 / 413 / 500) ------------------- */
.errscreen { min-height: 60vh; display: grid; place-items: center; }
.errscreen .errbox {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 36px 28px; max-width: 460px; text-align: center;
}
.errscreen .errmark {
  width: 76px; height: 76px; display: grid; place-items: center;
  background: var(--accent); color: var(--ink); border-radius: 16px;
  box-shadow: 0 24px 60px rgba(198,245,49,.18), 0 2px 8px rgba(0,0,0,.4);
}
.errscreen .errmark svg { width: 40px; height: 40px; display: block; }
.errscreen .errcode {
  font-family: var(--display); font-weight: 700; font-size: 72px; line-height: 1;
  letter-spacing: -2px; margin-top: 6px; font-variant-numeric: tabular-nums;
}
.errscreen .errmsg  { color: var(--muted); font-size: 14.5px; line-height: 1.55; }
.errscreen .errback { margin-top: 8px; }

/* ---- Responsive ------------------------------------------------------ */
@media (max-width: 860px) {
  body.app { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: static; flex-direction: row; align-items: center;
    flex-wrap: wrap; gap: 10px; border-right: none; border-bottom: 1px solid var(--line-soft); }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .side-foot { margin-top: 0; margin-left: auto; flex-direction: row; align-items: center; }
  .side-foot form { margin: 0; }
  .content { padding: 20px 16px 36px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) { .stat-grid { grid-template-columns: 1fr; } }

/* ---- Light theme via prefers-color-scheme ---------------------------- */
/* The panel is designed dark-first; this block opt-in-swaps surfaces when the
   OS reports a light preference. `--accent` becomes a darker green so lime-
   coloured text/borders stay legible on white; brand pills get the original
   bright lime restored for recognisability. Add `[data-theme="dark"]` on
   <html> to force dark even on a light OS. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f2f3f5;
    --sidebar: #ffffff;
    --card: #ffffff;
    --raised: #eef0f3;
    --field: #ffffff;
    --active: #edf4d4;
    --line: #b8bcc4;
    --line-soft: #e2e4e8;
    --text: #15171a;
    --muted: #4b5058;
    --faint: #6c7177;
    --accent: #5e9412;           /* dark lime — AA on white */
    --accent-2: #6ba616;
    --accent-weak: rgba(94, 148, 18, .14);
    --ink: #0a0a0b;
    --primary: #e9ecf0;
    --primary-border: #b8bcc3;
    --green: #16a34a; --green-bg: rgba(22,163,74,.14);
    --red:   #d02e4b; --red-bg:   rgba(208,46,75,.12);
    --grey:  #70747a; --grey-bg:  rgba(112,116,122,.12);
    --amber: #b8821f; --amber-bg: rgba(184,130,31,.14);
  }
  /* Keep the bright-lime brand mark + accent fills — "black text on lime"
     is the project's recognisable signature. */
  :root:not([data-theme="dark"]) .brand .logo,
  :root:not([data-theme="dark"]) .auth-brand .logo,
  :root:not([data-theme="dark"]) .errmark,
  :root:not([data-theme="dark"]) .newchip,
  :root:not([data-theme="dark"]) .copy-code.copied,
  :root:not([data-theme="dark"]) .lang-btn.active {
    background: #c6f531; color: #0a0a0b;
  }
  /* Cards on light bg need a subtle shadow instead of the dark hairline. */
  :root:not([data-theme="dark"]) .card,
  :root:not([data-theme="dark"]) .stat,
  :root:not([data-theme="dark"]) .filters,
  :root:not([data-theme="dark"]) .bulk-all,
  :root:not([data-theme="dark"]) .agent-chip {
    box-shadow: 0 1px 2px rgba(10,12,16,.04), 0 4px 10px rgba(10,12,16,.03);
  }
  /* Toasts: slightly stronger shadow on white. */
  :root:not([data-theme="dark"]) .toast {
    box-shadow: 0 8px 24px rgba(10,12,16,.08), 0 2px 6px rgba(10,12,16,.04);
  }
  /* Sidebar language switcher chrome reads too dark on a white sidebar. */
  :root:not([data-theme="dark"]) .lang-switch {
    background: #f6f7f9; border-color: #dcdfe4;
  }
  :root:not([data-theme="dark"]) .lang-btn:hover { background: #ebeef2; }
  /* Hover row: use near-black alpha instead of near-white. */
  :root:not([data-theme="dark"]) tbody tr:hover { background: rgba(10,12,16,.035); }
  /* Button body: raised bg sits on white, hover goes a hair darker. */
  :root:not([data-theme="dark"]) button:hover,
  :root:not([data-theme="dark"]) .btn:hover { background: #dde0e5; }
  /* Auth screen radial glow */
  :root:not([data-theme="dark"]) body.auth {
    background:
      radial-gradient(1200px 600px at 50% -10%, rgba(94,148,18,.12), transparent),
      var(--bg);
  }
}

/* ---- Reduced motion: honor the OS preference universally ------------ */
/* Blanket safety net for any animation we forgot to gate individually
   (bulk-in, toast-in, build-anim's gear spin and phrase pulse, etc.).
   Transitions are kept functional but near-instant so hover states still work.
   Individual guards above may still override this where a non-zero duration
   is needed (e.g. the geo-spin falls back to a slower spin so the user still
   gets a progress signal). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
