/* pvedash: единый каркас админки pve — по образцу админки VPN (admin_new/static/ui.css) и панели AI Studio (panel/admin.css, ui-vpn.css).
   Меню слева (≥1100 px), на узких экранах — выезжающее меню, верхняя панель и нижние вкладки (<720 px).
   Цвета — только синяя палитра из style.css (--blue*, --ink, --muted, --line, --surface, --bg); оттенки считаются через color-mix().
   Файл подключается ПОСЛЕ style.css и panel.css и приводит кнопки, поля, карточки, бейджи, таблицы и окна к одному виду на всех страницах. */

:root {
  --sidebar-w: 268px; --appbar-h: 60px; --tabbar-h: 64px; --gutter: clamp(14px, 2.4vw, 32px);
  --nav-hover: color-mix(in srgb, var(--line) 40%, var(--surface));
  --u-hover: color-mix(in srgb, var(--ink) 4%, var(--surface));
  --u-fill: color-mix(in srgb, var(--ink) 2.5%, var(--surface));
  --u-line-2: color-mix(in srgb, var(--line) 55%, var(--surface));
  --u-field-line: color-mix(in srgb, var(--line) 70%, var(--muted));
  --u-shadow-sm: 0 1px 2px color-mix(in srgb, var(--ink) 5%, transparent);
  --u-ring: 0 0 0 3px color-mix(in srgb, var(--blue) 18%, transparent);
  --u-blue-hover: color-mix(in srgb, var(--blue) 86%, var(--ink));
}
html { scroll-padding-top: 90px; }
body {
  background: radial-gradient(circle at 85% -10%, color-mix(in srgb, var(--blue) 12%, var(--bg)) 0, transparent 36%), var(--bg);
  background-attachment: fixed; -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
body.menu-open { overflow: hidden; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; box-shadow: none; border-radius: 6px; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 300; padding: 10px 14px; border-radius: var(--radius-s); background: var(--surface); color: var(--ink); font-weight: 600; text-decoration: none; box-shadow: var(--shadow); }
.skip-link:focus { left: 8px; }
.shell #theme { display: none; } /* тема переключается в боковом меню */
.topnav { display: none !important; } /* прежняя верхняя полоса заменена боковым меню; элемент оставлен для app.js */

/* ---------- каркас ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.main { min-width: 0; display: flex; flex-direction: column; }
.no-shell .shell { grid-template-columns: minmax(0, 1fr); }
.no-shell .sidebar, .no-shell .appbar, .no-shell .tabbar { display: none !important; }
.shell .main > .wrap { width: 100%; max-width: 1480px; margin: 0 auto; padding: 8px var(--gutter) 48px; }
.shell .main > .pwrap { max-width: 1180px; }
.shell .main > .pwrap.fmwrap { max-width: 1480px; }
.shell .main > .login { max-width: none; padding: 24px 12px; }
.conn { left: var(--sidebar-w); }

/* боковое меню */
.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; z-index: 60;
  background: color-mix(in srgb, var(--surface) 80%, transparent); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border-right: 1px solid var(--line);
}
.side-head { display: flex; align-items: center; gap: 10px; padding: 20px 14px 14px; }
.brand-link { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; text-decoration: none; color: var(--ink); border-radius: var(--radius-s); }
.brand-link:hover { color: var(--ink); }
.brand-mark { display: block; width: 38px; height: 38px; border-radius: 11px; flex: none; }
.brand-link strong { display: block; font-size: 16px; letter-spacing: -.02em; line-height: 1.2; }
.brand-link small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.shell-btn { display: inline-grid; place-items: center; width: 42px; height: 42px; flex: none; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); color: var(--ink); cursor: pointer; transition: background-color .15s, border-color .15s; }
.shell-btn:hover { background: var(--nav-hover); }
.shell-btn svg, .nav svg, .tab svg { width: 1.25em; height: 1.25em; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.shell-btn svg { width: 20px; height: 20px; stroke-width: 2; }
.side-close { display: none; }
.nav { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; display: flex; flex-direction: column; gap: 2px; padding: 4px 12px 12px; }
.nav-group { margin: 0; padding: 18px 12px 6px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.nav-group:first-child { padding-top: 8px; }
.nav a { display: flex; align-items: center; gap: 11px; min-height: 40px; padding: 8px 12px; border-radius: var(--radius-s); color: var(--soft); font-weight: 600; font-size: 14px; text-decoration: none; transition: background-color .15s, color .15s; }
.nav a:hover { background: var(--nav-hover); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--blue-soft); color: var(--blue-ink); }
.nav-sub { display: flex; flex-direction: column; gap: 1px; margin: 2px 0 6px 22px; padding-left: 12px; border-left: 1px solid var(--line); }
.nav-sub a { font-weight: 500; min-height: 38px; }
.nav-spacer { flex: 1; }
.nav-foot { display: flex; align-items: center; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.user-chip { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 6px; border-radius: var(--radius-s); color: var(--ink); text-decoration: none; }
a.user-chip:hover { background: var(--nav-hover); color: var(--ink); }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 50%; background: var(--blue-soft); color: var(--blue-ink); font-weight: 700; text-transform: uppercase; }
.user-chip .who { min-width: 0; }
.user-chip b { display: block; font-size: 14px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-foot .shell-btn { width: 38px; height: 38px; }
.nav-logout { color: var(--red-ink); }
.nav-logout:hover { background: var(--red-soft); border-color: var(--red-line); }
.backdrop { position: fixed; inset: 0; z-index: 59; background: color-mix(in srgb, var(--ink) 40%, transparent); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .2s; }

/* верхняя панель (только узкие экраны) */
.appbar { display: none; position: sticky; top: 0; z-index: 50; align-items: center; gap: 10px; min-height: var(--appbar-h); padding: 10px var(--gutter); background: color-mix(in srgb, var(--bg) 84%, transparent); -webkit-backdrop-filter: saturate(1.4) blur(12px); backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--line); }
.appbar .brand-link { flex: 0 1 auto; }
.appbar .brand-mark { width: 32px; height: 32px; border-radius: 10px; }
.appbar .grow { flex: 1; }

/* нижние вкладки (телефон) */
.tabbar { display: none; }
.tab { font-size: 10.5px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: none; color: var(--muted); font: 600 11px/1.1 inherit; text-decoration: none; border-radius: 12px; cursor: pointer; padding: 4px 2px; min-width: 0; }
.tab svg { width: 23px; height: 23px; }
.tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab[aria-current="page"] { color: var(--blue-ink); }
.tab[aria-current="page"] span { font-weight: 700; }

@media (max-width: 1099px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .conn { left: 0; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(86vw, 320px); transform: translateX(-104%); visibility: hidden; transition: transform .22s ease, visibility 0s linear .22s; background: var(--surface); box-shadow: 0 30px 80px color-mix(in srgb, var(--ink) 30%, transparent); }
  body.menu-open .sidebar { transform: none; visibility: visible; transition: transform .22s ease; }
  body.menu-open .backdrop { opacity: 1; pointer-events: auto; }
  .side-close { display: inline-grid; }
  .appbar { display: flex; }
}
@media (max-width: 719px) {
  body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 58; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding: 6px 6px env(safe-area-inset-bottom); background: color-mix(in srgb, var(--surface) 92%, transparent); -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px); border-top: 1px solid var(--line); }
  .ftoasts { bottom: calc(var(--tabbar-h) + 12px); }
  .fup { bottom: calc(var(--tabbar-h) + 8px); }
  .paused { bottom: calc(var(--tabbar-h) + 12px); }
}
@media (min-width: 1700px) { :root { --sidebar-w: 288px; } .shell .main > .wrap { max-width: 1640px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
@media print { .sidebar, .appbar, .tabbar { display: none !important; } .shell { display: block; } }

/* ---------- заголовок страницы ---------- */
.ph1 { font-size: clamp(20px, 2vw, 24px); letter-spacing: -.03em; font-weight: 700; line-height: 1.15; margin: 14px 0 16px; }
.shell .main > .wrap > .ph1:first-child, .shell .main > .pwrap > .ph1:first-child { margin-top: 12px; }

/* ---------- кнопки: основная / нейтральная / опасная ---------- */
.btn { min-height: 40px; height: auto; padding: 0 16px; border-radius: var(--radius-s); border: 1px solid var(--blue); background: var(--blue); color: #fff; font-weight: 600; font-size: 14px; line-height: 1.2; white-space: nowrap;
  box-shadow: 0 1px 2px color-mix(in srgb, var(--blue) 28%, transparent); transition: background-color .15s, border-color .15s, box-shadow .15s, transform .16s, color .15s; text-decoration: none; }
.btn:hover:not(:disabled) { filter: none; background: var(--u-blue-hover); border-color: var(--u-blue-hover); transform: translateY(-1px); box-shadow: 0 8px 18px color-mix(in srgb, var(--blue) 26%, transparent); color: #fff; }
.btn:active:not(:disabled) { transform: none; box-shadow: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: var(--surface); border-color: var(--line); color: var(--ink); box-shadow: var(--u-shadow-sm); }
.btn.ghost:hover:not(:disabled) { background: var(--u-hover); border-color: var(--u-field-line); color: var(--ink); box-shadow: 0 8px 18px color-mix(in srgb, var(--ink) 8%, transparent); }
.btn.danger { background: var(--red-soft); border-color: var(--red-line); color: var(--red-ink); box-shadow: none; }
.btn.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--red) 12%, var(--surface)); border-color: color-mix(in srgb, var(--red) 45%, var(--surface)); color: var(--red-ink); box-shadow: 0 8px 18px color-mix(in srgb, var(--red) 14%, transparent); }
.btn.small { min-height: 34px; height: auto; padding: 0 12px; font-size: 13px; border-radius: 9px; gap: 6px; }
.btn.small svg.i { width: 16px; height: 16px; }
.btn svg.i { width: 18px; height: 18px; }
.tool-btn { border-radius: 9px; }

/* ---------- поля ---------- */
.input { height: auto; min-height: 42px; padding: 9px 12px; border: 1px solid var(--u-field-line); border-radius: var(--radius-s); background-color: var(--surface); color: var(--ink); font-size: 14.5px; line-height: 1.35; transition: border-color .15s, box-shadow .15s; }
.input:hover:not(:disabled) { border-color: var(--muted); }
.input:focus { outline: 0; border-color: var(--blue); box-shadow: var(--u-ring); }
.input::placeholder { color: var(--muted); opacity: .75; }
.input:disabled { background-color: var(--u-hover); color: var(--muted); cursor: not-allowed; }
select.input { appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%; background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; }
.field label { font-weight: 600; }
input[type=checkbox], input[type=radio] { accent-color: var(--blue); }

/* ---------- карточки, бейджи, заметки, таблицы ---------- */
.card { border-radius: var(--radius); box-shadow: var(--u-shadow-sm), var(--shadow); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--u-hover); color: var(--soft); font-size: 12px; font-weight: 700; line-height: 1.35; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; flex: none; }
.badge.nodot::before { display: none; }
.badge svg.i { width: 13px; height: 13px; }
.badge.ok { background: var(--green-soft); border-color: var(--green-line); color: var(--green-ink); }
.badge.warn { background: var(--orange-soft); border-color: var(--orange-line); color: var(--orange-ink); }
.badge.err, .badge.bad { background: var(--red-soft); border-color: var(--red-line); color: var(--red-ink); }
.badge.info { background: var(--blue-soft); border-color: var(--blue-line); color: var(--blue-ink); }
.msg { display: flex; gap: 10px; align-items: flex-start; border-radius: var(--radius-s); line-height: 1.5; }
.tbl th { padding: 11px 14px; background: var(--u-fill); font-size: 12px; font-weight: 700; letter-spacing: .02em; border-bottom: 1px solid var(--line); }
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--u-line-2); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--u-fill); }
.tblwrap { border: 1px solid var(--line); border-radius: var(--radius-s); }
.card > .tblwrap, .card > div > .tblwrap { border: 0; }
.subtabs, .tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; }
.subtabs a { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); color: var(--soft); font-weight: 600; font-size: 13.5px; text-decoration: none; box-shadow: var(--u-shadow-sm); }
.subtabs a:hover { background: var(--u-hover); color: var(--ink); }
.subtabs a[aria-current="page"] { background: var(--blue-soft); border-color: var(--blue-line); color: var(--blue-ink); box-shadow: none; }

/* ---------- окна ---------- */
.dlg { border: 0; border-radius: var(--radius); background: var(--surface); color: var(--ink);
  box-shadow: 0 30px 80px color-mix(in srgb, var(--ink) 25%, transparent), 0 0 0 1px color-mix(in srgb, var(--line) 60%, transparent); }
.dlg[open] { animation: u-pop .16s ease-out; }
.dlg::backdrop, .fv::backdrop { background: color-mix(in srgb, var(--ink) 45%, transparent); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
@keyframes u-pop { from { opacity: 0; transform: translateY(6px) scale(.985); } to { opacity: 1; transform: none; } }
.dlg h2 { font-size: 19px; font-weight: 700; letter-spacing: -.015em; line-height: 1.25; }
@media (prefers-reduced-motion: reduce) { .dlg[open] { animation: none; } }
@media (max-width: 719px) {
  .btn { min-height: 44px; }
  .btn.small { min-height: 40px; }
  .input { min-height: 46px; font-size: 16px; }
  input[type=checkbox], input[type=radio] { width: 22px; height: 22px; }
  dialog.dlg { width: 100%; max-width: 100%; margin: auto 0 0; max-height: 92dvh; border-radius: 20px 20px 0 0; overflow: auto; }
  dialog.dlg .row .btn { flex: 1 1 auto; }
}

/* ---------- общие компоненты для страниц разделов (Файлы, Сервисы, Торренты, Доступы): как в ui-vpn.css AI Studio ---------- */
/* заголовок страницы с подписью и действиями: <div class="page-head"><div><h1>…</h1><p>…</p></div><div class="row">кнопки</div></div> */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px 20px; flex-wrap: wrap; padding: 12px 0 16px; }
.page-head > div:first-child { min-width: 0; flex: 1 1 320px; }
.page-head h1 { font-size: clamp(20px, 2vw, 24px); letter-spacing: -.03em; font-weight: 700; margin: 0; line-height: 1.15; }
.page-head p { margin: 6px 0 0; color: var(--muted); font-size: 14px; max-width: 68ch; }
/* карточка с шапкой: .card > .card-head > h2 + p; .card-body */
.card-head { padding: 18px 22px 14px; border-bottom: 1px solid var(--u-line-2); display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.card-head h2 { font-size: 17px; font-weight: 700; letter-spacing: -.015em; }
.card-head p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.card-body { padding: 18px 22px 22px; }
/* таблица, которая прокручивается внутри своей обёртки (для широких таблиц; там, где нужна «карточная» раскладка на телефоне, — .tbl.stack из panel.css) */
.table-wrap { overflow-x: auto; max-width: 100%; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); scrollbar-width: thin; }
.table-wrap > table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.table-wrap th { padding: 11px 14px; text-align: left; white-space: nowrap; background: var(--u-fill); color: var(--muted); font-size: 12px; font-weight: 700; border-bottom: 1px solid var(--line); }
.table-wrap td { padding: 12px 14px; border-bottom: 1px solid var(--u-line-2); vertical-align: middle; }
.table-wrap tbody tr:last-child td { border-bottom: 0; }
.table-wrap tbody tr:hover td { background: var(--u-fill); }
.table-wrap td.num, .table-wrap th.num { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 719px) { .table-wrap > table { min-width: 640px; } }
/* заметки: .note.info | .warn | .bad | .ok */
.note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--u-fill); color: var(--soft); font-size: 14px; line-height: 1.5; }
.note.info { background: var(--blue-soft); border-color: var(--blue-line); color: var(--blue-ink); }
.note.warn { background: var(--orange-soft); border-color: var(--orange-line); color: var(--orange-ink); }
.note.bad { background: var(--red-soft); border-color: var(--red-line); color: var(--red-ink); }
.note.ok { background: var(--green-soft); border-color: var(--green-line); color: var(--green-ink); }
/* переключатель-фильтр: <button class="chip-btn on" aria-pressed="true"> */
.chip-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--soft); font-size: 13px; font-weight: 600; cursor: pointer; box-shadow: var(--u-shadow-sm); transition: background-color .15s, border-color .15s, color .15s; }
.chip-btn:hover:not(:disabled) { background: var(--u-hover); color: var(--ink); }
.chip-btn.on, .chip-btn[aria-pressed="true"] { background: var(--blue-soft); border-color: var(--blue-line); color: var(--blue-ink); box-shadow: none; }
/* пустое состояние: <div class="empty-state"><h3>…</h3><p>…</p></div> */
.empty-state { display: grid; justify-items: center; gap: 8px; padding: 32px 18px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); background: var(--u-fill); color: var(--muted); }
.empty-state h3 { font-size: 19px; color: var(--ink); letter-spacing: -.015em; }
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
/* уведомления (все страницы): FM.toast(text, "err") из panel_files.js или свой .ftoast в контейнере .ftoasts */

/* в style.css класс .stack занят полосой памяти дашборда (flex, высота 18 px): таблицам «.tbl.stack» (карточный вид на телефоне) возвращаем табличный вид */
table.tbl.stack { display: table; height: auto; margin-top: 0; overflow: visible; background: none; border-radius: 0; }
