:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-light: #eef2ff;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #059669;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

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

main {
  width: min(1100px, calc(100% - 48px));
  margin: 40px auto;
}

/* Header */
.topbar {
  height: 64px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(24px, calc((100vw - 1100px) / 2));
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  font-weight: 800;
  font-size: 18px;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.brand:hover {
  color: var(--accent);
}

nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

nav > a {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  transition: all 0.15s;
}

nav > a:hover {
  color: var(--ink);
  background: var(--bg);
}

nav form button {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
}

nav form button:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: #fef2f2;
}

/* Typography */
h1 {
  font-size: 26px;
  font-weight: 700;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
  color: var(--ink);
}

h2 {
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

p {
  color: var(--muted);
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* Cards */
.card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, border-color 0.2s;
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: #d1d5db;
}

.card {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.card h2 {
  font-size: 16px;
  margin-bottom: 2px;
}

.card p {
  font-size: 13px;
}

/* Stack layout */
.stack {
  display: grid;
  gap: 20px;
}

section.stack + section.stack {
  margin-top: 16px;
  padding-top: 32px;
  border-top: 1px solid var(--line);
}

/* Row layout */
.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* Inputs */
input,
select {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 8px 12px;
  font: inherit;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

input::placeholder {
  color: #9ca3af;
}

input[type="file"] {
  padding: 6px 8px;
  font-size: 13px;
  cursor: pointer;
}

input[type="checkbox"] {
  min-height: auto;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

/* Buttons */
button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 8px 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

button:hover,
.button:hover {
  background: var(--accent-hover);
  color: #fff;
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

button:active,
.button:active {
  transform: translateY(0);
}

button.secondary,
.button.secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

button.secondary:hover,
.button.secondary:hover {
  background: var(--bg);
  border-color: #d1d5db;
}

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

button.danger:hover {
  background: var(--danger-hover);
}

/* Tables */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  font-size: 14px;
}

th,
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

tr:last-child td {
  border-bottom: none;
}

th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
  background: #f9fafb;
}

tbody tr:hover {
  background: #f9fafb;
}

/* Forms */
form {
  margin: 0;
}

/* Panels */
.panel {
  padding: 24px;
}

.panel h2 {
  margin-bottom: 12px;
}

/* Labels */
label.row {
  font-size: 14px;
  color: var(--muted);
  gap: 6px;
  cursor: pointer;
}

/* Utilities */
.muted {
  color: var(--muted);
}

.error {
  color: var(--danger);
  font-weight: 500;
}

/* Login page */
.panel.stack h1 {
  text-align: center;
}

.panel.stack .button {
  justify-content: center;
}

/* Help page */
.help-page {
  display: grid;
  gap: 28px;
}

.help-hero {
  text-align: center;
  max-width: 680px;
  margin: 8px auto 4px;
  padding: 28px 20px 12px;
}

.help-icon {
  color: var(--ink);
  margin-bottom: 18px;
  animation: orbit 7s ease-in-out infinite;
}

.eyebrow {
  color: var(--accent);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.help-hero h1 {
  font-size: 34px;
  margin-bottom: 12px;
  letter-spacing: -0.03em;
}

.help-hero p:not(.eyebrow) {
  font-size: 16px;
  line-height: 1.7;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.help-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  min-height: 220px;
}

.help-card-number {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 16px;
}

.help-card h2 {
  font-size: 18px;
  margin-bottom: 8px;
}

.help-card p {
  min-height: 64px;
}

.endpoint {
  margin-top: 18px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fafb;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.help-note {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 22px;
  border-left: 3px solid var(--accent);
  background: var(--accent-light);
  border-radius: 0 8px 8px 0;
  color: var(--muted);
  font-size: 14px;
}

.help-note strong {
  color: var(--ink);
}

/* Error / 404 page */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 55vh;
  padding: 60px 20px;
}

.error-page .error-icon {
  margin-bottom: 32px;
  color: var(--ink);
  animation: orbit 6s ease-in-out infinite;
}

.error-page h1 {
  font-size: 30px;
  margin-bottom: 12px;
  letter-spacing: -0.03em;
}

.error-page p {
  font-size: 16px;
  max-width: 420px;
  margin-bottom: 24px;
  line-height: 1.7;
}

.error-quote {
  font-style: italic;
  color: var(--muted);
  font-size: 14px;
  max-width: 380px;
  margin-bottom: 32px;
  padding: 16px 24px;
  border-left: 3px solid var(--accent);
  background: var(--accent-light);
  border-radius: 0 8px 8px 0;
  text-align: left;
}

.error-page .button {
  padding: 12px 28px;
  font-size: 15px;
}

@keyframes orbit {
  0%, 100% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(2deg) scale(1.02); }
  50% { transform: rotate(0deg) scale(1); }
  75% { transform: rotate(-2deg) scale(1.02); }
}

/* Responsive */
@media (max-width: 640px) {
  main {
    width: calc(100% - 32px);
    margin: 24px auto;
  }

  .topbar {
    padding: 0 16px;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .card {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .card .row {
    width: 100%;
  }

  .card .row .button {
    flex: 1;
  }

  .help-grid {
    grid-template-columns: 1fr;
  }

  .help-hero h1 {
    font-size: 28px;
  }

  .help-card {
    min-height: auto;
  }

  .help-card p {
    min-height: auto;
  }

  table {
    font-size: 13px;
  }

  th, td {
    padding: 10px 12px;
  }
}
