:root {
  color-scheme: light;
  --ink: #1d2430;
  --muted: #667085;
  --line: #d7dde7;
  --panel: #ffffff;
  --page: #f4f7fb;
  --accent: #0f766e;
  --accent-2: #2563eb;
  --warn: #b45309;
  --danger: #b42318;
  --ok: #15803d;
  --shadow: 0 18px 40px rgba(29, 36, 48, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--page);
}

button,
.button,
input,
select,
textarea {
  font: inherit;
}

button,
.button {
  min-height: 40px;
  border: 0;
  border-radius: 7px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--accent);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

button:hover,
.button:hover {
  filter: brightness(0.96);
}

.ghost {
  color: var(--ink);
  background: #e8edf4;
}

.danger-button {
  color: #fff;
  background: var(--danger);
}

.topbar {
  min-height: 86px;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1.05;
}

h2 {
  font-size: 22px;
  line-height: 1.2;
}

h3 {
  font-size: 15px;
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.top-actions,
.toolbar,
.panel-heading,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.layout {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 20px;
}

.auth-view {
  width: min(960px, 100%);
  margin: 0 auto;
  padding: 42px 24px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.auth-view.single-auth {
  width: min(520px, 100%);
  grid-template-columns: 1fr;
}

.auth-card {
  padding: 20px;
  display: grid;
  gap: 14px;
}

.help-text {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.staff-panel {
  padding: 18px;
  align-self: start;
}

.planner {
  min-width: 0;
  display: grid;
  gap: 16px;
}

.toolbar {
  min-height: 78px;
  padding: 16px 18px;
}

.pill,
.notice {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
}

.pill {
  background: #e6f4f1;
  color: #0f766e;
}

.notice {
  color: var(--ok);
  background: #dcfce7;
}

.notice.warn {
  color: var(--warn);
  background: #fef3c7;
}

.notice.danger {
  color: var(--danger);
  background: #fee4e2;
}

.field {
  display: grid;
  gap: 6px;
}

.check-field {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.check-field input {
  width: 16px;
  height: 16px;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.field input,
.field select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
}

.field.compact {
  min-width: 170px;
}

.stack {
  margin-top: 18px;
  display: grid;
  gap: 12px;
}

.form-grid,
.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.staff-list {
  margin-top: 16px;
  display: grid;
  gap: 10px;
}

.staff-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.staff-card strong {
  display: block;
  margin-bottom: 4px;
}

.staff-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.staff-card.inactive {
  opacity: 0.68;
  background: #f1f5f9;
}

.staff-actions {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.staff-actions button {
  min-height: 32px;
  padding: 0 8px;
}

.shift-form {
  padding: 16px;
  display: grid;
  grid-template-columns: 1.1fr 0.75fr 0.75fr 1.25fr 1fr 0.9fr auto;
  align-items: end;
  gap: 12px;
}

.event-form {
  padding: 16px;
  display: grid;
  grid-template-columns: 1.25fr 1.5fr 0.9fr 0.9fr auto auto;
  align-items: end;
  gap: 12px;
}

.summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric {
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 28px;
}

.metric .text-metric {
  font-size: 15px;
  line-height: 1.35;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(160px, 1fr));
  gap: 10px;
}

.day-column {
  min-height: 360px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.day-column.today {
  border-color: var(--accent-2);
}

.day-head {
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.day-head strong {
  display: block;
}

.day-head span {
  color: var(--muted);
  font-size: 13px;
}

.shift {
  margin-bottom: 8px;
  padding: 10px;
  border-left: 4px solid var(--accent);
  border-radius: 7px;
  background: #f8fafc;
}

.shift.extra {
  border-left-color: var(--warn);
}

.shift.festivo {
  border-left-color: var(--accent-2);
}

.shift.comida {
  border-left-color: #be123c;
  background: #ffe4e6;
  box-shadow: inset 0 0 0 1px #f43f5e;
}

.shift.comida time,
.shift.comida strong {
  color: #9f1239;
}

.shift time {
  display: block;
  margin-bottom: 4px;
  font-weight: 800;
}

.shift small {
  display: block;
  color: var(--muted);
}

.shift button {
  width: 100%;
  min-height: 30px;
  margin-top: 8px;
  color: var(--danger);
  background: #fee4e2;
}

.messages-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.message-card {
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.message-card pre {
  margin: 0;
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  color: var(--ink);
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

dialog {
  width: min(720px, calc(100% - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.38);
}

.dialog {
  padding: 20px;
  display: grid;
  gap: 16px;
}

textarea {
  min-height: 320px;
  resize: vertical;
  line-height: 1.45;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .auth-view {
    grid-template-columns: 1fr;
  }

  .week-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .shift-form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .event-form,
  .messages-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .topbar,
  .top-actions,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .layout {
    padding: 14px;
  }

  .week-grid,
  .summary-grid,
  .shift-form,
  .event-form,
  .messages-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 6mm;
  }

  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  body {
    background: #fff;
    font-size: 8px;
  }

  .topbar,
  .staff-panel,
  .toolbar .eyebrow,
  .toolbar .notice,
  .toolbar button,
  .event-form,
  .shift-form,
  .summary-grid,
  .messages-grid,
  .shift button,
  dialog {
    display: none !important;
  }

  .layout {
    width: 100%;
    display: block;
    padding: 0;
  }

  .panel,
  .day-column,
  .metric {
    box-shadow: none;
    border-color: #9ca3af;
  }

  .planner {
    display: block;
  }

  .toolbar {
    min-height: auto;
    margin: 0;
    padding: 0 0 4px;
    border: 0;
  }

  .toolbar h2 {
    font-size: 13px;
    line-height: 1.15;
  }

  .week-grid {
    height: 267mm;
    margin-top: 4px;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: repeat(7, minmax(0, 1fr));
    gap: 3.5px;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .day-column {
    display: grid;
    grid-template-columns: 24mm repeat(4, minmax(0, 1fr));
    align-items: stretch;
    gap: 4px;
    min-height: 0;
    max-height: none;
    padding: 4px;
    border-radius: 4px;
    break-inside: avoid;
    page-break-inside: avoid;
    overflow: hidden;
  }

  .day-head {
    height: 100%;
    margin: 0;
    padding: 3px;
    border-right: 1px solid #9ca3af;
    border-bottom: 0;
  }

  .day-head strong {
    font-size: 9px;
    line-height: 1.2;
  }

  .day-head span {
    font-size: 7px;
    line-height: 1.15;
  }

  .shift {
    height: 100%;
    min-height: 0;
    margin: 0;
    padding: 5px;
    border-left-width: 3px;
    border-radius: 3px;
    overflow: hidden;
  }

  .shift time,
  .shift strong {
    font-size: 8px;
    line-height: 1.2;
  }

  .shift small,
  .muted {
    font-size: 7px;
    line-height: 1.2;
  }

  .muted {
    align-self: stretch;
    margin: 0;
    padding: 5px;
    border: 1px dashed #cbd5e1;
    border-radius: 3px;
  }
}
