/* corp_vpn panels (company + owner admin). No external assets. */
:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --card-2: #f8f9fc;
  --text: #141821;
  --muted: #677085;
  --line: #e2e6ee;
  --line-2: #d3d9e4;
  --accent: #2f5bea;
  --accent-2: #2448c4;
  --accent-soft: #e8eefe;
  --ok: #13804b;
  --ok-soft: #e3f5ec;
  --warn: #a35a00;
  --warn-soft: #fff3e0;
  --bad: #c62a2a;
  --bad-soft: #fdeaea;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --radius: 14px;
  --radius-sm: 9px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --card: #161a22;
    --card-2: #1b2029;
    --text: #e7eaf0;
    --muted: #98a1b3;
    --line: #262c38;
    --line-2: #333b4a;
    --accent: #6f8fff;
    --accent-2: #8aa4ff;
    --accent-soft: #1d2645;
    --ok: #45c784;
    --ok-soft: #13291f;
    --warn: #f0a640;
    --warn-soft: #2d2213;
    --bad: #f07272;
    --bad-soft: #321819;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 14px 40px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
p { margin: 0 0 10px; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 22px; padding-bottom: 48px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; word-break: break-all; }
.bad { color: var(--bad); }
.warn { color: var(--warn); }
.ok { color: var(--ok); }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pad { padding: 0 16px 14px; }
[hidden] { display: none !important; }

/* --- Header --- */
.top { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.top-in { display: flex; align-items: center; gap: 18px; min-height: 58px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; color: var(--text); white-space: nowrap; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
.brand:hover { text-decoration: none; }
.brand span:last-child { overflow: hidden; text-overflow: ellipsis; }
.logo, .auth-logo {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M16 7l8 3v6c0 5-3.4 8.4-8 9.8C11.4 24.4 8 21 8 16v-6z' fill='%23fff'/%3E%3C/svg%3E") center / 100% no-repeat;
}
.tabs { display: flex; gap: 4px; }
.tabs a { padding: 7px 12px; border-radius: 9px; color: var(--muted); font-weight: 550; }
.tabs a:hover { background: var(--card-2); color: var(--text); text-decoration: none; }
.tabs a.active { background: var(--accent-soft); color: var(--accent); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.top-right form { margin: 0; }

/* --- Cards, layout --- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin-bottom: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush > h2, .card-head { padding: 16px 16px 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.card:not(.card-flush) > .card-head { padding: 0; }
.card-head h2 { margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; align-items: start; }
.empty { text-align: center; padding: 28px 18px; }

/* --- Stats --- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 8px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.stat-wide { grid-column: span 4; }
.stat-label { color: var(--muted); font-size: 13px; font-weight: 550; margin-bottom: 4px; }
.stat-value { font-size: 24px; font-weight: 680; letter-spacing: -.01em; line-height: 1.25; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 15px; color: var(--muted); font-weight: 500; }
.stat-value time { white-space: nowrap; }
.stat-note { color: var(--muted); font-size: 13px; margin-top: 6px; }

.meter { position: relative; height: 10px; border-radius: 99px; background: var(--card-2); border: 1px solid var(--line); overflow: hidden; margin-top: 10px; }
.meter span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }
.meter i { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text); opacity: .35; }
.meter.warn span { background: var(--warn); }
.meter.buffer span { background: var(--warn); }
.meter.over span { background: var(--bad); }
.meter-unlimited span { background: repeating-linear-gradient(-45deg, var(--accent-soft), var(--accent-soft) 6px, transparent 6px, transparent 12px); }
td .meter { margin-top: 6px; height: 6px; min-width: 90px; }

.bars { display: flex; align-items: flex-end; gap: 3px; height: 150px; padding-top: 8px; }
.bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; position: relative; min-width: 0; }
.bar span { display: block; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 0; opacity: .85; }
.bar:hover span { opacity: 1; }
.bar.today span { background: var(--accent-2); }
.bar.future span { background: transparent; }
.bar em { position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--muted); font-style: normal; }
.bars { margin-bottom: 24px; border-bottom: 1px solid var(--line); }

.kv { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.kv div { background: var(--card-2); border-radius: var(--radius-sm); padding: 10px; min-width: 0; }
.kv span { display: block; color: var(--muted); font-size: 12px; }
.kv b { font-size: 16px; font-variant-numeric: tabular-nums; }

/* --- Tables --- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 16px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
.table thead th { border-top: 0; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; background: var(--card-2); }
.table td.actions { text-align: right; white-space: nowrap; }
.table td.actions .btn + .btn, .table td.actions form + form { margin-left: 6px; }
.card:not(.card-flush) .table th, .card:not(.card-flush) .table td { padding-left: 0; }
.card:not(.card-flush) .table th:last-child, .card:not(.card-flush) .table td:last-child { padding-right: 0; }

/* --- Buttons, tags --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 7px 14px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--card); color: var(--text); font: inherit; font-weight: 580; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--card-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { filter: brightness(1.05); background: var(--bad); }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn-icon { width: 32px; padding: 0; font-size: 18px; line-height: 1; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost-bad { border-color: transparent; background: transparent; color: var(--bad); }
.btn-ghost-bad:hover { background: var(--bad-soft); }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 4px; }
.btn-link:hover { color: var(--text); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
form.inline { display: inline; margin: 0; }
.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--line-2); color: var(--muted); font-weight: 550; vertical-align: 1px; white-space: nowrap; }
.tag-ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.tag-warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.tag-bad { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 99px; white-space: nowrap; }
.chip-wait { background: var(--accent-soft); color: var(--accent); }
.chip-wait::before { content: ""; width: 8px; height: 8px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
@keyframes spin { to { transform: rotate(360deg); } }
.count { display: inline-block; min-width: 22px; padding: 0 7px; border-radius: 99px; background: var(--card-2); border: 1px solid var(--line); font-size: 12px; font-weight: 650; text-align: center; color: var(--muted); }

/* --- Banners, flash --- */
.flash, .banner { border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 16px; border: 1px solid transparent; }
.flash-ok, .banner-ok { background: var(--ok-soft); color: var(--text); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.flash-err, .banner-bad { background: var(--bad-soft); color: var(--text); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.flash-warn, .banner-warn { background: var(--warn-soft); color: var(--text); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.banner b { display: inline; }
pre.creds { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; margin: 10px 0; white-space: pre-wrap; word-break: break-all; font-size: 13px; }

/* --- Forms --- */
.form { display: flex; flex-direction: column; gap: 12px; }
.form > .btn { align-self: flex-start; }
.form .btn-block { align-self: stretch; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--muted); min-width: 0; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-weight: 500; font-size: 14px; }
input, select, textarea {
  font: inherit; font-size: 15px; color: var(--text); background: var(--card);
  border: 1px solid var(--line-2); border-radius: 9px; padding: 8px 11px; min-height: 40px; width: 100%; min-width: 0;
}
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; margin: 0; accent-color: var(--accent); flex: none; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 0; border-color: var(--accent); }
input:disabled { opacity: .55; }
textarea { resize: vertical; }
.hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; align-items: end; }
.form-error { color: var(--bad); font-size: 14px; }
.checks { display: flex; flex-direction: column; gap: 6px; padding-left: 26px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; margin: 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
legend { font-size: 13px; font-weight: 650; padding: 0 6px; }
.helpers { display: flex; flex-direction: column; gap: 8px; }
.helper { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.helper input[type=number] { width: 80px; }
.helper input[type=date] { width: auto; }
details { margin-top: 10px; }
details summary { cursor: pointer; color: var(--accent); font-size: 14px; margin-bottom: 8px; }
.result-preview { font-size: 13px; color: var(--muted); }

/* --- Auth --- */
.auth { min-height: 80vh; display: flex; align-items: center; justify-content: center; }
.auth-card { width: 100%; max-width: 380px; padding: 28px 24px; }
.auth-logo { width: 44px; height: 44px; border-radius: 12px; margin-bottom: 14px; }
.auth h1 { font-size: 22px; margin-bottom: 18px; }

/* --- Employees board --- */
.subtabs { display: flex; gap: 6px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.subtabs a { padding: 9px 4px; margin-right: 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; display: flex; gap: 8px; align-items: center; }
.subtabs a:hover { text-decoration: none; color: var(--text); }
.subtabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.toolbar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .search { flex: 1 1 260px; width: auto; }

.group { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px; }
.group-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; flex-wrap: wrap; }
.group-head h2 { margin: 0; font-size: 16px; overflow-wrap: anywhere; }
.group-none .group-head h2 { color: var(--muted); }
.group-traffic { margin-left: 2px; }
.group-tools { margin-left: auto; display: flex; gap: 2px; }
.emp-list { list-style: none; margin: 0; padding: 0; }
.drop-hint { display: none; margin: 0 14px 14px; padding: 14px; border: 1.5px dashed var(--line-2); border-radius: var(--radius-sm); color: var(--muted); font-size: 13px; text-align: center; }
.emp-list:empty + .drop-hint { display: block; }
.group-none .emp-list:empty + .drop-hint { display: none; }
body.dragging-emp .group-none .emp-list:empty + .drop-hint { display: block; }
/* An empty "Без группы" is only a drop target: shown while dragging (or when there are no groups at all). */
.group-none:has(.emp-list:empty):has(+ #groups > .group) { display: none; }
body.dragging-emp .group-none { display: block !important; }

.emp { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 10px 14px 10px 8px; border-top: 1px solid var(--line); background: var(--card); }
.emp:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.emp-name { font-weight: 620; overflow-wrap: anywhere; }
.emp-sub { color: var(--muted); font-size: 13px; display: flex; gap: 4px 10px; flex-wrap: wrap; }
.emp-comment { font-style: italic; }
.emp-traffic { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.emp-traffic b { display: block; font-size: 14px; }
.emp-traffic span { font-size: 12px; color: var(--muted); }
.emp-actions { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.handle {
  width: 28px; height: 32px; border: 0; padding: 0; border-radius: 7px; cursor: grab; touch-action: none; flex: none;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 20' fill='%23909aae'%3E%3Ccircle cx='3' cy='4' r='1.6'/%3E%3Ccircle cx='9' cy='4' r='1.6'/%3E%3Ccircle cx='3' cy='10' r='1.6'/%3E%3Ccircle cx='9' cy='10' r='1.6'/%3E%3Ccircle cx='3' cy='16' r='1.6'/%3E%3Ccircle cx='9' cy='16' r='1.6'/%3E%3C/svg%3E") center / 10px no-repeat;
}
.handle:hover { background-color: var(--card-2); }
.handle:active { cursor: grabbing; }
body.filtering .handle { visibility: hidden; }
.drag-ghost { position: fixed; z-index: 100; pointer-events: none; box-shadow: var(--shadow-lg); border-radius: var(--radius-sm); opacity: .96; margin: 0; list-style: none; border: 1px solid var(--accent); }
.drag-placeholder { opacity: .35; outline: 2px dashed var(--accent); outline-offset: -2px; }
body.dragging, body.dragging * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }
body.dragging-emp .emp-list { min-height: 8px; }
body.dragging-groups #groups .emp-list, body.dragging-groups #groups .drop-hint { display: none; }

/* --- Menu, modal, toast --- */
.menu { position: absolute; z-index: 60; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; min-width: 210px; }
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 9px 12px; border-radius: 8px; font: inherit; color: var(--text); cursor: pointer; }
.menu button:hover, .menu button:focus-visible { background: var(--card-2); outline: none; }
.menu button.danger { color: var(--bad); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

.modal-back { position: fixed; inset: 0; z-index: 80; background: rgba(10, 14, 22, .5); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--card); border-radius: 16px; box-shadow: var(--shadow-lg); width: 100%; max-width: 460px; max-height: calc(100vh - 32px); overflow: auto; padding: 22px; }
.modal h2 { font-size: 19px; margin-bottom: 14px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.modal p { color: var(--muted); }
.key-link { display: flex; gap: 8px; }
.key-link input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.qr { display: flex; justify-content: center; margin: 16px 0 8px; }
.qr svg { width: 220px; height: 220px; background: #fff; border-radius: 12px; padding: 10px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 90; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 14px; max-width: calc(100vw - 32px); }
.toast.err { background: var(--bad); color: #fff; }

/* --- Responsive --- */
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-wide { grid-column: span 2; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  h1 { font-size: 22px; }
  .top-in { gap: 6px 12px; padding-top: 8px; padding-bottom: 6px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  .hide-sm { display: none; }
  .stats { grid-template-columns: minmax(0, 1fr); }
  .stat-wide { grid-column: span 1; }
  .emp { grid-template-columns: 28px minmax(0, 1fr) auto; row-gap: 6px; }
  .emp-traffic { grid-column: 2; grid-row: 2; text-align: left; }
  .emp-traffic b { display: inline; margin-right: 6px; }
  .emp-actions { grid-column: 3; grid-row: 1 / span 2; flex-direction: column; align-items: flex-end; }
  .group-tools { margin-left: 0; width: 100%; }
  .table th, .table td { padding: 9px 12px; }
  .bars { gap: 1px; }
}
