:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #18202b;
  --muted: #667085;
  --border: #d9dee7;
  --accent: #1559b3;
  --accent-2: #0f468c;
  --danger: #b42318;
  --ok-bg: #e8f6ec;
  --ok-text: #186b35;
  --err-bg: #fdecea;
  --err-text: #8f1d14;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161d;
    --surface: #18202a;
    --surface-2: #202a36;
    --text: #e6ebf2;
    --muted: #98a4b5;
    --border: #2e3a49;
    --accent: #6ea8fe;
    --accent-2: #8abbff;
    --danger: #ff8a80;
    --ok-bg: #15341f;
    --ok-text: #9be7b3;
    --err-bg: #3a1b18;
    --err-text: #ffb4ab;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.brand {
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.who {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
}

.user { font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.container {
  width: min(1180px, 100%);
  margin: 1.5rem auto;
  padding: 0 1.25rem;
  flex: 1;
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 1rem 1.25rem 1.5rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.request-id { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }

h1 {
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  margin: 0 0 0.25rem;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.heading p { margin: 0; }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.narrow {
  max-width: 480px;
  margin: 2rem auto;
}

.table-card { padding: 0; overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th, td {
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--surface-2);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }

.name-cell { overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
.actions-col { width: 9rem; }
.actions-col .muted { display: inline-block; }

.action-trigger {
  background: none;
  color: var(--accent);
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.action-trigger:hover {
  background: none;
  text-decoration: underline;
}

.no-script-note { padding: 0.75rem 1rem; margin: 0; border-top: 1px solid var(--border); }

[hidden] { display: none !important; }

.upload-progress {
  display: grid;
  gap: 0.35rem;
  padding: 0.6rem 0.7rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.upload-progress.is-error { border-color: var(--danger); }

.upload-progress-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.upload-progress.is-error .upload-progress-head { color: var(--danger); }

.upload-progress-bar {
  width: 100%;
  height: 0.7rem;
  accent-color: var(--accent);
}

.upload-progress-bar::-webkit-progress-bar {
  background: var(--surface);
  border-radius: 999px;
}

.upload-progress-bar::-webkit-progress-value {
  background: var(--accent);
  border-radius: 999px;
}

.upload-progress-bar::-moz-progress-bar {
  background: var(--accent);
  border-radius: 999px;
}

button[disabled] {
  opacity: 0.65;
  cursor: wait;
}

.badge {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.badge-write { background: var(--ok-bg); color: var(--ok-text); border-color: transparent; }
.badge-read { background: var(--surface-2); color: var(--muted); }

.tag {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0 0.35rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.7rem;
  color: var(--muted);
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.crumb-sep { color: var(--muted); }
.breadcrumbs .current { color: var(--muted); }

.panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
}

.panel > summary {
  cursor: pointer;
  font-weight: 600;
}

.panel[open] > summary { margin-bottom: 0.8rem; }

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.stack.compact { gap: 0.45rem; }

label { font-size: 0.88rem; font-weight: 600; }
label.checkbox { font-weight: 400; display: flex; align-items: center; gap: 0.4rem; }

input[type="text"], input[type="password"], input[name="login"], input[name="name"], input[type="file"] {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem 0.6rem;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
}

input[type="file"] { padding: 0.4rem; }

input:focus-visible, button:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button {
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 7px;
  padding: 0.48rem 0.85rem;
  cursor: pointer;
}

button:hover { background: var(--accent-2); }
button.danger { background: var(--danger); }
button.danger:hover { filter: brightness(0.9); }

button.secondary {
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

button.secondary:hover { background: var(--surface-2); filter: brightness(0.97); }

.icon-button {
  color: var(--muted);
  background: none;
  border: 0;
  padding: 0.05rem 0.45rem;
  font-size: 1.5rem;
  line-height: 1;
  border-radius: 6px;
}

.icon-button:hover { color: var(--text); background: var(--surface-2); }

.link-button {
  background: none;
  color: var(--accent);
  padding: 0;
  font-weight: 500;
}

.link-button:hover { background: none; text-decoration: underline; }

.login-link { font-weight: 600; }

.inline { display: inline; }

.flash {
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  margin: 0 0 1rem;
  font-size: 0.9rem;
}

.flash-ok { background: var(--ok-bg); color: var(--ok-text); }
.flash-error { background: var(--err-bg); color: var(--err-text); }

.location-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}

.location-list li {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}

.location-list a { font-weight: 600; overflow-wrap: anywhere; }

.empty { padding: 1.25rem; margin: 0; color: var(--muted); }

.modal {
  width: min(560px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  margin: auto;
  padding: 0;
  overflow: auto;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}

.modal[open] { animation: modal-in 0.13s ease-out; }

@keyframes modal-in {
  from { opacity: 0; transform: translateY(6px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

body:has(dialog.modal[open]) { overflow: hidden; }

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  margin: 0.15rem 0 0;
  font-size: 1.2rem;
  overflow-wrap: anywhere;
}

.modal-body {
  display: grid;
  gap: 1.1rem;
  padding: 1.1rem 1.25rem;
}

.modal-section h3 {
  margin: 0 0 0.65rem;
  font-size: 1rem;
}

.modal-section p { margin: 0 0 0.65rem; }

.danger-zone {
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.danger-zone h3 { color: var(--danger); }

.modal-actions {
  display: flex;
  justify-content: flex-start;
  gap: 0.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  padding: 0.8rem 1.25rem;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}

@media (max-width: 700px) {
  .modal { width: calc(100vw - 1rem); max-height: calc(100vh - 1rem); }
  .modal-header, .modal-body, .modal-footer { padding-left: 0.9rem; padding-right: 0.9rem; }
}

@media (max-width: 700px) {
  th:nth-child(2), td:nth-child(2),
  th:nth-child(3), td:nth-child(3) { display: none; }
  .actions-col { width: auto; }
  .topbar { align-items: flex-start; }
}
