:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --faint: #9ca3af;
  --border: #e5e7eb;
  --hover: #f3f4f6;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --err: #dc2626;
  --err-soft: #fef2f2;
  --warn: #d97706;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(16 24 40 / .04), 0 1px 3px rgb(16 24 40 / .06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
main { max-width: 920px; margin: 0 auto; padding: 0 16px 48px; }
body { overflow-x: hidden; }

[hidden] { display: none !important; }

/* icons (sprite symbols inherit these through <use>) */
.i {
  width: 18px; height: 18px; flex: none; vertical-align: -3px;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.i-lg { width: 22px; height: 22px; }
.i-xl { width: 40px; height: 40px; }

/* top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 0; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.logo {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff;
}
.logo .i { width: 18px; height: 18px; }
.who { display: flex; align-items: center; gap: 10px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: .82rem; font-weight: 600;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.muted { background: var(--hover); color: var(--muted); }

/* cards */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 1rem; }
.card-body { padding: 20px; }
h2 .i { color: var(--muted); }

/* form controls */
input, select, button { font: inherit; }
input[type=text], input[type=password], input[type=number], input:not([type]) {
  height: 38px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border); background: #fff; color: var(--text);
  min-width: 0; transition: border-color .15s, box-shadow .15s;
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgb(79 70 229 / .15); }
.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 14px;
  border-radius: 8px; border: 1px solid transparent; background: var(--accent); color: #fff; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: background .15s, color .15s, border-color .15s;
}
.btn:hover, button:hover { background: var(--accent-hover); text-decoration: none; }
.btn-ghost { background: #fff; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--hover); }
.btn-danger { background: #fff; color: var(--err); border-color: #fecaca; }
.btn-danger:hover { background: var(--err-soft); }
.icon-btn { width: 34px; height: 34px; padding: 0; background: transparent; color: var(--faint); border: 0; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.danger:hover { background: var(--err-soft); color: var(--err); }
label.field { display: grid; gap: 6px; font-size: .85rem; font-weight: 600; color: #374151; }
label.field small { font-weight: 400; color: var(--muted); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row input { flex: 1; min-width: 140px; }
.muted { color: var(--muted); }

/* flash */
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 10px; margin-bottom: 20px; border: 1px solid; }
.flash.ok { background: var(--ok-soft); color: #065f46; border-color: #a7f3d0; }
.flash.err { background: var(--err-soft); color: #991b1b; border-color: #fecaca; }
.secret { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; }
.secret code { font: 600 1.05rem ui-monospace, SFMono-Regular, Menlo, monospace; background: #fff; border: 1px solid #a7f3d0; padding: 4px 10px; border-radius: 6px; user-select: all; }

/* breadcrumbs */
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; font-weight: 600; min-width: 0; }
.crumbs a, .crumbs span { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 6px; color: var(--muted); word-break: break-all; }
.crumbs a:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.crumbs .current { color: var(--text); }
.crumbs .sep { color: var(--faint); padding: 0; }
.crumbs .sep .i { width: 14px; height: 14px; }

/* quota */
.quota { display: flex; align-items: center; gap: 10px; font-size: .85rem; color: var(--muted); }
.meter { width: 120px; height: 6px; border-radius: 99px; background: var(--hover); overflow: hidden; }
.meter > div { height: 100%; background: var(--accent); border-radius: 99px; }
.quota.warn .meter > div { background: var(--warn); }
.quota.full .meter > div { background: var(--err); }
.quota.full { color: var(--err); }

/* drop zone */
.drop {
  display: grid; justify-items: center; gap: 6px; padding: 32px 16px; text-align: center;
  border: 2px dashed var(--border); border-radius: var(--radius); background: #fafafa; transition: border-color .15s, background .15s;
}
.drop .i-xl { color: var(--accent); stroke-width: 1.5; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop p { margin: 0; }
.drop .hint { font-size: .85rem; color: var(--muted); }

/* upload queue */
#queue { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
#queue:empty { display: none; }
#queue li { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
#queue .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#queue .status { font-size: .85rem; color: var(--muted); }
#queue .bar { grid-column: 1 / -1; height: 4px; background: var(--hover); border-radius: 99px; overflow: hidden; }
#queue .bar > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
#queue li.done .bar > div { background: var(--ok); }
#queue li.done .status { color: var(--ok); }
#queue li.error .bar > div { background: var(--err); width: 100%; }
#queue li.error .status { color: var(--err); }

/* toolbar */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; padding: 14px 20px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background: #fcfcfd; }
.toolbar form { display: flex; gap: 8px; flex: 1 1 280px; align-items: center; }
.toolbar input { flex: 1; }
.lock-state { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; font-weight: 600; white-space: nowrap; color: var(--muted); }
.lock-state.on { color: var(--ok); }

/* file list */
.files { width: 100%; border-collapse: collapse; }
.files td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.files tr:last-child td { border-bottom: 0; }
.files tbody tr:hover { background: #fafafa; }
.files td.name { width: 100%; max-width: 0; }
.files .entry { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 500; min-width: 0; }
.files .entry span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files a.entry:hover { text-decoration: none; color: var(--accent); }
.files td.meta { color: var(--muted); font-size: .85rem; white-space: nowrap; text-align: right; }
.files td.act { white-space: nowrap; text-align: right; padding-right: 8px; }
.empty { display: grid; justify-items: center; gap: 4px; padding: 36px 16px; color: var(--faint); }
.empty .i-xl { stroke-width: 1.5; }

/* file kind colors */
.k-dir, .k-dir-lock { color: #f59e0b; }
.k-dir .i, .k-dir-lock .i { fill: #fef3c7; }
.k-up { color: var(--faint); }
.k-image { color: #10b981; }
.k-video { color: #8b5cf6; }
.k-audio { color: #ec4899; }
.k-archive { color: #ea580c; }
.k-pdf { color: #ef4444; }
.k-doc { color: #3b82f6; }
.k-sheet { color: #16a34a; }
.k-code { color: #475569; }
.k-text, .k-file { color: #94a3b8; }

/* admin forms */
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; align-items: end; }
.grid-form input { width: 100%; }
.users td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.users tr:last-child td { border-bottom: 0; }
.users .uname { font-weight: 600; }
.users .upath { font-size: .85rem; color: var(--muted); }
.users input.num { width: 90px; flex: none; min-width: 0; }
.users input { flex: 1; }
.users .row { flex-wrap: nowrap; }

/* login / unlock */
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth { width: 100%; max-width: 380px; padding: 32px 28px; display: grid; gap: 16px; text-align: center; }
.auth .logo { width: 48px; height: 48px; border-radius: 14px; margin: 0 auto; }
.auth .logo .i { width: 24px; height: 24px; }
.auth h1 { margin: 0; font-size: 1.25rem; }
.auth p { margin: -8px 0 0; color: var(--muted); font-size: .9rem; word-break: break-all; }
.auth form { display: grid; gap: 12px; text-align: left; }
.auth button { width: 100%; height: 42px; }
.auth input { height: 42px; width: 100%; }

@media (max-width: 640px) {
  .card-head, .card-body, .toolbar { padding-left: 14px; padding-right: 14px; }
  .files td { padding: 10px 8px; }
  .files td.date { display: none; }
  .users thead { display: none; }
  .users tr, .users td { display: block; }
  .users td { border: 0; padding: 6px 14px; }
  .users tr { border-bottom: 1px solid var(--border); padding: 8px 0; }
  .users .row { flex-wrap: wrap; }
  .meter { width: 80px; }
  .brand { white-space: nowrap; }
  .who .btn-ghost span { display: none; }
  .who .btn-ghost { padding: 0 10px; }
  .toolbar form { flex-wrap: wrap; flex-basis: 100%; }
  .toolbar .lock-state { width: 100%; }
}
