:root {
  --bg: #0b1020;
  --panel: rgba(22, 31, 54, .94);
  --panel-2: #1c2947;
  --line: rgba(117, 155, 216, .22);
  --text: #f4f7fb;
  --muted: #9fb0ca;
  --dim: #71839e;
  --blue: #5c8ee6;
  --blue-2: #76b2ff;
  --gold: #f4c64e;
  --green: #3bd39b;
  --red: #ff7b83;
  --orange: #ffb25f;
  --shadow: 0 24px 70px rgba(0, 0, 0, .34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 15% 15%, #15254a 0, transparent 36%), radial-gradient(circle at 90% 80%, #172b3d 0, transparent 35%), var(--bg); color: var(--text); }
.background-grid { position: fixed; inset: 0; pointer-events: none; opacity: .16; background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px); background-size: 42px 42px; mask-image: linear-gradient(to bottom, #000, transparent 85%); }
a { color: inherit; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; min-height: 68px; padding: 0 4vw; background: rgba(8, 13, 27, .88); border-bottom: 1px solid var(--line); backdrop-filter: blur(18px); }
.brand { display: inline-flex; align-items: center; gap: .75rem; text-decoration: none; }
.brand-mark { display: grid; place-items: center; flex: 0 0 auto; width: 44px; height: 44px; padding: 4px; border: 1px solid rgba(118, 178, 255, .24); border-radius: 12px; background: linear-gradient(145deg, rgba(28, 41, 71, .94), rgba(11, 16, 32, .92)); box-shadow: 0 8px 26px rgba(18, 83, 190, .28), inset 0 1px 0 rgba(255, 255, 255, .06); }
.brand-mark img { display: block; width: 100%; height: 100%; object-fit: contain; }
.brand span:last-child { display: flex; flex-direction: column; }
.brand strong { font-size: .95rem; }
.brand small { color: var(--muted); font-size: .67rem; text-transform: uppercase; letter-spacing: .12em; }
.topnav { display: flex; align-items: center; gap: 1rem; font-size: .82rem; }
.topnav a { text-decoration: none; color: var(--muted); }
.topnav a:hover { color: var(--text); }
.topnav form { margin: 0; }
.user-pill { padding: .4rem .75rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: rgba(255,255,255,.03); }
.link-button { border: 0; background: none; color: var(--muted); cursor: pointer; font: inherit; }
.page-shell { position: relative; z-index: 1; width: min(1180px, 92vw); margin: 0 auto; padding: 3rem 0 6rem; }
.hero { display: flex; justify-content: space-between; align-items: center; gap: 2rem; margin-bottom: 2rem; }
.compact-hero { margin-bottom: 1.5rem; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: .55rem; font-size: clamp(2rem, 4vw, 3.4rem); letter-spacing: -.045em; }
h2 { margin-bottom: .3rem; font-size: 1.25rem; letter-spacing: -.02em; }
.hero p:not(.eyebrow), .section-heading p { max-width: 720px; color: var(--muted); line-height: 1.65; }
.eyebrow { margin-bottom: .45rem; color: var(--gold); font-size: .68rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.status-card { min-width: 250px; display: flex; align-items: center; gap: .8rem; padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.035); }
.status-card div { display: flex; flex-direction: column; }
.status-card small { color: var(--muted); margin-top: .2rem; }
.status-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 5px rgba(255, 123, 131, .12); }
.status-dot.online { background: var(--green); box-shadow: 0 0 0 5px rgba(59, 211, 155, .12); }
.mode-tabs { display: inline-flex; gap: .35rem; padding: .35rem; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 1rem; background: rgba(8,13,27,.5); }
.mode-tab { border: 0; border-radius: 9px; padding: .72rem 1rem; background: transparent; color: var(--muted); cursor: pointer; font: inherit; font-weight: 700; }
.mode-tab.active { background: var(--panel-2); color: var(--text); box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.panel { display: block; margin-bottom: 1.4rem; padding: 1.5rem; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); box-shadow: var(--shadow); }
.source-panel { display: none; }
.panel.active-panel { display: block; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.badge, .status-badge { display: inline-flex; align-items: center; padding: .28rem .58rem; border: 1px solid var(--line); border-radius: 999px; color: var(--blue-2); background: rgba(92,142,230,.1); font-size: .67rem; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; }
.status-badge.status-done { color: var(--green); background: rgba(59,211,155,.1); }
.status-badge.status-error { color: var(--red); background: rgba(255,123,131,.1); }
.status-badge.status-expired { color: var(--dim); }
.status-badge.status-downloading, .status-badge.status-resolving, .status-badge.status-queued { color: var(--orange); background: rgba(255,178,95,.1); }
.notice { margin-bottom: 1.25rem; padding: .9rem 1rem; border-left: 3px solid var(--gold); border-radius: 8px; background: rgba(244,198,78,.07); color: var(--muted); line-height: 1.6; font-size: .82rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.compact-form { gap: .8rem; }
.span-2 { grid-column: span 2; }
label { display: flex; flex-direction: column; gap: .42rem; color: var(--muted); font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
label small, .field-help { color: var(--dim); font-size: .68rem; text-transform: none; letter-spacing: 0; font-weight: 500; line-height: 1.45; }
input, select, textarea { width: 100%; min-height: 44px; padding: .7rem .85rem; border: 1px solid var(--line); border-radius: 9px; outline: none; color: var(--text); background: rgba(255,255,255,.035); font: inherit; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(92,142,230,.16); }
input[type=file] { padding: .55rem; }
textarea { resize: vertical; min-height: 130px; line-height: 1.5; }
input[readonly] { color: var(--muted); cursor: default; }
.input-with-suffix { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.input-with-suffix input { border: 0; border-radius: 0; }
.input-with-suffix span { padding: 0 .8rem; color: var(--dim); font-size: .72rem; }
.form-actions, .button-row { display: flex; gap: .7rem; align-items: center; margin-top: .2rem; }
.primary-button, .secondary-button, .small-button { display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; padding: .72rem 1rem; border: 1px solid transparent; font: inherit; font-weight: 800; cursor: pointer; text-decoration: none; }
.primary-button { color: white; background: linear-gradient(135deg, var(--blue), #4775c9); box-shadow: 0 8px 22px rgba(92,142,230,.25); }
.primary-button:disabled { cursor: not-allowed; opacity: .4; }
.secondary-button, .small-button { color: var(--muted); background: rgba(255,255,255,.035); border-color: var(--line); }
.small-button { padding: .42rem .62rem; font-size: .7rem; }
.small-button.accent { color: var(--gold); border-color: rgba(244,198,78,.25); }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .65rem; min-height: 62px; }
.empty-choice, .empty-state { display: grid; place-items: center; min-height: 64px; padding: 1rem; color: var(--dim); border: 1px dashed var(--line); border-radius: 10px; text-align: center; }
.choice { display: flex; flex-direction: row; align-items: center; gap: .65rem; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.025); text-transform: none; letter-spacing: 0; cursor: pointer; }
.choice input { width: 17px; min-height: 17px; }
.choice span { display: flex; flex-direction: column; color: var(--text); font-size: .78rem; }
.choice small { color: var(--dim); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 11px; }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th, td { padding: .78rem .85rem; border-bottom: 1px solid rgba(117,155,216,.12); text-align: left; vertical-align: top; font-size: .75rem; }
th { color: var(--dim); background: rgba(0,0,0,.12); text-transform: uppercase; letter-spacing: .08em; font-size: .64rem; }
td { color: var(--muted); }
td strong { display: block; color: var(--text); }
td small { display: block; margin-top: .2rem; color: var(--dim); }
.actions-cell { display: flex; gap: .45rem; }
.mono, code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .68rem; }
.compact-table { margin-top: 1rem; max-height: 420px; overflow: auto; }
.compact-table table { min-width: 720px; }
.admin-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 1.4rem; }
hr { margin: 1.3rem 0; border: 0; border-top: 1px solid var(--line); }
.flash { margin-bottom: 1rem; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.04); }
.flash.error { color: #ffc1c5; border-color: rgba(255,123,131,.3); background: rgba(255,123,131,.08); }
.flash.success { color: #9ff0d2; border-color: rgba(59,211,155,.3); background: rgba(59,211,155,.08); }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 2rem 0; }
.auth-card { width: min(440px, 92vw); padding: 2rem; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); box-shadow: var(--shadow); }
.wide-auth { width: min(520px, 92vw); }
.auth-brand { margin-bottom: 2rem; }
.auth-brand .brand-mark { width: 54px; height: 54px; padding: 5px; border-radius: 15px; }
.stack-form { display: grid; gap: 1rem; }
.modal { position: fixed; inset: 0; z-index: 100; display: none; place-items: center; padding: 2rem; background: rgba(3,7,15,.82); backdrop-filter: blur(8px); }
.modal.open { display: grid; }
.modal-card { position: relative; width: min(700px, 96vw); max-height: 90vh; overflow: auto; padding: 1.5rem; border: 1px solid var(--line); border-radius: 16px; background: #121b30; box-shadow: var(--shadow); }
.large-modal { width: min(1050px, 96vw); }
.modal-close { position: absolute; right: 1rem; top: .7rem; border: 0; background: none; color: var(--muted); font-size: 1.7rem; cursor: pointer; }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: .7rem; margin: 1rem 0; }
.summary-grid div { padding: .8rem; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.025); }
.summary-grid small { display: block; color: var(--dim); }
.modal-actions { display: flex; justify-content: flex-end; margin-top: 1rem; }
.toast { position: fixed; right: 1.2rem; bottom: 1.2rem; z-index: 200; max-width: 420px; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: 10px; background: #17233c; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(255,123,131,.35); }
.hidden { display: none !important; }
@media (max-width: 850px) {
  .topbar, .hero { align-items: flex-start; flex-direction: column; }
  .topbar { position: relative; padding: 1rem 4vw; }
  .topnav { flex-wrap: wrap; }
  .form-grid, .admin-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .status-card { width: 100%; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
}
