:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e2e6ec;
  --text: #1c2530;
  --text-muted: #6b7684;
  --primary: #2557d6;
  --primary-dark: #1a3fa0;
  --accent: #0fae7a;
  --danger: #d64545;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 30, 50, 0.08);
}

* { box-sizing: border-box; }

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-title { display: flex; align-items: baseline; gap: 12px; }
.topbar-title h1 { font-size: 20px; margin: 0; }
.last-updated { font-size: 13px; color: var(--text-muted); }

.btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}
.btn:hover { background: var(--primary-dark); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); }

.status-banner {
  padding: 10px 28px;
  font-size: 14px;
  background: #fdecea;
  color: var(--danger);
  border-bottom: 1px solid #f5c6c2;
}
.status-banner.hidden { display: none; }

main { padding: 24px 28px 60px; max-width: 1400px; margin: 0 auto; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label { font-size: 12px; color: var(--text-muted); }
.filter-group select,
.filter-group input {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  min-width: 140px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kpi-label { font-size: 13px; color: var(--text-muted); }
.kpi-value { font-size: 28px; font-weight: 600; }

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.chart-wide { grid-column: 1 / -1; }
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.chart-card h2 { font-size: 14px; margin: 0 0 12px; color: var(--text-muted); font-weight: 600; }
.chart-card canvas { max-height: 280px; }

.table-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.table-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.table-header h2 { font-size: 16px; margin: 0; }
.row-count { font-size: 13px; color: var(--text-muted); }
.table-scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th {
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 600;
  user-select: none;
}
th:hover { color: var(--text); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--bg); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-yes { background: #e3f7ee; color: var(--accent); }
.badge-no { background: #fdecea; color: var(--danger); }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 30, 50, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal.hidden { display: none; }
.modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 640px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-muted);
}
.detail-list { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 0; }
.detail-list dt { font-size: 12px; color: var(--text-muted); }
.detail-list dd { margin: 0 0 6px; font-size: 14px; }

@media (max-width: 900px) {
  .charts-grid { grid-template-columns: 1fr; }
}
