:root {
  color-scheme: light dark;
  --bg: #f5f5f7;
  --panel: #ffffff;
  --text: #1c1c1e;
  --muted: #6e6e73;
  --accent: #0a6cff;
  --border: #d8d8dc;
  --error: #c8281e;
  --status-queued: #6e6e73;
  --status-processing: #b4790a;
  --status-done: #1a8a3d;
  --status-error: #c8281e;
  --status-needs_review: #a84b0a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17171a;
    --panel: #232326;
    --text: #f2f2f3;
    --muted: #9a9aa0;
    --border: #38383c;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  max-width: 320px;
}
.auth-card h1 { margin-top: 0; font-size: 1.25rem; }
.auth-card form { display: flex; flex-direction: column; gap: 0.5rem; }
.auth-card label { font-size: 0.85rem; color: var(--muted); margin-top: 0.5rem; }
.auth-card input {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
}
.auth-card button, .link-button {
  margin-top: 1rem;
  padding: 0.55rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: 1rem;
  cursor: pointer;
}
.error { color: var(--error); font-size: 0.9rem; }

.link-button {
  background: none;
  color: var(--accent);
  padding: 0;
  margin: 0;
  font-size: 0.9rem;
  text-decoration: underline;
  border: none;
  cursor: pointer;
}
.link-button.danger { color: var(--error); }

.app-shell { display: flex; align-items: stretch; min-height: 100vh; }
.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.25rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand { font-size: 1.15rem; font-weight: 700; padding: 0 0.6rem; }
.sidebar-nav { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; }
.sidebar-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  padding: 0.55rem 0.6rem;
  border-radius: 8px;
}
.sidebar-nav a:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); color: var(--text); }
.sidebar-nav a.active {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  font-weight: 600;
}
.sidebar-user {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  padding: 1rem 0.6rem 0;
}
.app-main { flex: 1; min-width: 0; }

main { max-width: 900px; margin: 0 auto; padding: 1.5rem; }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 3rem 1rem;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone.dragover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

#upload-status { min-height: 1.2rem; color: var(--muted); }

table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
th, td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
th { color: var(--muted); font-weight: 600; }

.status-pill {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: white;
}
.status-queued { background: var(--status-queued); }
.status-detecting, .status-processing, .status-running { background: var(--status-processing); }
.status-done { background: var(--status-done); }
.status-error { background: var(--status-error); }
.status-needs_review { background: var(--status-needs_review); }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.card h2 { margin-top: 0; font-size: 1.05rem; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.5rem; }
.card-header h2 { margin: 0; }
.hint { color: var(--muted); font-size: 0.85rem; }

.page-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.page-header h2 { margin: 0; }
.primary-button {
  padding: 0.55rem 1rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

/* Tabs -- see static/tabs.js. Used on account.html and help.html. */
.tab-buttons {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
  overflow-x: auto;
}
.tab-button {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.tab-button:hover { color: var(--text); }
.tab-button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Modal -- see admin.html's "Add a user" popup. */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}
.modal-overlay[hidden] { display: none; }
.modal { width: 100%; max-width: 420px; margin: 0; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.25rem; }
.modal-header h2 { margin: 0; }
.modal-header .link-button { font-size: 1.5rem; line-height: 1; }

.stack-form { display: flex; flex-direction: column; gap: 0.5rem; max-width: 420px; }
.stack-form input, .stack-form select, .stack-form textarea {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}
.stack-form button {
  padding: 0.5rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: 0.95rem;
  cursor: pointer;
  width: fit-content;
}
.field-status { color: var(--muted); font-size: 0.85rem; min-height: 1.1rem; }

.card > button {
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: transparent;
  color: var(--accent);
  font-size: 0.9rem;
  cursor: pointer;
  margin-top: 0.5rem;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.4rem;
  max-width: 480px;
}
.checkbox-label input { margin-top: 0.15rem; }

.help-main { max-width: 760px; margin: 0 auto; padding: 1.5rem; }
.help-main .card { line-height: 1.5; }
.help-main h2 { margin-top: 0; }
.help-main h3 { font-size: 0.95rem; margin-bottom: 0.4rem; }
.help-main ul, .help-main ol { padding-left: 1.4rem; }
.help-main li { margin-bottom: 0.4rem; }
.help-main code {
  background: color-mix(in srgb, var(--text) 8%, transparent);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85em;
}
.help-main pre {
  background: color-mix(in srgb, var(--text) 6%, transparent);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  overflow-x: auto;
  font-size: 0.85rem;
}
.help-main pre code { background: none; padding: 0; }
.help-main a { color: var(--accent); }

table.admin-table input[type="text"], table.admin-table input[type="password"] {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  width: 100%;
}
