/* Студия — как «Гибрид» в CRM: белые страницы, графитовое меню, синий акцент. */
:root {
  --bg: #f4f5f7; --surface: #fff; --surface-2: #fafbfc; --border: #e5e7eb; --border-strong: #d1d5db;
  --text: #111827; --muted: #6b7280; --accent: #2563eb; --accent-hover: #1d4ed8; --accent-soft: #eaf1ff;
  --ok: #16a34a; --ok-soft: #e7f6ec; --warn: #d97706; --warn-soft: #fdf2e3; --err: #dc2626; --err-soft: #fdecec;
  --side: #111214; --side-text: #c9ccd1; --side-active: #2563eb; --row-hover: #f7f9fc; --th: #f9fafb;
  --ig: #d62976; --tt: #111827; --th-c: #4b5563;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 4px 12px rgba(16,24,40,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141518; --surface: #1c1d21; --surface-2: #202126; --border: #2c2e34; --border-strong: #3a3d44;
    --text: #e8e9ec; --muted: #9298a2; --accent: #3b82f6; --accent-hover: #2563eb; --accent-soft: #1d2a44;
    --ok: #22c55e; --ok-soft: #13291b; --warn: #f59e0b; --warn-soft: #2e2412; --err: #f87171; --err-soft: #331b1b;
    --side: #0e0f11; --row-hover: #23252b; --th: #202126; --tt: #e8e9ec; --th-c: #c0c4cc;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.up { color: var(--ok); font-weight: 600; }
.down { color: var(--err); font-weight: 600; }
.sub { color: var(--muted); margin: 0 0 20px; }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; flex: none; background: var(--side); color: var(--side-text); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.logo { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 16px; padding: 4px 8px 16px; }
.logo:hover { text-decoration: none; }
.logo-sq { width: 30px; height: 30px; border-radius: 8px; background: var(--side-active); display: grid; place-items: center; font-size: 15px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--side-text); }
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav a.active { background: var(--side-active); color: #fff; }
.nav .grp { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #8a8f98; padding: 14px 10px 4px; font-weight: 600; }
.side-foot { margin-top: auto; font-size: 13px; padding: 8px 10px; }
.side-foot button { background: none; border: 0; color: var(--side-text); cursor: pointer; padding: 0; font: inherit; }
.side-foot button:hover { color: #fff; }
.main { flex: 1; padding: 28px 32px 60px; min-width: 0; max-width: 1280px; }
.nav-toggle { display: none; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; background: var(--ok-soft); color: var(--ok); font-weight: 500; }
.flash.err { background: var(--err-soft); color: var(--err); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); border-top: 3px solid var(--accent); }
.stat .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.stat .v { font-size: 26px; font-weight: 700; margin: 2px 0; }
.stat .h { font-size: 13px; color: var(--muted); }
.stat.ok { border-top-color: var(--ok); } .stat.warn { border-top-color: var(--warn); }
.stat.low, .stat.empty { border-top-color: var(--err); }
.stat.empty .v, .stat.low .v { color: var(--err); }
.bar { height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

.acc-card { border-top: 3px solid var(--th-c); }
.acc-card.instagram { border-top-color: var(--ig); } .acc-card.tiktok { border-top-color: var(--tt); }
.acc-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.acc-head img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: var(--border); }
.acc-head b { display: block; }
.acc-num { font-size: 28px; font-weight: 700; }
.deltas { display: flex; gap: 14px; font-size: 13px; margin: 2px 0 8px; }
.spark { width: 100%; height: 44px; color: var(--accent); display: block; margin: 6px 0 10px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 13px; }
.kv span:nth-child(odd) { color: var(--muted); }

.pf { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; }
.pf::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--th-c); }
.pf.instagram::before { background: var(--ig); } .pf.tiktok::before { background: var(--tt); }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; background: var(--th); padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:hover td { background: var(--row-hover); }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cap { min-width: 220px; max-width: 420px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.thumb { width: 42px; height: 56px; object-fit: cover; border-radius: 6px; background: var(--border); display: block; }
.tbl-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; }
.btn:hover { background: var(--row-hover); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--err); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.inline { display: inline; }

input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { width: 100%; min-height: 70px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 14px; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days label { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--border-strong); border-radius: 8px; padding: 6px 10px; color: var(--text); margin: 0; cursor: pointer; }
.days input { margin: 0; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--border); color: var(--text); white-space: nowrap; }
.pill.ok { background: var(--ok); color: #fff; } .pill.warn { background: var(--warn); color: #fff; } .pill.err { background: var(--err); color: #fff; }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.tabs a.on { background: var(--accent-soft); color: var(--accent); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.empty-box { text-align: center; padding: 36px 20px; color: var(--muted); }
.callout { background: var(--accent-soft); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 18px; }
.code { font-family: ui-monospace, Menlo, monospace; background: var(--surface-2); border: 1px solid var(--border); padding: 2px 6px; border-radius: 6px; font-size: 13px; word-break: break-all; }
.log { font-size: 13px; }
.log td { padding: 6px 10px; }
.log .error td { color: var(--err); }
.pager { display: flex; gap: 6px; margin-top: 14px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); padding: 2px 8px; border-radius: 6px; }
details.more summary { cursor: pointer; color: var(--accent); font-weight: 500; }

/* вход и публичные страницы */
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 360px; }
.login .head { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; font-size: 18px; font-weight: 700; }
.login .logo-sq { color: #fff; }
.login form > div { margin-bottom: 12px; }
.login input { width: 100%; }
.login .btn { width: 100%; justify-content: center; }
.error { background: var(--err-soft); color: var(--err); padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; }
.doc { max-width: 760px; margin: 0 auto; padding: 40px 16px 80px; }
.doc h1 { font-size: 26px; margin-bottom: 6px; }
.doc h2 { margin-top: 28px; }
.doc p, .doc li { line-height: 1.65; }

@media (max-width: 1000px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .layout { display: block; }
  .sidebar { width: auto; height: auto; position: static; padding: 10px 16px; }
  .sidebar .nav, .sidebar .side-foot { display: none; }
  body.nav-open .sidebar .nav, body.nav-open .sidebar .side-foot { display: block; }
  .logo { padding-bottom: 4px; }
  .brand-row { display: flex; justify-content: space-between; align-items: center; }
  .nav-toggle { display: block; background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer; }
  .main { padding: 18px 16px 50px; }
  .g4, .g2 { grid-template-columns: 1fr; }
  .card { padding: 14px 16px; }
  .tbl-wrap { margin: 0 -16px; padding: 0 16px; }
}
