:root {
  --bg: #07111f;
  --bg2: #0c1a30;
  --card: #0f2340;
  --ink: #e6f0ff;
  --muted: #7b93b8;
  --accent: #60a5fa;
  --accent-2: #3b82f6;
  --line: #1e3a63;
  --line2: #264a7a;
  --ok: #4ade80;
  --ok-dim: #166534;
  --bad: #f87171;
  --glow: rgba(59, 130, 246, 0.28);
  --radius: 10px;
  font-family: "Segoe UI", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(1100px 480px at 8% -12%, #123066 0%, transparent 55%),
    radial-gradient(800px 360px at 92% 0%, #0d2a55 0%, transparent 50%),
    var(--bg);
}

a { color: var(--accent); }
[hidden] { display: none !important; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 17, 31, 0.88);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.brand-mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(165deg, #3b82f6, #1d4ed8);
  box-shadow: 0 0 12px var(--glow);
  flex-shrink: 0;
}
.brand h1 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
  letter-spacing: 0.02em;
}
.brand p { margin: 0; color: var(--muted); font-size: 0.7rem; }
.tabs { display: flex; gap: 0.3rem; }
.tab {
  padding: 0.38rem 0.75rem;
  border-radius: 7px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.8rem;
  border: 1px solid transparent;
}
.tab:hover { color: var(--ink); border-color: var(--line); }
.tab.active {
  color: var(--ink);
  background: var(--card);
  border-color: var(--line2);
}
.topbar-actions { display: flex; gap: 0.4rem; align-items: center; }

.container { max-width: 1120px; margin: 0 auto; padding: 0.85rem 1rem 1.4rem; }

.card {
  background: linear-gradient(180deg, var(--card) 0%, var(--bg2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 0.95rem;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.card-head h2, .card h2 { margin: 0; font-size: 0.95rem; font-weight: 650; }
.hint { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.75rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.42rem 0.75rem;
  border-radius: 7px;
  border: 1px solid var(--line2);
  background: linear-gradient(180deg, #1e4a8a, #163a6e);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
}
.btn:hover { border-color: var(--accent); }
.btn-ghost {
  background: transparent;
  color: var(--muted);
}
.btn-primary {
  background: linear-gradient(180deg, #3b82f6, #1d4ed8);
  border-color: #60a5fa;
  color: #fff;
}
.btn-danger {
  background: linear-gradient(180deg, #7f1d1d, #450a0a);
  border-color: #ef4444;
  color: #fecaca;
}
.btn-icon {
  width: 2rem;
  height: 2rem;
  padding: 0;
  font-size: 1.15rem;
  line-height: 1;
}

.user-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.55rem;
}
.user-card {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  padding: 0.65rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 20, 40, 0.55);
}
.user-meta { min-width: 0; flex: 1; }
.btn-edit {
  margin-left: auto;
  flex-shrink: 0;
  opacity: 0.65;
  font-size: 0.9rem;
}
.btn-edit:hover { opacity: 1; }
.badge-off {
  background: rgba(248, 113, 113, 0.15);
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.35);
}
input.readonly {
  opacity: 0.7;
  cursor: default;
}
.check-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.75rem;
  color: var(--ink);
  font-size: 0.8rem;
  cursor: pointer;
}
.check-row input { width: auto; margin: 0; }
.avatar, .avatar.placeholder {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.avatar.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(165deg, #1e4a8a, #0f2a52);
  color: #93c5fd;
  font-size: 0.75rem;
  font-weight: 650;
}
.avatar-sm, .avatar-sm.placeholder {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.avatar-sm.placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #1e4a8a;
  color: #93c5fd;
  font-size: 0.58rem;
  font-weight: 650;
}
.user-name { font-weight: 650; font-size: 0.86rem; }
.user-sub { color: var(--muted); font-size: 0.72rem; margin-top: 0.12rem; }
.badge {
  display: inline-block;
  margin-top: 0.28rem;
  padding: 0.08rem 0.4rem;
  border-radius: 999px;
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
  border: 1px solid rgba(96, 165, 250, 0.25);
}

.matrix-wrap { overflow-x: auto; }
.matrix {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}
.matrix th, .matrix td {
  padding: 0.55rem 0.45rem;
  border-bottom: 1px solid rgba(30, 58, 99, 0.7);
  vertical-align: middle;
}
.matrix th {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}
.user-cell {
  min-width: 170px;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
}
.matrix-cell { text-align: center; width: 112px; }

.cell-issue { margin: 0; }
.cell-empty {
  width: 100%;
  min-height: 32px;
  border: 1px dashed var(--line2);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
}
.cell-empty:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(59, 130, 246, 0.08);
}
.cell-na { display: block; min-height: 32px; }

.badge-active {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 68px;
  max-width: 100%;
  padding: 0.28rem 0.6rem;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #22c55e, #15803d);
  color: #ecfdf5;
  text-decoration: none;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 0 10px rgba(74, 222, 128, 0.22);
}
.badge-active:hover { filter: brightness(1.08); }

.slot-item {
  border: 1px solid var(--line2);
  border-radius: 10px;
  padding: 0.7rem 0.75rem 0.5rem;
  margin-bottom: 0.7rem;
}
.slot-item:last-of-type { margin-bottom: 0.9rem; }
.slot-item-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.slot-item-title { font-weight: 650; font-size: 0.85rem; }
.slot-item .stats-list { margin: 0.5rem 0 0.6rem; }

.stats-list {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 0.4rem 0.8rem;
  margin: 0.85rem 0 1rem;
  font-size: 0.82rem;
}
.stats-list dt { color: var(--muted); }
.stats-list dd { margin: 0; }
.actions-row { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }

dialog.sheet {
  width: min(440px, 94vw);
  padding: 0;
  border: 1px solid var(--line2);
  border-radius: 12px;
  background: linear-gradient(180deg, #122848, #0c1a30);
  color: var(--ink);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}
dialog.sheet::backdrop { background: rgba(4, 10, 22, 0.72); }
.sheet-body { padding: 1rem 1.05rem 1.05rem; }
.sheet-body h3 { margin: 0 0 0.75rem; font-size: 0.95rem; }
.modal-tabs { display: flex; gap: 0.3rem; margin-bottom: 0.75rem; }
.modal-tabs .btn.active {
  background: linear-gradient(180deg, #3b82f6, #1d4ed8);
  border-color: #60a5fa;
  color: #fff;
}

label { display: block; margin: 0.65rem 0 0.28rem; font-size: 0.75rem; color: var(--muted); }
input[type="text"],
input[type="password"],
input[type="email"] {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border-radius: 7px;
  border: 1px solid var(--line2);
  background: #0a1528;
  color: var(--ink);
  font: inherit;
}
input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus {
  outline: 1px solid var(--accent);
}
.file-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.2rem 0 0.55rem;
  cursor: pointer;
}
.file-btn input { display: none; }
.file-name { color: var(--muted); font-size: 0.72rem; }
.avatar-paste {
  border: 1px dashed var(--line2);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  color: var(--muted);
  font-size: 0.75rem;
  margin: 0.25rem 0 0.5rem;
  cursor: text;
  background: #0a1528;
}
.avatar-paste:focus { outline: 1px solid var(--accent); }
.sheet-actions { display: flex; gap: 0.4rem; margin-top: 0.85rem; }

.alert {
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  margin-bottom: 0.7rem;
  font-size: 0.8rem;
}
.alert-error { background: #3f1515; border: 1px solid #7f1d1d; }
.alert-success { background: #14532d; border: 1px solid #166534; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-card { width: min(380px, 100%); }
.login-card h1 { margin: 0 0 0.2rem; font-size: 1.15rem; }
.login-card .btn { margin-top: 0.95rem; width: 100%; }
code {
  background: #0a1528;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.78rem;
}
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 0.8rem; }

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}
@media (max-width: 900px) {
  .settings-grid { grid-template-columns: 1fr; }
}
.settings-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.settings-form textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line2);
  border-radius: 8px;
  background: #0a1528;
  color: var(--ink);
  padding: 0.55rem 0.65rem;
  line-height: 1.35;
}
.live-blocks details {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 0.55rem;
  background: rgba(8, 20, 40, 0.45);
  overflow: hidden;
}
.live-blocks summary {
  cursor: pointer;
  padding: 0.55rem 0.7rem;
  color: var(--ink);
  font-size: 0.78rem;
}
.live-pre {
  margin: 0;
  padding: 0.65rem 0.75rem;
  max-height: 28rem;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border-top: 1px solid var(--line);
  background: #07101d;
  color: #c9daf8;
  font-size: 0.72rem;
  line-height: 1.4;
}
.row-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

