/* Скомпилированная тёмная тема Torrez Panel (статический CSS, без сборки в рантайме).
   Пересборка при желании: bunx @tailwindcss/cli -i tailwind.input.css -o static/css/style.css */

:root {
  --bg: #050505;
  --bg2: #0b0b0c;
  --card: #121214;
  --card2: #1a1a1d;
  --border: #2c2224;
  --text: #ece6e7;
  --muted: #9c8d90;
  --accent: #dc143c;
  --accent2: #ff4d6d;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  background: radial-gradient(1200px 600px at 20% -10%, #2a070f 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  min-height: 100vh;
}
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* -------- layout -------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex-shrink: 0; background: var(--bg2);
  border-right: 1px solid var(--border); padding: 16px 12px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .logo { display:flex; align-items:center; gap:10px; padding: 4px 8px 16px; }
.sidebar .logo img { width: 42px; height: 42px; border-radius: 10px; }
.sidebar .logo span { font-weight: 700; letter-spacing: .5px; font-size: 1.05rem; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: 8px; color: var(--muted); font-size: .95rem;
}
.nav-link:hover { background: var(--card); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent); color: #fff; }
.nav-link .badge { margin-left: auto; }
.nav-section { margin: 12px 8px 4px; font-size: .72rem; text-transform: uppercase;
  letter-spacing: 1px; color: var(--muted); opacity: .7; }
.main { flex: 1; padding: 24px 28px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.topbar h1 { font-size: 1.45rem; font-weight: 700; }
.userchip { display:flex; align-items:center; gap:10px; background: var(--card);
  border:1px solid var(--border); padding:6px 12px; border-radius: 999px; }
.userchip img { width:28px; height:28px; border-radius:50%; }
.userchip .rank { color: var(--muted); font-size:.82rem; }

/* -------- components -------- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin-bottom: 18px;
}
.card h2 { font-size: 1.05rem; margin-bottom: 12px; font-weight: 600; }
.card h3 { font-size: .95rem; margin: 10px 0 8px; color: var(--muted); }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.stat { display:flex; flex-direction:column; gap:4px; }
.stat .value { font-size: 1.7rem; font-weight: 700; }
.stat .label { color: var(--muted); font-size: .85rem; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: #fff; border: none; cursor: pointer;
  border-radius: 8px; padding: 8px 16px; font-size: .92rem; font-weight: 500;
  transition: filter .15s;
}
.btn:hover { filter: brightness(1.15); text-decoration: none; }
.btn.secondary { background: var(--card2); border: 1px solid var(--border); color: var(--text); }
.btn.success { background: var(--success); }
.btn.danger { background: var(--danger); }
.btn.warning { background: var(--warning); color: #1a1204; }
.btn.sm { padding: 4px 10px; font-size: .82rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: .75rem; font-weight: 600; background: var(--card2);
  border: 1px solid var(--border); color: var(--muted);
}
.badge.blue { background: rgba(220,20,60,.18); color: #ff8fa3; border-color: rgba(220,20,60,.45); }
.badge.green { background: rgba(34,197,94,.15); color: #86efac; border-color: rgba(34,197,94,.35); }
.badge.red { background: rgba(239,68,68,.15); color: #fca5a5; border-color: rgba(239,68,68,.35); }
.badge.yellow { background: rgba(245,158,11,.15); color: #fcd34d; border-color: rgba(245,158,11,.35); }
.badge.purple { background: rgba(139,92,246,.15); color: #c4b5fd; border-color: rgba(139,92,246,.35); }

table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: .78rem;
  text-transform: uppercase; letter-spacing: .5px;
  padding: 8px 10px; border-bottom: 1px solid var(--border);
}
.table td { padding: 9px 10px; border-bottom: 1px solid rgba(37,49,89,.5); vertical-align: middle; }
.table tr:hover td { background: rgba(26,37,71,.5); }

input, select, textarea {
  background: var(--bg2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px; font-size: .92rem; width: 100%;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
input[type="checkbox"] { width: auto; accent-color: var(--accent); transform: scale(1.15); }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .field { flex: 1; min-width: 180px; }

.alert { border-radius: 8px; padding: 12px 16px; margin-bottom: 14px; font-size: .9rem;
  border: 1px solid; }
.alert.info { background: rgba(220,20,60,.12); border-color: rgba(220,20,60,.4); color: #ffb3c1; }
.alert.warning { background: rgba(245,158,11,.1); border-color: rgba(245,158,11,.35); color: #fde68a; }
.alert.danger { background: rgba(239,68,68,.1); border-color: rgba(239,68,68,.35); color: #fecaca; }
.alert.success { background: rgba(34,197,94,.1); border-color: rgba(34,197,94,.35); color: #bbf7d0; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab { padding: 8px 16px; color: var(--muted); border-radius: 8px 8px 0 0; cursor: pointer;
  border-bottom: 2px solid transparent; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--accent2); border-bottom-color: var(--accent); }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.dot.green { background: var(--success); box-shadow: 0 0 6px var(--success); }
.dot.red { background: var(--danger); box-shadow: 0 0 6px var(--danger); }
.dot.yellow { background: var(--warning); }

.muted { color: var(--muted); }
.small { font-size: .82rem; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
.mb0 { margin-bottom: 0; }
.mt { margin-top: 14px; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-between { display:flex; align-items:center; justify-content: space-between; gap:10px; }
.wrap { flex-wrap: wrap; }
.right { margin-left: auto; }
.center { text-align: center; }
.w-auto { width: auto; }

/* toasts */
#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100;
  display: flex; flex-direction: column; gap: 10px; max-width: 380px; }
.toast { background: var(--card2); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: 8px; padding: 12px 16px; box-shadow: 0 8px 30px rgba(0,0,0,.45);
  animation: slidein .25s ease; }
.toast.warning { border-left-color: var(--warning); }
.toast.error, .toast.critical { border-left-color: var(--danger); }
.toast .t-title { font-weight: 600; font-size: .9rem; }
.toast .t-body { color: var(--muted); font-size: .82rem; margin-top: 2px; }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 380px; text-align: center; padding: 40px 32px; }
.login-card img.logo { width: 120px; height: 120px; border-radius: 20px; margin-bottom: 18px;
  box-shadow: 0 0 60px rgba(220,20,60,.45); }
.login-card h1 { font-size: 1.4rem; margin-bottom: 6px; }
.login-card p { color: var(--muted); margin-bottom: 22px; font-size: .9rem; }

/* embed preview */
.embed-preview { background: #2b2d31; border-radius: 6px; padding: 14px 16px;
  border-left: 4px solid var(--accent); max-width: 480px; }
.embed-preview .ep-title { font-weight: 700; margin-bottom: 6px; color: #fff; }
.embed-preview .ep-desc { font-size: .88rem; color: #dbdee1; white-space: pre-wrap; }
.embed-preview .ep-footer { font-size: .74rem; color: #949ba4; margin-top: 10px; }
.embed-preview .ep-field { margin-top: 8px; }
.embed-preview .ep-field .name { font-weight: 600; font-size: .85rem; color: #fff; }
.embed-preview .ep-field .value { font-size: .85rem; color: #dbdee1; }

/* logs */
.logbox { background: #0a0e1c; border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; max-height: 65vh; overflow: auto; font-family: ui-monospace, Consolas, monospace;
  font-size: .78rem; line-height: 1.5; white-space: pre-wrap; word-break: break-all; }
.logbox .warn { color: var(--warning); }
.logbox .err { color: var(--danger); }

/* rbac matrix */
.rbac-table td.center input { margin: 0 auto; display: block; }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; }
  .main { padding: 16px; }
}

/* ==================== ТЕМЫ (data-theme на <html>) ==================== */
/* По умолчанию: crimson (тёмно-багровая) — переменные в :root выше */

html[data-theme="midnight"] {
  --bg: #0b1020; --bg2: #101731; --card: #141d3a; --card2: #1a2547;
  --border: #253159; --text: #dbe4ff; --muted: #8b9bc7;
  --accent: #3b82f6; --accent2: #60a5fa;
}
html[data-theme="midnight"] body { background: radial-gradient(1200px 600px at 20% -10%, #16224a 0%, var(--bg) 55%) fixed; }

html[data-theme="emerald"] {
  --bg: #04100a; --bg2: #081711; --card: #0d1f17; --card2: #12291e;
  --border: #1e3a2c; --text: #e2f5ea; --muted: #8fb8a2;
  --accent: #10b981; --accent2: #34d399;
}
html[data-theme="emerald"] body { background: radial-gradient(1200px 600px at 20% -10%, #0a2e1e 0%, var(--bg) 55%) fixed; }

html[data-theme="violet"] {
  --bg: #0c0714; --bg2: #130b20; --card: #1a102c; --card2: #221539;
  --border: #34215a; --text: #ece4fb; --muted: #a292c7;
  --accent: #8b5cf6; --accent2: #a78bfa;
}
html[data-theme="violet"] body { background: radial-gradient(1200px 600px at 20% -10%, #241040 0%, var(--bg) 55%) fixed; }

html[data-theme="amber"] {
  --bg: #120c02; --bg2: #1c1305; --card: #241a08; --card2: #2e210b;
  --border: #4a3a14; --text: #f7eeda; --muted: #bda677;
  --accent: #f59e0b; --accent2: #fbbf24;
}
html[data-theme="amber"] body { background: radial-gradient(1200px 600px at 20% -10%, #3a2905 0%, var(--bg) 55%) fixed; }

html[data-theme="steel"] {
  --bg: #0d0f12; --bg2: #14171c; --card: #1b1f26; --card2: #232830;
  --border: #333a45; --text: #e8ebef; --muted: #97a1ae;
  --accent: #64748b; --accent2: #94a3b8;
}
html[data-theme="steel"] body { background: radial-gradient(1200px 600px at 20% -10%, #232c38 0%, var(--bg) 55%) fixed; }

/* часы */
#clock {
  position: fixed; left: 16px; bottom: 14px; z-index: 60;
  background: var(--card2); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 14px; font-family: ui-monospace, Consolas, monospace;
  font-size: .95rem; box-shadow: 0 6px 24px rgba(0,0,0,.4);
}
#clock .tz { color: var(--muted); font-size: .7rem; margin-left: 6px; }
@media (max-width: 900px) { #clock { display: none; } }

/* мульти-чекбокс дропдаун */
.msel { position: relative; }
.msel-btn { cursor: pointer; user-select: none; min-width: 130px; text-align: left; }
.msel-list {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 50; min-width: 180px;
  background: var(--card2); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px; box-shadow: 0 10px 34px rgba(0,0,0,.5);
}
.msel-list label { display: flex; align-items: center; gap: 8px; padding: 5px 6px;
  margin: 0; color: var(--text); font-size: .88rem; border-radius: 6px; cursor: pointer; }
.msel-list label:hover { background: var(--card); }

/* колесо удачи */
.wheel-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; }
#wheel-canvas { border-radius: 50%; box-shadow: 0 0 40px rgba(0,0,0,.55), 0 0 80px color-mix(in srgb, var(--accent) 35%, transparent); }
.wheel-pointer { width: 0; height: 0; border-left: 16px solid transparent;
  border-right: 16px solid transparent; border-top: 26px solid var(--accent2); margin-bottom: -6px; z-index: 2; }
.wheel-winner { font-size: 1.5rem; font-weight: 800; color: var(--accent2); min-height: 2rem; }

/* ---------- №29: мобильная вёрстка ---------- */
@media (max-width: 768px) {
  .grid, .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr !important; }
  .form-row { flex-direction: column; }
  .form-row .field { width: 100%; }
  /* таблицы: горизонтальный скролл вместо расползания */
  .card { overflow-x: auto; }
  .table { min-width: 560px; }
  .table th, .table td { padding: 6px 8px; font-size: 13px; }
  /* компактные кнопки в ячейках */
  .table .btn.sm { padding: 4px 8px; }
  h1, .page-title { font-size: 20px; }
}
@media (max-width: 480px) {
  .table { min-width: 480px; }
  .toast { max-width: 90vw; }
}
