:root {
  --bg: #0f1419;
  --panel: #1a212b;
  --panel-2: #222c38;
  --line: #2c3947;
  --text: #e6edf3;
  --muted: #8b9bb0;
  --accent: #4da3ff;
  --accent-2: #56d4a0;
  --warn: #f0a868;
  --bad: #f0686b;
  --violet: #b78cff;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
h2, h3, h4 { margin: 0 0 .6rem; font-weight: 600; }
h3 { font-size: .95rem; color: var(--text); }
h4 { font-size: .85rem; color: var(--muted); margin-top: 1rem; }
a { color: var(--accent); }

/* ---- top bar / nav ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .7rem 1.2rem; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: .7rem; }
.brand span { color: var(--muted); font-weight: 400; font-size: .85rem; }
.brand .logo { height: 44px; width: auto; display: block; }
.brand .sep { color: var(--line); font-weight: 300; }
/* Centered app title — absolutely positioned so it stays centered regardless of the
   (uneven) left brand / right user-controls widths. */
.app-title {
  position: absolute; left: 50%; transform: translateX(-50%);
  font-weight: 700; font-size: 1.1rem; letter-spacing: .02em; white-space: nowrap;
  pointer-events: none;
}
@media (max-width: 720px) { .app-title { display: none; } }
.topbar-right { display: flex; align-items: center; gap: .6rem; margin-left: auto; }
.user { color: var(--muted); font-size: .8rem; }
.topnav { display: flex; gap: .4rem; margin-left: 1.4rem; }
.topnav a {
  color: var(--muted); text-decoration: none; font-size: .85rem; font-weight: 600;
  padding: .35rem .7rem; border-radius: 7px;
}
.topnav a:hover { background: var(--panel-2); color: var(--text); }
.topnav a.active { background: var(--panel-2); color: var(--accent); }
.logout-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 8px;
  color: var(--muted); text-decoration: none; font-size: 1.05rem; line-height: 1;
}
.logout-btn:hover { background: var(--warn); color: #2a1500; border-color: var(--warn); }

/* ---- buttons / inputs ---- */
.btn {
  background: var(--accent); color: #04101f; border: 0; border-radius: 8px;
  padding: .45rem .8rem; font-weight: 600; cursor: pointer; font-size: .85rem;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn.sm { padding: .3rem .55rem; font-size: .78rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

select, input[type="search"], input[type="text"], input[type="number"],
input[type="date"], input[type="time"], input[type="file"], textarea {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: .4rem .55rem; font-size: .85rem; outline: none;
  font-family: inherit;
}
select:hover, input:hover { border-color: #3a4a5c; }
select:focus, input:focus, textarea:focus { border-color: var(--accent); }
select option, select optgroup { background: #222c38; color: var(--text); }
select { color-scheme: dark; }
input[type="search"]::placeholder { color: #6c7c8e; }
label { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
/* small hint badge / info icon next to a field label */
.hint-ico {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .62rem; font-weight: 700; text-transform: none; letter-spacing: 0;
  color: var(--accent); border: 1px solid var(--line); border-radius: 999px;
  padding: 0 .35rem; min-width: 1rem; height: 1rem; line-height: 1; cursor: help;
  vertical-align: middle; margin-left: .25rem;
}
/* read-only (auto-computed) inputs look distinct from editable ones */
input[readonly] { background: var(--panel); color: var(--muted); cursor: not-allowed; border-style: dashed; }
/* day-of-week badge next to the Fecha label */
.dow { color: var(--accent); font-weight: 700; text-transform: none; letter-spacing: 0; margin-left: .35rem; }

/* ---- filters bar ---- */
.filters {
  display: flex; gap: .8rem; align-items: flex-end; flex-wrap: wrap;
  padding: .9rem 1.2rem; background: var(--panel); border-bottom: 1px solid var(--line);
}
.filter { display: flex; flex-direction: column; gap: .25rem; }

main { padding: 1.2rem; max-width: 1500px; margin: 0 auto; }

/* ---- cards / grid ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: .9rem; margin-bottom: 1rem; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; margin-bottom: 1.2rem;
}
.card.wide { grid-column: 1 / -1; }
@media (min-width: 1100px) { .grid .card.wide { grid-column: span 2; } }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .6rem; }
.muted { color: var(--muted); font-weight: 400; font-size: .8rem; }

/* ---- KPI cards ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .8rem; margin-bottom: 1.2rem; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.kpi .label { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 1.5rem; font-weight: 700; margin-top: .25rem; }
.kpi .sub { font-size: .75rem; margin-top: .2rem; color: var(--muted); }

/* ---- entry form ---- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .8rem; }
.form-field { display: flex; flex-direction: column; gap: .25rem; }
.form-field.col-2 { grid-column: span 2; }
.form-field input, .form-field select, .form-field textarea { width: 100%; }
.form-actions { display: flex; gap: .6rem; align-items: center; margin-top: .9rem; }

/* Grouped, intuitive entry form */
.entry-form .fgroup {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: .6rem .9rem .9rem; margin: 0 0 .8rem;
}
.entry-form legend {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--accent); font-weight: 700; padding: 0 .4rem;
}
.entry-form .frow { display: flex; flex-wrap: wrap; gap: .7rem 1rem; align-items: flex-end; }
.entry-form .form-field { gap: .3rem; }
/* field widths — fixed enough to align in tidy rows, no wasted space */
.entry-form .w-date  { width: 150px; }
.entry-form .w-time  { width: 110px; }
.entry-form .w-sm    { width: 96px; }
.entry-form .w-md    { width: 150px; }
.entry-form .w-grow  { flex: 1 1 240px; min-width: 200px; }
.entry-form .w-full  { flex: 1 1 100%; }
.entry-form .form-field input,
.entry-form .form-field select { width: 100%; }
/* highlight the field the user is on for an easy-to-follow flow */
.entry-form input:focus, .entry-form select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 2px rgba(77,163,255,.18);
}

/* little keyboard hint chips on the action buttons */
kbd {
  font-family: inherit; font-size: .72rem; font-weight: 700;
  background: rgba(0,0,0,.18); border: 1px solid rgba(255,255,255,.18);
  border-radius: 5px; padding: 0 .3rem; margin-left: .35rem;
}

/* ---- live KPI preview ---- */
.preview { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .9rem;
  padding-top: .9rem; border-top: 1px dashed var(--line); }
.preview .chip {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: .4rem .65rem; min-width: 90px;
}
.preview .chip .k { color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .03em; }
.preview .chip .v { font-size: 1.05rem; font-weight: 700; margin-top: .15rem; }
.preview .chip.good .v { color: var(--accent-2); }
.preview .chip.bad .v { color: var(--warn); }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .82rem; }
thead th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: .72rem;
  text-transform: uppercase; letter-spacing: .03em; padding: .5rem .55rem;
  border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0;
  background: var(--panel);
}
tbody td { padding: .45rem .55rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr:hover td { background: var(--panel-2); }
/* Subtle separation between day groups in the Registro table */
tbody tr.day-start td { border-top: 2px solid var(--panel-2); padding-top: .65rem; }
tbody tr.day-start td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { padding: .5rem .55rem; border-top: 2px solid var(--line); font-weight: 700; }
.row-actions { display: flex; gap: .3rem; }
.icon-btn {
  background: transparent; border: 1px solid var(--line); border-radius: 6px;
  color: var(--muted); cursor: pointer; padding: .2rem .4rem; font-size: .85rem;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); }
.pill { padding: .1rem .45rem; border-radius: 999px; font-size: .72rem; font-weight: 600; }
.pill.good { background: rgba(86,212,160,.16); color: var(--accent-2); }
.pill.bad { background: rgba(240,168,104,.16); color: var(--warn); }

/* ---- modal ---- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex;
  align-items: center; justify-content: center; z-index: 40; }
.modal[hidden] { display: none; }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.4rem; width: min(640px, 94vw); max-height: 92vh; overflow: auto; position: relative; }
.modal-close { position: absolute; top: .7rem; right: .8rem; background: transparent;
  border: 0; color: var(--muted); font-size: 1.4rem; cursor: pointer; line-height: 1; }

/* ---- toast / empty / status ---- */
.toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: .6rem 1rem; border-radius: 8px; z-index: 60; box-shadow: 0 6px 24px rgba(0,0,0,.4); }
.toast[hidden] { display: none; }
.empty { color: var(--muted); text-align: center; padding: 2.5rem 1rem; }
.status { margin-top: .6rem; font-size: .82rem; color: var(--muted); }

/* ---- segmented control (period toggle) ---- */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button {
  background: var(--panel-2); color: var(--muted); border: 0; cursor: pointer;
  padding: .4rem .7rem; font-size: .82rem; font-weight: 600; font-family: inherit;
  border-right: 1px solid var(--line);
}
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--accent); color: #04101f; }

/* ---- charts ---- */
.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 320px; }

/* ---- login ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 2rem; width: min(360px, 92vw); text-align: center; }
.login-card .logo { height: 42px; margin-bottom: 1rem; }
.login-card .err { color: var(--bad); font-size: .82rem; margin-top: .8rem; }
