/* --------------------------------------------------------------------------
   Niche File Gateway - explorer stylesheet. One file, every colour a token so
   day and night share one layout. Day is the default (light palette on :root,
   so the page is light before any script runs); night is opt-in through
   html[data-theme="dark"], remembered per browser.

   The gateway blue #2f6fb7 is the same one the public link.php and index.php
   pages use, so the whole site reads as one thing.
   -------------------------------------------------------------------------- */

:root {
  --bg:        #f2f4f7;
  --bg-2:      #e9edf3;
  --panel:     #ffffff;
  --panel-2:   #f5f7fa;
  --line:      #d8dee8;
  --line-soft: #e7ebf1;
  --ink:       #16202c;
  --ink-2:     #33414f;
  --muted:     #5b6c80;
  --faint:     #8a97a8;

  --accent:      #2f6fb7;
  --accent-d:    #255b98;
  --accent-ink:  #ffffff;
  --accent-text: #255b98;
  --accent-soft: rgba(47,111,183,.12);

  --ok:      #2f8a3f;
  --warn:    #a06a0c;
  --danger:  #b03030;
  --info:    #1b6fa8;
  --purple:  #6f48ad;

  --radius:   12px;
  --radius-s: 8px;
  --shadow:   0 10px 26px rgba(20,30,45,.14);
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Inter, Arial, sans-serif;
}

html[data-theme="dark"] {
  --bg:        #0f151d;
  --bg-2:      #151d27;
  --panel:     #18212c;
  --panel-2:   #1e2935;
  --line:      #2d3b4b;
  --line-soft: #243040;
  --ink:       #e6ecf3;
  --ink-2:     #c0cbd8;
  --muted:     #93a2b4;
  --faint:     #66758a;

  --accent:      #4a8ad6;
  --accent-d:    #3b78c0;
  --accent-ink:  #ffffff;
  --accent-text: #7fb3ea;
  --accent-soft: rgba(74,138,214,.18);

  --ok:      #5fc56f;
  --warn:    #e6b45a;
  --danger:  #ef6b6b;
  --info:    #6bb8ef;
  --purple:  #b48ce8;
  --shadow:  0 10px 30px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
html, body { height: 100%; }

a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5em; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.4rem; } h2 { font-size: 1.05rem; } h3 { font-size: .95rem; }

.hidden { display: none !important; }
.dim { color: var(--muted); }
.mono { font-family: var(--mono); font-size: .93em; }
.mono.small { font-size: 11.5px; word-break: break-all; }
.nowrap { white-space: nowrap; }
.spacer { flex: 1 1 auto; }
.hint { color: var(--faint); font-size: 12.5px; margin: -4px 0 10px; }

/* ------------------------------------------------------------- app shell */

.shell { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  flex: none; display: flex; align-items: center; gap: 14px;
  padding: 9px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 680; letter-spacing: -.015em; white-space: nowrap; }
.brand .mark {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  background: linear-gradient(140deg, var(--accent), var(--accent-d));
  display: grid; place-items: center; color: var(--accent-ink); font-size: 12px; font-weight: 800;
}
.brand small { display: block; font-size: 11px; color: var(--muted); font-weight: 500; letter-spacing: .04em; }

.appsel { display: flex; align-items: center; gap: 8px; margin-left: 10px; }
.appsel > span { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.appsel select { width: auto; min-width: 200px; padding: 6px 30px 6px 10px; }

.topnav { display: flex; gap: 4px; margin-left: 6px; }
.topnav button {
  border: none; background: none; padding: 7px 12px; border-radius: var(--radius-s);
  color: var(--ink-2); font-weight: 550;
}
.topnav button:hover { background: var(--panel-2); color: var(--ink); }
.topnav button.on { background: var(--accent-soft); color: var(--accent-text); }

.who { text-align: right; line-height: 1.25; font-size: 13px; }
.who b { display: block; font-weight: 600; }
.who span { color: var(--muted); font-size: 11.5px; }

/* ------------------------------------------------------------- status bar */

.statusbar {
  flex: none; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 6px 16px; font-size: 12.5px;
  background: var(--panel-2); border-bottom: 1px solid var(--line); color: var(--ink-2);
}
.node-strip, .traffic-strip { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.statusbar .sep { color: var(--faint); }
.ndot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex: none;
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--faint) 20%, transparent); }
.ndot.on  { background: var(--ok);     box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.ndot.off { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent); }

/* -------------------------------------------------------------- explorer */

.explorer { flex: 1 1 auto; display: flex; min-height: 0; }

.tree-pane {
  width: 290px; flex: none; display: flex; flex-direction: column; min-height: 0;
  background: var(--panel); border-right: 1px solid var(--line);
}
.pane-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 14px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 650; border-bottom: 1px solid var(--line-soft);
}
.pane-head .dim { text-transform: none; letter-spacing: 0; font-weight: 500; }
.tree-scroll { flex: 1 1 auto; overflow: auto; padding: 6px 0 20px; }

ul.tree, ul.tree ul { list-style: none; margin: 0; padding: 0; }
.tnode {
  display: flex; align-items: center; gap: 5px; padding: 4px 10px 4px 8px;
  cursor: pointer; user-select: none; white-space: nowrap; border-radius: 0;
  color: var(--ink-2);
}
.tnode:hover { background: var(--panel-2); color: var(--ink); }
.tnode.on { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.tnode .tname { overflow: hidden; text-overflow: ellipsis; }
.tnode .ico { display: inline-flex; flex: none; color: var(--accent); }
.tnode.on .ico { color: var(--accent-text); }
.caret {
  width: 18px; height: 18px; padding: 0; border: none; background: none; border-radius: 4px;
  color: var(--faint); font-size: 12px; flex: none; display: grid; place-items: center;
  transition: transform .12s;
}
.caret:hover { background: var(--line-soft); color: var(--ink); }
.caret.open { transform: rotate(90deg); }
.caret.none { visibility: hidden; }

.list-pane { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }

.toolbar {
  flex: none; display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.toolbar button { padding: 6px 11px; font-size: 13px; }
.tb-sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.searchbox input { width: 280px; padding: 6px 10px; }

.crumbs {
  flex: none; display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  padding: 7px 14px; font-size: 13px; background: var(--panel); border-bottom: 1px solid var(--line-soft);
  color: var(--muted);
}
.crumb { border: none; background: none; padding: 2px 5px; border-radius: 5px; color: var(--accent-text); font-weight: 550; font-size: 13px; }
button.crumb:hover { background: var(--accent-soft); }
.crumb.cur { color: var(--ink); font-weight: 650; }
.crumbs .sep { color: var(--faint); }

.list-scroll { flex: 1 1 auto; overflow: auto; background: var(--panel); position: relative; }
.listfoot {
  flex: none; display: flex; align-items: center; gap: 12px; padding: 6px 14px;
  font-size: 12.5px; background: var(--panel-2); border-top: 1px solid var(--line);
}

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow: auto; }

table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; padding: 8px 12px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 650; border-bottom: 1px solid var(--line); background: var(--panel-2);
  white-space: nowrap; position: sticky; top: 0; z-index: 2;
}
table.data td { padding: 7px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.data tbody tr:hover { background: var(--panel-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr.row-off { opacity: .55; }

table.files { table-layout: fixed; }
table.files .col-size   { width: 100px; }
table.files .col-status { width: 230px; }
table.files .col-links  { width: 70px; }
table.files .col-date   { width: 150px; }
table.files td.name { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
table.files td.name .ico { display: inline-flex; flex: none; color: var(--muted); }
table.files tr.folder td.name .ico { color: var(--accent); }
/* Zero basis + max-content cap: a long name stays on the icon's line and truncates
   (a wrapping flex line breaks before it shrinks), a short one keeps its slug chip close. */
table.files td.name .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; min-width: 0; flex: 1 1 0; max-width: max-content; }
table.files td.name .cell-sub { flex: 1 1 100%; }
/* "frow", not "row": .row is the flex layout utility and would blockify the cells. */
table.files tr.frow { cursor: default; user-select: none; }
table.files tr.frow.sel { background: var(--accent-soft); }
table.files tr.frow.sel td { border-bottom-color: color-mix(in srgb, var(--accent) 30%, var(--line-soft)); }
table.files tr.folder .fname { color: var(--ink); }

.cell-title { font-weight: 600; color: var(--ink); }
.cell-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink-2); margin-bottom: 5px; font-size: 14.5px; }
.empty.small { padding: 18px; }

/* ----------------------------------------------------------------- chips */

.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .02em; white-space: nowrap;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink-2);
}
.chip.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.tiny { padding: 0 6px; font-size: 10.5px; }

.st-staged   { color: var(--info);   border-color: color-mix(in srgb, var(--info) 42%, var(--line));   background: color-mix(in srgb, var(--info) 12%, transparent); }
.st-scanning { color: var(--warn);   border-color: color-mix(in srgb, var(--warn) 42%, var(--line));   background: color-mix(in srgb, var(--warn) 12%, transparent); }
.st-stored   { color: var(--ok);     border-color: color-mix(in srgb, var(--ok) 42%, var(--line));     background: color-mix(in srgb, var(--ok) 12%, transparent); }
.st-infected { color: #fff; background: var(--danger); border-color: var(--danger); }
.st-deleting { color: var(--muted);  border-color: color-mix(in srgb, var(--muted) 42%, var(--line));  background: color-mix(in srgb, var(--muted) 12%, transparent); }
.st-deleted  { color: var(--faint); }
.st-missing  { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 42%, var(--line)); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.st-pending  { color: var(--purple); border-color: color-mix(in srgb, var(--purple) 42%, var(--line)); background: color-mix(in srgb, var(--purple) 12%, transparent); }
.st-link     { color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 42%, var(--line)); background: var(--accent-soft); }
.st-live     { color: var(--ok);     border-color: color-mix(in srgb, var(--ok) 42%, var(--line));     background: color-mix(in srgb, var(--ok) 12%, transparent); }
.st-revoked  { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 42%, var(--line)); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.st-expired, .st-spent { color: var(--faint); }
.st-queued   { color: var(--info); }
.st-taken, .st-staging { color: var(--warn); }
.st-done     { color: var(--ok); }
.st-error    { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 42%, var(--line)); background: color-mix(in srgb, var(--danger) 12%, transparent); }
/* Admin -> Users: the role chips and the "you" marker */
.st-admin    { color: var(--purple); border-color: color-mix(in srgb, var(--purple) 42%, var(--line)); background: color-mix(in srgb, var(--purple) 12%, transparent); }
.st-staff    { color: var(--ink-2); }
.st-you      { color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 42%, var(--line)); background: var(--accent-soft); }

.pending-anim::before { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* ---------------------------------------------------------------- inputs */

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 550; letter-spacing: .02em; }

input[type=text], input[type=email], input[type=number], input[type=search], input[type=password],
input[type=datetime-local], select, textarea {
  width: 100%; padding: 8px 11px; background: var(--bg-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-s); font: inherit; font-size: 14px;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input:disabled, select:disabled, textarea:disabled { opacity: .55; cursor: not-allowed; }
select { cursor: pointer; }

.check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; flex: none; }
.checks { display: flex; gap: 6px 14px; flex-wrap: wrap; margin: 4px 0 12px; }
.radios { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 12px; }
.radios .check { align-items: flex-start; }
.radios .check input { margin-top: 2px; }
.radios .check b { color: var(--ink); }

/* Per-row controls in the Users table: a compact select beside the buttons */
.row-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
table.users select.small { width: auto; padding: 4px 26px 4px 8px; font-size: 12.5px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > * { min-width: 0; }
.row.center { justify-content: center; align-items: center; margin-top: 8px; }
.grow { flex: 1 1 180px; }

/* --------------------------------------------------------------- buttons */

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--radius-s);
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 550; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .05s;
}
button:hover { background: var(--line-soft); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
button:disabled:hover { background: var(--panel-2); }

button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 620; }
button.primary:hover { background: var(--accent-d); border-color: var(--accent-d); }
button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
button.danger:hover { background: color-mix(in srgb, var(--danger) 14%, transparent); }
button.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 650; }
button.danger-solid:hover { background: color-mix(in srgb, var(--danger) 88%, #000); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover { background: var(--panel-2); color: var(--ink); }
button.small { padding: 4px 10px; font-size: 12.5px; }
button.icon { padding: 6px; width: 32px; height: 32px; }
button.wide { width: 100%; margin-bottom: 8px; }

/* ---------------------------------------------------------------- panels */

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel + .panel { margin-top: 14px; }
.panel-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 11px 16px; border-bottom: 1px solid var(--line); background: var(--panel-2);
}
.panel-head h2 { margin: 0; font-size: 1rem; display: flex; align-items: center; gap: 8px; }
.panel-body { padding: 16px; }
.app-card.off { opacity: .7; }

.admin { flex: 1 1 auto; min-height: 0; padding: 16px; overflow: auto; }
.admin > .panel { min-height: 100%; display: flex; flex-direction: column; }
.admin .panel-body { flex: 1 1 auto; }

.tabs { display: flex; gap: 3px; border-bottom: 1px solid var(--line); padding: 0 12px; background: var(--panel-2); overflow-x: auto; }
.tabs button { border: none; background: none; border-radius: 0; border-bottom: 2px solid transparent; padding: 11px 13px; color: var(--muted); font-weight: 560; }
.tabs button:hover { background: none; color: var(--ink); }
.tabs button.on { color: var(--accent-text); border-bottom-color: var(--accent); }

.grid.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 14px; }
.stat b { display: block; font-size: 1.45rem; font-weight: 680; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; }
.stat.alert b { color: var(--warn); }
.stat.bad b { color: var(--danger); }
.stat.good b { color: var(--ok); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; font-size: 13.5px; margin: 0; }
.kv dt { color: var(--muted); white-space: nowrap; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.note { padding: 10px 13px; border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--panel-2); font-size: 13.5px; color: var(--ink-2); margin-bottom: 12px; }
.note b { color: var(--ink); }
.note.warn   { border-color: color-mix(in srgb, var(--warn) 45%, var(--line));   background: color-mix(in srgb, var(--warn) 12%, transparent);   color: var(--warn); }
.note.danger { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.note.ok     { border-color: color-mix(in srgb, var(--ok) 45%, var(--line));     background: color-mix(in srgb, var(--ok) 12%, transparent);     color: var(--ok); }
.note.info   { border-color: color-mix(in srgb, var(--info) 45%, var(--line));   background: color-mix(in srgb, var(--info) 12%, transparent);   color: var(--info); }

.keybox {
  display: flex; gap: 10px; align-items: center;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px 12px; margin: 8px 0 4px;
}
.keybox code { flex: 1 1 auto; font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; word-break: break-all; user-select: all; }

/* ------------------------------------------------------------- pagination */

.pager { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 0 0; }
.pager .count { color: var(--muted); font-size: 13px; }
.pager .pages { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.pager button { padding: 4px 10px; font-size: 13px; }
.pager button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------------------------------------------------------- traffic bars */

.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding: 6px 0 0; border-bottom: 1px solid var(--line); }
.bars .bar { flex: 1 1 0; min-width: 4px; background: var(--accent); border-radius: 3px 3px 0 0; opacity: .85; position: relative; min-height: 1px; }
.bars .bar.zero { background: var(--line); }
.bars .bar:hover { opacity: 1; }
.bars-x { display: flex; justify-content: space-between; color: var(--faint); font-size: 11px; margin-top: 4px; }

/* ---------------------------------------------------------------- modals */

.backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(6,12,20,.6); backdrop-filter: blur(2px);
  display: grid; place-items: center; padding: 20px; animation: fade .12s ease;
}
/* Only the dimming fades in. Animating the backdrop's opacity would make the
   dialog itself translucent for as long as the frame lasts (group opacity). */
@keyframes fade { from { background-color: rgba(6,12,20,0); } }
.modal {
  width: min(760px, 100%); max-height: calc(100vh - 40px);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.modal.wide { width: min(1100px, 100%); }
.modal.narrow { width: min(480px, 100%); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.modal-head h2 { margin: 0; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.modal-body { padding: 18px; overflow: auto; flex: 1 1 auto; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--panel-2); }
.modal-foot .left { margin-right: auto; color: var(--muted); font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.picker { max-height: 50vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--bg-2); padding: 4px 0; }
.pick { display: flex; align-items: center; gap: 7px; padding: 5px 10px; cursor: pointer; user-select: none; white-space: nowrap; }
.pick:hover { background: var(--panel-2); }
.pick.on { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.pick.dis { opacity: .4; cursor: not-allowed; }
.pick em { color: var(--faint); font-style: normal; font-size: 12px; }
.pick svg { color: var(--accent); flex: none; }

/* ---------------------------------------------------------------- toasts */

#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast {
  pointer-events: auto; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--radius-s); box-shadow: var(--shadow); padding: 10px 14px; font-size: 14px; max-width: 440px;
  animation: slidein .18s ease;
}
.toast.bad  { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
.toast.ok   { border-left-color: var(--ok); }
@keyframes slidein { from { opacity: 0; transform: translateY(8px); } }

/* --------------------------------------------------------------- sign-in */

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 22px; }
.auth { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-top: 4px solid var(--accent); border-radius: 16px; box-shadow: var(--shadow); padding: 30px; }
.auth .brand { justify-content: center; margin-bottom: 18px; }
.auth .sub { text-align: center; color: var(--muted); font-size: 13.5px; margin: 0 0 16px; }
.auth .sub b { color: var(--ink); overflow-wrap: anywhere; }
.code-input { text-align: center; font-family: var(--mono); font-size: 26px !important; letter-spacing: .34em; padding: 12px !important; text-indent: .34em; }

/* ------------------------------------------------------------------ misc */

.spin { width: 16px; height: 16px; border-radius: 50%; margin: 0 auto; border: 2px solid color-mix(in srgb, currentColor 28%, transparent); border-top-color: currentColor; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { padding: 40px; text-align: center; color: var(--muted); }
hr.sep { border: none; border-top: 1px solid var(--line); margin: 16px 0; }

@media (max-width: 900px) {
  .tree-pane { width: 220px; }
  .who { display: none; }
  .searchbox input { width: 180px; }
  table.files .col-date, table.files tr.frow td:nth-child(5) { display: none; }
}

/* ------------------------------------------------------------- view menu */

.dropdown { position: relative; }
.dropdown .menu {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 60; min-width: 200px; padding: 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-s); box-shadow: var(--shadow);
}
.menu .mi {
  display: flex; align-items: center; justify-content: flex-start; gap: 6px; width: 100%;
  border: none; background: none; border-radius: 6px; padding: 6px 12px 6px 6px; font-size: 13px; text-align: left; color: var(--ink);
}
.menu .mi:hover { background: var(--panel-2); }
.menu .mi .tick { width: 16px; flex: none; text-align: center; color: var(--accent-text); font-weight: 700; }
.menu .mi-sep { height: 1px; background: var(--line); margin: 4px 2px; }
.caret-dn { font-size: 10px; color: var(--faint); margin-left: 2px; }
#tb-view .ico { display: inline-flex; color: var(--muted); }

/* ----------------------------------------------------------- list views */

.ico svg { display: block; width: 16px; height: 16px; }
.fitem { cursor: default; user-select: none; }
.fitem .ico { display: inline-flex; flex: none; color: var(--muted); position: relative; }
.fitem .fname { font-weight: 550; color: var(--ink); }
/* Icon families by kind. Three classes deep so they beat the
   table.files td.name .ico colour of the Details view. */
.explorer .ico.k-folder, .explorer .ico.k-app, .explorer .ico.k-apps { color: var(--accent); }
.explorer .ico.k-pdf     { color: var(--danger); }
.explorer .ico.k-image   { color: var(--ok); }
.explorer .ico.k-dwg     { color: var(--purple); }
.explorer .ico.k-dxf     { color: var(--info); }
.explorer .ico.k-generic { color: var(--muted); }

/* the tiny status dot on tiles and icons */
.sdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; vertical-align: middle; }
.sdot.stored   { background: var(--ok); }
.sdot.staged   { background: var(--info); }
.sdot.scanning { background: var(--warn); }
.sdot.infected, .sdot.missing { background: var(--danger); }
.sdot.deleting { background: var(--muted); }
.sdot.deleted  { background: var(--faint); }
.sdot.pending  { background: var(--purple); }
.sdot.folder   { background: var(--accent); opacity: .55; }

/* icon grids: Extra large / Large / Medium / Small */
.v-icons {
  display: grid; gap: 4px; padding: 12px; align-content: start;
  grid-template-columns: repeat(auto-fill, minmax(var(--cell), 1fr));
}
.v-icons.xl { --cell: 280px; --ico: 256px; }
.v-icons.lg { --cell: 184px; --ico: 160px; }
.v-icons.md { --cell: 120px; --ico: 96px; }
.v-icons.sm { --cell: 84px;  --ico: 48px; }
.v-icons .fitem {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px 8px;
  border-radius: var(--radius-s); border: 1px solid transparent; min-width: 0;
}
.v-icons .fitem:hover { background: var(--panel-2); }
.v-icons .fitem.sel { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.v-icons .ico { width: var(--ico); height: var(--ico); }
.v-icons .ico svg { width: 100%; height: 100%; }
.v-icons .sdot { position: absolute; right: 9%; bottom: 8%; width: 9px; height: 9px; box-shadow: 0 0 0 2px var(--panel); }
.v-icons.sm .sdot { right: 2px; bottom: 2px; width: 7px; height: 7px; }
.v-icons .fname {
  font-size: 12.5px; line-height: 1.3; text-align: center; max-width: 100%; overflow: hidden; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.v-icons.xl .fname, .v-icons.lg .fname { font-size: 13px; }
.v-icons.sm .fname { font-size: 12px; }

/* List: a column-wise flow that wraps into more columns, scrolling sideways */
.v-list { height: 100%; padding: 8px 6px; column-width: 240px; column-gap: 4px; column-fill: auto; }
.v-list .fitem {
  display: flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 5px;
  break-inside: avoid; page-break-inside: avoid; min-width: 0;
}
.v-list .fitem:hover { background: var(--panel-2); }
.v-list .fitem.sel { background: var(--accent-soft); }
.v-list .fname { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Tiles: icon + name + "size · status" */
.v-tiles {
  display: grid; gap: 4px 8px; padding: 12px; align-content: start;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}
.v-tiles .fitem {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-s);
  border: 1px solid transparent; min-width: 0;
}
.v-tiles .fitem:hover { background: var(--panel-2); }
.v-tiles .fitem.sel { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.v-tiles .ico { width: 48px; height: 48px; }
.v-tiles .ico svg { width: 100%; height: 100%; }
.v-tiles .txt { min-width: 0; flex: 1 1 auto; }
.v-tiles .fname, .v-tiles .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-tiles .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* Content: one row per item, metadata on the right */
.v-content .fitem { display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-bottom: 1px solid var(--line-soft); }
.v-content .fitem:hover { background: var(--panel-2); }
.v-content .fitem.sel { background: var(--accent-soft); }
.v-content .ico { width: 32px; height: 32px; }
.v-content .ico svg { width: 100%; height: 100%; }
.v-content .txt { flex: 1 1 auto; min-width: 0; }
.v-content .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-content .sub { color: var(--muted); font-size: 12px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-content .meta { flex: none; display: flex; gap: 16px; align-items: center; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.v-content .meta > span { text-align: right; white-space: nowrap; }

/* The Details table's fixed columns (size + status + links + date = 550 px)
   must leave room for the name when the side panes narrow the list pane, so
   the columns fold by the pane's own width rather than the window's. */
.list-pane { container-type: inline-size; }
@container (max-width: 640px) {
  table.files .col-status { width: 120px; }
  table.files .col-date, table.files tr.frow td:nth-child(5) { display: none; }
}
@container (max-width: 480px) {
  table.files .col-links, table.files tr.frow td:nth-child(4) { display: none; }
}

/* Details (the table): sortable headers */
table.files th.sortable { cursor: pointer; }
table.files th.sortable:hover, table.files th.sortable.on { color: var(--ink); }
table.files th .sort-ind { font-size: 9px; margin-left: 5px; color: var(--accent-text); }
table.files td.name .chip.tiny { flex: none; }

/* ------------------------------------------------------------ side panes */

.side-pane {
  width: 320px; flex: none; display: flex; flex-direction: column; min-height: 0; position: relative;
  background: var(--panel); border-left: 1px solid var(--line);
  /* A width dragged wide on a big screen is remembered as an inline style; on a
     narrower window it must not squeeze the list pane (min-width 0) to nothing. */
  max-width: max(220px, calc(100vw - 600px));
}
.side-pane .grip { position: absolute; left: -4px; top: 0; bottom: 0; width: 7px; cursor: col-resize; z-index: 3; }
.side-pane .grip:hover { background: var(--accent-soft); }
body.col-drag { cursor: col-resize; user-select: none; }
body.col-drag iframe { pointer-events: none; }

.pv-pane { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.dt-pane { flex: 1 1 auto; min-height: 0; overflow: auto; }
.side-pane.both .pv-pane { flex: 1 1 55%; border-bottom: 1px solid var(--line); }
.side-pane.both .dt-pane { flex: 1 1 45%; }

.pv-head { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.pv-head .ico { width: 18px; height: 18px; flex: none; }
.pv-head .ico svg { width: 100%; height: 100%; }
.pv-head .nm { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.pv-body {
  flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center;
  overflow: auto; background: var(--bg-2); padding: 10px;
}
.pv-body img { max-width: 100%; max-height: 100%; object-fit: contain; }
.pv-body iframe { width: 100%; height: 100%; border: none; background: #fff; }
.pv-body:has(iframe) { padding: 0; }
.pv-big { text-align: center; color: var(--muted); font-size: 13px; padding: 10px; max-width: 100%; }
.pv-big .ico { width: 96px; height: 96px; margin: 0 auto 10px; display: block; }
.pv-big .ico svg { width: 100%; height: 100%; }
.pv-big .err { color: var(--danger); }
.pv-bar { width: 200px; max-width: 100%; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 12px auto 8px; }
.pv-fill { height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .4s; }
.pv-foot { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line-soft); font-size: 12.5px; min-height: 42px; }

.dt-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line-soft); }
.dt-head .ico { width: 36px; height: 36px; flex: none; }
.dt-head .ico svg { width: 100%; height: 100%; }
.dt-head .txt { min-width: 0; }
.dt-head .nm { font-weight: 600; overflow-wrap: anywhere; }
.dt-head .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.dt-body { padding: 12px 14px; }
.dt-body .kv { grid-template-columns: 88px 1fr; gap: 7px 10px; font-size: 12.5px; }
.dt-body .kv dt { white-space: normal; }
.dt-body .kv dd .cell-sub { font-size: 11.5px; }
.dt-body .kv button.ghost.small { padding: 0 6px; font-size: 11.5px; vertical-align: middle; }
.dt-actions { margin-top: 14px; gap: 6px; }

@media (max-width: 1100px) {
  .side-pane { width: 260px; }
}
