:root {
  --bg: #f6f7f5; --surface: #ffffff; --surface-2: #eef1ee; --border: #dde2dd;
  --text: #1a1f1c; --muted: #5d6862; --accent: #0f766e; --accent-ink: #ffffff; --accent-soft: #d8efeb;
  --ok: #15803d; --ok-soft: #dcf2e3; --warn: #b45309; --warn-soft: #fbedd8; --bad: #b91c1c; --bad-soft: #fbe2e2;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111513; --surface: #1a1f1c; --surface-2: #232a26; --border: #313a35;
    --text: #e9eeea; --muted: #9aa7a0; --accent: #2bb3a3; --accent-ink: #062521; --accent-soft: #163a35;
    --ok: #4ade80; --ok-soft: #163a22; --warn: #f5b04c; --warn-soft: #3d2c12; --bad: #f87171; --bad-soft: #3d1a1a;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); }
a { color: var(--accent); }
h1 { font-size: 1.45rem; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
h3 { font-size: .95rem; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* Layout */
.layout { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--border); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; padding: 4px 8px 18px; }
.brand img { width: 30px; height: 30px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; color: var(--text); text-decoration: none; margin-bottom: 2px; }
.nav a:hover { background: var(--surface-2); }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav svg { width: 18px; height: 18px; flex: none; }
.side .foot { margin-top: auto; padding: 8px; font-size: .85rem; }
main { padding: 26px 30px 90px; max-width: 1180px; width: 100%; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; flex-direction: row; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--border); z-index: 20; }
  .brand, .side .foot { display: none; }
  .nav { display: flex; width: 100%; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 2px; font-size: .68rem; padding: 6px 4px; margin: 0; flex: 1; text-align: center; }
  .nav a .lbl-long { display: none; }
  main { padding: 18px 16px 100px; }
}

/* Componentes */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 820px) { .g2, .g3 { grid-template-columns: 1fr; } .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
.stat { padding: 14px 16px; }
.stat .v { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: .85rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 8px 14px; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; min-height: 38px; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 10px; min-height: 30px; font-size: .85rem; }
.btn.mp { background: #009ee3; border-color: #009ee3; color: #fff; }
.btn:disabled { opacity: .55; cursor: default; }
td .btn + .btn { margin-left: 4px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

label { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px; min-height: 38px; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.form { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0,1fr)); }
.form .full { grid-column: 1 / -1; }
.form.f3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
@media (max-width: 600px) { .form, .form.f3 { grid-template-columns: 1fr; } }

.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.acc { background: var(--accent-soft); color: var(--accent); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 12px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 600; }
.tabs a.on { color: var(--accent); border-color: var(--accent); }

.empty { text-align: center; color: var(--muted); padding: 28px 10px; }
.alert { padding: 10px 14px; border-radius: 9px; margin-bottom: 14px; }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.bad { background: var(--bad-soft); color: var(--bad); }

.list-item { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.time { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 52px; }

.ex { padding: 12px 0; border-bottom: 1px solid var(--border); display: flex; gap: 12px; }
.ex:last-child { border-bottom: 0; }
.ex .n { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: .85rem; flex: none; }
.ex .t { font-weight: 600; }
.ex .d { color: var(--muted); font-size: .88rem; }
.ex.done .t { text-decoration: line-through; color: var(--muted); }
.daytabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.daytabs button { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 99px; padding: 5px 12px; font: inherit; font-size: .85rem; cursor: pointer; }
.daytabs button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.slots { display: flex; flex-wrap: wrap; gap: 8px; }
.slots button { border: 1px solid var(--accent); color: var(--accent); background: var(--surface); padding: 8px 14px; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; }
.slots button:hover { background: var(--accent-soft); }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--surface); border-radius: 14px; width: min(720px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { width: min(1000px, 100%); }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { background: var(--bad); color: #fff; }
@media (max-width: 820px) { #toast { bottom: 90px; } }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(380px, 100%); padding: 28px; }
.login img { width: 48px; height: 48px; }

.ej-table td { padding: 4px; border: 0; }
.ej-table input, .ej-table select { min-height: 34px; padding: 5px 7px; }
.spark { width: 100%; height: 60px; }
