/* Админка Helios: Jinja2 + vanilla JS, без фреймворков и внешних ассетов. */
:root {
  --sidebar-bg: #151922;
  --sidebar-bg-2: #1d2430;
  --sidebar-width: 244px;
  --topbar-height: 56px;
  --accent: #f59e0b;
  --accent-dark: #d97706;
  --accent-soft: #fff3d6;
  --signal: #24b6c8;
  --bg: #eef2f6;
  --surface: #fff;
  --surface-muted: #f8fafc;
  --text: #171b24;
  --muted: #667085;
  --border: #d9e1ea;
  --border-strong: #c6d0dc;
  --danger: #dc2626;
  --ok: #059669;
  --warn: #b45309;
  --shadow: 0 14px 34px rgba(15, 23, 42, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; min-height: 100vh; }
html:has(.login) {
  background: linear-gradient(135deg, #11141b 0%, #202532 48%, #102c34 100%);
}
body {
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(36, 182, 200, .08), rgba(238, 242, 246, 0) 260px),
    var(--bg);
}
body:has(.login) {
  background: linear-gradient(135deg, #11141b 0%, #202532 48%, #102c34 100%);
}
a { color: var(--accent); text-decoration: none; }
button, input, select { font: inherit; }
button:disabled { cursor: not-allowed; opacity: .5; }

/* Topbar */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-height);
  display: flex; align-items: center; gap: 14px; padding: 0 18px;
  background: rgba(21, 25, 34, .98); color: #fff; z-index: 10;
  box-shadow: 0 1px 0 rgba(255,255,255,.08), 0 10px 30px rgba(15, 23, 42, .18);
}
.brand {
  color: #fff; display: inline-flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 15px; letter-spacing: 1.2px;
}
.brand img { display: block; width: 30px; height: 30px; }
.spacer { flex: 1; }
.topbar .muted { color: #b8c2d2; }
.icon-btn {
  width: 36px; height: 36px; border: 1px solid rgba(255,255,255,.13); border-radius: 8px;
  background: rgba(255,255,255,.04); color: #fff; font-size: 19px; line-height: 1; cursor: pointer;
}
.icon-btn:hover { background: rgba(255,255,255,.1); }
.link {
  background: none; border: 0; color: #b8c2d2; cursor: pointer;
  padding: 7px 8px; border-radius: 6px;
}
.link:hover { color: #fff; }

/* Sidebar */
.sidebar {
  position: fixed; top: var(--topbar-height); bottom: 0; left: 0;
  width: var(--sidebar-width); background: var(--sidebar-bg);
  display: flex; flex-direction: column; padding: 12px 10px;
  transition: transform .15s ease;
  box-shadow: inset -1px 0 0 rgba(255,255,255,.06);
}
.sidebar a {
  color: #c9d3e2; padding: 10px 12px; display: flex; align-items: center; gap: 10px;
  min-height: 42px; border-radius: 8px; font-weight: 600;
}
.sidebar a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar a.active {
  background: linear-gradient(90deg, rgba(245, 158, 11, .23), rgba(36, 182, 200, .12));
  color: #fff; box-shadow: inset 3px 0 0 var(--accent);
}
.sidebar .icon {
  width: 24px; height: 24px; display: grid; place-items: center; text-align: center;
  border-radius: 7px; background: rgba(255,255,255,.08); font-size: 14px;
}
.sidebar a.active .icon { background: var(--accent); color: #11141b; }
body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
body.sidebar-collapsed .content { margin-left: 0; }

/* Content */
.content {
  margin-left: var(--sidebar-width); padding: calc(var(--topbar-height) + 24px) 28px 48px;
  transition: margin .15s ease;
}
.page-head {
  display: flex; align-items: center; gap: 16px; margin-bottom: 18px;
  min-height: 40px;
}
.page-head h1 { margin: 0; font-size: 24px; line-height: 1.15; font-weight: 760; }
#page-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.error { color: var(--danger); }

/* Cards / stats */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 16px;
  box-shadow: var(--shadow);
}
.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.stat { min-height: 104px; display: flex; flex-direction: column; justify-content: center; }
.stat .value { font-size: 30px; line-height: 1; font-weight: 780; }
.stat .label { color: var(--muted); margin-top: 8px; font-weight: 600; }

/* Tables */
.table-wrap {
  overflow-x: auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 11px 13px; text-align: left; border-bottom: 1px solid var(--border);
  white-space: nowrap; vertical-align: middle;
}
th {
  background: var(--surface-muted); font-weight: 700; color: #394253;
  position: sticky; top: 0; box-shadow: inset 0 -1px 0 var(--border);
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--accent); }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f8fbfd; }
.skeleton td span {
  display: inline-block; height: 12px; width: 80px; background: #e2e8f0; border-radius: 4px;
  animation: pulse 1.2s infinite;
}
@keyframes pulse { 50% { opacity: .4; } }
.pager { display: flex; gap: 8px; align-items: center; padding: 12px 2px 0; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; min-height: 22px; padding: 2px 8px;
  border-radius: 999px; font-size: 12px; font-weight: 700; background: #e7edf4; color: #475467;
}
.badge.ok { background: #d1fae5; color: #065f46; }
.badge.off { background: #fee2e2; color: #991b1b; }
.badge.warn { background: #fef3c7; color: #92400e; }

/* Buttons */
.btn {
  background: var(--accent); color: #15100a; border: 1px solid transparent; border-radius: 8px;
  padding: 8px 14px; cursor: pointer; font-weight: 740;
  box-shadow: 0 8px 18px rgba(245, 158, 11, .2);
}
.btn:hover { background: var(--accent-dark); }
.btn.secondary {
  background: var(--surface); color: var(--text); border-color: var(--border-strong);
  box-shadow: none;
}
.btn.secondary:hover { background: #edf2f7; }
.btn.danger { background: var(--danger); color: #fff; box-shadow: 0 8px 18px rgba(220, 38, 38, .18); }
.btn.small { padding: 4px 10px; font-size: 13px; }

/* Forms / modal */
dialog {
  border: 1px solid var(--border); border-radius: 8px; padding: 0; min-width: 420px; max-width: 640px;
  box-shadow: 0 22px 70px rgba(15, 23, 42, .34);
}
dialog::backdrop { background: rgba(15, 23, 42, .5); }
dialog form { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
dialog h2 { margin: 0 0 4px; font-size: 18px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: #394253; font-weight: 650; }
input, select {
  padding: 9px 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff;
  color: var(--text);
}
input:focus, select:focus { outline: 3px solid rgba(36, 182, 200, .25); outline-offset: 0; border-color: var(--signal); }
select[multiple] { min-height: 110px; }
.row { display: flex; gap: 12px; }
.row > label { flex: 1; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
code.token { display: block; padding: 10px; background: #111827; color: #a7f3d0; border-radius: 8px; word-break: break-all; }

/* Login */
.login {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(circle at 50% 24%, rgba(245, 158, 11, .18), transparent 280px),
    linear-gradient(135deg, #11141b 0%, #202532 48%, #102c34 100%);
}
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 24px; }
.login-brand { display: grid; justify-items: center; gap: 6px; margin-bottom: 4px; }
.login-brand img { width: 196px; height: auto; }
.login-brand span { color: var(--muted); font-size: 13px; font-weight: 700; }
.login-submit { width: 100%; padding: 10px; }

/* Toast */
.toast {
  position: fixed; bottom: 20px; right: 20px; background: #111827; color: #fff;
  padding: 10px 16px; border-radius: 8px; z-index: 20; box-shadow: 0 18px 44px rgba(15, 23, 42, .28);
}
.toast.error { background: var(--danger); }

@media (max-width: 800px) {
  .topbar { padding: 0 12px; }
  .brand span { display: none; }
  .content { margin-left: 0; padding: calc(var(--topbar-height) + 18px) 14px 32px; }
  .page-head { align-items: flex-start; flex-direction: column; gap: 10px; }
  #page-actions { margin-left: 0; width: 100%; }
  .sidebar { transform: translateX(-100%); z-index: 9; }
  body.sidebar-open .sidebar { transform: none; }
  dialog { min-width: auto; width: calc(100vw - 24px); }
  .row { flex-direction: column; }
}
