:root {
  color-scheme: light dark;
  --bg: #f4f7f8;
  --panel: #ffffff;
  --panel-2: #eef4f3;
  --text: #14212b;
  --muted: #60717d;
  --line: #d7e1e3;
  --accent: #0f766e;
  --accent-2: #b45309;
  --danger: #b91c1c;
  --shadow: 0 18px 48px rgba(30, 45, 55, .08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1519;
    --panel: #151d22;
    --panel-2: #1b282d;
    --text: #edf5f6;
    --muted: #a5b4ba;
    --line: #2b3b42;
    --accent: #5eead4;
    --accent-2: #fbbf24;
    --danger: #f87171;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(860px, 100%);
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 32px;
  align-items: center;
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 14px; font-size: clamp(34px, 6vw, 58px); line-height: 1; }
h2 { margin-bottom: 8px; font-size: 18px; }
.muted { color: var(--muted); line-height: 1.65; }

.login-form,
.password-form {
  display: grid;
  gap: 16px;
}

.login-form label,
.password-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.login-form input,
.password-form input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

.login-form button,
.password-form button,
.refresh,
.topbar button {
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
}

.form-status {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.form-status.ok { color: var(--accent); }
.form-status.error { color: var(--danger); }

.notice {
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--danger) 50%, var(--line));
  border-radius: 8px;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 14px clamp(16px, 4vw, 42px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  backdrop-filter: blur(14px);
}

.brand { font-weight: 800; }
.topbar nav { display: flex; align-items: center; gap: 10px; }
.topbar nav a,
.topbar button {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 14px;
}
.topbar nav a.active { background: var(--panel-2); color: var(--accent); }
.topbar form { margin: 0; }
.topbar button { border-color: var(--line); background: transparent; color: var(--muted); }

.workspace {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.hero,
.admin-head {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  margin-bottom: 24px;
}

.secondary-link,
.refresh {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 112px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
}

.secondary-link {
  border: 1px solid var(--line);
  color: var(--accent);
}

.category-grid,
.stats-grid,
.admin-grid {
  display: grid;
  gap: 14px;
}

.category-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.category-card,
.stat,
.admin-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.category-card {
  min-height: 188px;
  padding: 20px;
  display: grid;
  align-content: start;
  gap: 8px;
}

.category-card p { color: var(--muted); line-height: 1.55; }
.category-card span { color: var(--accent-2); font-size: 13px; font-weight: 700; }

.card-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--accent);
  font-weight: 800;
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 14px;
}

.stat {
  padding: 16px;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.stat span,
.empty {
  color: var(--muted);
  font-size: 13px;
}

.admin-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-panel {
  min-height: 220px;
  padding: 18px;
  overflow: auto;
}

.admin-panel.wide { grid-column: 1 / -1; }
pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
}

.list {
  display: grid;
  gap: 8px;
}

.pill {
  display: inline-flex;
  width: fit-content;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
}

.table {
  display: grid;
  gap: 1px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.row {
  display: grid;
  grid-template-columns: 1.1fr .7fr 1.3fr .55fr .55fr;
  gap: 10px;
  padding: 10px 12px;
  background: var(--panel-2);
  font-size: 13px;
}

.row.header {
  color: var(--muted);
  font-weight: 700;
}

@media (max-width: 820px) {
  .auth-panel,
  .category-grid,
  .stats-grid,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .hero,
  .admin-head,
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar nav {
    flex-wrap: wrap;
  }

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