:root {
  color-scheme: dark;
  --bg: #090d14;
  --surface: #101722;
  --surface-raised: #151e2c;
  --surface-soft: #0d131d;
  --border: #263244;
  --border-soft: #1c2737;
  --text: #f5f7fb;
  --muted: #91a0b5;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, .13);
  --success: #36c98f;
  --warning: #f4b942;
  --danger: #f06a75;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 85% -20%, #162947 0, transparent 35rem), var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }
pre { max-height: 520px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
button, input, textarea, select { font: inherit; }
button, .button { cursor: pointer; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 28px 20px; border-right: 1px solid var(--border-soft); background: rgba(8, 12, 19, .9); backdrop-filter: blur(18px); }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 26px; font-weight: 720; letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 11px; background: linear-gradient(145deg, #60a5fa, #2563eb); box-shadow: 0 10px 32px rgba(37, 99, 235, .25); }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.nav { display: grid; gap: 5px; }
.nav a { display: flex; gap: 11px; align-items: center; min-height: 42px; padding: 0 12px; border-radius: 10px; color: var(--muted); font-size: 14px; font-weight: 590; }
.nav a:hover, .nav a.active { color: var(--text); background: var(--accent-soft); }
.nav .icon { width: 20px; color: #9ec5ff; text-align: center; }
.sidebar-foot { position: absolute; left: 20px; right: 20px; bottom: 24px; color: #64748b; font-size: 12px; }

.main { min-width: 0; padding: 34px clamp(24px, 4vw, 58px) 70px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.eyebrow { margin: 0 0 6px; color: #79adfb; font-size: 12px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(28px, 4vw, 42px); line-height: 1.08; letter-spacing: -.045em; }
.lead { max-width: 720px; margin: 9px 0 0; color: var(--muted); line-height: 1.55; }
.user { display: flex; align-items: center; gap: 10px; padding: 7px 8px 7px 12px; border: 1px solid var(--border); border-radius: 999px; background: rgba(16, 23, 34, .75); color: var(--muted); font-size: 13px; white-space: nowrap; }
.avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: #9ec5ff; font-weight: 750; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { min-width: 0; padding: 21px; border: 1px solid var(--border-soft); border-radius: var(--radius); background: linear-gradient(160deg, rgba(21, 30, 44, .94), rgba(14, 20, 30, .94)); box-shadow: 0 18px 60px rgba(0, 0, 0, .12); }
.card h2, .card h3 { margin: 0; letter-spacing: -.025em; }
.card h2 { font-size: 18px; }
.card h3 { font-size: 15px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
.section { margin-top: 24px; }
.metric { min-height: 136px; display: flex; flex-direction: column; justify-content: space-between; }
.metric .label { color: var(--muted); font-size: 13px; }
.metric .value { margin-top: 12px; font-size: 29px; font-weight: 730; letter-spacing: -.04em; }
.metric .detail { color: #708197; font-size: 12px; }
.status { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 650; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 0 4px rgba(244, 185, 66, .08); }
.status.ok::before { background: var(--success); box-shadow: 0 0 0 4px rgba(54, 201, 143, .09); }
.status.bad::before { background: var(--danger); box-shadow: 0 0 0 4px rgba(240, 106, 117, .09); }

.table-wrap { overflow: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 11px 12px; border-bottom: 1px solid var(--border); color: #718198; font-size: 11px; letter-spacing: .07em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 13px 12px; border-bottom: 1px solid var(--border-soft); color: #cbd5e1; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.mono { font-family: "SFMono-Regular", Consolas, monospace; font-size: 11px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.truncate { display: block; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border: 1px solid var(--border); border-radius: 999px; background: #111a27; color: #aab8ca; font-size: 10px; font-weight: 760; letter-spacing: .05em; text-transform: uppercase; }
.badge.qualified, .badge.accepted, .badge.open { border-color: rgba(54, 201, 143, .3); color: #75e0b7; background: rgba(54, 201, 143, .08); }
.badge.pending, .badge.manual_review, .badge.submitted { border-color: rgba(244, 185, 66, .3); color: #f6cb72; background: rgba(244, 185, 66, .08); }
.badge.rejected, .badge.revoked { border-color: rgba(240, 106, 117, .3); color: #f69ba3; background: rgba(240, 106, 117, .08); }

form { margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
label { color: #aebacc; font-size: 12px; font-weight: 650; }
input, textarea, select { width: 100%; border: 1px solid var(--border); border-radius: 9px; outline: 0; background: #0b111a; color: var(--text); }
input, select { height: 42px; padding: 0 11px; }
textarea { min-height: 110px; padding: 11px; line-height: 1.5; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: #3f78ca; box-shadow: 0 0 0 3px rgba(59, 130, 246, .1); }
input[type="color"] { padding: 5px; }
.checkbox { display: flex; align-items: center; gap: 9px; min-height: 42px; }
.checkbox input { width: 17px; height: 17px; }
.actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 17px; }
.button, button { display: inline-flex; justify-content: center; align-items: center; min-height: 38px; padding: 0 13px; border: 1px solid transparent; border-radius: 9px; background: var(--accent); color: white; font-size: 12px; font-weight: 700; }
.button:hover, button:hover { filter: brightness(1.08); }
.button.secondary, button.secondary { border-color: var(--border); background: #151e2c; color: #c4cfdd; }
.button.danger, button.danger { background: #a93846; }
.button.small, button.small { min-height: 30px; padding: 0 9px; font-size: 11px; }
.inline-form { display: flex; align-items: center; gap: 7px; min-width: 260px; }
.inline-form input, .inline-form select { height: 32px; }
.inline-form button { min-height: 32px; }

.notice { margin-bottom: 18px; padding: 12px 14px; border: 1px solid rgba(54, 201, 143, .24); border-radius: 10px; background: rgba(54, 201, 143, .08); color: #8ee7c5; font-size: 13px; }
.notice.error { border-color: rgba(240, 106, 117, .28); background: rgba(240, 106, 117, .08); color: #f5a6ad; }
.empty { padding: 34px 12px; color: var(--muted); text-align: center; }

.embed-preview { padding: 16px; border-left: 4px solid var(--preview-color, #3b82f6); border-radius: 5px; background: #202225; color: #dcddde; }
.embed-preview h3 { margin: 0 0 8px; color: white; }
.embed-preview p { margin: 0; white-space: pre-wrap; line-height: 1.45; }
.embed-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.embed-field strong { display: block; margin-bottom: 3px; color: white; font-size: 12px; }
.embed-field span { color: #c8c9cb; font-size: 12px; white-space: pre-wrap; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(440px, 100%); padding: 34px; border: 1px solid var(--border); border-radius: 20px; background: rgba(16, 23, 34, .94); box-shadow: 0 34px 100px rgba(0,0,0,.35); }
.login-card .brand { padding: 0 0 28px; }
.login-card h1 { font-size: 30px; }
.login-card p { color: var(--muted); line-height: 1.6; }
.login-card .button { width: 100%; min-height: 46px; margin-top: 12px; }

.mobile-nav { display: none; }
@media (max-width: 1060px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 780px) {
  .shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 17px 18px; border-right: 0; border-bottom: 1px solid var(--border-soft); }
  .brand { padding: 0; }
  .nav { display: none; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 15px; }
  .nav.open { display: grid; }
  .mobile-nav { display: inline-flex; position: absolute; top: 18px; right: 18px; }
  .sidebar-foot { display: none; }
  .main { padding: 27px 18px 56px; }
  .topbar { display: block; }
  .user { display: inline-flex; margin-top: 17px; }
  .grid-2, .grid-3, .grid-4, .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .inline-form { min-width: 220px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
