:root {
  --color-bg: #f4f6f5;
  --color-surface: #ffffff;
  --color-primary: #1f6f4a;
  --color-primary-dark: #16532f;
  --color-text: #1c2521;
  --color-muted: #6b7a72;
  --color-border: #dbe3de;
  --color-danger: #c0392b;
  --radius: 10px;
}

* { box-sizing: border-box; }

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

/* ---------- Login ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-card {
  background: var(--color-surface);
  padding: 2.5rem;
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  width: 320px;
}
.login-card h1 { margin: 0 0 0.25rem; color: var(--color-primary-dark); }
.login-card h1 span { color: var(--color-primary); }
.subtitle { color: var(--color-muted); margin: 0 0 1.5rem; font-size: 0.9rem; }

label { display: block; font-size: 0.85rem; margin: 0.75rem 0 0.25rem; color: var(--color-muted); }
input, select, textarea {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
}
button {
  margin-top: 1.25rem;
  width: 100%;
  padding: 0.7rem;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  cursor: pointer;
}
button:hover { background: var(--color-primary-dark); }
.error-msg { color: var(--color-danger); font-size: 0.85rem; margin-top: 0.75rem; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  background: var(--color-primary-dark);
  color: white;
  padding: 1.5rem 1rem;
  flex-shrink: 0;
}
.sidebar h2 { font-size: 1.1rem; margin: 0 0 1.5rem; }
.sidebar h2 span { opacity: 0.75; font-weight: 400; }
.sidebar nav { display: flex; flex-direction: column; gap: 0.5rem; }
.sidebar nav a {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  padding: 0.6rem 0.7rem;
  border-radius: 6px;
  font-size: 0.9rem;
}
.sidebar nav a:hover, .sidebar nav a.active { background: rgba(255, 255, 255, 0.15); color: white; }

main { flex: 1; padding: 2rem; max-width: 1100px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.topbar h1 { margin: 0; font-size: 1.4rem; }
.muted { color: var(--color-muted); font-size: 0.85rem; }

.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.kpi-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.kpi-card span { display: block; font-size: 1.8rem; font-weight: 700; color: var(--color-primary-dark); }
.kpi-card label { margin: 0.25rem 0 0; }

.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.chart-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  max-height: 320px;
}

.filters { margin-bottom: 1rem; }
.filters select { width: auto; display: inline-block; }

.tickets-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.tickets-table th, .tickets-table td {
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.88rem;
  text-align: left;
}
.tickets-table th { background: #eef2f0; color: var(--color-muted); font-weight: 600; }
.vencido { color: var(--color-danger); font-weight: 600; }

.badge { padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.badge-pendiente { background: #fdf1d0; color: #916200; }
.badge-en-progreso { background: #d6eaf8; color: #1a5276; }
.badge-bloqueado { background: #fadbd8; color: #922b21; }
.badge-completado { background: #d5f5e3; color: #1e7d45; }

.form-card, .gestion-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 500px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  margin-bottom: 1.5rem;
}

.detail-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.detail-grid label { font-size: 0.78rem; }
.detail-grid p { margin: 0.15rem 0 0; font-weight: 600; }

.historial-list { list-style: none; padding: 0; }
.historial-list li { padding: 0.6rem 0; border-bottom: 1px solid var(--color-border); font-size: 0.88rem; }

@media (max-width: 800px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: auto; }
  .kpi-row, .charts-row, .detail-grid { grid-template-columns: 1fr 1fr; }
}
