*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 13px;
  background: #f4f6f9;
  color: #2d3748;
  min-height: 100vh;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 20px 32px;
  gap: 12px;
}

/* ── Header ────────────────────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 4px;
  border-bottom: 2px solid #e2e8f0;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.app-header h1 {
  font-size: 18px;
  font-weight: 700;
  color: #1a202c;
  letter-spacing: -0.01em;
}

.row-count {
  font-size: 12px;
  color: #718096;
}

/* ── Filter bar ────────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 150px;
}

.filter-group label {
  font-size: 10px;
  font-weight: 700;
  color: #4a5568;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.filter-group select {
  height: 32px;
  padding: 0 10px;
  border: 1px solid #cbd5e0;
  border-radius: 5px;
  background: #fff;
  color: #2d3748;
  font-size: 12px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.filter-group select:focus {
  border-color: #3182ce;
  box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.15);
}

.btn-clear {
  height: 32px;
  padding: 0 16px;
  background: #edf2f7;
  border: 1px solid #cbd5e0;
  border-radius: 5px;
  color: #4a5568;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  align-self: flex-end;
  transition: background 0.15s, border-color 0.15s;
}

.btn-clear:hover {
  background: #e2e8f0;
  border-color: #a0aec0;
}

/* ── Table wrapper ─────────────────────────────────────────────────────────── */
.table-wrapper {
  flex: 1;
  overflow: auto;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* ── Status messages ───────────────────────────────────────────────────────── */
.status-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px 32px;
  text-align: center;
  color: #718096;
  font-size: 13px;
  min-height: 180px;
}

.status-message.error {
  color: #c53030;
}

.error-help {
  margin-top: 8px;
  font-size: 12px;
  color: #718096;
  line-height: 1.7;
  max-width: 540px;
}

.error-help code {
  background: #edf2f7;
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 11px;
  color: #2d3748;
}

.hidden {
  display: none !important;
}

/* ── Spinner ───────────────────────────────────────────────────────────────── */
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #e2e8f0;
  border-top-color: #3182ce;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Table ─────────────────────────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7fafc;
}

thead th {
  padding: 9px 14px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #4a5568;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
  user-select: none;
  cursor: pointer;
  transition: background 0.1s;
}

thead th:hover {
  background: #edf2f7;
}

thead th.sort-asc::after  { content: ' ▲'; font-size: 8px; opacity: 0.7; }
thead th.sort-desc::after { content: ' ▼'; font-size: 8px; opacity: 0.7; }

tbody tr {
  border-bottom: 1px solid #edf2f7;
  transition: background 0.08s;
}

tbody tr:hover {
  background: #ebf8ff;
}

tbody tr:last-child {
  border-bottom: none;
}

tbody td {
  padding: 7px 14px;
  color: #2d3748;
  white-space: nowrap;
}

tbody td.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: 'Consolas', 'Menlo', monospace;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .filter-group { min-width: 120px; }
  .app-header h1 { font-size: 15px; }
}
