/* Sistema de diseño del panel tucable.es. Tokens tomados de la guia interna
   de visualizacion de datos (paleta validada para accesibilidad en claro/oscuro). */

:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --page-plane: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);

  --series-1: #2a78d6; /* azul: serie principal */
  --series-2: #eb6834; /* naranja */
  --series-3: #1baf7a; /* aqua */

  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;

  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --page-plane: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --page-plane: #0d0d0d;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --gridline: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--page-plane);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar .brand {
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 24px;
  padding: 0 8px;
}

.sidebar a {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.sidebar a:hover { background: var(--gridline); }
.sidebar a.active { background: var(--series-1); color: #fff; }

.sidebar-section-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 16px 12px 4px;
}

.notice-box {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  background: var(--surface-2, var(--surface-1));
  color: var(--text-secondary);
  line-height: 1.5;
  max-width: 640px;
}
.notice-box .error-detail {
  margin-top: 12px;
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--status-critical);
  word-break: break-word;
  white-space: pre-wrap;
}

.table-scroll { overflow-x: auto; }

.sidebar form { margin-top: auto; }
.sidebar button.logout {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.9rem;
}

.main {
  flex: 1;
  padding: 32px 40px;
  max-width: 1100px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 4px;
}

.page-subtitle {
  color: var(--text-secondary);
  margin: 0 0 28px;
  font-size: 0.95rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.stat-tile .label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-tile .value {
  font-size: 1.8rem;
  font-weight: 700;
  margin-top: 6px;
  font-variant-numeric: proportional-nums;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.card h2 {
  font-size: 1.05rem;
  margin: 0 0 16px;
}

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--gridline);
}
th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.badge.good { background: color-mix(in srgb, var(--status-good) 15%, transparent); color: var(--status-good); }
.badge.critical { background: color-mix(in srgb, var(--status-critical) 15%, transparent); color: var(--status-critical); }
.badge::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor;
}

.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.bar-row .bar-label { width: 160px; font-size: 0.85rem; color: var(--text-secondary); flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bar-track { flex: 1; background: var(--gridline); border-radius: 4px; height: 10px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; background: var(--series-1); border-radius: 4px; }
.bar-row .bar-value { width: 90px; text-align: right; font-size: 0.85rem; font-variant-numeric: tabular-nums; }

.filters { display: flex; gap: 12px; align-items: end; margin-bottom: 20px; }
.filters label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 4px; }
.filters input[type="date"], .filters input[type="datetime-local"], .filters select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  font-family: var(--font);
}
.filters button, .btn {
  padding: 9px 16px;
  border-radius: 8px;
  border: none;
  background: var(--series-1);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-disabled {
  background: var(--gridline);
  color: var(--text-muted);
  cursor: default;
}

.table-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}
.results-count {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 20px;
}
.pagination-info {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--page-plane);
}
.login-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 320px;
}
.login-card h1 { font-size: 1.3rem; margin-bottom: 24px; }
.login-card input {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--page-plane);
  color: var(--text-primary);
  font-family: var(--font);
}
.login-card button { width: 100%; margin-top: 8px; }
.error-msg { color: var(--status-critical); font-size: 0.85rem; margin-bottom: 12px; }

.empty-state { color: var(--text-muted); font-size: 0.9rem; padding: 20px 0; text-align: center; }

.trend-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 140px;
  border-bottom: 1px solid var(--baseline);
  padding-bottom: 2px;
}
.trend-bar {
  flex: 1;
  background: var(--series-1);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  cursor: default;
}
.trend-labels { display: flex; gap: 6px; margin-top: 6px; }
.trend-labels span { flex: 1; text-align: center; font-size: 0.7rem; color: var(--text-muted); }

form.inline { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
form.inline > div { display: flex; flex-direction: column; }
form.inline label { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 4px; }
form.inline input, form.inline select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--page-plane);
  color: var(--text-primary);
  font-family: var(--font);
}