:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #16181d;
  --muted: #6b7280;
  --line: #e6e8ec;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --ok: #15803d;
  --ok-soft: #ecfdf3;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --danger: #dc2626;
  --input: #ffffff;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #171a21;
    --text: #e8eaee;
    --muted: #9aa1ad;
    --line: #262a33;
    --accent: #6d68f5;
    --accent-hover: #827df7;
    --accent-soft: #1f2040;
    --ok: #4ade80;
    --ok-soft: #10261a;
    --warn: #fbbf24;
    --warn-soft: #2a2110;
    --danger: #f87171;
    --input: #11141a;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
main { max-width: 1120px; margin: 0 auto; padding: 28px 20px 60px; }
h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 20px; }
h2 { font-size: 17px; font-weight: 650; letter-spacing: -.01em; margin: 28px 0 10px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- top bar */
nav {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px;
  padding: 0 20px; min-height: 60px;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 750; letter-spacing: -.02em; font-size: 16px; }
.brand::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--accent); margin-right: 8px; vertical-align: 1px; }
nav .links { display: flex; flex-wrap: wrap; gap: 4px; }
nav .links a { color: var(--muted); font-weight: 550; padding: 7px 12px; border-radius: 8px; }
nav .links a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
nav .links a.active { background: var(--accent-soft); color: var(--accent); }
nav .me { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
nav .me a { color: var(--muted); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); font-size: 12px; font-weight: 600; color: var(--text); }

.banner { background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--line); padding: 10px 20px; font-weight: 600; font-size: 14px; }
.banner a { color: inherit; text-decoration: underline; }
.msg { background: var(--ok-soft); color: var(--ok); border-radius: 10px; padding: 10px 14px; font-weight: 550; }
.warn { color: var(--warn); }
.ok { color: var(--ok); }
.dim { color: var(--muted); font-size: 13.5px; }
.note { font-size: 13.5px; color: var(--muted); margin-top: 2px; }

/* ---- cards */
.box, .upload {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 6px 22px 10px; margin: 0 0 20px; max-width: 680px;
}
.box h2, .upload h2 { margin-top: 16px; }
.upload { max-width: none; border: 1.5px dashed color-mix(in srgb, var(--accent) 45%, var(--line)); background: color-mix(in srgb, var(--accent-soft) 40%, var(--card)); }
.hint { font-size: 13.5px; color: var(--muted); }

/* ---- tables */
table {
  width: 100%; border-collapse: separate; border-spacing: 0; margin: 8px 0 20px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: color-mix(in srgb, var(--bg) 60%, var(--card)); }
tr:hover td { background: color-mix(in srgb, var(--bg) 45%, var(--card)); }
td.act { white-space: nowrap; text-align: right; }
td.act form { display: inline; margin-left: 12px; }
td.act > button + button, td.act > a + button { margin-left: 12px; }
tr.gone { opacity: .4; }
form.inline-l { display: inline; margin-left: 6px; }
ul.checks.plats { display: flex; flex-wrap: wrap; gap: 4px 22px; }
ul.checks.plats li { margin: 4px 0; }
ul.folders ul li, ul.folders li.grp > .row { flex-wrap: wrap; align-items: center; }
.pcs { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.chip { font-size: 12px; font-weight: 550; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.chip b { font-weight: 750; margin-left: 2px; }
.chip.zero { background: var(--bg); color: var(--muted); }
.fcell { display: flex; align-items: center; gap: 12px; }
.thumb { flex: none; width: 48px; height: 64px; border-radius: 8px; object-fit: cover; background: var(--bg); border: 1px solid var(--line); }
.thumb.none { display: inline-flex; align-items: center; justify-content: center; font-size: 18px; opacity: .6; }

/* ---- inputs */
input, select, textarea, button { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=file]), select, textarea {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--input);
  max-width: 100%; width: 320px; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { width: 380px; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; vertical-align: -3px; margin-right: 4px; }
label { font-size: 14px; font-weight: 550; }
ul.checks label { font-weight: 450; }

/* ---- buttons */
button, .btn, input[type=file]::file-selector-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--card); color: var(--text); font-weight: 600; font-size: 14px;
  cursor: pointer; text-decoration: none; box-shadow: var(--shadow); transition: background .15s, border-color .15s, transform .05s;
}
button:hover, .btn:hover, input[type=file]::file-selector-button:hover { background: var(--bg); text-decoration: none; }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: default; }
.primary, button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.primary:hover, button.primary:hover, .btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.wide { width: 100%; padding: 11px 16px; }
button.danger { color: var(--danger); }
button.link { border: 0; background: none; box-shadow: none; padding: 0; color: var(--accent); font-weight: 550; }
button.link:hover { background: none; text-decoration: underline; }
button.link.danger { color: var(--danger); }
input[type=file] { font-size: 14px; color: var(--muted); }
input[type=file]::file-selector-button { margin-right: 12px; }

form.inline { display: inline-flex; align-items: center; gap: 8px; margin: 3px 10px 3px 0; }
form.inline input:not([type=hidden]) { width: 220px; padding: 7px 10px; }

/* ---- folder lists */
ul.folders, ul.checks { padding: 0; list-style: none; }
ul.folders > li {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 18px; margin: 0 0 12px;
}
ul.folders > li > a { font-weight: 600; }
ul.folders ul { list-style: none; padding: 6px 0 0; margin: 0; }
ul.folders ul li { padding: 8px 10px; border-radius: 8px; display: flex; justify-content: space-between; gap: 12px; }
ul.folders ul li:hover { background: var(--bg); }
ul.folders ul li.grp { display: block; padding: 8px 10px 2px; }
ul.folders ul li.grp:hover { background: none; }
ul.folders li.grp > .row { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; }
ul.folders li.grp ul { padding: 2px 0 0 20px; }
ul.folders .dim { white-space: nowrap; }
form.inline input.short { width: 170px; }
ul.checks li { margin: 8px 0; }
ul.checks ul { list-style: none; padding-left: 26px; }

/* ---- upload queue */
.queue { padding-left: 0; list-style: none; }
.queue li { margin: 8px 0; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; font-size: 14px; }
.queue progress { width: 160px; height: 8px; vertical-align: middle; margin: 0 8px; accent-color: var(--accent); }
.queue li.done .st { color: var(--ok); font-weight: 600; }
.queue li.warn .st { color: var(--warn); font-weight: 600; }
.queue li.fail .st { color: var(--danger); }
.queue li.skip .st { color: var(--muted); }
.queue li.end { background: none; border: 0; padding: 4px 0; font-weight: 600; }

input.copy { width: 100%; max-width: 560px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
input.copy.big { font-size: 14px; padding: 12px 14px; }

/* ---- login / setup / invite pages */
body.auth main { max-width: 420px; padding-top: 12px; }
body.auth h1 { text-align: center; font-size: 22px; }
body.auth .box { max-width: none; padding: 10px 26px 16px; }
body.auth input:not([type=checkbox]) { width: 100%; }
.brand.solo { text-align: center; padding: 56px 0 12px; font-size: 18px; }

@media (max-width: 700px) {
  main { padding: 20px 14px 50px; }
  nav { padding: 10px 14px; }
  nav .me { margin-left: 0; width: 100%; }
  table, tbody, tr, td { display: block; width: 100%; }
  tr:first-child:has(th) { display: none; }
  td { border: 0; padding: 3px 14px; }
  tr { border-bottom: 1px solid var(--line); padding: 10px 0; }
  tr:last-child { border-bottom: 0; }
  td.act { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; text-align: left; padding-top: 10px; }
  td.act form, td.act > button + button, td.act > a + button { margin-left: 0; }
  input:not([type=checkbox]):not([type=file]), textarea { width: 100%; }
  ul.folders ul li, ul.folders li.grp > .row { gap: 6px 12px; }
  .pcs { width: 100%; justify-content: flex-start; }
}
