:root {
  /* Default to dark theme */
  --bg: radial-gradient(120% 120% at 20% 20%, #103f3b 0%, #0b1d3a 45%, #07152c 100%);
  --card: #0f233d;
  --card-2: #103f3b;
  --primary: #16a3ff;
  --primary-strong: #0e7ed1;
  --accent: #32d6a0;
  --text: #e9f2ff;
  --muted: #a3bbd4;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --input-bg: rgba(255, 255, 255, 0.04);
  --input-text: #e9f2ff;
  --row-alt: rgba(255, 255, 255, 0.02);
  --pill-bg: rgba(50, 214, 160, 0.14);
  --pill-border: rgba(50, 214, 160, 0.25);
  --pill-text: #c3ffe8;
  --badge-bg: rgba(22, 163, 255, 0.15);
  --badge-border: rgba(22, 163, 255, 0.25);
  --badge-text: #bfe5ff;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: radial-gradient(120% 120% at 20% 20%, #103f3b 0%, #0b1d3a 45%, #07152c 100%);
  --card: #0f233d;
  --card-2: #103f3b;
  --primary: #16a3ff;
  --primary-strong: #0e7ed1;
  --accent: #32d6a0;
  --text: #e9f2ff;
  --muted: #a3bbd4;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --input-bg: rgba(255, 255, 255, 0.04);
  --input-text: #e9f2ff;
  --row-alt: rgba(255, 255, 255, 0.02);
  --pill-bg: rgba(50, 214, 160, 0.14);
  --pill-border: rgba(50, 214, 160, 0.25);
  --pill-text: #c3ffe8;
  --badge-bg: rgba(22, 163, 255, 0.15);
  --badge-border: rgba(22, 163, 255, 0.25);
  --badge-text: #bfe5ff;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: radial-gradient(140% 120% at 15% 20%, #f7fbff 0%, #eef3f8 45%, #e3ebf5 100%);
  --card: #ffffff;
  --card-2: #f7fbff;
  --primary: #0f7fe3;
  --primary-strong: #0c63b4;
  --accent: #17b890;
  --text: #1f2a3d;
  --muted: #5a6b7d;
  --shadow: 0 12px 28px rgba(18, 47, 92, 0.12);
  --border: rgba(16, 30, 56, 0.08);
  --border-strong: rgba(16, 30, 56, 0.16);
  --input-bg: #f2f6fb;
  --input-text: #1f2a3d;
  --row-alt: rgba(16, 30, 56, 0.04);
  --pill-bg: rgba(23, 184, 144, 0.14);
  --pill-border: rgba(23, 184, 144, 0.32);
  --pill-text: #0f5132;
  --badge-bg: rgba(15, 127, 227, 0.12);
  --badge-border: rgba(15, 127, 227, 0.28);
  --badge-text: #0f3e7a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 32px;
  transition: background-color 180ms ease, color 180ms ease, background 300ms ease;
}

a {
  color: var(--primary);
}

.layout {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(24px, 4vw, 32px);
  letter-spacing: -0.5px;
}

.hero p {
  margin: 6px 0 0;
  color: var(--muted);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
}

.card {
  background: linear-gradient(160deg, var(--card) 0%, var(--card) 65%, rgba(0, 0, 0, 0.04) 100%);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card.alt {
  background: linear-gradient(150deg, var(--card-2) 0%, var(--card-2) 60%, rgba(0, 0, 0, 0.03) 100%);
}

.card h2 {
  margin: 0 0 12px;
  font-size: 20px;
}

.muted {
  color: var(--muted);
  margin: 0 0 12px;
  font-size: 14px;
}

form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

label {
  font-size: 14px;
  color: var(--muted);
}

input,
textarea,
select {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--input-text);
  font-size: 15px;
}

/* Mejor contraste en selects (dropdown abierto) */
select {
  background: var(--input-bg);
  color: var(--input-text);
}

select option {
  background: var(--input-bg);
  color: var(--input-text);
}

textarea {
  resize: vertical;
  min-height: 70px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.button {
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: #041325;
  font-weight: 700;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, filter 180ms ease;
  box-shadow: 0 10px 30px rgba(22, 163, 255, 0.35);
}

.button:hover {
  transform: translateY(-2px) scale(1.01);
  filter: brightness(1.05);
}

.button:active {
  transform: translateY(0);
}

.button.secondary {
  background: linear-gradient(135deg, var(--primary-strong) 0%, var(--primary) 100%);
  color: #eaf5ff;
  box-shadow: 0 12px 28px rgba(15, 111, 181, 0.35);
}

.button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}

.stack {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.table-wrapper {
  overflow-x: auto;
  padding-bottom: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  color: var(--text);
  min-width: 640px;
}

th,
td {
  text-align: left;
  padding: 10px 8px;
}

th {
  color: var(--muted);
  border-bottom: 1px solid var(--border-strong);
  font-size: 13px;
  letter-spacing: 0.2px;
}

tr:nth-child(even) {
  background: var(--row-alt);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--pill-bg);
  border: 1px solid var(--pill-border);
  color: var(--pill-text);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 10px;
  background: var(--badge-bg);
  color: var(--badge-text);
  font-size: 12px;
  border: 1px solid var(--badge-border);
  text-transform: capitalize;
}

.inline {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status {
  color: var(--muted);
  font-size: 13px;
  margin-top: 8px;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 24px 0;
}

.login-gate {
  max-width: 420px;
  margin: 0 auto;
}

.report-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.summary {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.theme-toggle {
  min-width: 140px;
}

@media (max-width: 640px) {
  body {
    padding: 20px;
  }
  .hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .hero .stack {
    width: 100%;
    flex-wrap: wrap;
  }
  .report-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .card {
    padding: 16px;
  }
  .table-wrapper {
    margin: 0 -4px;
  }
  .actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 6px;
  }
  .button {
    width: 100%;
    justify-content: center;
    text-align: center;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .inline {
    flex-wrap: wrap;
  }
  .pill {
    width: 100%;
    justify-content: center;
  }
}
