/* === SPRYNTR BRAND TOKENS === */
:root {
  --primary: #B86B52;
  --primary-hover: #a35c45;
  --accent: #2D4033;
  --bg: #F6F4EE;
  --bg-card: #FFFFFF;
  --text: #2D4033;
  --text-light: #6b7c6f;
  --border: #e0ddd6;
  --error: #c0392b;
  --success: #27ae60;
  --radius: 0px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --font-heading: 'Newsreader', Georgia, serif;
  --font-body: 'Outfit', system-ui, sans-serif;
  --font-mono: 'Inter', monospace;
}

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

[hidden] { display: none !important; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* === LOGIN === */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: var(--bg-card);
  padding: 48px 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-card h1 {
  font-family: var(--font-heading);
  font-size: 2rem;
  color: var(--accent);
  margin-bottom: 4px;
}

.login-card p {
  color: var(--text-light);
  margin-bottom: 32px;
  font-size: 0.95rem;
}

.login-card input {
  display: block;
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--text);
}

.login-card input:focus {
  outline: none;
  border-color: var(--primary);
}

.error-text {
  color: var(--error);
  font-size: 0.85rem;
  margin-top: 12px;
}

/* === BUTTONS === */
.btn-primary {
  display: inline-block;
  padding: 12px 24px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover { background: var(--primary-hover); }

.btn-sm { padding: 8px 16px; font-size: 0.85rem; }

.btn-outlined {
  display: inline-block;
  padding: 8px 16px;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-outlined:hover {
  background: var(--accent);
  color: #fff;
}

/* === HEADER === */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

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

.header h1 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  color: var(--accent);
}

.header-subtitle {
  color: var(--text-light);
  font-size: 0.9rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-email {
  color: var(--text-light);
  font-size: 0.85rem;
  font-family: var(--font-mono);
}

/* === FILTERS === */
.filters {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  padding: 20px 32px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

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

.filter-group label {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
}

.filter-group select,
.filter-group input[type="date"] {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.85rem;
  background: var(--bg);
  color: var(--text);
  min-width: 140px;
}

.filter-group select:focus,
.filter-group input[type="date"]:focus {
  outline: none;
  border-color: var(--primary);
}

/* === KPI CARDS === */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  padding: 24px 32px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kpi-label {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
}

.kpi-value {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--accent);
}

/* === CHARTS === */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 0 32px 24px;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.chart-card h3 {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 16px;
}

.chart-wide {
  grid-column: 1 / -1;
}

/* === TABLES === */
.table-section {
  padding: 0 32px 24px;
}

.table-section h3 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 12px;
}

.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead th {
  background: var(--bg);
  padding: 10px 14px;
  text-align: left;
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

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

tbody tr:hover { background: rgba(184, 107, 82, 0.04); }

/* Result badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 500;
  font-family: var(--font-body);
}

.badge-found { background: #e8f5e9; color: #2e7d32; }
.badge-not-found { background: #fff3e0; color: #e65100; }
.badge-error { background: #ffebee; color: #c62828; }

/* === LOADING === */
.loading {
  position: fixed;
  inset: 0;
  background: rgba(246, 244, 238, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* === RESPONSIVE === */
@media (max-width: 900px) {
  .charts-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .header, .filters, .kpi-grid, .charts-grid, .table-section { padding-left: 16px; padding-right: 16px; }
}

@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .filters { flex-direction: column; align-items: stretch; }
  .header { flex-direction: column; gap: 12px; align-items: flex-start; }
}
