/* Панель — спокойный «системный» стиль в духе приложений Apple */
:root {
  --acc: #0a84ff; --acc-soft: rgba(10,132,255,.12);
  --bg: #f2f2f7; --side: rgba(236,236,240,.86); --card: #ffffff; --card2: #f7f7f9;
  --fg: #1c1c1e; --mut: #6c6c70; --faint: #aeaeb2; --sep: rgba(60,60,67,.14);
  --ok: #34c759; --warn: #ff9f0a; --crit: #ff3b30; --off: #c7c7cc;
  --ok-soft: rgba(52,199,89,.14); --warn-soft: rgba(255,159,10,.16); --crit-soft: rgba(255,59,48,.13);
  --shadow: 0 1px 2px rgba(0,0,0,.04);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #000000; --side: rgba(28,28,30,.86); --card: #1c1c1e; --card2: #2c2c2e;
  --fg: #f2f2f7; --mut: #98989f; --faint: #636366; --sep: rgba(84,84,88,.55);
  --ok: #30d158; --warn: #ff9f0a; --crit: #ff453a; --off: #48484a;
  --ok-soft: rgba(48,209,88,.16); --warn-soft: rgba(255,159,10,.18); --crit-soft: rgba(255,69,58,.18);
  --shadow: none;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow-x: hidden; }
body { font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--fg); -webkit-font-smoothing: antialiased; letter-spacing: -0.01em; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; }
.hidden { display: none !important; }
a { color: var(--acc); text-decoration: none; }

/* ---------- каркас ---------- */
#app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100%; }
#app > * { min-width: 0; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 18px 10px; display: flex; flex-direction: column; gap: 2px;
  background: var(--side); border-right: 1px solid var(--sep); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
.brand { display: flex; align-items: center; gap: 9px; padding: 4px 10px 16px; font-weight: 600; font-size: 15px; }
.brand img { width: 26px; height: 26px; border-radius: 7px; }
.tab { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border-radius: 8px; font-size: 14px; text-align: left; }
.tab:hover { background: rgba(127,127,127,.12); }
.tab.active { background: var(--acc); color: #fff; }
.tab.active .tile { box-shadow: 0 0 0 1.5px rgba(255,255,255,.6); }
.tab .badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--warn); color: #fff; font-size: 12px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; }
.tab.active .badge { background: rgba(255,255,255,.3); }
.sidebar .spacer { flex: 1; }
.sidebar .foot { padding: 8px 10px 0; color: var(--mut); font-size: 12px; }
main { padding: 34px 40px 60px; width: 100%; }
@media (min-width: 1600px) { main { padding-left: 56px; padding-right: 56px; } .topbar { margin-left: -56px !important; margin-right: -56px !important; padding-left: 56px !important; padding-right: 56px !important; } }

/* ---------- заголовки ---------- */
.ptitle { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.ptitle h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; margin: 0; flex: 1; min-width: 0; }
.psub { color: var(--mut); font-size: 14px; margin: 0 0 22px; }
.icon-btn { width: 34px; height: 34px; border-radius: 17px; display: inline-flex; align-items: center; justify-content: center; background: var(--card); box-shadow: var(--shadow); color: var(--acc); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.mob { display: none; }
.sect { color: var(--mut); font-size: 13px; margin: 24px 16px 7px; }
.foot-note { color: var(--mut); font-size: 12.5px; margin: 7px 16px 0; line-height: 1.45; }

/* ---------- сгруппированные списки (как «Настройки») ---------- */
.group { background: var(--card); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.row { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 8px 16px; position: relative; }
.row + .row::before { content: ""; position: absolute; top: 0; right: 0; left: 16px; height: 1px; background: var(--sep); }
.row.has-tile + .row::before, .row + .row.has-tile::before { left: 58px; }
.row.link { cursor: pointer; }
.row.link:hover { background: rgba(127,127,127,.06); }
.row .t { flex: 1; min-width: 0; }
.row .t .s { color: var(--mut); font-size: 12.5px; margin-top: 1px; }
.row .t .main { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .v { color: var(--mut); text-align: right; font-variant-numeric: tabular-nums; flex-shrink: 0; max-width: 60%; }
.row .v.ok { color: var(--ok); } .row .v.warn { color: var(--warn); } .row .v.crit { color: var(--crit); }
.row .chev { width: 8px; height: 13px; color: var(--faint); flex-shrink: 0; }
.row.btnrow { justify-content: center; color: var(--acc); cursor: pointer; }
.row.btnrow.danger { color: var(--crit); }
.row.btnrow:hover { background: rgba(127,127,127,.06); }
.tile { width: 30px; height: 30px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; }
.tile svg { width: 18px; height: 18px; }
.tile.sm { width: 24px; height: 24px; border-radius: 6px; } .tile.sm svg { width: 15px; height: 15px; }
.t-blue { background: #0a84ff; } .t-green { background: #34c759; } .t-orange { background: #ff9f0a; } .t-red { background: #ff3b30; }
.t-gray { background: #8e8e93; } .t-indigo { background: #5e5ce6; } .t-teal { background: #30b0c7; } .t-purple { background: #af52de; } .t-pink { background: #ff2d55; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; background: var(--off); }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.crit { background: var(--crit); }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 20px; background: var(--card2); color: var(--mut); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.warn { background: var(--warn-soft); color: var(--warn); } .pill.crit { background: var(--crit-soft); color: var(--crit); }
.pill.acc { background: var(--acc-soft); color: var(--acc); }

/* ---------- сегменты ---------- */
.seg { display: inline-flex; background: rgba(118,118,128,.14); border-radius: 9px; padding: 2px; gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { padding: 6px 14px; border-radius: 7px; font-size: 13px; font-weight: 500; white-space: nowrap; color: var(--fg); }
.seg button.on { background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; }
:root[data-theme="dark"] .seg button.on { background: #636366; }
.seg.full { display: flex; width: 100%; } .seg.full button { flex: 1; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { padding: 6px 13px; border-radius: 18px; font-size: 13px; font-weight: 500; background: var(--card); box-shadow: var(--shadow); }
.chip.on { background: var(--acc); color: #fff; }
.chip .n { opacity: .65; margin-left: 4px; }

/* ---------- обзор ---------- */
.status { display: flex; align-items: center; gap: 14px; padding: 16px; }
.status .big { width: 44px; height: 44px; border-radius: 22px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.status .big svg { width: 24px; height: 24px; }
.status .big.ok { background: var(--ok-soft); color: var(--ok); } .status .big.warn { background: var(--warn-soft); color: var(--warn); } .status .big.crit { background: var(--crit-soft); color: var(--crit); }
.status .h { font-size: 17px; font-weight: 600; }
.status .s { color: var(--mut); font-size: 13.5px; margin-top: 2px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.scard { background: var(--card); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); cursor: pointer; transition: transform .12s ease; }
.scard:active { transform: scale(.985); }
.scard .head { display: flex; align-items: center; gap: 10px; }
.scard .name { font-size: 17px; font-weight: 600; flex: 1; }
.ips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 14px; }
.ip { font: 12.5px ui-monospace, "SF Mono", Menlo, monospace; padding: 3px 8px; border-radius: 6px; background: var(--card2); color: var(--mut); }
.ip.main { background: var(--acc-soft); color: var(--acc); }
.meters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.meter .k { color: var(--mut); font-size: 12px; }
.meter .val { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.bar { height: 5px; border-radius: 3px; background: rgba(120,120,128,.18); margin-top: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: var(--acc); }
.bar > i.warn { background: var(--warn); } .bar > i.crit { background: var(--crit); }
.spark { width: 100%; height: 30px; margin-top: 14px; display: block; }
.spark path { fill: none; stroke: var(--acc); stroke-width: 1.6; }
.spark .area { fill: var(--acc-soft); stroke: none; }
.scard .meta { display: flex; justify-content: space-between; color: var(--mut); font-size: 12.5px; margin-top: 10px; gap: 8px; }

/* ---------- VPN / цифры ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 4px; }
.kpi { background: var(--card); border-radius: 12px; padding: 13px 15px; box-shadow: var(--shadow); }
.kpi .k { color: var(--mut); font-size: 12.5px; }
.kpi .val { font-size: 24px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.kpi .s { color: var(--mut); font-size: 12px; margin-top: 1px; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 110px; padding: 16px 16px 6px; }
.bars i { flex: 1; background: var(--acc); border-radius: 3px 3px 1px 1px; min-height: 2px; opacity: .9; }
.axis { display: flex; justify-content: space-between; color: var(--faint); font-size: 11px; padding: 0 16px 12px; }
.avatar { width: 32px; height: 32px; border-radius: 16px; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; font-size: 13px; flex-shrink: 0; position: relative; }
.avatar .st { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--card); background: var(--off); }
.avatar .st.ok { background: var(--ok); }
.search { width: 100%; padding: 9px 12px 9px 34px; border-radius: 10px; border: 0; background: rgba(118,118,128,.12); color: var(--fg); outline: none; margin-bottom: 12px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2.2' stroke-linecap='round'><circle cx='11' cy='11' r='7'/><path d='M20 20l-3.5-3.5'/></svg>");
  background-repeat: no-repeat; background-position: 10px center; background-size: 16px; }

/* ---------- модальные окна ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.32); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal { background: var(--card); border-radius: 14px; width: 100%; max-width: 340px; overflow: hidden; text-align: center; }
.modal .body { padding: 20px 18px 16px; }
.modal .h { font-weight: 600; font-size: 17px; }
.modal .d { color: var(--mut); font-size: 13.5px; margin-top: 4px; }
.modal .acts { display: flex; border-top: 1px solid var(--sep); }
.modal .acts button { flex: 1; padding: 12px; color: var(--acc); font-size: 16px; }
.modal .acts button + button { border-left: 1px solid var(--sep); font-weight: 600; }
.modal .acts button.danger { color: var(--crit); }
.sheet .opt { display: block; width: 100%; padding: 13px; border-top: 1px solid var(--sep); color: var(--acc); font-size: 16px; }
.sheet .opt.sel { font-weight: 650; }
.sheet .opt.cancel { font-weight: 600; }
.modal input { width: 100%; margin-top: 10px; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--sep); background: var(--card2); color: var(--fg); outline: none; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(26px + env(safe-area-inset-bottom)); background: rgba(40,40,42,.94); color: #fff;
  padding: 10px 16px; border-radius: 12px; z-index: 60; font-size: 14px; max-width: 90vw; }

/* ---------- вход ---------- */
#login { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login { width: 100%; max-width: 330px; text-align: center; }
.login img { width: 72px; height: 72px; border-radius: 17px; margin-bottom: 14px; }
.login h1 { font-size: 26px; margin: 0 0 4px; }
.login p { color: var(--mut); margin: 0 0 22px; }
.login input { width: 100%; padding: 12px 14px; border-radius: 11px; border: 0; background: var(--card); color: var(--fg); outline: none; font-size: 16px; box-shadow: var(--shadow); }
.btn-main { display: block; width: 100%; padding: 12px; border-radius: 11px; background: var(--acc); color: #fff; font-weight: 600; font-size: 16px; margin-top: 10px; }
.btn-sec { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 12px; border-radius: 11px; background: var(--card); color: var(--acc); font-weight: 600; font-size: 16px; margin-top: 10px; box-shadow: var(--shadow); }
.btn-sec svg { width: 20px; height: 20px; }
.err { color: var(--crit); font-size: 13.5px; min-height: 20px; margin-top: 10px; }
.swatches { display: flex; gap: 10px; }
.swatch { width: 26px; height: 26px; border-radius: 13px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
.swatch.on { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px currentColor; }

/* ---------- телефон ---------- */
@media (max-width: 760px) {
  #app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 20; flex-direction: row; padding: 5px 4px calc(4px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--sep); }
  .brand, .sidebar .spacer, .sidebar .foot, .tab.desk { display: none; }
  .tab { flex: 1; flex-direction: column; gap: 2px; padding: 4px 0; font-size: 10.5px; border-radius: 0; color: var(--mut); text-align: center; position: relative; }
  .tab:hover { background: none; }
  .tab .tile { background: none !important; color: inherit; width: 26px; height: 24px; box-shadow: none !important; }
  .tab .tile svg { width: 23px; height: 23px; }
  .tab.active { background: none; color: var(--acc); }
  .tab .badge { position: absolute; top: 0; left: 50%; margin-left: 6px; min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; }
  main { padding: calc(14px + env(safe-area-inset-top)) 16px calc(92px + env(safe-area-inset-bottom)); }
  .ptitle h1 { font-size: 28px; }
  .icon-btn.mob { display: inline-flex; }
  .cards { grid-template-columns: minmax(0, 1fr); }
  .row .v { max-width: 55%; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .seg button { padding: 6px 11px; }
  .toast { bottom: calc(92px + env(safe-area-inset-bottom)); }
}

/* ---------- v3: верхняя полоса вместо крупных заголовков ---------- */
.topbar { position: sticky; top: 0; z-index: 15; display: flex; align-items: center; gap: 8px; min-height: 52px; margin: -34px -40px 18px; padding: 10px 40px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border-bottom: 1px solid transparent; }
.topbar.scrolled { border-bottom-color: var(--sep); }
.topbar .ttl { font-size: 17px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .back { display: inline-flex; align-items: center; gap: 2px; color: var(--acc); font-size: 16px; padding: 4px 6px 4px 0; }
.topbar .back svg { width: 11px; height: 18px; }
.hero { display: flex; align-items: center; gap: 14px; padding: 4px 4px 18px; }
.hero .avatar { width: 56px; height: 56px; border-radius: 28px; font-size: 22px; }
.hero .avatar .st { width: 15px; height: 15px; }
.hero .nm { font-size: 22px; font-weight: 700; }
.hero .sb { color: var(--mut); font-size: 13.5px; margin-top: 2px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); }
.stats > div { padding: 14px 16px; }
.stats > div + div { border-left: 1px solid var(--sep); }
.stats .k { color: var(--mut); font-size: 12.5px; }
.stats .val { font-size: 22px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.seg.icons button { padding: 6px 12px; }
.seg.icons svg { width: 17px; height: 17px; vertical-align: -3px; }
.swatches.wide { display: flex; justify-content: space-between; width: 100%; padding: 4px 0; }
.swatches.wide .swatch { width: 30px; height: 30px; border-radius: 15px; }
.count { color: var(--mut); margin-right: 2px; }
@media (max-width: 760px) {
  .topbar { margin: calc(-14px - env(safe-area-inset-top)) -16px 14px; padding: calc(8px + env(safe-area-inset-top)) 16px 8px; }
  .stats .val { font-size: 19px; }
  .stats > div { padding: 12px 12px; }
}

/* ---------- v4 ---------- */
.topbar { min-height: 56px; }
.topbar .ttl { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; line-height: 34px; }
.topbar .back { height: 34px; line-height: 34px; font-size: 17px; align-self: center; margin-right: 4px; }
.topbar .back svg { width: 10px; height: 17px; margin-right: 4px; }
.topbar .back + .ttl { font-size: 19px; }
.bell { position: relative; }
.bell .bdg { position: absolute; top: -3px; right: -3px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--crit); color: #fff; font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; }
.tab { font-size: 15px; font-weight: 500; padding: 8px 10px; }
.tab .tile.sm { width: 26px; height: 26px; border-radius: 7px; } .tab .tile.sm svg { width: 17px; height: 17px; }
.sidebar { gap: 3px; }
.ev-time { color: var(--faint); font-size: 12px; white-space: nowrap; }

/* бэкапы */
.btn-mini { font-size: 13px; font-weight: 600; color: var(--acc); background: var(--acc-soft); padding: 5px 11px; border-radius: 14px; white-space: nowrap; }
.btn-mini:active { opacity: .6; }
.row code, .note code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--card2); padding: 1px 5px; border-radius: 5px; }
