:root {
  --bg: #f4f5f7;
  --card: #fff;
  --text: #1a1a1a;
  --muted: #5c6570;
  --border: #dfe3e8;
  --accent: #2563eb;
  --danger: #b91c1c;
  --ok: #047857;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.top {
  padding: 1.25rem 1.5rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.top-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.top h1 {
  margin: 0 0 0.35rem;
  font-size: 1.25rem;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
}

.nav-links a {
  color: var(--accent);
}

.linkish {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
  padding: 0;
}

.small {
  font-size: 0.85rem;
  margin: 0 0 0.5rem;
}

.req {
  color: var(--danger);
  font-weight: 600;
}

code {
  font-size: 0.88em;
  background: #eef2f7;
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

.table-wrap {
  overflow: auto;
  margin-top: 0.5rem;
}

.api-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.api-table th,
.api-table td {
  border: 1px solid var(--border);
  padding: 0.45rem 0.55rem;
  text-align: left;
  vertical-align: top;
}

.api-table th {
  background: #f8fafc;
  font-weight: 600;
}

.method {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  color: #fff;
}

.method.get {
  background: #059669;
}

.method.post {
  background: #2563eb;
}

.method.del {
  background: #b45309;
}

.archive-filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.archive-filters label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.archive-filters input {
  padding: 0.4rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit;
}

.small-btn {
  font-size: 0.8rem !important;
  padding: 0.35rem 0.65rem !important;
}

.full-kpi {
  grid-column: 1 / -1;
}

.category-block {
  grid-column: 1 / -1;
}

.category-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0.35rem 0 0.5rem;
}

.category-toolbar input[type="search"] {
  flex: 1;
  min-width: 160px;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit;
}

.category-select {
  width: 100%;
  min-height: 11rem;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit;
  font-size: 0.82rem;
  background: #fff;
}

.category-select-hidden {
  display: none !important;
}

.category-manual-input {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit;
}

.category-manual-check {
  margin-top: 0.5rem;
}

.muted {
  color: var(--muted);
  margin: 0;
  font-size: 0.9rem;
}

.layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.65rem 1rem;
}

.grid-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.grid-form label.full {
  grid-column: 1 / -1;
}

.grid-form input,
.grid-form select {
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit;
}

.checkbox,
.inline {
  flex-direction: row !important;
  align-items: center;
  gap: 0.5rem !important;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.actions button {
  padding: 0.5rem 0.85rem;
  border-radius: 4px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
}

.actions button.secondary {
  background: #fff;
  color: var(--accent);
}

.actions button:hover {
  filter: brightness(1.05);
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.75rem 0 0;
}

.status {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.status.ok {
  color: var(--ok);
}

.status.err {
  color: var(--danger);
  white-space: pre-wrap;
}

.json-out {
  margin: 0;
  padding: 0.75rem;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 6px;
  overflow: auto;
  max-height: 420px;
  font-size: 0.8rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.kpi {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
  font-size: 0.85rem;
}

.kpi strong {
  display: block;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.chart-box {
  min-height: 220px;
  position: relative;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.row-between h2 {
  margin: 0;
}

.archive-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 320px;
  overflow: auto;
}

.archive-list li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.archive-list li button {
  flex-shrink: 0;
  font-size: 0.75rem;
  padding: 0.2rem 0.45rem;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
}

.archive-meta {
  color: var(--muted);
  font-size: 0.78rem;
}

.archive-title {
  cursor: pointer;
  color: var(--accent);
  text-decoration: underline;
}
