:root {
  color-scheme: dark;
  --bg: #0d1016;
  --surface: #141923;
  --surface-2: #1a2030;
  --surface-3: #222a3c;
  --line: rgba(255, 255, 255, .08);
  --text: #f8f6fb;
  --muted: #979eae;
  --pink: #ee7daf;
  --pink-strong: #f0599c;
  --purple: #8f78ea;
  --green: #69d3a2;
  --amber: #efbf67;
  --red: #f47780;
  --shadow: 0 18px 60px rgba(0, 0, 0, .28);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); background: var(--bg); font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.login-page { display: grid; place-items: center; overflow: hidden; background:
  radial-gradient(circle at 15% 15%, rgba(238, 125, 175, .16), transparent 31%),
  radial-gradient(circle at 84% 80%, rgba(143, 120, 234, .15), transparent 30%), var(--bg); }
.login-page::before, .login-page::after { content: ""; position: fixed; width: 34rem; height: 34rem; border: 1px solid rgba(238, 125, 175, .12); border-radius: 50%; pointer-events: none; }
.login-page::before { left: -20rem; top: -17rem; }
.login-page::after { right: -20rem; bottom: -18rem; }
.login-shell { width: min(100% - 32px, 460px); }
.login-card { padding: 42px; border: 1px solid var(--line); border-radius: 28px; background: rgba(20, 25, 35, .88); box-shadow: var(--shadow); backdrop-filter: blur(24px); }
.brand-mark { display: grid; place-items: center; width: 58px; height: 58px; margin-bottom: 24px; border-radius: 18px; color: #fff; font-size: 28px; background: linear-gradient(145deg, var(--pink), var(--purple)); box-shadow: 0 12px 35px rgba(238, 125, 175, .25); }
.brand-mark.small { width: 42px; height: 42px; margin: 0; border-radius: 13px; font-size: 20px; }
.eyebrow { margin: 0 0 7px; color: var(--pink); font-size: 11px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
.login-card h1 { margin-bottom: 12px; font-size: clamp(30px, 7vw, 42px); line-height: 1.06; letter-spacing: -.04em; }
.muted { color: var(--muted); }
.login-status { display: flex; align-items: center; gap: 10px; margin: 28px 0 18px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.025); color: var(--muted); }
.status-dot { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 4px rgba(244,119,128,.11); }
.status-dot.online { background: var(--green); box-shadow: 0 0 0 4px rgba(105,211,162,.11); }
.status-dot.status-waiting { background: var(--amber); }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border: 1px solid transparent; border-radius: 11px; color: var(--text); text-decoration: none; cursor: pointer; transition: transform .16s ease, background .16s ease, border-color .16s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { color: #17111a; font-weight: 800; background: linear-gradient(135deg, #f39ac1, var(--pink)); }
.button-quiet { border-color: var(--line); background: rgba(255,255,255,.035); }
.button-danger { color: #ffdfe1; border-color: rgba(244,119,128,.26); background: rgba(244,119,128,.1); }
.button-wide { width: 100%; min-height: 48px; }
.is-disabled { opacity: .45; pointer-events: none; }
.security-note { display: grid; gap: 2px; margin-top: 24px; padding-top: 21px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.security-note strong { color: #cfd3dc; }
.login-error { margin: 14px 0 0; color: #ffc4c8; }

.app-shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 22px 16px; border-right: 1px solid var(--line); background: #10141c; z-index: 10; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 24px; }
.sidebar-brand div:last-child { display: grid; }
.sidebar-brand strong { font-size: 16px; }
.sidebar-brand span, .sidebar-footer span, .user-copy span { color: var(--muted); font-size: 11px; }
.navigation { display: grid; gap: 4px; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 11px; width: 100%; padding: 10px 12px; border: 0; border-radius: 11px; color: #b0b6c3; background: transparent; text-align: left; cursor: pointer; }
.nav-item span { width: 20px; color: #737b8e; text-align: center; }
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.035); }
.nav-item.active { color: #fff; background: linear-gradient(90deg, rgba(238,125,175,.17), rgba(143,120,234,.08)); }
.nav-item.active span { color: var(--pink); }
.nav-item[hidden] { display: none; }
.sidebar-footer { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 16px 10px 2px; border-top: 1px solid var(--line); }
.sidebar-footer div { display: grid; }
.workspace { min-width: 0; }
.topbar { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; min-height: 72px; padding: 0 28px; border-bottom: 1px solid var(--line); background: rgba(13,16,22,.85); backdrop-filter: blur(18px); z-index: 8; }
.breadcrumbs { display: grid; }
.breadcrumbs span { color: var(--muted); font-size: 11px; }
.breadcrumbs strong { font-size: 15px; }
.user-menu { display: flex; align-items: center; gap: 10px; }
.user-copy { display: grid; min-width: 110px; }
.user-avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: linear-gradient(145deg, rgba(238,125,175,.25), rgba(143,120,234,.25)); font-weight: 800; background-size: cover; background-position: center; }
.content { width: min(100%, 1500px); margin: 0 auto; padding: 28px; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.page-head h1 { margin-bottom: 5px; font-size: clamp(25px, 4vw, 34px); letter-spacing: -.035em; }
.page-head p { margin: 0; color: var(--muted); }
.grid { display: grid; gap: 16px; }
.stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.two-column { grid-template-columns: minmax(0, 1.45fr) minmax(280px, .75fr); }
.three-column { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { min-width: 0; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 8px 30px rgba(0,0,0,.12); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.card-head h2, .card-head h3 { margin: 0; font-size: 15px; }
.stat-card { position: relative; overflow: hidden; }
.stat-card::after { content: ""; position: absolute; right: -30px; bottom: -36px; width: 110px; height: 110px; border-radius: 50%; background: var(--accent, var(--pink)); opacity: .08; }
.stat-card.accent-green { --accent: var(--green); }
.stat-card.accent-purple { --accent: var(--purple); }
.stat-card.accent-amber { --accent: var(--amber); }
.stat-card.accent-red { --accent: var(--red); }
.stat-card.accent-pink { --accent: var(--pink); }
.section-gap { margin-top: 16px; }
.stat-label { color: var(--muted); font-size: 12px; }
.stat-value { display: block; margin-top: 9px; font-size: 29px; letter-spacing: -.04em; }
.stat-foot { display: block; margin-top: 10px; color: #bcc2ce; font-size: 11px; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 999px; color: #c8ced8; background: rgba(255,255,255,.055); font-size: 11px; white-space: nowrap; }
.badge.success { color: #b9f5d7; background: rgba(105,211,162,.1); }
.badge.warning { color: #fbe0ad; background: rgba(239,191,103,.1); }
.badge.danger { color: #ffc6ca; background: rgba(244,119,128,.1); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 13px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 10px; letter-spacing: .09em; text-transform: uppercase; background: rgba(255,255,255,.02); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255,255,255,.018); }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.stack { display: grid; gap: 12px; }
.item-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.item-row:last-child { border-bottom: 0; }
.item-main { min-width: 0; }
.item-main strong, .item-main span { display: block; }
.item-main span { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 7px; }
.actions .button { min-height: 33px; padding: 0 11px; font-size: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 16px; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; outline: 0; color: var(--text); background: var(--surface-2); }
input:focus, select:focus, textarea:focus { border-color: rgba(238,125,175,.55); box-shadow: 0 0 0 3px rgba(238,125,175,.08); }
textarea { min-height: 86px; resize: vertical; }
.field { display: grid; gap: 6px; }
.field label { color: #c3c8d2; font-size: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }
.empty-state, .state-card { display: grid; place-items: center; min-height: 260px; padding: 30px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.empty-state h3, .state-card h1 { margin: 12px 0 4px; color: var(--text); }
.loader { width: 30px; height: 30px; border: 3px solid rgba(255,255,255,.1); border-top-color: var(--pink); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.event-line { display: grid; grid-template-columns: 100px 1fr auto; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.event-line:last-child { border: 0; }
.event-line span { color: var(--muted); font-size: 11px; }
.toast-region { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 30; }
.toast { width: min(360px, calc(100vw - 40px)); padding: 13px 15px; border: 1px solid var(--line); border-radius: 12px; background: #222936; box-shadow: var(--shadow); }
.toast.error { border-color: rgba(244,119,128,.35); }
.toast.success { border-color: rgba(105,211,162,.35); }
.modal { width: min(620px, calc(100vw - 28px)); padding: 0; border: 1px solid var(--line); border-radius: 20px; color: var(--text); background: var(--surface); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(5,7,10,.72); backdrop-filter: blur(5px); }
.modal-head, .modal-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px; }
.modal-head { border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; }
.modal-body { display: grid; gap: 13px; max-height: 65vh; padding: 20px; overflow-y: auto; }
.modal-actions { justify-content: flex-end; border-top: 1px solid var(--line); }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: rgba(255,255,255,.035); cursor: pointer; }
.mobile-only { display: none; }
.code-block { max-height: 420px; overflow: auto; padding: 14px; border-radius: 12px; color: #cfd6e2; background: #0d1118; white-space: pre-wrap; overflow-wrap: anywhere; }

@media (max-width: 1120px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-column { grid-template-columns: 1fr; }
  .three-column { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; transform: translateX(-105%); width: 260px; transition: transform .2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: inline-grid; place-items: center; }
  .topbar { padding: 0 14px; }
  .breadcrumbs { display: none; }
  .user-copy { display: none; }
  .user-menu { gap: 6px; }
  #logout-all-button { width: 40px; padding: 0; overflow: hidden; font-size: 0; }
  #logout-all-button::after { content: "⇥"; font-size: 16px; }
  .content { padding: 20px 14px; }
  .stats-grid, .three-column, .form-grid { grid-template-columns: 1fr; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .login-card { padding: 30px 24px; }
  .event-line { grid-template-columns: 1fr; gap: 3px; }
}
