:root {
  color-scheme: dark;
  --bg: #0e1116;
  --surface: #151a22;
  --surface-2: #1b212b;
  --border: #272e3a;
  --text: #e7eaf0;
  --muted: #8d96a6;
  --accent: #4c8dff;
  --accent-ink: #07121f;
  --danger: #ff6b6b;
  --ok: #4cc38a;
  --warn: #f0b429;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text); font: 15px/1.5 var(--font);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }
code, pre { font-family: var(--mono); }
pre { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: .6rem .8rem; overflow-x: auto; margin: .25rem 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }

/* header */
.top {
  display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
  padding: .7rem max(16px, calc((100% - 1100px) / 2));
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .55rem; color: var(--text); font-weight: 650; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.logo { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); display: inline-block; position: relative; }
.logo::after { content: ""; position: absolute; left: 5px; top: 10px; width: 12px; height: 7px; background: #fff; border-radius: 1.5px; }
.top nav { display: flex; gap: 1rem; }
.top nav a { color: var(--muted); }
.top nav a:hover { color: var(--text); text-decoration: none; }
.who { margin-left: auto; display: flex; align-items: center; gap: .9rem; }
.who form { margin: 0; }
button.link { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; font: inherit; }
button.link:hover { color: var(--text); text-decoration: underline; }

main { width: 100%; max-width: 1100px; margin: 0 auto; padding: 1.25rem 16px 2rem; flex: 1; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem; border-top: 1px solid var(--border); }

/* cards and forms */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.card.narrow { max-width: 420px; margin: 3rem auto; }
.card.center { text-align: center; }
.card.creds { border-color: var(--warn); }
label { display: block; margin: 0 0 .9rem; font-weight: 500; }
input, select, textarea {
  width: 100%; margin-top: .3rem; padding: .55rem .7rem; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
}
input:focus, select:focus, .btn:focus-visible, summary:focus-visible, .dropzone:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type=checkbox] { width: auto; margin: 0 .4rem 0 0; }
form.inline, .toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin: 0 0 .75rem; }
form.inline input, form.inline select, .toolbar input, .toolbar select { width: auto; margin: 0; flex: 1 1 180px; }
.toolbar input[type=search] { flex: 3 1 240px; }
.btn {
  display: inline-block; padding: .5rem .9rem; font: inherit; font-weight: 550; color: var(--text); cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; text-align: center;
}
.btn:hover { text-decoration: none; border-color: #3a4454; background: #222a36; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #6aa0ff; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.small { padding: .25rem .6rem; font-size: .85rem; }
.btn.wide { width: 100%; padding: .65rem; }
.flash { padding: .65rem .9rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid var(--border); background: var(--surface-2); }
.flash.ok { border-color: #245c44; background: #11261d; }
.flash.err { border-color: #6b2b2b; background: #2a1414; color: #ffb4b4; }
.empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); }
.crumbs { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; color: var(--muted); }

/* tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table.list { width: 100%; border-collapse: collapse; }
.list th, .list td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.list thead th { color: var(--muted); font-weight: 500; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.list tbody tr:last-child td { border-bottom: 0; }
.list tbody tr:hover { background: var(--surface-2); }
.list .r { text-align: right; }
.list td.r { white-space: nowrap; }
.list td.name { word-break: break-word; min-width: 180px; }
.list .actions { white-space: nowrap; }
.list .actions > * { display: inline-block; vertical-align: middle; }
.list td.detail { word-break: break-word; max-width: 420px; font-size: .88rem; }
.ico { margin-right: .5rem; }
.tag { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .75rem; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); margin-left: .25rem; }
.tag.ok { color: var(--ok); border-color: #245c44; }
.tag.bad { color: var(--danger); border-color: #6b2b2b; }
.tag.warn { color: var(--warn); border-color: #6a5316; }
.list td > .tag:first-child { margin-left: 0; }

/* menus */
details.menu { position: relative; display: inline-block; }
details.menu > summary { list-style: none; cursor: pointer; padding: .2rem .6rem; border-radius: 8px; color: var(--muted); user-select: none; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu > summary:hover { background: var(--surface-2); color: var(--text); }
details.menu > summary.btn { color: var(--text); }
.menu-body {
  /* fixed + positioned by app.js so the menu is never clipped by the table's scroll container */
  position: fixed; z-index: 20; top: 0; left: 0; width: 300px; max-width: calc(100vw - 16px); text-align: left; white-space: normal;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem;
  box-shadow: 0 8px 28px rgba(0,0,0,.5); display: grid; gap: .6rem;
}
.menu-body form { display: flex; gap: .4rem; margin: 0; }
.menu-body input, .menu-body select { margin: 0; min-width: 0; flex: 1; }
.admin-tools { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; margin-bottom: .75rem; }
.admin-tools form.inline { margin: 0; flex: 1 1 320px; }
.grow-right { margin-left: auto; }

/* file page */
.filename { word-break: break-word; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.25rem; margin: 0 0 1rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; }
.sum { display: inline-block; word-break: break-all; font-size: .85rem; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: .2rem .45rem; margin-right: .4rem; }
.howto summary { cursor: pointer; color: var(--accent); }
.checks { list-style: none; padding: 0; margin: 0 0 1rem; columns: 2 260px; }
.checks li { padding: .2rem 0; }
.checks label { font-weight: 400; margin: 0; }
.pager { display: flex; gap: .5rem; margin-top: 1rem; }

/* uploader */
.uploader { margin-bottom: 1rem; }
.dropzone { border: 1.5px dashed var(--border); border-radius: var(--radius); padding: 1rem; text-align: center; display: flex; gap: .6rem; align-items: center; justify-content: center; flex-wrap: wrap; }
.dropzone.over { border-color: var(--accent); background: rgba(76,141,255,.08); }
.upload-list { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; gap: .4rem; }
.upload-list li { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .5rem .75rem; }
.up-top { display: flex; justify-content: space-between; gap: 1rem; font-size: .88rem; }
.up-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-stat { color: var(--muted); white-space: nowrap; }
.up-bar { height: 6px; background: var(--bg); border-radius: 99px; margin-top: .4rem; overflow: hidden; }
.up-bar > div { height: 100%; width: 0; background: var(--accent); transition: width .15s linear; }
.upload-list li.done .up-bar > div { background: var(--ok); }
.upload-list li.fail .up-bar > div { background: var(--danger); }
.upload-list li.fail .up-stat { color: var(--danger); }

@media (max-width: 640px) {
  .hide-sm { display: none; }
  .top { gap: .75rem; }
  .list th, .list td { padding: .55rem .5rem; }
  .list td.name { min-width: 0; }
  .list td.actions { white-space: normal; text-align: right; }
  .list .actions > * { margin: 2px 0 2px 4px; }
  .toolbar select { flex: 1 1 30%; min-width: 0; }
  .toolbar input[type=search] { flex: 1 1 100%; }
  .facts { grid-template-columns: 1fr; gap: .1rem; }
  .facts dd { margin-bottom: .6rem; }
}
