:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #e4e7ec;
  --text: #1d2939;
  --muted: #667085;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --ok-bg: #ecfdf3;
  --ok-text: #027a48;
  --warn-bg: #fffaeb;
  --warn-text: #b54708;
  --err-bg: #fef3f2;
  --err-text: #b42318;
  --radius: 10px;
}

* { box-sizing: border-box; }

/* Several elements below set `display`, which would otherwise beat the UA
   stylesheet's `[hidden] { display: none }` and leave them permanently visible. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1120px; margin: 0 auto; padding: 24px 20px 48px; }

.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

/* ── Buttons ─────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 8px; border: 1px solid transparent;
  padding: 8px 14px; font-size: 13px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: background-color .15s, border-color .15s, opacity .15s;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--brand-dark); }

.btn.ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn.ghost:hover:not(:disabled) { background: #f2f4f7; }

.ico { font-size: 14px; line-height: 1; }

/* ── Banner ──────────────────────────────────────────────────────────── */

.banner {
  padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px;
  font-size: 13px; display: flex; align-items: center; gap: 10px;
}
.banner.info { background: var(--warn-bg); color: var(--warn-text); }
.banner.ok   { background: var(--ok-bg);   color: var(--ok-text); }
.banner.err  { background: var(--err-bg);  color: var(--err-text); }

.spinner {
  width: 13px; height: 13px; flex: none;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toolbar ─────────────────────────────────────────────────────────── */

.toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }

.search { position: relative; flex: 1; max-width: 420px; }
.search-ico {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}
.search input {
  width: 100%; padding: 9px 12px 9px 34px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font-size: 13px;
}
.search input:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }

.count { color: var(--muted); font-size: 13px; }

/* ── Table ───────────────────────────────────────────────────────────── */

.table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow-x: auto;
}

.tbl { width: 100%; border-collapse: collapse; min-width: 720px; }
.tbl th {
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted);
  padding: 11px 16px; border-bottom: 1px solid var(--border); background: #fcfcfd;
}
.tbl td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: #fcfcfd; }

.col-files { width: 110px; }
.col-action { width: 190px; text-align: right; }
.col-action { white-space: nowrap; }

.name { font-weight: 500; }
.mono { color: var(--muted); font-size: 13px; }
.dash { color: #d0d5dd; }

.pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  background: #eff4ff; color: #175cd3; font-size: 12px; font-weight: 500;
}

.filelist { margin: 4px 0 0; padding: 0; list-style: none; color: var(--muted); font-size: 12px; }
.filelist li { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 340px; }

/* Nothing to browse until the session handshake succeeds. */
body.no-session .toolbar,
body.no-session .table-wrap,
body.no-session .pager,
body.no-session #refresh { display: none; }

.empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); margin-bottom: 6px; font-size: 15px; }

/* ── Pager ───────────────────────────────────────────────────────────── */

.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 18px; }
.pageinfo { color: var(--muted); font-size: 13px; }

@media (max-width: 640px) {
  .wrap { padding: 16px 12px 32px; }
  .head { flex-direction: column; align-items: stretch; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .search { max-width: none; }
}
