:root {
  --bg: #f3efe4;
  --card: #fffdf7;
  --card-border: #e4d7bd;
  --text: #231f1a;
  --muted: #746b5f;
  --line: #eadfc9;
  --field: #fffaf0;
  --field-border: #ddcfb4;
  --primary: #172f2a;
  --primary-dark: #0d1f1b;
  --accent: #d96b43;
  --ok-bg: #edf7ee;
  --ok-border: #bcdcbc;
  --ok-text: #1f5b34;
  --err-bg: #fff0ec;
  --err-border: #efc0b2;
  --err-text: #983f2e;
  --extra-bg: #ffe9e1;
  --extra-text: #a54832;
  --less-bg: #e8f5e8;
  --less-text: #2d6a3e;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  font-family: "Avenir Next", "Nunito Sans", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 18% 8%, rgba(217, 107, 67, 0.18), transparent 28%),
    radial-gradient(circle at 85% 12%, rgba(23, 47, 42, 0.13), transparent 26%),
    linear-gradient(180deg, #f8f1df 0%, var(--bg) 48%, #e9dfca 100%);
  color: var(--text);
  overflow-x: hidden;
  width: 100%;
  max-width: 100%;
}

.shell {
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  padding: 22px 12px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.card {
  width: min(100%, 460px);
  max-width: 460px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 28px;
  box-shadow: 0 22px 60px rgba(63, 47, 23, 0.14);
  padding: 22px 18px 18px;
  overflow: hidden;
  position: relative;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(217, 107, 67, 0.16) 0 3px, transparent 3px 100%),
    repeating-linear-gradient(180deg, transparent 0 35px, rgba(35, 31, 26, 0.035) 35px 36px);
  opacity: 0.7;
}

.hero {
  margin-bottom: 18px;
  position: relative;
}

.eyebrow {
  margin: 0 0 8px;
  width: fit-content;
  padding: 5px 9px;
  border: 1px solid #dfc9a4;
  border-radius: 999px;
  background: #fff7e8;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

h1 {
  margin: 0 0 6px;
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.panel {
  margin-top: 14px;
  min-width: 0;
  position: relative;
}

.hidden {
  display: none;
}

label {
  display: block;
  margin: 16px 0 7px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: #3f362b;
}

input,
button {
  font: inherit;
}

input {
  width: 100%;
  inline-size: 100%;
  max-inline-size: 100%;
  min-height: 52px;
  padding: 13px 15px;
  border-radius: 16px;
  border: 1.5px solid var(--field-border);
  background: var(--field);
  color: var(--text);
  max-width: 100%;
  min-width: 0;
}

input:focus {
  outline: none;
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(217, 107, 67, 0.14);
}

.native-field {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.native-display {
  width: 100%;
  min-height: 52px;
  padding: 13px 15px;
  border-radius: 16px;
  border: 1.5px solid var(--field-border);
  background: var(--field);
  color: var(--text);
  display: flex;
  align-items: center;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.native-display.is-placeholder {
  color: var(--muted);
}

.native-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0.01;
  cursor: pointer;
}

.time-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: end;
  width: 100%;
  min-width: 0;
}

.field {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

form {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.primary-btn,
.icon-btn,
.tab-btn,
.month-btn {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.primary-btn {
  width: 100%;
  min-height: 54px;
  margin-top: 22px;
  background: linear-gradient(135deg, var(--primary) 0%, #244b41 100%);
  color: #ffffff;
  font-weight: 800;
  border-radius: 18px;
  box-shadow: 0 14px 24px rgba(23, 47, 42, 0.18);
}

.primary-btn:hover {
  background: linear-gradient(135deg, var(--primary-dark) 0%, #18372f 100%);
}

.primary-btn:disabled,
.icon-btn:disabled,
.tab-btn:disabled,
.month-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 999px;
  background: #f5ead7;
  color: #786851;
  font-size: 28px;
  line-height: 1;
}

.icon-btn:hover {
  background: #eadbc0;
  color: var(--primary);
}

.user-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 250, 240, 0.72);
}

.user-value {
  margin: 0;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.02em;
}

.user-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.tab-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #f4ead9;
}

.tab-btn {
  min-height: 44px;
  padding: 0 12px;
  border-radius: 14px;
  background: transparent;
  color: #6d6255;
  font-weight: 800;
}

.tab-btn.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 6px 18px rgba(63, 47, 23, 0.1);
}

.tab-panel {
  width: 100%;
  min-width: 0;
}

.section-head {
  margin-bottom: 12px;
}

.month-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f7efdf;
}

.month-btn {
  min-height: 38px;
  padding: 0 10px;
  border-radius: 12px;
  background: transparent;
  color: #6d6255;
  font-size: 13px;
  font-weight: 800;
}

.month-btn.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(23, 47, 42, 0.12);
}

.section-title {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.section-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.history-balance {
  margin: 0 0 12px;
  padding: 12px 13px;
  border: 1px solid #dfc9a4;
  border-radius: 16px;
  background: #fff7e8;
  color: var(--primary);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.35;
}

.history-status {
  margin: 0;
  padding: 14px 0 2px;
  color: var(--muted);
  font-size: 14px;
}

.history-status.err {
  color: var(--err-text);
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}

.history-item:first-child {
  border-top: 0;
}

.history-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.history-date {
  font-size: 13px;
  color: var(--muted);
}

.history-range {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
}

.history-delta {
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 900;
  min-width: 48px;
  padding: 6px 9px;
  border-radius: 999px;
  text-align: center;
}

.history-delta.positive {
  background: var(--extra-bg);
  color: var(--extra-text);
}

.history-delta.negative {
  background: var(--less-bg);
  color: var(--less-text);
}

.history-delta.neutral,
.history-delta.muted {
  background: #f1e8d8;
  color: var(--muted);
}

.message {
  margin-top: 16px;
  padding: 13px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  position: relative;
}

.message.ok {
  background: var(--ok-bg);
  border: 1px solid var(--ok-border);
  color: var(--ok-text);
}

.message.err {
  background: var(--err-bg);
  border: 1px solid var(--err-border);
  color: var(--err-text);
}

.message strong {
  display: block;
  margin-bottom: 6px;
}

@media (max-width: 520px) {
  .shell {
    padding: 8px;
  }

  .card {
    width: 100%;
    max-width: 100%;
    border-radius: 22px;
    padding: 18px 14px;
  }

  h1 {
    font-size: 24px;
  }

  .time-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .user-bar {
    align-items: flex-start;
  }

  .primary-btn,
  .native-field,
  .native-display,
  .field,
  .time-grid,
  form,
  .panel,
  .tab-panel,
  .history-list,
  .history-item {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .primary-btn {
    display: block;
    width: 100%;
    max-width: 100%;
    margin-right: 0;
  }

  .tab-btn {
    min-height: 40px;
  }

  .history-item {
    align-items: flex-start;
  }

  .history-delta {
    margin-top: 2px;
  }

  .icon-btn {
    margin-top: -4px;
  }
}

/* Estilos para la pestaña de Horarios */
.schedule-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 14px;
}

.schedule-week-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.schedule-week-title {
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin: 6px 0 2px;
}

.schedule-day-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.schedule-day-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 253, 247, 0.6);
  border: 1px dashed var(--line);
  transition: all 0.2s ease;
}

.schedule-day-card:hover {
  background: var(--card);
  border-style: solid;
  border-color: var(--card-border);
  box-shadow: 0 4px 12px rgba(63, 47, 23, 0.04);
}

.schedule-day-card.is-today {
  background: linear-gradient(135deg, #fffcf5 0%, #fff7e8 100%);
  border: 2px solid var(--accent);
  box-shadow: 0 6px 16px rgba(217, 107, 67, 0.1);
}

.schedule-day-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.schedule-day-name {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.schedule-today-badge {
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #ffffff;
  background: var(--accent);
  padding: 2px 6px;
  border-radius: 6px;
  line-height: 1;
}

.schedule-day-date {
  font-size: 12px;
  color: var(--muted);
}

.schedule-shifts {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
}

.schedule-shift-pill {
  font-size: 11px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid transparent;
}

.schedule-shift-pill.comida {
  background: var(--less-bg);
  color: var(--less-text);
  border-color: var(--ok-border);
}

.schedule-shift-pill.cena {
  background: var(--extra-bg);
  color: var(--extra-text);
  border-color: var(--err-border);
}

.schedule-shift-pill.libre {
  background: #f1e8d8;
  color: var(--muted);
  font-style: italic;
}

/* Horizontal scrollable week tabs */
#scheduleWeekTabs {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 6px;
  padding: 4px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f7efdf;
  scrollbar-width: none; /* Ocultar scrollbar en Firefox */
  -ms-overflow-style: none; /* Ocultar en IE/Edge */
}

#scheduleWeekTabs::-webkit-scrollbar {
  display: none; /* Ocultar scrollbar en Chrome/Safari */
}

#scheduleWeekTabs .month-btn {
  flex: 0 0 auto;
  text-align: center;
  white-space: nowrap;
  transition: all 0.2s ease-in-out;
}

/* Badge de turno inesperado en historial */
.history-delta.unexpected {
  background: #e0f2fe; /* Azul muy claro */
  color: #0369a1;      /* Azul oscuro */
}

/* Indicadores de colores especiales en el horario */
.schedule-day-card.color-preventivo {
  background: rgba(253, 230, 238, 0.65); /* Rosa suave */
  border-color: rgba(236, 72, 153, 0.4);
}
.schedule-day-card.color-preventivo:hover {
  background: rgba(253, 230, 238, 0.85);
}

.schedule-day-card.color-descanso {
  background: rgba(254, 249, 195, 0.65); /* Amarillo suave */
  border-color: rgba(234, 179, 8, 0.4);
}
.schedule-day-card.color-descanso:hover {
  background: rgba(254, 249, 195, 0.85);
}

.schedule-day-card.color-vacaciones {
  background: rgba(220, 252, 231, 0.65); /* Verde suave */
  border-color: rgba(34, 197, 94, 0.4);
}
.schedule-day-card.color-vacaciones:hover {
  background: rgba(220, 252, 231, 0.85);
}

/* Tarjeta hoy con color de horario */
.schedule-day-card.is-today.color-preventivo {
  background: linear-gradient(135deg, #fffcf5 0%, #fce7f3 100%);
  border: 2px solid var(--accent);
}
.schedule-day-card.is-today.color-descanso {
  background: linear-gradient(135deg, #fffcf5 0%, #fef9c3 100%);
  border: 2px solid var(--accent);
}
.schedule-day-card.is-today.color-vacaciones {
  background: linear-gradient(135deg, #fffcf5 0%, #dcfce7 100%);
  border: 2px solid var(--accent);
}

/* Estilos de badges descriptivos en las tarjetas */
.schedule-badge {
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 6px;
  line-height: 1;
  display: inline-block;
  margin-left: 2px;
}
.schedule-badge.preventivo {
  color: #be185d;
  background: #fbcfe8;
}
.schedule-badge.descanso {
  color: #854d0e;
  background: #fef08a;
}
.schedule-badge.vacaciones {
  color: #166534;
  background: #bbf7d0;
}

/* Pastillas de turno especiales */
.schedule-shift-pill.descanso {
  background: #fef08a;
  color: #854d0e;
  border-color: #fde047;
}
.schedule-shift-pill.vacaciones {
  background: #bbf7d0;
  color: #166534;
  border-color: #86efac;
}
