:root {
  --bg: #f4f6f9;
  --card-bg: #ffffff;
  --text: #1c2733;
  --text-muted: #6b7a8d;
  --border: #e1e6ec;
  --primary: #2f5fdb;
  --primary-dark: #1f47b0;
  --danger: #d1453b;
  --shadow: 0 1px 3px rgba(20, 30, 50, 0.08);
  --radius: 10px;
}

* { box-sizing: border-box; }

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

a { color: var(--primary); text-decoration: none; }

/* --- Auth / login --- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  background: var(--card-bg);
  padding: 2.5rem 2.5rem 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 360px;
}

.auth-card h1 {
  margin: 0 0 .25rem;
  font-size: 1.4rem;
}

.auth-card p.subtitle {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  font-size: .9rem;
}

.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .85rem; margin-bottom: .3rem; color: var(--text-muted); }
.field input, .field select {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .95rem;
}

button, .btn {
  cursor: pointer;
  border: none;
  border-radius: 6px;
  padding: .6rem 1rem;
  font-size: .9rem;
  background: var(--primary);
  color: #fff;
  transition: background .15s;
}
button:hover, .btn:hover { background: var(--primary-dark); }
button.secondary, .btn.secondary { background: #eef1f6; color: var(--text); }
button.secondary:hover { background: #e2e7ef; }
button.danger { background: var(--danger); }

.error-msg { color: var(--danger); font-size: .85rem; margin-top: .75rem; min-height: 1.1em; }

/* --- App shell --- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .9rem 1.5rem;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}

.app-header .brand { font-weight: 700; font-size: 1.15rem; }
.app-header .user-info { display: flex; align-items: center; gap: .9rem; font-size: .85rem; color: var(--text-muted); }
.app-header .role-badge {
  background: #eaf0ff;
  color: var(--primary-dark);
  padding: .15rem .55rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}

main { padding: 1.5rem; max-width: 1200px; margin: 0 auto; }

/* --- Tabs --- */
.tabs {
  display: flex;
  gap: .4rem;
  margin-bottom: 1.25rem;
}
.tab-btn {
  background: none;
  color: var(--text-muted);
  padding: .55rem 1.1rem;
  border-radius: 8px 8px 0 0;
  font-weight: 600;
  font-size: .9rem;
}
.tab-btn:hover { background: #eef1f6; color: var(--text); }
.tab-btn--active, .tab-btn--active:hover {
  background: var(--card-bg);
  color: var(--primary-dark);
  box-shadow: var(--shadow);
}

/* --- Filters --- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: .9rem;
  background: var(--card-bg);
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
  align-items: flex-end;
}
.filters .field { margin-bottom: 0; min-width: 150px; }
.month-year-pair { display: flex; gap: .4rem; }
.month-year-pair select { flex: 1; min-width: 0; }

.list-link-row { margin-bottom: 1.25rem; }

/* --- KPI cards --- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.kpi-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem;
}
.kpi-card .label { color: var(--text-muted); font-size: .8rem; margin-bottom: .35rem; }
.kpi-card .value { font-size: 1.6rem; font-weight: 700; }

/* --- Charts --- */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 1.25rem;
}
.chart-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem;
}
.chart-card h3 { margin: 0 0 .8rem; font-size: 1rem; }
.chart-card canvas { max-height: 320px; }
.chart-tall-wrap { position: relative; height: 640px; }
.chart-tall-wrap canvas { max-height: none; }

/* --- Tables (admin) --- */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; }

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.card h2 { margin-top: 0; font-size: 1.05rem; }
.inline-form { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.inline-form .field { margin-bottom: 0; }
.muted { color: var(--text-muted); font-size: .85rem; }
