/* Admin layout on top of Basecoat (shadcn/ui for plain HTML). */

@font-face { font-family: "Inter"; font-style: normal; font-display: swap; font-weight: 100 900; src: url("/static/vendor/inter/inter-latin-wght-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; font-style: normal; font-display: swap; font-weight: 100 900; src: url("/static/vendor/inter/inter-latin-ext-wght-normal.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Inter"; font-style: normal; font-display: swap; font-weight: 100 900; src: url("/static/vendor/inter/inter-cyrillic-wght-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Inter"; font-style: normal; font-display: swap; font-weight: 100 900; src: url("/static/vendor/inter/inter-cyrillic-ext-wght-normal.woff2") format("woff2"); unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }

:root {
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --primary: oklch(0.55 0.19 256);
  --primary-foreground: oklch(0.985 0 0);
  --ring: oklch(0.55 0.19 256 / 0.55);
  --sidebar-primary: oklch(0.55 0.19 256);
  --sidebar-width: 15.5rem;
  --success: oklch(0.62 0.16 150);
  --warning: oklch(0.75 0.15 70);
  --tg-bg: #cfdcb8;
  --tg-in: #ffffff;
  --tg-out: #e2f7cb;
  --tg-meta: #8aa47f;
  --tg-link: #2f7ec2;
  --header-height: 3.5rem;
  /* CSP blocks data: URIs, so Basecoat icons point to local files. */
  --chevron-down-icon: url("/static/img/chevron-down.svg");
  --chevron-down-icon-50: url("/static/img/chevron-down-50.svg");
  --check-icon: url("/static/img/check-muted.svg");
}

html, body { font-family: var(--font-sans); }
body { background: var(--background); color: var(--foreground); font-feature-settings: "cv11", "ss01"; }
.num, td.num, .tabular { font-variant-numeric: tabular-nums; }

/* Sidebar */
.sidebar .brand { display: flex; align-items: center; gap: .6rem; padding: .25rem .25rem; font-weight: 600; font-size: .9rem; color: var(--foreground); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: .55rem; background: var(--primary); color: var(--primary-foreground); flex: none; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dev-badge { margin-left: auto; background: oklch(0.86 0.17 90); color: oklch(0.3 0.06 80); border-color: transparent; font-weight: 700; letter-spacing: .04em; }
.sidebar nav > section ul li > a { position: relative; }
.nav-count { margin-left: auto; min-width: 1.25rem; padding: 0 .4rem; border-radius: 999px; font-size: .7rem; font-weight: 600; line-height: 1.25rem; text-align: center; background: oklch(0.94 0.06 60); color: oklch(0.45 0.13 50); }
.sidebar footer .logout { display: flex; align-items: center; gap: .6rem; padding: .25rem; }
.operator-avatar { display: grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 999px; background: var(--muted); font-size: .75rem; font-weight: 600; }
.operator-name { font-size: .85rem; font-weight: 500; flex: 1; }

/* Shell */
.app-main { min-height: 100vh; display: flex; flex-direction: column; }
.app-header { position: sticky; top: 0; z-index: 10; height: var(--header-height); display: flex; align-items: center; gap: .75rem; padding: 0 1.5rem 0 1rem; border-bottom: 1px solid var(--border); background: color-mix(in oklab, var(--background) 92%, transparent); backdrop-filter: blur(8px); }
.app-title { display: flex; align-items: center; gap: .5rem; min-width: 0; font-size: .95rem; font-weight: 600; }
.app-title .crumb { color: var(--muted-foreground); font-weight: 500; text-decoration: none; }
.app-title .crumb:hover { color: var(--foreground); }
.app-title .sep { color: var(--muted-foreground); }
.app-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.app-content { flex: 1; padding: 1.5rem; min-width: 0; }
.app-content.wide { max-width: none; }
.app-content.narrow > * { max-width: 72rem; }
body.fill .app-main { height: 100vh; min-height: 0; }
body.fill .app-content { padding: 0; min-height: 0; display: flex; }

.page-stack { display: flex; flex-direction: column; gap: 1.25rem; }
.muted { color: var(--muted-foreground); }
.small { font-size: .8rem; }
.row { display: flex; align-items: center; gap: .5rem; }
.spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; }
.card > header h2 { font-size: .95rem; font-weight: 600; }
.card > header p { color: var(--muted-foreground); font-size: .85rem; }
.badge .dot, .dot { display: inline-block; width: .45rem; height: .45rem; border-radius: 999px; background: currentColor; }
.badge[data-variant="success"] { background: oklch(0.95 0.05 150); color: oklch(0.42 0.12 150); border-color: transparent; }
.badge[data-variant="warning"] { background: oklch(0.96 0.06 80); color: oklch(0.48 0.12 60); border-color: transparent; }
.link { color: var(--primary); text-decoration: none; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.kbd-hint { font-size: .75rem; color: var(--muted-foreground); }

/* Avatars */
.uavatar { display: grid; place-items: center; flex: none; width: 2rem; height: 2rem; border-radius: 999px; font-size: .75rem; font-weight: 600; color: oklch(0.32 0.08 var(--h)); background: oklch(0.92 0.06 var(--h)); }
.uavatar.lg { width: 3.5rem; height: 3.5rem; font-size: 1.15rem; }
.uname { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.uname b { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.uname span { color: var(--muted-foreground); font-size: .78rem; }
.ucell { display: flex; align-items: center; gap: .65rem; color: inherit; text-decoration: none; min-width: 0; }

/* Telegram preview */
.tg { position: relative; display: flex; flex-direction: column; justify-content: flex-end; gap: .35rem; padding: 1rem; border-radius: var(--radius); background-color: var(--tg-bg); background-image: radial-gradient(circle at 20% 15%, rgba(255,255,255,.35) 0 2px, transparent 3px), radial-gradient(circle at 70% 60%, rgba(255,255,255,.28) 0 2px, transparent 3px), linear-gradient(160deg, #d8e5bf, #bfd3a6); background-size: 46px 46px, 62px 62px, 100% 100%; font-family: -apple-system, "SF Pro Text", "Segoe UI", Roboto, var(--font-sans); font-size: .9rem; line-height: 1.38; color: #111; overflow: hidden; }
.tg-day { align-self: center; margin: .5rem 0; padding: .15rem .6rem; border-radius: 999px; background: rgba(60, 85, 50, .32); color: #fff; font-size: .75rem; font-weight: 500; }
.tg-msg { position: relative; max-width: min(24rem, 88%); align-self: flex-start; background: var(--tg-in); border-radius: 1rem 1rem 1rem .3rem; box-shadow: 0 1px 1px rgba(0,0,0,.13); overflow: hidden; }
.tg-msg.out { align-self: flex-end; background: var(--tg-out); border-radius: 1rem 1rem .3rem 1rem; }
.tg-msg .tg-photo { display: block; width: 100%; aspect-ratio: 16/10; object-fit: cover; background: #9fb894; }
.tg-msg .tg-text { padding: .45rem .7rem .2rem; white-space: normal; overflow-wrap: anywhere; }
.tg-msg .tg-text:empty { display: none; }
.tg-msg .tg-meta { float: right; margin: .35rem 0 0 .6rem; font-size: .7rem; color: var(--tg-meta); }
.tg-msg.out .tg-meta { color: #62a85a; }
.tg-msg .tg-foot { padding: 0 .7rem .35rem; text-align: right; font-size: .7rem; color: var(--tg-meta); }
.tg-reply { margin: .45rem .7rem 0; padding: .1rem .5rem; border-left: 2px solid var(--tg-link); border-radius: .25rem; background: rgba(47,126,194,.08); font-size: .78rem; color: var(--tg-link); }
.tg-kb { align-self: flex-start; display: grid; gap: .25rem; width: min(24rem, 88%); }
.tg-kb.cols-2 { grid-template-columns: 1fr 1fr; }
.tg-kb span { padding: .5rem .5rem; border-radius: .6rem; background: rgba(66, 94, 54, .38); color: #fff; font-size: .82rem; font-weight: 500; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-voice { display: flex; align-items: center; gap: .55rem; padding: .5rem .7rem .2rem; }
.tg-voice .play { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: 999px; background: #5dad55; color: #fff; flex: none; }
.tg-voice .play svg { width: .9rem; height: .9rem; fill: currentColor; }
.tg-voice .wave { display: flex; align-items: center; gap: 2px; height: 1.4rem; }
.tg-voice .wave i { width: 3px; border-radius: 2px; background: #79b86f; }
.tg-voice .dur { font-size: .72rem; color: #62a85a; }
.tg-file { display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem .2rem; }
.tg-file .fi { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: 999px; background: #3c9ae0; color: #fff; flex: none; }
.tg-file b { display: block; font-weight: 500; font-size: .85rem; }
.tg-file small { color: var(--tg-meta); font-size: .72rem; }
.tg-service { align-self: center; padding: .2rem .7rem; border-radius: 999px; background: rgba(60,85,50,.32); color: #fff; font-size: .75rem; }
.tg-operator { align-self: center; max-width: 88%; padding: .5rem .75rem; border-radius: .75rem; background: oklch(0.97 0.03 256 / .95); border: 1px dashed oklch(0.7 0.1 256); font-size: .82rem; }
.tg-operator .who { display: block; font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: oklch(0.5 0.15 256); margin-bottom: .15rem; }
.tg-cmdline { align-self: flex-end; }
.tg-header { display: flex; align-items: center; gap: .6rem; padding: .55rem .9rem; background: #fff; border-bottom: 1px solid rgba(0,0,0,.06); font-family: -apple-system, "Segoe UI", Roboto, var(--font-sans); }
.tg-header .bot-ava { display: grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: 999px; background: var(--primary); color: #fff; }
.tg-header b { display: block; font-size: .85rem; font-weight: 600; }
.tg-header small { font-size: .72rem; color: #7d8b99; }
.phone { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: calc(var(--radius) + .25rem); overflow: hidden; background: #fff; }
.phone .tg { border-radius: 0; flex: 1; }

/* Overview */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1rem; }
.kpi { padding: 1rem 1.1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.kpi span { display: block; font-size: .8rem; color: var(--muted-foreground); }
.kpi b { display: block; margin-top: .3rem; font-size: 1.6rem; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi small { display: block; margin-top: .15rem; font-size: .75rem; color: var(--success); }
.kpi small.neutral { color: var(--muted-foreground); }
.chart { display: flex; align-items: flex-end; gap: 3px; height: 9rem; padding-top: .5rem; }
.chart .col { position: relative; flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.chart .bar { border-radius: 3px 3px 0 0; background: oklch(0.55 0.19 256 / .22); }
.chart .bar.new { position: absolute; left: 0; right: 0; bottom: 0; background: var(--primary); }
.chart .col:hover .bar { filter: brightness(.92); }
.chart .col .tip { display: none; position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); padding: .3rem .5rem; border-radius: .4rem; background: var(--foreground); color: var(--background); font-size: .72rem; white-space: nowrap; z-index: 2; }
.chart .col:hover .tip { display: block; }
.chart-axis { display: flex; justify-content: space-between; margin-top: .4rem; font-size: .72rem; color: var(--muted-foreground); }
.legend { display: flex; gap: 1rem; font-size: .78rem; color: var(--muted-foreground); }
.legend i { display: inline-block; width: .6rem; height: .6rem; border-radius: 2px; margin-right: .35rem; vertical-align: -1px; }
.stars-bars { display: flex; align-items: flex-end; gap: 3px; height: 4.5rem; }
.stars-bars i { flex: 1; border-radius: 2px 2px 0 0; background: oklch(0.8 0.15 85); min-height: 2px; }
.lang-share { display: flex; height: .6rem; border-radius: 999px; overflow: hidden; gap: 2px; }
.lang-share i { display: block; }
.lang-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: .35rem .75rem; margin-top: .75rem; font-size: .8rem; }
.lang-list span { display: flex; align-items: center; gap: .4rem; }
.lang-list b { margin-left: auto; font-weight: 500; font-variant-numeric: tabular-nums; }
.feed { display: flex; flex-direction: column; }
.feed .feed-row { display: grid; grid-template-columns: 2rem 1fr auto; align-items: center; gap: .65rem; padding: .55rem 0; border-top: 1px solid var(--border); }
.feed .feed-row:first-child { border-top: 0; }
.feed .what { font-size: .85rem; min-width: 0; }
.feed .what b { font-weight: 500; }
.feed .what span { display: block; color: var(--muted-foreground); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed .val { font-size: .82rem; font-variant-numeric: tabular-nums; text-align: right; }
.plus { color: var(--success); }
.minus { color: var(--muted-foreground); }
.err { color: var(--destructive); }

/* Tables */
.table-card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--card); }
.table-card .table { width: 100%; }
.table th a { display: inline-flex; align-items: center; gap: .3rem; color: inherit; text-decoration: none; }
.table th a[aria-sort] { color: var(--foreground); }
.table th a svg { width: .8rem; height: .8rem; opacity: .5; }
.table td.num, .table th.num { text-align: right; }
.table tr.clickable { cursor: pointer; }
.toolbar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.search-input { position: relative; }
.search-input svg { position: absolute; left: .65rem; top: 50%; transform: translateY(-50%); color: var(--muted-foreground); pointer-events: none; }
.search-input .input { padding-left: 2rem; width: 20rem; }
.seg { display: inline-flex; padding: .2rem; border-radius: calc(var(--radius) - 2px); background: var(--muted); gap: .15rem; }
.seg a, .seg button { padding: .3rem .7rem; border-radius: calc(var(--radius) - 4px); font-size: .82rem; font-weight: 500; color: var(--muted-foreground); text-decoration: none; border: 0; background: transparent; cursor: pointer; white-space: nowrap; }
.seg a[aria-current], .seg button[aria-pressed="true"] { background: var(--background); color: var(--foreground); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg .c { margin-left: .3rem; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: .65rem 1rem; border-top: 1px solid var(--border); font-size: .82rem; color: var(--muted-foreground); }

/* Forms */
.form-grid { display: grid; gap: 1.1rem; }
.field .hint { color: var(--muted-foreground); font-size: .8rem; }
.input-suffix { position: relative; }
.input-suffix .input { padding-right: 4.5rem; }
.input-suffix span { position: absolute; right: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted-foreground); font-size: .82rem; pointer-events: none; }
.savebar { position: sticky; bottom: 0; display: flex; align-items: center; gap: .75rem; padding: .75rem 1.5rem; margin: 1.5rem -1.5rem -1.5rem; border-top: 1px solid var(--border); background: color-mix(in oklab, var(--background) 94%, transparent); backdrop-filter: blur(8px); }
.savebar .state { font-size: .85rem; color: var(--muted-foreground); }
.savebar .state.dirty { color: oklch(0.55 0.15 55); font-weight: 500; }

@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .grid-2, .grid-3, .kpis { grid-template-columns: 1fr 1fr; }
  .search-input .input { width: 100%; }
}

/* Login */
.login-page { min-height: 100vh; display: grid; place-items: center; background: var(--muted); }
.login-wrap { width: min(24rem, calc(100% - 2rem)); display: flex; flex-direction: column; gap: 1.25rem; }
.login-brand { display: flex; align-items: center; justify-content: center; gap: .6rem; font-weight: 600; }
.login-card > header h2 { font-size: 1.15rem; }
.login-submit { width: 100%; }

/* Overview grid */
.overview-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1.25rem; }
.stars-block { margin-top: 1.25rem; display: flex; flex-direction: column; gap: .5rem; }
@media (max-width: 1100px) { .overview-grid { grid-template-columns: 1fr; } }

