:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --text: #1d2433;
  --muted: #667085;
  --line: #e1e4ea;
  --accent: #2b5bd7;
  --accent-text: #ffffff;
  --sel: #e8eefc;
  --good: #17794a;
  --good-bg: #e2f3ea;
  --mid: #8f5f00;
  --mid-bg: #fff1cf;
  --bad: #b92d1c;
  --bad-bg: #fbe7e4;
  --neutral: #4a5365;
  --neutral-bg: #eceff3;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #13161c;
    --panel: #1b1f27;
    --text: #e7eaf0;
    --muted: #98a2b3;
    --line: #2a2f3a;
    --accent: #7b9bff;
    --accent-text: #0c1226;
    --sel: #222c49;
    --good: #62d49c;
    --good-bg: #153225;
    --mid: #f0c34e;
    --mid-bg: #382f10;
    --bad: #ff8f80;
    --bad-bg: #3a1d19;
    --neutral: #b4bccb;
    --neutral-bg: #272c36;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

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

header {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

h1 {
  font-size: 16px;
  margin: 0;
  font-weight: 650;
}

h2 {
  font-size: 16px;
  margin: 0 0 12px 0;
  font-weight: 650;
}

h3 {
  font-size: 14px;
  margin: 22px 0 8px;
  font-weight: 650;
}

.nav-links {
  display: flex;
  gap: 12px;
  margin-left: 8px;
}

.nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 4px;
}

.nav-links a.active,
.nav-links a:hover {
  color: var(--accent);
  background: var(--sel);
}

.user-info {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

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

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

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

select,
input,
textarea,
button {
  font: inherit;
  color: var(--text);
}

select,
input[type=text],
input[type=search],
input[type=date],
input[type=email],
input[type=password],
textarea {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
}

textarea {
  width: 100%;
  resize: vertical;
}

input[type=text] {
  width: 100%;
  max-width: 280px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  gap: 12px;
  padding: 12px 16px;
}

main.full-width {
  display: block;
  overflow: auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  min-height: 0;
}

.pad {
  padding: 16px 20px;
}

.empty {
  padding: 24px;
  color: var(--muted);
}

.item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.item:hover {
  background: var(--bg);
}

.item.sel {
  background: var(--sel);
}

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

.row2 {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  align-items: center;
}

.date {
  color: var(--muted);
  font-size: 13px;
}

.state {
  font-size: 12px;
  color: var(--muted);
}

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

.badge {
  display: inline-block;
  padding: 1px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

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

.badge.mid {
  background: var(--mid-bg);
  color: var(--mid);
}

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

.badge.neutral {
  background: var(--neutral-bg);
  color: var(--neutral);
}

.dhead {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.btn {
  display: inline-block;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
  text-decoration: none;
  font-weight: 600;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.btn.danger {
  background: var(--bad-bg);
  border-color: var(--bad);
  color: var(--bad);
}

.btn:disabled {
  opacity: .6;
  cursor: default;
}

.dhead .btn {
  margin-left: auto;
}

.meta {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 6px 12px;
  margin-top: 14px;
  align-items: start;
}

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

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dim,
.imp {
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.dim:first-of-type,
.imp:first-of-type {
  border-top: 0;
}

.dim p,
.imp p {
  margin: 4px 0 0;
  max-width: 75ch;
}

.dimhead {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.hitl {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--bg);
}

.hitl p {
  margin: 0 0 8px;
  max-width: 75ch;
}

.hitl label {
  display: block;
  margin: 10px 0 4px;
  font-weight: 600;
}

.hitl label.vopt {
  display: inline-block;
  margin: 0 14px 0 0;
  font-weight: 400;
}

.verdicts {
  margin-top: 4px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.err {
  color: var(--bad);
  margin-top: 6px;
  min-height: 1em;
}

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

.notice {
  margin: 8px 16px;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--mid-bg);
  color: var(--mid);
  cursor: pointer;
}

.notice.err {
  background: var(--bad-bg);
  color: var(--bad);
}

.notice.ok {
  background: var(--good-bg);
  color: var(--good);
}

.load-more-container {
  padding: 12px;
  text-align: center;
}

/* Stats Styles */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 20px;
}

.card-stat {
  font-size: 32px;
  font-weight: 700;
  color: var(--accent);
  margin: 8px 0;
}

.stat-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.stat-table th,
.stat-table td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.stat-table th {
  color: var(--muted);
  font-weight: 600;
}

.svg-chart {
  width: 100%;
  height: 220px;
  margin-top: 12px;
}

/* Login Page Styles */
.login-container {
  max-width: 380px;
  margin: 80px auto;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.login-form label {
  display: block;
  margin: 12px 0 4px;
  font-weight: 600;
}

.login-form input {
  width: 100%;
  max-width: none;
}

.login-form button {
  width: 100%;
  margin-top: 16px;
}

@media (max-width: 800px) {
  html,
  body {
    height: auto;
  }

  main {
    display: block;
  }

  .panel {
    margin-bottom: 12px;
  }

  #list {
    max-height: 45vh;
  }

  .filters {
    margin-left: 0;
    width: 100%;
  }

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

  .user-info {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
  }
}
