:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #667085;
  --line: #e3e6eb;
  --brand: #0b6bcb;
  --brand-ink: #ffffff;
  --ok: #0f8a5f;
  --wait: #b7791f;
  --err: #c0392b;
  --off: #a0a7b2;
  --radius: 10px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --surface: #1a1f27;
    --text: #e6e9ee;
    --muted: #98a2b3;
    --line: #2b323d;
    --brand: #4c9be8;
    --brand-ink: #0b1420;
    --ok: #38c48b;
    --wait: #e0a43c;
    --err: #ef6a5b;
    --off: #6b7380;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
main { max-width: 760px; margin: 0 auto; padding: 16px; }
body.wide main { max-width: 1180px; }
a { color: var(--brand); }
h1 { font-size: 1.4rem; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; margin: 0 0 .5rem; }
code { font-size: .9em; background: var(--line); padding: 0 .25em; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.text-err { color: var(--err); }

.demo-banner { background: #7a3cc2; color: #fff; text-align: center; font-weight: 600; padding: 6px 12px; letter-spacing: .02em; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.05rem; }
.brand span:not(.logo) { font-weight: 400; color: var(--muted); }
.logo { color: var(--brand); display: inline-flex; }
.logo .icon { width: 24px; height: 24px; }
.nav { display: flex; align-items: center; gap: 16px; }
.nav a { text-decoration: none; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 24px 16px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.narrow { max-width: 420px; margin: 40px auto; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.inline { display: inline; margin: 0; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

input, select, button, .button { font: inherit; }
input[type=password], input[type=search], input:not([type]), select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text);
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
button:hover, .button:hover { border-color: var(--muted); }
.primary, button.primary, .button.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.danger, button.danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, var(--line)); }
.subtle { background: transparent; }
.small.button, .button.small { padding: 4px 10px; font-size: .85rem; }
.link { background: none; border: 0; padding: 0; color: var(--brand); cursor: pointer; text-decoration: underline; font: inherit; }

.alert { padding: 10px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); margin: 0 0 12px; }
.alert.error { border-color: color-mix(in srgb, var(--err) 50%, var(--line)); color: var(--err); }
.alert.warn { border-color: color-mix(in srgb, var(--wait) 60%, var(--line)); }
.alert.ok { border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); }

.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 8px; }
.search { display: flex; gap: 8px; flex: 1 1 380px; }
.search input { flex: 1; }
.quota { padding: 8px 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); }
.quota.full { border-color: var(--err); color: var(--err); }
.catalog-info { margin: 4px 0 10px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.files { width: 100%; border-collapse: collapse; }
table.files th, table.files td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
table.files thead th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
table.files tr.folder th { background: var(--bg); font-weight: 600; font-size: .9rem; color: var(--muted); padding: 6px 12px; }
table.files tr.folder .icon { width: 16px; height: 16px; vertical-align: -3px; }
table.files tr:last-child td { border-bottom: 0; }
.c-icon { width: 44px; }
.c-size, .c-date { white-space: nowrap; color: var(--muted); font-size: .9rem; }
.fname { word-break: break-all; font-weight: 500; }
.meta-mobile { display: none; }
.c-status { min-width: 220px; }
.c-status > span { display: block; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.actions:empty { display: none; }
.admin-form { display: inline-flex; gap: 6px; align-items: center; }
.admin-form select { width: auto; padding: 4px 8px; font-size: .85rem; }
.empty { text-align: center; color: var(--muted); padding: 30px !important; }

.icon { width: 26px; height: 26px; display: inline-block; }
.button .icon { width: 16px; height: 16px; }
.globe { display: inline-flex; border-radius: 50%; padding: 2px; }
.globe.off { color: var(--off); }
.globe.on { color: var(--ok); }
.globe.wait { color: var(--wait); }
.globe.run { color: var(--brand); }
.globe.err { color: var(--err); }
.globe.exp { color: var(--off); }
a.globe:hover { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); }
.globe.disabled { opacity: .45; cursor: not-allowed; }
.spin { animation: spin 1.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

.status { font-weight: 600; font-size: .9rem; }
.s-none { color: var(--muted); font-weight: 500; }
.s-wait { color: var(--wait); }
.s-run { color: var(--brand); }
.s-ok { color: var(--ok); }
.s-err { color: var(--err); }
.s-exp { color: var(--muted); }
progress { width: 100%; max-width: 260px; height: 8px; accent-color: var(--brand); }

dialog { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; width: min(440px, calc(100vw - 32px)); background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgb(0 0 0 / .45); }
.durations { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.durations legend { font-weight: 600; margin-bottom: 6px; }
.radio { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.radio:has(input:checked) { border-color: var(--brand); }

.admin { margin-bottom: 20px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin: 10px 0; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; }
.tile-v { font-size: 1.35rem; font-weight: 700; }
.tile-l { color: var(--muted); font-size: .85rem; }
.tile-h { color: var(--muted); font-size: .75rem; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; align-items: start; }
.admin-grid details summary { cursor: pointer; font-weight: 600; }
.admin-grid details[open] summary { margin-bottom: 10px; }
table.mini { width: 100%; border-collapse: collapse; font-size: .85rem; }
table.mini td, table.mini th { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }

@media (max-width: 720px) {
  .c-size, .c-date, thead { display: none; }
  table.files, table.files tbody, table.files tr, table.files td, table.files th { display: block; }
  table.files tr.file { display: grid; grid-template-columns: 40px 1fr; padding: 10px 6px; border-bottom: 1px solid var(--line); }
  table.files tr.file td { border: 0; padding: 2px 6px; }
  table.files tr.file td.c-status { grid-column: 2; min-width: 0; }
  .meta-mobile { display: block; color: var(--muted); font-size: .8rem; }
  .durations { grid-template-columns: 1fr; }
  .search { flex-basis: 100%; }
}
