/* Админка: тёмная тема, боковое меню, стеклянные карточки.
   Цвет акцента — одна переменная (--accent): у другого клиента — свой. */
:root {
  color-scheme: dark;
  --bg:          #0b0c0f;
  --sidebar:     rgba(16, 17, 21, .72);
  --glass:       linear-gradient(180deg, rgba(255,255,255,.055), rgba(255,255,255,.025));
  --glass-solid: #15161b;
  --row:         rgba(255,255,255,.035);
  --row-hover:   rgba(255,255,255,.06);
  --line:        rgba(255,255,255,.07);
  --line-2:      rgba(255,255,255,.12);
  --text:        #eceef2;
  --text-2:      #b7bac3;
  --muted:       #7f838e;
  /* Акцент — из бренда (brand.palette); здесь — нейтральный */
  --accent:      #e6e8ee;
  --accent-2:    #ffffff;
  --accent-rgb:  230, 232, 238;
  --accent-soft: rgba(var(--accent-rgb), .14);
  --on-accent:   #121318;
  --ok:          #3ddc97;  --ok-soft:     rgba(61,220,151,.12);
  --danger:      #ff7b7b;  --danger-soft: rgba(255,123,123,.12);
  --info:        #74a7ff;  --info-soft:   rgba(116,167,255,.12);
  --violet:      #a78bfa;  --violet-soft: rgba(167,139,250,.13);
  --radius:      18px;
  --radius-sm:   12px;
  --blur:        blur(20px) saturate(150%);
  --highlight:   inset 0 1px 0 rgba(255,255,255,.07);
  --shadow:      0 12px 40px rgba(0,0,0,.35);
  --sidebar-w:   264px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  font: 14.5px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 520px at 12% -8%, rgba(var(--accent-rgb),.10), transparent 60%),
    radial-gradient(800px 560px at 108% 4%, rgba(116,120,255,.10), transparent 62%),
    radial-gradient(700px 500px at 50% 120%, rgba(61,220,151,.05), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--text); text-decoration: none; }
a:hover { color: var(--accent-2); }
h1, h2, h3 { margin: 0; letter-spacing: -.015em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 650; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .92em; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.wrap { overflow-wrap: anywhere; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8;
        stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Каркас: меню сбоку + содержимое ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; z-index: 50;
  display: flex; flex-direction: column; gap: 6px;
  padding: 18px 14px 14px;
  background: var(--sidebar); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border-right: 1px solid var(--line);
}
.brand-row { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  display: grid; place-items: center; font-weight: 800; font-size: 15px; color: var(--on-accent);
  background: linear-gradient(145deg, var(--accent-2), var(--accent));
  box-shadow: 0 6px 18px rgba(var(--accent-rgb),.25), inset 0 1px 0 rgba(255,255,255,.35);
}
.brand-logo { height: 30px; width: auto; max-width: 64px; flex: none; object-fit: contain; }
.brand { font-size: 16px; font-weight: 700; color: var(--text); white-space: nowrap; }
.brand:hover { color: var(--text); }
.brand-sub { color: var(--muted); font-weight: 500; }

.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-label { color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: 11px; color: var(--text-2); font-weight: 500;
  border: 1px solid transparent; transition: background .15s, color .15s, border-color .15s;
}
.nav a:hover { background: var(--row-hover); color: var(--text); }
.nav a.active {
  color: var(--text); background: var(--glass); border-color: var(--line-2);
  box-shadow: var(--highlight), 0 6px 18px rgba(0,0,0,.25);
}
.nav a.active svg.i { color: var(--accent-2); }

.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.sidebar-foot .who { flex: 1; min-width: 0; }
.sidebar-foot .who b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .who span { color: var(--muted); font-size: 12.5px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  height: 66px; padding: 0 30px;
  background: rgba(11,12,15,.55); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--line);
}
.topbar .crumb { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-weight: 550; min-width: 0; }
.topbar .crumb span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .spacer { flex: 1; }
.topbar .menu-button { display: none; }
.page { width: 100%; padding: 26px 32px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 6px 0 0; color: var(--text-2); }
.page-head p b { color: var(--text); font-weight: 650; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); margin-bottom: 14px; }
.overlay { display: none; }

/* ---------- Карточки ---------- */
.card {
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--highlight), var(--shadow);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  padding: 20px 22px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head .hint { color: var(--muted); font-size: 13px; }
.stack { display: grid; gap: 18px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 18px; }

/* Метрики */
.metrics { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.linkish { display: inline-flex; align-items: center; gap: 8px; }
.linkish svg.i { width: 16px; height: 16px; color: var(--muted); }
.metric { position: relative; overflow: hidden; padding: 18px 20px 16px; }
.metric .label { color: var(--text-2); font-size: 13.5px; font-weight: 500; padding-right: 50px; min-height: 40px; }
.metric .value { font-size: 36px; font-weight: 700; letter-spacing: -.03em; line-height: 1.05; margin-top: 12px; }
.metric .value small { font-size: 18px; color: var(--muted); font-weight: 600; }
.metric .sub { margin-top: 8px; color: var(--muted); font-size: 12.5px; }
.metric .sub b { color: var(--text); font-weight: 650; }
.metric .sub b.up { color: var(--ok); }
.metric .tile {
  position: absolute; top: 16px; right: 16px; width: 44px; height: 44px; border-radius: 13px;
  display: grid; place-items: center; color: var(--accent);
  background: linear-gradient(160deg, rgba(255,255,255,.09), rgba(255,255,255,.02));
  border: 1px solid var(--line-2); box-shadow: var(--highlight), 0 8px 20px rgba(0,0,0,.35);
}
.metric .tile.ok { color: var(--ok); } .metric .tile.info { color: var(--info); } .metric .tile.violet { color: var(--violet); }

/* График столбиками */
.chart { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 8px; align-items: end; height: 190px; }
.chart .bar { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; gap: 6px; }
.chart .col {
  position: relative; border-radius: 9px; min-height: 6px;
  background: repeating-linear-gradient(135deg, rgba(255,255,255,.035) 0 6px, rgba(255,255,255,.015) 6px 12px);
  height: 100%; display: flex; align-items: flex-end;
}
.chart .fill {
  width: 100%; border-radius: 9px; min-height: 4px;
  background: linear-gradient(180deg, rgba(255,255,255,.28), rgba(255,255,255,.10));
  border: 1px solid rgba(255,255,255,.12);
}
.chart .bar.today .fill { background: linear-gradient(180deg, var(--accent-2), var(--accent)); border-color: transparent; }
.chart .n { font-size: 11px; color: var(--text-2); text-align: center; height: 14px; }
.chart .d { font-size: 11px; color: var(--muted); text-align: center; }
.chart-empty { height: 190px; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 0 20px;
               border: 1px dashed var(--line-2); border-radius: var(--radius-sm); }
.big { font-size: 30px; font-weight: 700; letter-spacing: -.02em; }
.big small { font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 6px; }

/* ---------- Таблицы: строки-полоски ---------- */
.table-wrap { overflow-x: auto; margin: 0 -6px; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0 6px; }
.tbl th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted);
  padding: 4px 14px 6px; white-space: nowrap;
}
.tbl td { padding: 11px 14px; background: var(--row); vertical-align: middle; border-top: 1px solid transparent; border-bottom: 1px solid transparent; }
.tbl td:first-child { border-radius: 12px 0 0 12px; }
.tbl td:last-child { border-radius: 0 12px 12px 0; }
.tbl tbody tr { transition: transform .12s; }
.tbl tbody tr:hover td { background: var(--row-hover); }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl td.actions { white-space: nowrap; text-align: right; }
.tbl td.actions form { display: inline; }
.tbl td.empty { text-align: center; color: var(--muted); padding: 26px; border-radius: 12px; }

/* Пользователь в строке: аватар + имя */
.person { display: flex; align-items: center; gap: 11px; min-width: 0; }
.person .who { min-width: 0; }
.person b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person span { color: var(--muted); font-size: 12.5px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; color: var(--text);
  background: linear-gradient(145deg, rgba(255,255,255,.16), rgba(255,255,255,.04));
  border: 1px solid var(--line-2);
}
.avatar.lg { width: 56px; height: 56px; font-size: 20px; border-radius: 18px; }

/* Метки */
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: rgba(255,255,255,.07); color: var(--text-2); border: 1px solid var(--line);
}
.pill.ok     { background: var(--ok-soft);     color: var(--ok);     border-color: rgba(61,220,151,.25); }
.pill.off    { background: var(--danger-soft); color: var(--danger); border-color: rgba(255,123,123,.25); }
.pill.info   { background: var(--info-soft);   color: var(--info);   border-color: rgba(116,167,255,.25); }
.pill.accent { background: var(--accent-soft); color: var(--accent-2); border-color: rgba(var(--accent-rgb),.3); }
.pill.violet { background: var(--violet-soft); color: var(--violet); border-color: rgba(167,139,250,.25); }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill svg.i, .btn.small svg.i, button.small svg.i { width: 14px; height: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 5px 11px; border-radius: 10px; background: var(--row); border: 1px solid var(--line); font-size: 13px; }
a.chip:hover { border-color: var(--line-2); }

/* Доля: полоска прогресса */
.share { display: flex; align-items: center; gap: 10px; min-width: 140px; }
.share .track { flex: 1; height: 8px; border-radius: 99px; background: rgba(255,255,255,.07); overflow: hidden; }
.share .track i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.share span { color: var(--text-2); font-size: 12.5px; min-width: 38px; text-align: right; }

/* Список «название — значение» */
dl.facts { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 10px 16px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; min-width: 0; }
.section-title { display: flex; align-items: center; gap: 9px; margin: 22px 0 12px; }
.section-title:first-child { margin-top: 0; }
.section-title svg.i { color: var(--accent); }

/* ---------- Кнопки и поля ---------- */
.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 15px; border-radius: 11px; font: inherit; font-size: 14px; font-weight: 600; line-height: 1.2;
  cursor: pointer; color: var(--text); white-space: nowrap;
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.04));
  border: 1px solid var(--line-2); box-shadow: var(--highlight);
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover, button:hover { background: rgba(255,255,255,.1); color: var(--text); }
.btn:active, button:active { transform: translateY(1px); }
.btn.primary, button.primary {
  color: var(--on-accent); border-color: transparent;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow: 0 8px 22px rgba(var(--accent-rgb),.25), inset 0 1px 0 rgba(255,255,255,.35);
}
.btn.primary:hover, button.primary:hover { filter: brightness(1.06); color: var(--on-accent); }
.btn.danger, button.danger { color: var(--danger); border-color: rgba(255,123,123,.3); background: var(--danger-soft); }
.btn.danger:hover, button.danger:hover { background: rgba(255,123,123,.2); color: var(--danger); }
.btn.small, button.small { padding: 6px 11px; font-size: 13px; border-radius: 9px; }
.btn.icon { padding: 8px; }
button:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }

input[type=text], input[type=search], input[type=number], input[type=password], textarea, select {
  width: 100%; padding: 10px 13px; border-radius: 11px; font: inherit; color: var(--text);
  background: rgba(0,0,0,.25); border: 1px solid var(--line-2); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus { border-color: rgba(var(--accent-rgb),.6); box-shadow: 0 0 0 3px rgba(var(--accent-rgb),.15); }
input::placeholder, textarea::placeholder { color: var(--muted); }
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent); }
label { display: grid; gap: 6px; color: var(--text-2); font-size: 13px; font-weight: 500; }
label.chk { display: flex; align-items: center; gap: 8px; }
textarea { min-height: 140px; resize: vertical; }

.search { position: relative; display: flex; align-items: center; }
.search svg.i { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 38px; }
.topbar .search { width: min(340px, 40vw); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar .search { flex: 1; min-width: 220px; max-width: 460px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; align-items: end; }
details.create > summary { list-style: none; cursor: pointer; display: inline-flex; }
details.create > summary::-webkit-details-marker { display: none; }
details.create[open] > summary { margin-bottom: 16px; }

.flashes { display: grid; gap: 8px; margin-bottom: 18px; }
.flash { padding: 11px 15px; border-radius: 12px; font-size: 14px; border: 1px solid var(--line-2); background: var(--row); }
.flash.success, .flash.ok { background: var(--ok-soft); color: var(--ok); border-color: rgba(61,220,151,.25); }
.flash.error { background: var(--danger-soft); color: var(--danger); border-color: rgba(255,123,123,.25); }
.flash.warning { background: var(--accent-soft); color: var(--accent-2); border-color: rgba(var(--accent-rgb),.3); }
.note { color: var(--muted); font-size: 13px; margin-top: 18px; }

.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 18px; }
.progress { height: 10px; border-radius: 99px; background: rgba(255,255,255,.07); overflow: hidden; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 99px; }
.progress.off i { background: linear-gradient(90deg, #ff6b6b, var(--danger)); }

/* ---------- Вход ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(380px, 100%); padding: 32px 30px; display: grid; gap: 16px; }
.login-card .brand-row { border: 0; padding: 0; margin: 0 0 4px; }
.login-card .lead { margin: 0; color: var(--text-2); }
.login-card button { width: 100%; padding: 12px; }

/* ---------- Планшет и телефон ---------- */
@media (max-width: 1380px) {
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1180px) {
  .grid-main { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(var(--sidebar-w), 86vw);
    transform: translateX(-102%); transition: transform .22s ease; background: rgba(16,17,21,.92);
  }
  body.nav-open .sidebar { transform: none; box-shadow: 20px 0 60px rgba(0,0,0,.5); }
  .overlay { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(0,0,0,.45);
             opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.nav-open .overlay { opacity: 1; pointer-events: auto; }
  .topbar .menu-button { display: inline-flex; }
  .topbar { padding: 0 16px; height: 60px; }
  .page { padding: 20px 16px 56px; }
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  h1 { font-size: 22px; }
  .topbar .search { display: none; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .metric { padding: 14px 14px 13px; }
  .metric .value { font-size: 28px; margin-top: 8px; }
  .metric .tile { width: 34px; height: 34px; top: 12px; right: 12px; border-radius: 10px; }
  .metric .tile svg.i { width: 16px; height: 16px; }
  .card { padding: 16px; border-radius: 16px; }
  .chart { gap: 4px; height: 150px; }
  .chart .n { font-size: 9.5px; visibility: hidden; }
  .chart .bar.today .n { visibility: visible; }
  .chart .d { font-size: 9.5px; }
  dl.facts { grid-template-columns: 1fr; gap: 2px; }
  dl.facts dd { margin-bottom: 10px; }

  /* Таблицы превращаются в карточки: подписи столбцов — над значениями */
  .tbl.cards thead { display: none; }
  .tbl.cards, .tbl.cards tbody { display: block; }
  .tbl.cards tr { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; padding: 14px;
                  margin-bottom: 10px; border-radius: 14px; background: var(--row); border: 1px solid var(--line); }
  .tbl.cards td { display: block; padding: 0; background: none !important; border-radius: 0 !important; }
  .tbl.cards td[data-label]::before { content: attr(data-label); display: block; color: var(--muted); font-size: 11.5px; margin-bottom: 2px; }
  .tbl.cards td.wide { grid-column: 1 / -1; }
  .tbl.cards td.actions { grid-column: 1 / -1; text-align: left; white-space: normal; display: flex; gap: 8px; flex-wrap: wrap; }
  .tbl.cards td.empty { grid-column: 1 / -1; }
  .tbl.cards td.hide-sm { display: none; }
  .tbl.cards tr { gap: 8px 14px; padding: 12px 14px; }
  .table-wrap { margin: 0; overflow: visible; }
}
