:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --weekend-bg: #f8fafc;
  --today-ring: #2563eb;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* Header */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  font-size: 1.8rem;
}

.brand h1 {
  font-size: 1.15rem;
  font-weight: 700;
}

.subtitle {
  font-size: 0.8rem;
  color: var(--muted);
}

.tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tab-btn,
.tab-link {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

.tab-btn:hover,
.tab-link:hover {
  background: var(--bg);
  color: var(--text);
}

.tab-btn.active {
  background: #eff6ff;
  color: var(--primary);
  border-color: #bfdbfe;
}

/* Layout */
.container {
  max-width: 1360px;
  margin: 14px auto;
  padding: 0 16px 28px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.banner {
  background: linear-gradient(135deg, #eff6ff, #f0fdf4);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.banner p {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 4px;
}

.banner-actions {
  display: flex;
  gap: 10px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.toolbar h2 {
  font-size: 1.25rem;
}

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

.month-nav h2 {
  min-width: 190px;
  text-align: center;
  text-transform: capitalize;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 12px;
}

/* Buttons & Inputs */
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 15px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--bg);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--surface);
  color: var(--text);
}

.btn-icon {
  background: var(--surface);
  border-color: var(--border);
  padding: 7px 11px;
}

.btn-icon:hover {
  background: var(--bg);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
}

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  border-color: #fecaca;
}

.btn-danger-ghost:hover {
  background: #fef2f2;
}

.select,
input[type="text"],
input[type="email"],
input[type="date"],
.form select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--text);
}

input[type="color"] {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  background: var(--surface);
  cursor: pointer;
}

/* Calendar */
.calendar-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  text-align: center;
}

.calendar-weekdays div {
  padding: 7px 4px;
}

.calendar-weekdays .weekend {
  color: #dc2626;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.day-cell {
  min-width: 0;
  min-height: 84px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 6px;
  cursor: pointer;
  transition: background 0.12s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}

.day-cell:nth-child(7n) {
  border-right: none;
}

.day-cell:hover {
  background: #f8fafc;
}

.day-cell.other-month {
  background: #f8fafc;
  opacity: 0.45;
  cursor: default;
}

.day-cell.weekend {
  background: var(--weekend-bg);
}

.day-cell.holiday {
  background: #fef2f2;
}

.day-cell.today {
  box-shadow: inset 0 0 0 2px var(--today-ring);
}

.day-number {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
}

.day-cell.holiday .day-number {
  color: #dc2626;
}

.holiday-badge {
  font-size: 0.62rem;
  font-weight: 700;
  background: #fee2e2;
  color: #b91c1c;
  padding: 1px 5px;
  border-radius: 999px;
}

.toggle-permisos {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.permisos-list {
  margin-top: auto;
  padding-top: 3px;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  min-width: 0;
}

.permiso-chip {
  font-size: 0.65rem;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 4px;
  padding: 1px 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.day-cell.today .day-number {
  color: var(--primary);
}

.shift-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 3px 6px;
  border-radius: 6px;
  font-size: 0.73rem;
  color: #fff;
  font-weight: 600;
  line-height: 1.2;
  min-width: 0;
  max-width: 100%;
}

.shift-pill-text {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shift-tag {
  background: rgba(255, 255, 255, 0.24);
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 0.64rem;
  flex-shrink: 0;
}

.shift-delete {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  flex-shrink: 0;
}

.shift-delete:hover {
  color: #fff;
}

/* Table */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.table th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.table tr:last-child td {
  border-bottom: none;
}

.text-right {
  text-align: right;
}

.prof-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  background: #e2e8f0;
  color: #334155;
}

.badge-active {
  background: #dcfce7;
  color: #166534;
}

.badge-inactive {
  background: #fee2e2;
  color: #991b1b;
}

/* Resumen */
.resumen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 16px;
}

.resumen-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.resumen-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}

.resumen-total {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
}

.resumen-bar-bg {
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 12px;
}

.resumen-bar-fill {
  height: 100%;
  border-radius: 999px;
}

.resumen-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal-card {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 460px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.2);
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.btn-close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  color: var(--muted);
  cursor: pointer;
}

.form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.checkbox-label {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  font-weight: 500 !important;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.25);
  z-index: 100;
}

.toast.error {
  background: var(--danger);
}

.hidden {
  display: none !important;
}

@media (max-width: 768px) {
  .topbar-inner {
    padding: 10px 12px;
    gap: 10px;
  }
  .tabs {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }
  .tab-btn,
  .tab-link {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 8px 11px;
    font-size: 0.84rem;
  }
  .container {
    margin: 10px auto;
    padding: 0 10px 28px;
  }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .month-nav {
    justify-content: space-between;
  }
  .toolbar-actions {
    justify-content: space-between;
  }
  .calendar-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .calendar-weekdays,
  .calendar-grid {
    min-width: 650px;
  }
  .day-cell {
    min-height: 78px;
    padding: 5px;
  }
  .acum-table {
    min-width: 680px;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* Acumulaciones (estilo Excel sombreado gris) */
.acum-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.84rem;
}

.acum-table th,
.acum-table td {
  border: 1px solid #94a3b8;
  padding: 5px 6px;
  vertical-align: middle;
}

.acum-table th {
  background: #f1f5f9;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 2px solid #475569;
}

.acum-table th.acum-dia-col,
.acum-table td.acum-dia-col {
  width: 132px;
  font-weight: 800;
  font-size: 0.78rem;
  color: var(--text);
  background: #f8fafc;
  white-space: nowrap;
  text-align: left;
  padding-left: 10px;
}

.acum-week-sep td {
  height: 10px;
  padding: 0 !important;
  background: #e2e8f0;
  border-top: 2px solid #475569;
  border-bottom: 2px solid #475569;
}

.acum-row-weekend td {
  background: #f1f5f9;
}

.acum-row-holiday td {
  background: #fef2f2;
}

.acum-cell {
  position: relative;
  text-align: center;
  background: #ffffff;
  height: 48px;
}

.acum-cell.acum-marcado {
  background: #a6a6a6 !important;
  color: #0f172a;
}

.acum-motivo-text {
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #0f172a;
  text-align: center;
  line-height: 1.2;
}

.acum-motivo-btn {
  position: absolute;
  top: 2px;
  right: 3px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.72rem;
  opacity: 0;
  padding: 1px 2px;
  transition: opacity 0.12s ease;
}

.acum-cell:hover .acum-motivo-btn {
  opacity: 0.9;
}

.acum-input {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  color: var(--text);
  padding: 2px 4px;
  border-radius: 4px;
  resize: none;
  display: block;
}

.acum-input:hover,
.acum-input:focus {
  background: #f8fafc;
  border-color: #93c5fd;
  outline: none;
}

/* Semáforo de conexión (Firestore + SQLite) */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f8fafc;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  vertical-align: middle;
  transition: transform 0.12s ease;
}

.status-pill:hover {
  transform: scale(1.03);
}

.status-light {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-verde {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
}
.status-verde .status-light {
  background: #16a34a;
  box-shadow: 0 0 6px #22c55e;
}

.status-amarillo {
  background: #fef9c3;
  color: #854d0e;
  border-color: #fde047;
}
.status-amarillo .status-light {
  background: #eab308;
  box-shadow: 0 0 6px #facc15;
}

.status-rojo {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}
.status-rojo .status-light {
  background: #dc2626;
  box-shadow: 0 0 6px #ef4444;
}

/* Modo oscuro */
[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --border: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --weekend-bg: #172033;
  --today-ring: #60a5fa;
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .tab-btn.active {
  background: #1e3a5f;
  color: #93c5fd;
  border-color: #2563eb;
}

[data-theme="dark"] .calendar-weekdays,
[data-theme="dark"] .table th,
[data-theme="dark"] .acum-table th,
[data-theme="dark"] .acum-table td.acum-dia-col {
  background: #162032;
}

[data-theme="dark"] .day-cell:hover {
  background: #253349;
}

[data-theme="dark"] .day-cell.other-month {
  background: #0f172a;
}

[data-theme="dark"] .day-cell.holiday,
[data-theme="dark"] .acum-row-holiday td {
  background: #3b1822;
}

[data-theme="dark"] .acum-row-weekend td {
  background: #172033;
}

[data-theme="dark"] .acum-cell {
  background: #1e293b;
}

[data-theme="dark"] .acum-week-sep td {
  background: #0f172a;
}

[data-theme="dark"] .acum-cell.acum-marcado {
  background: #64748b !important;
}

[data-theme="dark"] .acum-motivo-text {
  color: #f8fafc;
}

[data-theme="dark"] .acum-input:hover,
[data-theme="dark"] .acum-input:focus {
  background: #0f172a;
  border-color: #60a5fa;
}

[data-theme="dark"] .badge {
  background: #334155;
  color: #e2e8f0;
}

[data-theme="dark"] .badge-active {
  background: #14532d;
  color: #86efac;
}

[data-theme="dark"] .badge-inactive {
  background: #7f1d1d;
  color: #fecaca;
}

[data-theme="dark"] .permiso-chip {
  background: #422006;
  color: #fde68a;
  border-color: #854d0e;
}

[data-theme="dark"] .holiday-badge {
  background: #7f1d1d;
  color: #fecaca;
}

[data-theme="dark"] .banner {
  background: linear-gradient(135deg, #1e293b, #172554);
  border-color: #334155;
}

[data-theme="dark"] .status-verde {
  background: #14532d;
  color: #86efac;
  border-color: #166534;
}

[data-theme="dark"] .status-amarillo {
  background: #422006;
  color: #fde047;
  border-color: #854d0e;
}

[data-theme="dark"] .status-rojo {
  background: #450a0a;
  color: #fca5a5;
  border-color: #7f1d1d;
}



