:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #1c2128;
  --border: rgba(255,255,255,.08);
  --border2: rgba(255,255,255,.14);
  --text: #e6edf3;
  --muted: #7d8590;
  --accent: #388bfd;
  --red: #f85149;
  --amber: #d29922;
  --green: #3fb950;
  --red-bg: rgba(248,81,73,.12);
  --amber-bg: rgba(210,153,34,.12);
  --green-bg: rgba(63,185,80,.12);
  --mono: 'IBM Plex Mono', monospace;
  --sans: 'IBM Plex Sans', sans-serif;
  --radius: 8px;
  --radius-lg: 12px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 3rem;
}

/* HEADER */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.header-title {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: .04em;
}
.header-sub {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
  margin-top: 2px;
}
.header-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  flex-shrink: 0;
}

/* MAIN */
.main { max-width: 680px; margin: 0 auto; padding: 1.25rem 1rem; }

/* SECTION */
.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.1rem;
  margin-bottom: 1rem;
}
.section-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .85rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.section-label::before {
  content: '';
  width: 3px; height: 12px;
  background: var(--accent);
  border-radius: 2px;
}

/* FORM */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
@media (max-width: 420px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .field-fecha { grid-column: 1 / -1; }
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: .04em;
}
.field input {
  height: 38px;
  padding: 0 10px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  width: 100%;
  -webkit-appearance: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input::placeholder { color: rgba(125,133,144,.5); }
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56,139,253,.15);
}
.form-actions { display: flex; gap: 8px; }
.btn {
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
  letter-spacing: .03em;
  flex-shrink: 0;
}
.btn:hover { background: var(--surface2); border-color: rgba(255,255,255,.2); }
.btn:active { transform: scale(.97); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  flex: 1;
}
.btn-primary:hover { background: #58a6ff; border-color: #58a6ff; }
.btn-danger {
  color: var(--red);
  border-color: rgba(248,81,73,.3);
}
.btn-danger:hover { background: var(--red-bg); }

.error-msg {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--red);
  margin-top: 8px;
  padding: 6px 10px;
  background: var(--red-bg);
  border-radius: var(--radius);
  border-left: 3px solid var(--red);
  display: none;
}

/* METRICS */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 1rem;
}
@media (max-width: 500px) {
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
}
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: .85rem .9rem;
}
.metric-label {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.metric-value {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  line-height: 1;
}
.metric-sub {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
}
.metric-card.danger .metric-value { color: var(--red); }
.metric-card.warning .metric-value { color: var(--amber); }

/* CHART */
.chart-wrap {
  position: relative;
  width: 100%;
  height: 280px;
}
@media (max-width: 480px) { .chart-wrap { height: 230px; } }

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 1rem;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}
.chart-legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}
.legend-bar {
  width: 12px; height: 12px;
  border-radius: 3px;
}
.legend-line {
  width: 20px; height: 2px;
  border-top: 2px dashed;
}

/* TABLE */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 12px;
  min-width: 520px;
}
thead th {
  text-align: left;
  padding: 6px 10px;
  color: var(--muted);
  font-weight: 500;
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.02); }
tbody td { padding: 8px 10px; vertical-align: middle; }
.num { text-align: right; }
.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .04em;
  white-space: nowrap;
}
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-green { background: var(--green-bg); color: var(--green); }
.del-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color .15s, background .15s;
}
.del-btn:hover { color: var(--red); background: var(--red-bg); }

/* EMPTY */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 13px;
}
.empty-icon {
  font-size: 32px;
  margin-bottom: .75rem;
  opacity: .4;
}
.empty-state p { line-height: 1.6; }

/* FOOTER */
.footer {
  text-align: center;
  font-family: var(--mono);
  font-size: 10px;
  color: rgba(125,133,144,.4);
  margin-top: 2rem;
  letter-spacing: .06em;
}