:root {
  --bg: #f5f6fa; --surface: #ffffff; --surface-2: #f0f2f7; --line: #e3e6ee; --text: #0f1424; --muted: #667089;
  --brand: #4f46e5; --brand-2: #6366f1; --brand-tint: #eef0ff; --ok: #0e9f6e; --warn: #c27c0e; --danger: #e0483b;
  --side: #0c1022; --side-2: #151a33; --side-text: #c9cde0; --side-muted: #7c84a3;
  --radius: 12px; --shadow: 0 1px 2px rgba(15,20,36,.05), 0 8px 24px rgba(15,20,36,.06);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text); background: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0a0d1a; --surface: #11152a; --surface-2: #171c35; --line: #232a47; --text: #e7e9f3; --muted: #8b93b3;
    --brand-tint: #1d2150; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25); --side: #070913; --side-2: #10142a; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }

/* ---------- layout */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-weight: 700; font-size: 17px; letter-spacing: -.02em; }
.logo { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, #6366f1, #4f46e5 60%, #22d3ee); display: grid; place-items: center; box-shadow: 0 4px 14px rgba(79,70,229,.45); }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--side-muted); padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--side-text); font-weight: 500; }
.nav a:hover { background: var(--side-2); color: #fff; }
.nav a.active { background: linear-gradient(90deg, rgba(99,102,241,.25), rgba(99,102,241,.05)); color: #fff; box-shadow: inset 2px 0 0 #818cf8; }
.nav svg { width: 18px; height: 18px; opacity: .85; }
.side-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--side-2); font-size: 12.5px; }
.usage-mini .bar { margin: 6px 0 4px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 18px 32px 0; }
.content { padding: 20px 32px 48px; max-width: 1240px; width: 100%; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.crumbs a { color: var(--muted); } .crumbs a:hover { color: var(--brand); }
h1 { font-size: 24px; letter-spacing: -.02em; margin: 6px 0 4px; }
.sub { color: var(--muted); margin: 0 0 20px; }
.row { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }
.btn.menu-btn { display: none; }

/* ---------- components */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 20px; }
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat .value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .hint { color: var(--muted); font-size: 12px; margin-top: 2px; }
.stat.hero { background: linear-gradient(135deg, #4f46e5, #6366f1 55%, #0891b2); border: 0; color: #fff; }
.stat.hero .label, .stat.hero .hint { color: rgba(255,255,255,.8); }
.btn { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { border-color: #c5cad8; background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn.icon-btn { width: 30px; height: 30px; padding: 0; justify-content: center; }
.btn svg { flex: none; }
.input, select.input { width: 100%; height: 38px; border: 1px solid var(--line); border-radius: 9px; padding: 0 12px; background: var(--surface); outline: none; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.15); }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: 13px; }
.field .help { color: var(--muted); font-size: 12px; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; margin-bottom: 14px; }
.check input { margin-top: 3px; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.pill.ok { background: rgba(14,159,110,.12); color: var(--ok); }
.pill.warn { background: rgba(194,124,14,.14); color: var(--warn); }
.pill.danger { background: rgba(224,72,59,.12); color: var(--danger); }
.pill.brand { background: var(--brand-tint); color: var(--brand); }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, #6366f1, #22d3ee); border-radius: 99px; transition: width .4s; }
.bar.high > i { background: linear-gradient(90deg, #f59e0b, #e0483b); }
.side .bar { background: var(--side-2); }

table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr:hover { background: var(--surface-2); }
.t .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.t .name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.t .name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t .actions { text-align: right; white-space: nowrap; }
.ficon { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--muted); }
.ficon svg { width: 17px; height: 17px; }
.ficon.folder { background: rgba(245,158,11,.14); color: #d97706; }
.ficon.img { background: rgba(14,159,110,.12); color: var(--ok); overflow: hidden; }
.ficon.img img { width: 100%; height: 100%; object-fit: cover; }
.ficon.bucket { background: var(--brand-tint); color: var(--brand); }
.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty .big { width: 56px; height: 56px; border-radius: 16px; background: var(--brand-tint); color: var(--brand); display: grid; place-items: center; margin: 0 auto 14px; }
.empty .big svg { width: 26px; height: 26px; }
.empty h3 { color: var(--text); margin: 0 0 6px; }

.dropzone { position: relative; }
.dropzone.drag::after { content: "Drop files to upload"; position: absolute; inset: 0; border: 2px dashed var(--brand); border-radius: var(--radius); background: rgba(79,70,229,.08); display: grid; place-items: center; font-weight: 700; color: var(--brand); font-size: 16px; z-index: 5; }
.uploads { position: fixed; right: 20px; bottom: 20px; width: 340px; z-index: 40; }
.uploads .card { padding: 14px; }
.up-item { display: grid; gap: 4px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 12.5px; }
.up-item:first-of-type { border-top: 0; }
.up-item .bar { height: 5px; }

.secret { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
.secret span { flex: 1; }
pre.code { background: #0b1022; color: #d6dcff; border-radius: 10px; padding: 14px; overflow: auto; font-size: 12px; margin: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tabs button { background: none; border: 0; padding: 8px 12px; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--brand); border-color: var(--brand); }
.callout { padding: 12px 14px; border-radius: 10px; background: rgba(194,124,14,.1); color: var(--warn); font-weight: 500; margin-bottom: 14px; font-size: 13px; }

/* ---------- modal & toast */
.overlay { position: fixed; inset: 0; background: rgba(8,10,25,.5); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .15s; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border-radius: 16px; box-shadow: 0 30px 80px rgba(0,0,0,.35); animation: pop .18s ease-out; }
.modal header { padding: 18px 22px 0; } .modal header h2 { margin: 0; font-size: 18px; }
.modal .body { padding: 16px 22px; }
.modal footer { padding: 0 22px 20px; display: flex; justify-content: flex-end; gap: 8px; }
#toasts { position: fixed; top: 16px; right: 16px; display: grid; gap: 8px; z-index: 60; }
.toast { background: #0f1424; color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); font-weight: 500; animation: pop .18s; max-width: 380px; }
.toast.err { background: var(--danger); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }

/* ---------- auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art { background: radial-gradient(1200px 600px at 10% 10%, #3730a3, transparent), linear-gradient(135deg, #0c1022, #1e1b4b); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-art h2 { font-size: 40px; letter-spacing: -.03em; line-height: 1.1; margin: 0 0 14px; max-width: 520px; }
.auth-art p { color: #b9bfe0; font-size: 16px; max-width: 460px; }
.auth-feats { display: grid; gap: 10px; margin-top: 28px; color: #d8dcf5; }
.auth-feats div { display: flex; gap: 10px; align-items: center; }
.auth-feats svg { width: 18px; height: 18px; color: #22d3ee; }
.auth-form { display: grid; place-items: center; padding: 32px; }
.auth-form .card { width: min(400px, 100%); padding: 28px; }
.auth-form h1 { margin-top: 0; }
.err-text { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 8px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: sh 1.2s infinite; border-radius: 8px; height: 16px; }
@keyframes sh { to { background-position: -200% 0; } }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; transform: translateX(-100%); transition: transform .2s; z-index: 30; }
  .side.open { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.5); }
  .btn.menu-btn { display: inline-flex; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .auth { grid-template-columns: 1fr; } .auth-art { display: none; }
  .hide-sm { display: none; }
  .uploads { left: 16px; right: 16px; width: auto; }
}
