:root {
  --bg: #0f1720;
  --panel: #16212e;
  --panel-2: #1d2a3a;
  --text: #e6edf3;
  --muted: #8b9bb0;
  --line: #263445;
  --brand: #4aa3ff;
  --ok: #2ea043;
  --warn: #d29922;
  --alert: #f85149;
  --nodata: #6e7681;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display:flex; align-items:center; gap:10px; font-weight:700; font-size:18px; color:#43ac3c; text-decoration:none; }
.brand-logo { height:20px; max-width:295px; }
.brand-text small { font-weight:400; font-size:12px; color:var(--muted); display:block; }
.topbar nav a { color: var(--muted); text-decoration: none; margin-left: 18px; padding: 5px 10px; border-radius: 6px; }
.topbar nav a:hover, .topbar nav a.active { background: var(--panel-2); color: var(--text); }

.container { max-width: 960px; margin: 24px auto; padding: 0 16px; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 20px 22px; margin-bottom: 20px;
}
/* --- Фиксация области на странице Загрузки --- */
body.page-fill { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
body.page-fill .container { flex: 1; overflow: hidden; display: flex; flex-direction: column; min-height: 0; max-width: 960px; width: 100%; margin: 24px auto; padding: 0 16px; }
body.page-fill .card-scroll { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0; margin-bottom: 0; }
body.page-fill .card-scroll h2 { flex-shrink: 0; }
body.page-fill .card-scroll h1 { flex-shrink: 0; }
body.page-fill .admin-nav { flex-shrink: 0; }
body.page-fill .card:not(.card-scroll) { flex-shrink: 0; }
body.page-fill .table-wrap { flex: 1; overflow-y: auto; min-height: 0; }
body.page-fill .table-wrap thead th { position: sticky; top: 0; background: var(--panel); z-index: 2; }
/* скрытый скроллбар — проявляется при наведении */
body.page-fill .table-wrap { scrollbar-width: thin; scrollbar-color: transparent transparent; }
body.page-fill .table-wrap:hover { scrollbar-color: var(--line) transparent; }
body.page-fill .table-wrap::-webkit-scrollbar { width: 5px; }
body.page-fill .table-wrap::-webkit-scrollbar-track { background: transparent; }
body.page-fill .table-wrap::-webkit-scrollbar-thumb { background: transparent; border-radius: 10px; }
body.page-fill .table-wrap:hover::-webkit-scrollbar-thumb { background: var(--line); }
h1 { margin: 0 0 8px; font-size: 22px; }
h2 { margin: 0 0 12px; font-size: 17px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin-top: 10px; }
.rowline { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.upload { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.upload input[type=file] {
  flex: 1; min-width: 220px; padding: 10px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px; color: var(--text);
}
button, .btn-link {
  background: var(--brand); color: #04121f; border: none; cursor: pointer;
  padding: 10px 16px; border-radius: 8px; font-weight: 600; text-decoration: none;
}
.btn-link { background: transparent; color: var(--brand); padding: 6px 10px; }
button:hover { filter: brightness(1.08); }
button:active { transform: scale(0.97); filter: brightness(0.92); transition: transform 0.1s; }
button.loading { pointer-events: none; opacity: 0.8; }
.btn-loader { display: none; width: 16px; height: 16px; border: 2px solid rgba(4,18,31,0.25); border-top-color: #04121f; border-radius: 50%; animation: spin 0.6s linear infinite; vertical-align: middle; margin-right: 6px; flex-shrink: 0; }
button.loading .btn-loader { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.grid { width: 100%; border-collapse: collapse; margin-top: 8px; }
.grid th, .grid td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
.grid th { color: var(--muted); font-weight: 600; font-size: 13px; }
.grid td.num, .grid th.num { text-align: right; font-variant-numeric: tabular-nums; }

.summary { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; color: #04121f;
}
.flag-ok { background: var(--ok); }
.flag-warn { background: var(--warn); }
.flag-alert { background: var(--alert); }
.flag-no_data { background: var(--nodata); color: var(--text); }

.row-alert { background: rgba(248, 81, 73, 0.10); }
.row-warn  { background: rgba(210, 153, 34, 0.10); }

.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 24px; }

/* --- Admin --- */
.admin-nav { display: flex; align-items: center; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; }
.admin-nav a { color: var(--muted); text-decoration: none; padding: 5px 10px; border-radius: 6px; font-size: 14px; }
.admin-nav a.active, .admin-nav a:hover { background: var(--panel-2); color: var(--text); }
.admin-nav .right { margin-left: auto; }
.flash-error { background: var(--alert); color: #04121f; padding: 8px 12px; border-radius: 8px; font-weight: 600; margin-bottom: 12px; }
.login-flash { margin-top:16px; margin-bottom:0; text-align:center; animation: fadeInOut 5s ease forwards; }
@keyframes fadeInOut {
  0% { opacity:0; transform:translateY(-8px); }
  10% { opacity:1; transform:translateY(0); }
  80% { opacity:1; }
  100% { opacity:0; }
}
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { color: var(--muted); font-size: 13px; }
.field input[type=text], .field input[type=password], select { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); padding: 8px 10px; border-radius: 8px; }
select { cursor: pointer; }

/* --- Монитор: плитки --- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.tile { }
.tile-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.tile-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; background: var(--panel-2); border-radius: 8px;
}
.tile-name { font-weight: 600; min-width: 80px; }
.tile-role { font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.pill-admin { background: #4aa3ff; color: #04121f; }
.pill-manager { background: #d29922; color: #04121f; }
.pill-operator { background: #495a6e; color: var(--text); }
.tile-time { margin-left: auto; color: var(--muted); font-size: 13px; }
/* Статистика: таблица */
.tile-table { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.tile-table-header {
  display: flex; gap: 0;
  color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 0 10px 4px; border-bottom: 1px solid var(--line);
}
.tile-table-header span:nth-child(1) { flex: 2; padding: 0 10px; }
.tile-table-header span:nth-child(2) { flex: 1; text-align: center; padding: 0 10px; }
.tile-table-header span:nth-child(3) { flex: 1.5; text-align: right; padding: 0 10px; }
.tile-table-row {
  display: flex; align-items: stretch; gap: 0;
  padding: 0; background: var(--panel-2); border-radius: 8px; overflow: hidden;
  flex-wrap: nowrap;
}
.tile-user { flex: 2; display: flex; align-items: center; gap: 8px; font-weight: 600; padding: 10px 10px 10px 10px; border-right: 1px solid var(--line); }
.tile-count { flex: 1; display: flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; padding: 10px 10px; border-right: 1px solid var(--line); }
.tile-count strong { font-size: 16px; }
.tile-last { flex: 1.5; display: flex; align-items: center; justify-content: flex-end; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; padding: 10px 10px 10px 10px; }

.dot-online {
  display: inline-block; width: 8px; height: 8px;
  background: var(--ok); border-radius: 50%; margin-left: 6px; vertical-align: middle;
}
