:root {
  --bg: #f6f8f6;
  --bg-2: #e6eee8;
  --ink: #0b0f0c;
  --muted: #3a453e;
  --line: #cdd8d1;
  --card: #ffffff;
  --sidebar: #0d2418;
  --on-sidebar: #f4f7f5;
  --on-sidebar-muted: #a8bfb0;
  --accent: #14532d;
  --accent-dark: #0f3d22;
  --accent-soft: #e7f2eb;
  --on-accent: #ffffff;
  --morning: #14532d;
  --morning-bg: #e7f3eb;
  --afternoon: #115e59;
  --afternoon-bg: #e4f1ee;
  --prob: #1b4332;
  --prob-bg: #eef5f1;
  --off: #3d4a42;
  --off-bg: #eef1ee;
  --sabadero: #3f5c28;
  --sabadero-bg: #eef3e8;
  --ok: #14532d;
  --danger: #8b2c2c;
  --danger-bg: #f8eaea;
  --sheet-head: #0d2418;
  --sheet-section: #14532d;
  --sheet-even: #f3f7f4;
  --sheet-off: #e5ebe7;
  --sheet-off-even: #dce5df;
  --sheet-border: #c5d2c9;
  --shadow: 0 16px 40px rgba(13, 36, 24, 0.08);
  --overlay: rgba(11, 15, 12, 0.46);
  --scrim: rgba(11, 15, 12, 0.35);
  --radius: 18px;
  --sans: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
}
button, input, select, textarea { font: inherit; color: inherit; }
button, .button, .nav-link {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  padding: 8px 14px;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
}
button:hover:not(:disabled), .button:hover { border-color: var(--accent); }
button.primary, .button.primary { background: var(--accent); border-color: transparent; color: var(--on-accent); }
button.primary:hover:not(:disabled) { background: var(--accent-dark); border-color: transparent; }
button.danger { background: var(--danger); border-color: transparent; color: var(--on-accent); }
button.danger:hover:not(:disabled) { border-color: transparent; }
button:disabled { opacity: 0.6; cursor: wait; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sidebar :focus-visible { outline-color: var(--on-sidebar-muted); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.02em; color: var(--accent); }
h1 { font-size: 2rem; margin: 0; }
h2 { margin: 0 0 8px; }
p { margin: 0 0 10px; }
.help { color: var(--muted); font-size: 0.92rem; }
.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.75rem;
  color: var(--accent);
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, var(--morning-bg), transparent 42%),
    radial-gradient(circle at bottom right, var(--afternoon-bg), transparent 38%),
    var(--bg);
}
.login-card {
  width: min(440px, 100%);
  background: var(--card);
  padding: 32px 28px;
  border-radius: 28px;
  box-shadow: var(--shadow);
}
.login-card h1 { font-size: 3.4rem; line-height: 0.95; margin: 4px 0 8px; }
.login-card form { display: grid; gap: 12px; margin-top: 18px; }

.shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--sidebar);
  color: var(--on-sidebar);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  gap: 8px;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px 12px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px; background: var(--accent);
  display: grid; place-items: center; font-family: var(--serif); font-size: 1.4rem; color: var(--on-accent);
}
.brand small { display: block; color: var(--on-sidebar-muted); letter-spacing: 0.12em; text-transform: uppercase; font-size: 0.68rem; }
.brand strong { font-family: var(--serif); font-size: 1.35rem; }
.nav { display: grid; gap: 4px; }
.nav-link {
  display: block;
  background: transparent;
  color: var(--on-sidebar);
  border-color: transparent;
  border-radius: 12px;
  padding: 10px 12px;
}
.nav-link.active, .nav-link:hover { background: rgba(244, 247, 245, 0.12); border-color: transparent; }
.sidebar-user { margin-top: auto; display: grid; gap: 4px; padding: 12px 8px 0; }
.sidebar-user span { color: var(--on-sidebar-muted); font-size: 0.85rem; }
.sidebar-user button {
  width: 100%;
  margin-top: 6px;
  background: transparent;
  color: var(--on-sidebar);
  border-color: rgba(244, 247, 245, 0.22);
}
.sidebar-user button:hover:not(:disabled) { border-color: var(--on-sidebar-muted); }
.nav-scrim { display: none; }
.content { padding: 22px 28px 56px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.menu-btn { display: none; }

.toolbar, .form-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar { margin: 8px 0 16px; }
.toolbar.flush { margin: 0; }
.stack { margin-top: 12px; }
fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; }
legend { padding: 0; }
.stats, .split, .cards, .slots { display: grid; gap: 12px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-bottom: 16px; }
.cards { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.slots { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.split { grid-template-columns: 1fr 1fr; }
.stat, .card, .panel, .slot-card, .mini-day {
  background: var(--card);
  border: 1px solid transparent;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stat, .card, .panel { padding: 16px; }
.stat strong { display: block; font-family: var(--serif); font-size: 2rem; line-height: 1.1; }
.stat span, .muted { color: var(--muted); }
.card h3 { margin: 8px 0 4px; }
.card.inactive { opacity: 0.72; }
.person {
  display: flex; gap: 10px; align-items: center; justify-content: space-between;
  padding: 8px 0; border-top: 1px solid var(--line);
}
.person:first-of-type { border-top: 0; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bg-2); font-size: 0.8rem; font-weight: 700;
}
.who { display: flex; gap: 10px; align-items: center; }
.pill {
  display: inline-flex; align-items: center; border-radius: 999px;
  padding: 2px 8px; font-size: 0.75rem; background: var(--bg-2); white-space: nowrap;
}
.pill.morning { background: var(--morning-bg); color: var(--morning); }
.pill.afternoon { background: var(--afternoon-bg); color: var(--afternoon); }
.pill.off { background: var(--off-bg); color: var(--off); }
.pill.sabadero { background: var(--sabadero-bg); color: var(--sabadero); }
.pill.manual { background: var(--prob-bg); color: var(--prob); }

label { display: grid; gap: 6px; font-size: 0.92rem; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--card);
}
textarea { min-height: 80px; resize: vertical; }
.form-grid { display: grid; gap: 12px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row.three { grid-template-columns: 1.1fr 1fr 1fr; }
.choice {
  display: flex; gap: 8px; align-items: flex-start;
  background: var(--accent-soft); border-radius: 12px; padding: 10px 12px;
}
.choice input { width: auto; margin-top: 3px; }
.check { display: flex; gap: 8px; align-items: center; }
.check input { width: auto; }

.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.dow { text-align: center; color: var(--muted); font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; }
.day-cell {
  min-height: 112px; text-align: left; border-radius: 14px; background: var(--card);
  padding: 8px; display: flex; flex-direction: column; gap: 2px; align-items: stretch;
  border: 1px solid var(--line); box-shadow: none;
}
.day-cell.is-today { box-shadow: inset 0 0 0 2px var(--accent); }
.day-cell.is-libranza { background: var(--off-bg); }
.day-cell .day-num { font-family: var(--serif); font-size: 1.15rem; }
.day-cell small { color: var(--muted); font-size: 0.75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-blank { min-height: 112px; }

.slot-card { padding: 14px; border: 1px solid var(--line); }
.slot-card.probadores { grid-column: 1 / -1; background: var(--prob-bg); border-color: var(--line); }
.slot-card h3 { margin: 0 0 6px; font-family: var(--sans); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--prob); }
.slot-card.drop-target { outline: 2px dashed var(--accent); }
.slot-card select { margin-top: 8px; }
.break-table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 16px; overflow: hidden; }
.break-table th, .break-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.break-table th { font-size: 0.78rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.shift-panel { display: none; }
.shift-panel.active { display: block; }
.print-head { display: none; }
.banner {
  background: var(--prob-bg); color: var(--prob); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px;
}
.empty { padding: 28px 8px; color: var(--muted); }
.error-block { background: var(--danger-bg); color: var(--danger); padding: 12px 14px; border-radius: 12px; }
.loading { color: var(--muted); }
.assign-row { display: grid; gap: 8px; padding: 12px 0; border-top: 1px solid var(--line); }
.modal-back {
  position: fixed; inset: 0; background: var(--overlay);
  display: grid; place-items: center; padding: 18px; z-index: 40;
}
.modal {
  width: min(880px, 100%);
  max-height: min(90vh, 920px);
  overflow: auto;
  background: var(--card);
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.modal-confirm { width: min(460px, 100%); }
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--sidebar); color: var(--on-sidebar); padding: 12px 14px; border-radius: 12px; max-width: min(340px, 80vw); }
.toast-ok { background: var(--ok); }
.toast-err { background: var(--danger); }
.toolbar input,
.toolbar select { width: auto; }
.toolbar .search { width: min(360px, 100%); }
.search { min-width: min(240px, 100%); }

.sheet-wrap {
  overflow: auto;
  max-height: calc(100vh - 210px);
  border: 1px solid var(--sheet-border);
  background: var(--card);
}
.sheet {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.92rem;
  min-width: 720px;
}
.sheet caption { caption-side: top; text-align: left; padding: 0 0 8px; }
.sheet th, .sheet td {
  border-right: 1px solid var(--sheet-border);
  border-bottom: 1px solid var(--sheet-border);
  padding: 4px 8px;
  background: var(--card);
  text-align: left;
  vertical-align: middle;
}
.sheet thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--sheet-head);
  color: var(--on-sidebar);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.sheet-section th {
  position: sticky;
  top: 27px;
  z-index: 2;
  background: var(--sheet-section);
  color: var(--on-accent);
  font-family: var(--serif);
  font-size: 0.95rem;
  letter-spacing: 0;
  text-transform: none;
}
.sheet-section .pill, .sheet-section button { margin-left: 8px; vertical-align: middle; }
.sheet-section button { padding: 2px 10px; font-size: 0.8rem; }
.sheet tr.sheet-even td { background: var(--sheet-even); }
.sheet tr.sheet-off td { background: var(--sheet-off); color: var(--muted); }
.sheet tr.sheet-off.sheet-even td { background: var(--sheet-off-even); }
.sheet tr.is-sabadero td { background: var(--sabadero-bg); }
.sheet-empty td { color: var(--muted); font-style: italic; }
.sheet-time { font-variant-numeric: tabular-nums; white-space: nowrap; }
.sheet select {
  width: 100%;
  min-width: 128px;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 2px 4px;
}
.sheet-puesto-label { display: none; }
.sheet-puesto.is-readonly .sheet-puesto-label { display: inline; }

@media (max-width: 860px) {
  .shell { display: block; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(280px, 86vw);
    transform: translateX(-105%); z-index: 30; transition: transform 0.2s ease;
  }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .nav-scrim { display: block; position: fixed; inset: 0; background: var(--scrim); border: 0; z-index: 25; }
  .menu-btn { display: inline-flex; }
  .content { padding: 16px; }
  .split { grid-template-columns: 1fr; }
  .form-row, .form-row.three { grid-template-columns: 1fr; }
  .login-card h1 { font-size: 2.8rem; }
}
@media (max-width: 720px) {
  .calendar { gap: 4px; }
  .day-cell, .day-blank { min-height: 76px; padding: 4px; }
  .day-cell .extra { display: none; }
  h1 { font-size: 1.6rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
@media print {
  body { background: var(--card); }
  .sidebar, .topbar, .no-print, .toasts, .nav-scrim { display: none !important; }
  .shell, .content { display: block; padding: 0; }
  .shift-panel { display: block !important; break-after: page; }
  .shift-panel:last-child { break-after: auto; }
  .print-head { display: block; }
  .slot-card, .break-table, .panel, .sheet-wrap { box-shadow: none; }
  h1, h2, h3 { color: var(--ink); }
  .sheet-wrap { max-height: none; overflow: visible; border-color: var(--muted); }
  .sheet { min-width: 0; }
  .sheet thead th, .sheet-section th { position: static; background: var(--bg-2) !important; color: var(--ink) !important; }
  .sheet-puesto-label { display: inline !important; }
  .slot-card select, .sheet select { display: none !important; }
  .sheet tr, .sheet td, .sheet th { break-inside: avoid; }
}
