:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #dfe3e8;
  --text: #17202a;
  --muted: #64707d;
  --accent: #1a73e8;
  --accent-text: #ffffff;
  --danger: #c62828;
  --ok: #2e7d32;
  --warn: #b26a00;
  --code-bg: #eef1f4;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0f1419;
    --surface: #171d24;
    --border: #2a323c;
    --text: #e6eaee;
    --muted: #93a0ad;
    --accent: #5aa2ff;
    --accent-text: #08111c;
    --danger: #ef7676;
    --ok: #6fcf78;
    --warn: #e8b04a;
    --code-bg: #10161c;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', sans-serif;
}

main,
header .bar {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px;
}

main {
  padding-top: 20px;
  padding-bottom: 60px;
}

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

header .bar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  min-height: 56px;
}

header h1 {
  font-size: 17px;
  margin: 0 8px 0 0;
}

nav {
  display: flex;
  gap: 4px;
  flex: 1;
  flex-wrap: wrap;
}

nav a {
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
}

nav a:hover {
  color: var(--text);
}

nav a[aria-current='page'] {
  background: var(--code-bg);
  color: var(--text);
}

a {
  color: var(--accent);
}

h2 {
  font-size: 18px;
  margin: 0 0 12px;
}

h3 {
  font-size: 15px;
  margin: 0 0 8px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}

.row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.row > label {
  flex: 1 1 180px;
}

.spread {
  justify-content: space-between;
  align-items: center;
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}

.row > label {
  margin-bottom: 0;
}

input,
select {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  min-width: 0;
}

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

button {
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 6px;
  padding: 8px 14px;
}

button:disabled {
  opacity: 0.55;
  cursor: default;
}

button.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

button.danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}

button.small {
  padding: 3px 9px;
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

td.actions {
  white-space: nowrap;
}

td.actions .menu {
  margin-left: 10px;
}

/* Row action dropdown. The panel is positioned by script (position: fixed) so tables can't clip it. */
.menu {
  display: inline-block;
}

.menu > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 9px;
  font-size: 13px;
  font-weight: 500;
}

.menu > summary::-webkit-details-marker {
  display: none;
}

.menu > summary::after {
  content: '\25BE';
  margin-left: 6px;
  color: var(--muted);
}

.menu > summary:hover,
.menu[open] > summary {
  background: var(--code-bg);
}

.menu-panel {
  position: fixed;
  z-index: 20;
  min-width: 190px;
  display: flex;
  flex-direction: column;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.menu-item {
  width: 100%;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-weight: 400;
  text-align: left;
  padding: 7px 10px;
}

.menu-item:hover,
.menu-item:focus-visible {
  background: var(--code-bg);
}

.menu-item.danger {
  color: var(--danger);
}

.menu-sep {
  height: 1px;
  margin: 4px 2px;
  background: var(--border);
}

.mono,
code,
pre {
  font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  font-size: 13px;
}

.mono {
  word-break: break-all;
}

pre {
  background: var(--code-bg);
  border-radius: 8px;
  padding: 12px;
  overflow: auto;
  max-height: 480px;
  margin: 8px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.muted {
  color: var(--muted);
}

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--code-bg);
  color: var(--muted);
}

.badge.bad {
  color: var(--danger);
}

.badge.good {
  color: var(--ok);
}

.badge.warn {
  color: var(--warn);
}

.hint {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 12px;
}

.notice {
  border-left: 3px solid var(--warn);
  padding: 8px 12px;
  background: var(--code-bg);
  border-radius: 0 6px 6px 0;
  margin-bottom: 12px;
  font-size: 14px;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list li {
  border-bottom: 1px solid var(--border);
  padding: 8px 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.list li:last-child {
  border-bottom: 0;
}

.list button.link {
  all: unset;
  cursor: pointer;
  color: var(--accent);
  word-break: break-all;
}

.log {
  max-height: 320px;
  overflow: auto;
  background: var(--code-bg);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 8px 0 0;
}

.log div {
  display: flex;
  gap: 10px;
}

.log time {
  color: var(--muted);
  flex: none;
}

.login {
  max-width: 360px;
  margin: 15vh auto 0;
}

dialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  padding: 20px;
  width: min(420px, calc(100vw - 32px));
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

dialog .row {
  justify-content: flex-end;
}

#toasts {
  position: fixed;
  bottom: 16px;
  right: 16px;
  left: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--text);
  color: var(--bg);
  padding: 10px 14px;
  border-radius: 8px;
  max-width: 480px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.toast.error {
  background: var(--danger);
  color: #fff;
}

.progress-line {
  margin: 8px 0 0;
  color: var(--muted);
}
