:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1c2128;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --ok: #16a34a;
  --warn: #d97706;
  --crit: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 24px 0 12px; }

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 0;
}

.sidebar__brand {
  font-weight: 700;
  font-size: 16px;
  padding: 0 20px 20px;
  color: var(--text);
}

.sidebar__nav { display: flex; flex-direction: column; }

.sidebar__nav a {
  padding: 10px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.sidebar__nav a:hover { background: var(--bg); text-decoration: none; }

.sidebar__nav a.is-active {
  color: var(--accent);
  background: #eff4ff;
  border-right: 2px solid var(--accent);
  font-weight: 600;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
}

.period-form { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--text-muted); }
.period-form input[type="date"] {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 13px;
}
.period-form button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
}

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

.content { padding: 28px; max-width: 1200px; width: 100%; margin: 0 auto; }

.subtitle { color: var(--text-muted); margin: 0 0 20px; }

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 8px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.card__header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.card__header h2 { margin: 0; font-size: 15px; }
.card__link { display: inline-block; margin-top: 10px; font-size: 13px; }

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef0f3;
  color: var(--text-muted);
  white-space: nowrap;
}
.badge--ok { background: #e7f8ee; color: var(--ok); }
.badge--muted { background: #eef0f3; color: var(--text-muted); }
.badge--not_authorized { background: #fff4e5; color: var(--warn); }
.badge--not_configured { background: #eef0f3; color: var(--text-muted); }
.badge--configured { background: #e7f0ff; color: var(--accent); }
.badge--connected { background: #e7f8ee; color: var(--ok); }
.badge--error { background: #fdecec; color: var(--crit); }

.kpi-list { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.kpi-list > div { display: flex; justify-content: space-between; font-size: 13px; }
.kpi-list dt { color: var(--text-muted); }
.kpi-list dd { margin: 0; font-weight: 600; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow);
}
.kpi__label { font-size: 12px; color: var(--text-muted); }
.kpi__value { font-size: 20px; font-weight: 700; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tabs a {
  padding: 8px 14px;
  color: var(--text-muted);
  font-size: 13px;
  border-bottom: 2px solid transparent;
}
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.is-active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }

table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.table th, table.table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.table th { color: var(--text-muted); font-weight: 600; background: #fafbfc; }
table.table tbody tr:last-child td { border-bottom: none; }

.empty-state {
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

.warnings { margin: 10px 0 0; padding-left: 18px; font-size: 13px; color: var(--warn); }

.dq-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.dq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--text-muted);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
}
.dq-item--critical { border-left-color: var(--crit); }
.dq-item--warning { border-left-color: var(--warn); }
.dq-item--info { border-left-color: var(--accent); }
.dq-item__meta { display: block; color: var(--text-muted); font-size: 11px; margin-top: 2px; }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; display: flex; align-items: center; padding: 10px 0; border-right: none; border-bottom: 1px solid var(--border); }
  .sidebar__brand { padding: 0 12px; }
  .sidebar__nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar__nav a.is-active { border-right: none; border-bottom: 2px solid var(--accent); }
  .content { padding: 16px; }
}
