/* Basic reset & theme */
:root {
  --bg: #f5f7fb;
  --card-bg: #ffffff;
  --border: #e2e6f0;
  --text-main: #1f2933;
  --text-muted: #6b7280;
  --accent: #1f7aed;
  --accent-soft: #e3efff;
  --accent-secondary: #1fbf6b;
  --danger: #e54848;
  --shadow-soft: 0 8px 20px rgba(15, 23, 42, 0.06);
  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-pill: 999px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text-main);
  padding: 24px;
}

.page {
  max-width: 1400px;
  margin: 0 auto;
}

header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
}

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

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0f4c81, #1fbf6b);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  box-shadow: var(--shadow-soft);
}

.brand-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-title span:first-child {
  font-weight: 600;
  font-size: 18px;
}

.brand-title span:last-child {
  font-size: 13px;
  color: var(--text-muted);
}

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

.filters-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-right: 4px;
}

.filter-btn {
  border: 1px solid var(--border);
  background: #fff;
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  cursor: pointer;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s ease, color 0.15s ease,
    border-color 0.15s ease, box-shadow 0.15s ease;
}

.filter-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 1px rgba(31, 122, 237, 0.2);
  font-weight: 500;
}

.filter-btn span.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.date-range-inputs {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  margin-left: 6px;
}

.date-range-inputs input[type="date"] {
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text-main);
  background: #fff;
}

/* Layout */
.upload-card {
  margin-bottom: 16px;
}

.upload-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  gap: 6px;
}

.upload-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.upload-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 420px;
}

.upload-label-main {
  font-size: 13px;
  font-weight: 500;
}

.upload-label-sub {
  font-size: 11px;
  color: var(--text-muted);
}

#csv-input {
  font-size: 12px;
}

.clear-btn {
  border-radius: var(--radius-pill);
  border: 1px solid var(--danger);
  background: #fff5f5;
  color: var(--danger);
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

.clear-btn:hover {
  background: #fee2e2;
}

.upload-status {
  font-size: 11px;
}

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 14px 16px 14px;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

main {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(260px, auto);
  gap: 16px;
}

@media (max-width: 960px) {
  main {
    grid-template-columns: 1fr;
  }
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
  gap: 6px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-subtitle {
  font-size: 11px;
  color: var(--text-muted);
}

.pill-tag {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: #eef2ff;
  color: #4f46e5;
  font-weight: 500;
}

.pill-tag.green {
  background: #e5f7ef;
  color: var(--accent-secondary);
}

.pill-tag.red {
  background: #fee2e2;
  color: var(--danger);
}

/* Card body + KPIs */
.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kpi-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.kpi {
  flex: 1;
  min-width: 120px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 8px 10px;
  background: #fafbff;
}

.kpi-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.kpi-value {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.kpi-trend {
  font-size: 11px;
  color: var(--accent-secondary);
}

.kpi-trend.neg {
  color: var(--danger);
}

.kpi-trend span.arrow {
  font-size: 11px;
}

.kpi-caption {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Tables */
.tables-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 640px) {
  .tables-row {
    grid-template-columns: 1fr;
  }
}

.table {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: #fff;
  overflow: hidden;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.table-body {
  max-height: 160px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

th,
td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid #f1f3f8;
  white-space: nowrap;
}

th {
  font-weight: 500;
  color: var(--text-muted);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 1;
}

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

.text-right {
  text-align: right;
}

.badge {
  display: inline-flex;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 500;
  background: #eef2ff;
  color: #4f46e5;
}

.badge.green {
  background: #e5f7ef;
  color: var(--accent-secondary);
}

.badge.red {
  background: #fee2e2;
  color: var(--danger);
}

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

.small-note {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}
