:root {
  color-scheme: light dark;
  --bg: #f6f7f8;
  --panel: #ffffff;
  --side: #eef0f2;
  --text: #1c2024;
  --muted: #5d6670;
  --line: #d8dde2;
  --accent: #1f6feb;
  --accent-text: #ffffff;
  --good: #1a7f4b;
  --bad: #b3261e;
  --warn: #9a6700;
  --notice-bg: #e6f0ff;
  --error-bg: #fdecea;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181b;
    --panel: #1d2125;
    --side: #1a1d21;
    --text: #e4e7ea;
    --muted: #9aa4ae;
    --line: #333a41;
    --accent: #6ea8fe;
    --accent-text: #0f1215;
    --good: #5bd08f;
    --bad: #f28b82;
    --warn: #e3b341;
    --notice-bg: #1d2c44;
    --error-bg: #3c1f1d;
  }
}

* { box-sizing: border-box; }

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

h1 { font-size: 1.4rem; margin: 0 0 1rem; }
h2 { font-size: 1.05rem; margin: 2rem 0 0.75rem; }
a { color: var(--accent); }
code { font-family: ui-monospace, Consolas, Menlo, monospace; font-size: 0.9em; overflow-wrap: anywhere; }

.shell { display: grid; grid-template-columns: 200px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  background: var(--side);
  border-right: 1px solid var(--line);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.sidebar ul { list-style: none; margin: 0; padding: 0; flex: 1; }
.sidebar a { display: block; padding: 0.35rem 0.5rem; border-radius: 6px; color: var(--text); text-decoration: none; }
.sidebar a:hover { background: var(--line); }
.sidebar a[aria-current="page"] { background: var(--accent); color: var(--accent-text); }
.brand { font-weight: 600; }
.logout { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.who { color: var(--muted); overflow-wrap: anywhere; }

.content { padding: 1.5rem 2rem; max-width: 1100px; }
.solo { max-width: 360px; margin: 12vh auto 0; padding: 0 16px; }

.card, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem 1.25rem;
}
.card { display: flex; flex-direction: column; gap: 0.75rem; }
.panel { margin-bottom: 1rem; }

label { display: block; }
input, select {
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  max-width: 100%;
}
.card input { width: 100%; margin-top: 0.2rem; }
input[type="checkbox"] { width: auto; }

button, .button {
  font: inherit;
  display: inline-block;
  background: var(--accent);
  color: var(--accent-text);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0.35rem 0.8rem;
  cursor: pointer;
  text-decoration: none;
}
button.quiet, .button.quiet { background: transparent; color: var(--text); border-color: var(--line); }
button.danger { background: var(--bad); border-color: var(--bad); color: var(--accent-text); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; }

table { border-collapse: collapse; width: 100%; background: var(--panel); }
th, td { text-align: left; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
.scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.nowrap { white-space: nowrap; }
.detail { overflow-wrap: anywhere; color: var(--muted); }

.filters { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; margin-bottom: 1rem; }
.pager { display: flex; gap: 1rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 0.75rem; }

.notice, .error { padding: 0.5rem 0.75rem; border-radius: 6px; margin: 0 0 1rem; }
.notice { background: var(--notice-bg); }
.error { background: var(--error-bg); color: var(--bad); }

.pill { font-size: 0.85em; }
.pill.on { color: var(--good); }
.pill.off { color: var(--muted); }
.pill.warn { color: var(--warn); }

.hint { color: var(--muted); }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 1rem; padding: 0.75rem 1rem; min-width: 0; }
legend { padding: 0 0.3rem; color: var(--muted); }
.check { display: block; }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.2rem 1rem; margin: 0 0 1rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.secret { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin: 0.75rem 0; }
.tabs { display: flex; gap: 0.5rem; list-style: none; margin: 1rem 0; padding: 0; border-bottom: 1px solid var(--line); }
.tabs li { margin-bottom: -1px; }
.tabs a { display: block; padding: 0.5rem 1rem; border-bottom: 2px solid transparent; color: var(--muted); text-decoration: none; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { border-bottom-color: var(--accent); color: var(--text); font-weight: 600; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
}
.stat-val {
  font-size: 1.65rem;
  font-weight: 600;
  line-height: 1.2;
}
.stat-lbl {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}
.stat-sub {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.4rem;
}
.time-tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1rem;
}
.time-tabs a {
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
}
.time-tabs a.active, .time-tabs a[aria-current="page"] {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}
.chart-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  overflow: hidden;
}
.chart-box h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}
.chart-empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--muted);
}
.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
.header-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.job-progress-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}
.job-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}
.job-header h3 {
  margin: 0;
  font-size: 1.1rem;
}
.progress-bar-container {
  background: var(--line);
  border-radius: 4px;
  height: 12px;
  overflow: hidden;
  margin: 0.75rem 0;
}
.progress-bar {
  background: var(--accent);
  height: 100%;
  width: 0;
}
.progress-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  font-size: 0.9em;
  color: var(--muted);
  margin-bottom: 0.75rem;
}
.preview-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-top: 1rem;
}

@media (max-width: 720px) {
  .shell { display: block; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: 0.75rem 16px; }
  .sidebar ul { display: flex; gap: 0.5rem; }
  .content { padding: 1rem 16px; }
}

.import-buckets input[type="text"] { width: 100%; min-width: 10rem; }
.import-settings > td { padding-top: 0; }
.import-settings summary { cursor: pointer; }
.import-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem 2rem; padding: 0.75rem 0; }
.import-grid fieldset { margin-top: 0.75rem; }
.import-grid label:not(.check) { display: block; margin-top: 0.5rem; }
