/* ============================================================
   CRIMSON — доработки UI: адаптив, a11y, гостевой режим
   ============================================================ */

button, input, select { font-family: inherit; }
button { color: inherit; }
.refresh-toggle, .user-chip, .theme-toggle, .lg, .lg-mode { font-family: var(--font); }

.stat-value {
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.stat-card.featured .stat-value {
  -webkit-text-fill-color: #fff;
  color: #fff;
}

.delta.down {
  color: #fff;
  background: linear-gradient(145deg, #6a5a58, #3a2c2a);
}
.stat-card.featured .delta.down { color: #fff; background: rgba(0,0,0,.22); }
.delta.flat {
  color: var(--ink-500);
  background: var(--paper-2);
}
.stat-card.featured .delta.flat { color: #fff; background: rgba(255,255,255,.16); }

.user-chip { position: relative; }
.stat-sub {
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-400);
  letter-spacing: .02em;
  position: relative;
  z-index: 1;
}
.cell-ip { white-space: nowrap; }
.ip-repeat {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 7px;
  border-radius: 50%;
  background: var(--red-500);
  box-shadow: 0 0 0 3px rgba(var(--red-glow), .18);
  vertical-align: middle;
  cursor: help;
}
.ip-copy {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-left: 6px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--ink-400);
  cursor: pointer;
  vertical-align: middle;
  opacity: .55;
  transition: .15s var(--ease);
}
.row:hover .ip-copy, .ip-copy:focus-visible { opacity: 1; }
.ip-copy:hover { color: var(--red-600); background: rgba(var(--red-glow), .08); border-color: var(--card-line-hi); }
.ip-copy.copied { opacity: 1; color: #2fbf71; }
.visit-no { font-family: var(--mono); font-size: 10.5px; color: var(--ink-400); }
.badge.online {
  color: #1f8f55;
  background: rgba(47, 191, 113, .14);
  border: 1px solid rgba(47, 191, 113, .35);
}
.badge.online::before {
  background: #2fbf71;
  box-shadow: 0 0 6px rgba(47, 191, 113, .7);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: transparent !important;
  background-image: none !important;
  box-shadow: 0 8px 18px -10px rgba(216, 20, 0, .55);
  overflow: hidden;
}
.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.brand-mark::after { display: none; }
html[data-theme="dark"] .badge.online { color: #7ee0a8; }
.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 168px;
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: 12px;
  box-shadow: var(--shadow-lift);
  padding: 6px;
  display: none;
  z-index: 40;
}
.flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 22px;
  height: 18px;
  padding: 0 2px;
  border-radius: 4px;
  margin-right: 8px;
  font-family: "Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji","Twemoji Mozilla",sans-serif;
  font-size: 16px;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1;
  color: inherit;
  background: transparent;
  box-shadow: none;
  vertical-align: middle;
}
.flag-img {
  display: inline-block;
  width: 20px;
  height: 15px;
  object-fit: cover;
  border-radius: 3px;
  margin-right: 8px;
  vertical-align: middle;
  box-shadow: 0 0 0 1px rgba(0,0,0,.18);
  background: var(--paper-2);
}
.flag-unknown {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 15px;
  margin-right: 8px;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  color: var(--ink-400);
  background: var(--paper-2);
  border: 1px solid var(--card-line);
  vertical-align: middle;
}
.user-chip.open .user-menu { display: block; animation: fadeIn .18s var(--ease) both; }
.user-menu button, .user-menu a {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: 0; background: transparent; cursor: pointer;
  font: 600 12.5px var(--font); color: var(--ink-700);
  padding: 8px 10px; border-radius: 8px; text-decoration: none; text-align: left;
}
.user-menu button:hover, .user-menu a:hover { background: var(--paper-2); color: var(--red-600); }

html[data-role="viewer"] .tab[data-view="settings"] { display: none; }
html[data-role="viewer"] .admin-only { display: none !important; }

.skeleton {
  background: linear-gradient(90deg, var(--paper-2) 0%, var(--card) 50%, var(--paper-2) 100%);
  background-size: 200% 100%;
  animation: sk 1.1s linear infinite;
  border-radius: 8px; color: transparent !important;
}
@keyframes sk { to { background-position: -200% 0; } }

.empty-state {
  padding: 28px 16px; text-align: center; color: var(--ink-400); font-size: 13px;
}
.empty-state b { display: block; color: var(--ink-900); font-size: 14px; margin-bottom: 6px; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.vtable { min-width: 720px; }

.live-flag.paused b { color: var(--ink-400); }
.live-flag.paused .live-dot { background: var(--ink-400); animation: none; box-shadow: none; }

.file-drop {
  margin: 0 0 16px;
  border: 1px dashed var(--card-line-hi);
  border-radius: var(--r-md);
  padding: 16px;
  text-align: center;
  color: var(--ink-500);
  font-size: 12.5px;
  background: var(--paper);
  cursor: pointer;
  transition: .2s var(--ease);
}
.file-drop:hover, .file-drop.over {
  border-color: var(--red-500);
  background: rgba(var(--red-glow), .06);
  color: var(--red-600);
}
.file-drop input { display: none; }

.guest-pw { word-break: break-all; }

:focus-visible {
  outline: 2px solid var(--red-500);
  outline-offset: 2px;
}

.confirm-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(10, 8, 12, .62);
  display: grid; place-items: center;
  padding: 20px;
}
.confirm-overlay[hidden] { display: none !important; }
.confirm-overlay.open {
  display: grid !important;
  z-index: 9999;
}
.confirm-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: 16px;
  box-shadow: var(--shadow-lift);
  padding: 22px 20px 18px;
}
.confirm-title { font-family: var(--display); font-size: 18px; margin-bottom: 8px; }
.confirm-text { color: var(--ink-500); font-size: 13.5px; line-height: 1.5; margin: 0 0 18px; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 1080px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat-card.featured { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  body { padding: 8px 12px 28px; }
  .stats { grid-template-columns: 1fr; }
  .header-controls { width: 100%; }
  .seg { width: 100%; }
  .seg-btn { flex: 1; }
  .refresh-toggle { width: 100%; justify-content: center; }
  .chart-wrap { height: 210px; }
  .vtable { min-width: 640px; }
  .cell-os, .cell-br { display: table-cell; }
  .vtable thead th:nth-child(6),
  .vtable thead th:nth-child(7),
  .vtable thead th:nth-child(8) { display: table-cell; }
  .toast-wrap { left: 12px; right: 12px; bottom: 12px; }
  .toast { max-width: none; }
}
@media (max-width: 480px) {
  .brand-sub { display: none; }
  .topbar { font-size: 10px; }
}
