:root {
  --navy: #022C68;
  --orange: #FD640C;
  --bg: #F4F6F9;
  --card-bg: #FFFFFF;
  --border: #E1E5EB;
  --text: #1A1F2B;
  --muted: #6B7280;
}

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

/* --- Login page --- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: linear-gradient(135deg, var(--navy), #04408f);
}
.login-card {
  background: var(--card-bg);
  padding: 2.5rem;
  border-radius: 12px;
  width: 340px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.login-card h1 { font-size: 1.4rem; margin: 0 0 0.25rem; color: var(--navy); }
.login-card .subtitle { color: var(--muted); margin: 0 0 1.5rem; font-size: 0.9rem; }
.login-card label { display: block; margin-bottom: 1rem; font-size: 0.85rem; font-weight: 600; }
.login-card input {
  width: 100%; padding: 0.6rem; margin-top: 0.3rem;
  border: 1px solid var(--border); border-radius: 6px; font-size: 1rem;
}
.login-card button {
  width: 100%; padding: 0.7rem; background: var(--orange); color: white;
  border: none; border-radius: 6px; font-weight: 600; cursor: pointer; font-size: 1rem;
}
.alert-error { background: #FEE2E2; color: #991B1B; padding: 0.6rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.85rem; }

/* --- Top bar --- */
.topbar {
  background: var(--navy);
  color: white;
  padding: 0.8rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.brand { font-weight: 700; font-size: 1.1rem; }
.topbar nav a, .topbar .user-chip {
  color: white; text-decoration: none; margin-left: 1.2rem; font-size: 0.9rem;
}
.topbar nav a:hover { color: var(--orange); }
.user-chip { opacity: 0.85; }

/* --- Layout --- */
.dashboard { padding: 1.5rem; max-width: 1400px; margin: 0 auto; }

.filter-bar {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 1.2rem;
  border: 1px solid var(--border);
}
.filter-group { display: flex; flex-direction: column; font-size: 0.8rem; font-weight: 600; gap: 0.3rem; }
.filter-group.custom-dates { flex-direction: row; align-items: center; gap: 0.5rem; }
select, input[type=date], input[type=text] {
  padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 6px; font-size: 0.9rem;
}
.btn-primary, .btn-secondary {
  padding: 0.5rem 1rem; border-radius: 6px; border: none; font-weight: 600; cursor: pointer; font-size: 0.9rem;
}
.btn-primary { background: var(--navy); color: white; }
.btn-secondary { background: white; color: var(--navy); border: 1px solid var(--navy); }
.btn-link { background: none; border: none; color: var(--navy); text-decoration: underline; cursor: pointer; font-size: 0.85rem; }

/* --- Cards --- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.2rem;
}
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.card-label { font-size: 0.78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.card-value { font-size: 1.6rem; font-weight: 700; color: var(--navy); }

/* --- Charts --- */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1rem;
  margin-bottom: 1.2rem;
}
.chart-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}
.chart-box h3 { margin: 0 0 0.8rem; font-size: 0.95rem; color: var(--navy); }

/* --- Tables --- */
.table-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1.2rem;
  overflow-x: auto;
}
.table-box h3 { margin: 0 0 0.8rem; font-size: 0.95rem; color: var(--navy); }
.muted { color: var(--muted); font-weight: 400; font-size: 0.85rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
th, td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; }

.status-badge { padding: 0.15rem 0.55rem; border-radius: 20px; font-size: 0.78rem; font-weight: 600; }
.status-answered { background: #E8F5E9; color: #2E7D32; }
.status-unanswered { background: #FFEBEE; color: #C62828; }
.status-waiting { background: #FFF8E1; color: #F9A825; }

.pagination { display: flex; align-items: center; gap: 0.8rem; margin-top: 0.8rem; justify-content: center; }
.pagination button {
  padding: 0.4rem 0.8rem; border: 1px solid var(--border); background: white; border-radius: 6px; cursor: pointer;
}
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* --- Modal --- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: white; border-radius: 10px; padding: 1.5rem; width: 420px; max-width: 90vw;
  position: relative; max-height: 85vh; overflow-y: auto;
}
.modal h3 { margin-top: 0; color: var(--navy); }
.modal-close {
  position: absolute; top: 0.8rem; right: 1rem; border: none; background: none;
  font-size: 1.4rem; cursor: pointer; color: var(--muted);
}
.detail-table th { width: 40%; color: var(--text); text-transform: none; font-weight: 600; }
.detail-table td { white-space: normal; word-break: break-word; }

/* --- Responsive --- */
@media (max-width: 640px) {
  .topbar { flex-direction: column; gap: 0.5rem; align-items: flex-start; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .cards { grid-template-columns: repeat(2, 1fr); }
}
