:root, :root[data-theme="dark"] {
  --bg: #0a0f1c; --bg-alt: #111827; --surface: #1e293b; --surface-alt: #172033;
  --text: #f1f5f9; --text-muted: #94a3b8;
  --accent: #009ddc; --accent-light: #4fc3f0; --accent-orange: #fd8000;
  --accent-gradient: linear-gradient(135deg, #009ddc 0%, #fd8000 100%);
  --border: #2a374d; --shadow: 0 10px 30px rgba(0,0,0,.35);
  --green: #4ade80; --red: #f87171; --yellow: #fbbf24;
}
:root[data-theme="light"] {
  --bg: #dfe5f0; --bg-alt: #eef1f8; --surface: #ffffff; --surface-alt: #f1f4fa;
  --text: #0f172a; --text-muted: #5c6b82;
  --accent: #009ddc; --accent-light: #0077a8; --accent-orange: #fd8000;
  --accent-gradient: linear-gradient(135deg, #009ddc 0%, #fd8000 100%);
  --border: #dde3ee; --shadow: 0 10px 30px rgba(15,23,42,.1);
  --green: #16a34a; --red: #dc2626; --yellow: #b45309;
}
:root { --radius: 16px; --radius-sm: 10px; color-scheme: light dark; }
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: var(--accent-light); text-decoration: none; }
.muted { color: var(--text-muted); }

/* ---- Login (centered) ---- */
.center { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px 28px; }
.card.narrow { max-width: 400px; width: 100%; }
.logo-wrap { text-align: center; margin-bottom: 8px; }
.logo-wrap img { height: 46px; }

h1 { margin: 0 0 6px; font-size: 1.5rem; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
.sub { color: var(--text-muted); margin: 0 0 20px; font-size: .92rem; }

label { display: block; font-size: .8rem; color: #b9c2d8; margin: 12px 0 6px; }
input, select, textarea { width: 100%; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-alt); color: var(--text); font-size: .93rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 15px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  font-size: .9rem; font-weight: 600; cursor: pointer; background: var(--surface-alt); color: var(--text); }
.btn.primary { background: var(--accent-gradient); border: none; color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; border-color: #5c2b33; color: #ff9aa6; }
.btn.sm { padding: 5px 10px; font-size: .8rem; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.block { width: 100%; }

.err { color: #ff9aa6; font-size: .85rem; margin-top: 10px; min-height: 1em; }
.ok { color: var(--green); }

/* ---- App shell (sidebar) ---- */
.sidebar { position: fixed; top: 0; left: 0; width: 216px; height: 100vh; overflow-y: auto;
  background: var(--bg-alt); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 16px 12px; }
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px; }
.sidebar .brand img { height: 30px; }
.sidebar .brand span { font-weight: 700; font-size: .98rem; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: .9rem; font-weight: 500; }
.sidebar nav a .ic { width: 20px; text-align: center; }
.sidebar nav a:hover { background: var(--surface-alt); color: var(--text); }
.sidebar nav a.active { background: var(--accent-gradient); color: #fff; }
.sidebar .spacer { flex: 1; }
.sidebar .me { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--border);
  padding-top: 12px; margin-top: 4px; color: var(--text); text-decoration: none; }
.sidebar .me:hover { color: var(--accent-light); }
.sidebar .me .nm { font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .me .rl { font-size: .72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0; border: 1px solid var(--border); }
.avatar.ph { display: grid; place-items: center; background: var(--accent-gradient); color: #fff; font-weight: 700; }
.thumb { border-radius: 8px; object-fit: cover; background: var(--surface-alt); border: 1px solid var(--border); vertical-align: middle; }
.thumb.ph { display: inline-grid; place-items: center; font-size: .9rem; }

/* Compact floating cluster in the top-right corner (like the old site). */
.topbar { position: fixed; top: 14px; right: 20px; left: auto; z-index: 150;
  display: flex; align-items: center; gap: 8px; padding: 0; background: none; border: none; }
.iconbtn { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font-size: 1rem; line-height: 1; }
.iconbtn:hover { border-color: var(--accent-light); }
.topbar .userchip { display: flex; }
.topbar .userchip .avatar { width: 34px; height: 34px; }

.content { margin-left: 216px; padding: 60px 28px 28px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-top: 18px; }
.mod { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: block; }
.mod:hover { border-color: var(--accent); }
.mod .ic { font-size: 1.6rem; }
.mod .t { font-weight: 700; margin: 8px 0 4px; color: var(--text); }
.mod .d { font-size: .82rem; color: var(--text-muted); }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin: 16px 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat .n { font-size: 1.6rem; font-weight: 700; }
.stat .l { font-size: .72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }

.badge { font-size: .66rem; text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-muted); }
.badge.ready { color: var(--green); border-color: rgba(74,222,128,.4); }
.badge.soon { color: var(--accent-orange); border-color: rgba(253,128,0,.4); }
.badge.admin { color: var(--accent-light); border-color: rgba(79,195,240,.4); }

table { width: 100%; border-collapse: collapse; margin-top: 12px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: .88rem; }
th { color: var(--text-muted); font-weight: 600; font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-alt); }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row > div { flex: 1; min-width: 130px; }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none; place-items: center; padding: 16px; z-index: 50; }
.modal-bg.show { display: grid; }
.modal-bg .card { max-width: 460px; width: 100%; max-height: 90vh; overflow-y: auto; }

@media (max-width: 720px) {
  .sidebar { position: static; width: 100%; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar .spacer, .sidebar .me { display: none; }
  .topbar { position: static; top: auto; left: auto; right: auto; padding: 10px 16px; justify-content: flex-end; }
  .content { margin-left: 0; padding: 16px; }
}
