:root {
  color-scheme: dark;
  --background: #101010;
  --surface: #202020;
  --elevated: #292929;
  --border: #3a3a3a;
  --text: #f5f5f5;
  --muted: #b6b6b6;
  --primary: #ffd400;
  --primary-hover: #ffd95a;
  --success: #65dc91;
  --success-bg: #173926;
  --warning: #ffc229;
  --danger: #ff9e9e;
  --danger-bg: #4a2525;
  --radius: 14px;
  font: 15px/1.5 Inter, system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--background); color: var(--text); }
[hidden] { display: none !important; }
.shell { width: min(100% - 48px, 1160px); margin-inline: auto; }
.masthead { border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 750; }
.brand img { border-radius: 8px; }
.intro { display: flex; align-items: end; justify-content: space-between; gap: 20px; padding: 34px 0 24px; }
.intro h1 { margin: 0; font-size: clamp(26px, 4vw, 37px); line-height: 1.16; letter-spacing: -.035em; }
.intro h1 small { color: var(--primary); font-size: .44em; white-space: nowrap; }
.intro p { max-width: 65ch; margin: 9px 0 0; color: var(--muted); }
.steps { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 8px; margin-bottom: 20px; }
.steps a { display:flex; align-items: center; gap: 8px; min-height: 46px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; color: var(--text); background: var(--surface); text-decoration: none; font-weight: 650; }
.steps a:hover, .steps a:focus-visible { border-color: var(--primary); }
.steps .step-number { flex: 0 0 23px; width: 23px; height: 23px; display: grid; place-items: center; border-radius: 50%; background: var(--primary); color: var(--background); font-size: 12px; }
.metrics { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; margin-bottom: 16px; }
.metric { min-width: 0; padding: 13px 15px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.metric small { display: block; color: var(--muted); }
.metric strong { display: block; margin-top: 4px; font-size: 26px; line-height: 1.13; font-variant-numeric: tabular-nums; }
.metric.is-attention strong { color: var(--warning); }
.panel { container-type: inline-size; scroll-margin-top: 14px; margin-bottom: 16px; padding: 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.section-head { margin-bottom: 16px; }
.section-head h2, .section-head h3 { margin: 0; line-height: 1.2; }
.section-head h2 { font-size: 22px; letter-spacing: -.02em; }
.section-head h3 { font-size: 18px; }
.section-head p { margin: 6px 0 0; color: var(--muted); max-width: 73ch; }
button, input, select { font: inherit; color: var(--text); }
button { min-height: 42px; padding: 9px 13px; border: 1px solid transparent; border-radius: 8px; cursor: pointer; background: var(--primary); color: var(--background); font-weight: 750; }
button:hover { background: var(--primary-hover); }
button.secondary { background: var(--elevated); border-color: var(--border); color: var(--text); }
button.secondary:hover { border-color: var(--primary); }
button.quiet-danger, button.danger { color: var(--danger); background: transparent; border-color: var(--border); }
button.quiet-danger:hover, button.danger:hover { border-color: var(--danger); background: var(--danger-bg); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
label { display: grid; gap: 5px; color: var(--muted); font-weight: 650; font-size: 13px; }
label small { font-weight: 400; }
input, select { min-width: 0; min-height: 40px; width: 100%; padding: 7px 8px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); background: var(--background); }
input[type=checkbox] { width: 20px; min-height: 20px; height: 20px; margin: 1px; accent-color: var(--primary); }
input:disabled { opacity: .5; }
.fields { display: grid; align-items: start; gap: 12px; margin-bottom: 16px; }
.business-fields { max-width: 540px; grid-template-columns: 1.15fr 1fr; }
.add-fields { align-items: end; grid-template-columns: minmax(110px,1fr) minmax(155px,1fr) minmax(110px,1fr) minmax(100px,.65fr) auto; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.staff-actions { margin-top: 14px; }
.staff-filter-controls { margin-bottom: 12px; }
.staff-filter-controls label, .shift-controls label { min-width: min(100%, 215px); }
.group-row th { background: var(--elevated); color: var(--primary); font-size: 13px; }
.group-row small { margin-left: 5px; color: var(--muted); font-weight: 400; }
#shift-table tbody .group-row th { position: static; background: var(--elevated); }
.staff-identity select { margin-top: 5px; max-width: 220px; }
.shift-controls { margin-bottom: 12px; }
.shift-controls small { flex-basis: 100%; color: var(--muted); }
.scroll { max-width: 100%; overflow: auto; border: 1px solid var(--border); border-radius: 9px; }
table { width: 100%; min-width: 510px; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 12px; }
thead th { background: var(--elevated); }
tbody th { background: var(--surface); color: var(--text); }
tr:last-child td, tr:last-child th { border-bottom: 0; }
td input { min-width: 72px; max-width: 190px; }
td input[type=checkbox] { min-width: 0; }
td input[type=number] { width: 75px; }
td input + input { margin-top: 5px; }
.daycell { min-width: 139px; vertical-align: top; }
.daycell label { margin-bottom: 6px; }
.daycell .day-off { display: flex; align-items: center; min-height: 28px; }
.daycell small { display: block; color: var(--muted); }
.shift-list table { min-width: 0; }
.shift-list td input[type=time] { max-width: none; }
#shift-table tbody th { position: sticky; left: 0; min-width: 105px; white-space: normal; z-index: 1; }
#shift-table .daycell[hidden], #shift-table thead th[hidden] { display: none; }
.empty { padding: 15px; border: 1px dashed var(--border); border-radius: 8px; color: var(--muted); background: var(--background); }
.empty a { color: var(--primary); }
.legend { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 10px 15px; }
.legend li { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.legend-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.heat { display: grid; grid-template-columns: 53px repeat(7,minmax(48px,1fr)); gap: 4px; min-width: 430px; padding: 8px; }
.heat span { text-align: center; font-size: 12px; padding: 5px 3px; border-radius: 4px; font-variant-numeric: tabular-nums; }
.good { background: var(--success-bg); color: var(--success); }
.bad { background: var(--danger-bg); color: var(--danger); }
.closed { background: var(--elevated); color: var(--muted); }
.review { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.warn { color: var(--warning); background: #382e1b; padding: 8px 11px; border-radius: 7px; margin: 6px 0; }
.ok { color: var(--success); margin: 0; }
footer { padding: 2px 0 25px; color: var(--muted); font-size: 12px; }
@container (max-width: 650px) {
  .add-fields { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 640px) {
  .shell { width: min(100% - 24px, 1160px); }
  .topbar { min-height: 58px; }
  .topbar .export { font-size: 13px; padding-inline: 8px; }
  .intro { flex-direction: column; align-items: flex-start; padding-top: 24px; gap: 12px; }
  .steps, .metrics { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .steps { gap: 6px; }
  .steps a { font-size: 13px; }
  .panel { padding: 14px; }
  .metric { padding: 10px 11px; }
  .metric strong { font-size: 22px; }
  button { min-height: 44px; }
  .business-fields { grid-template-columns: 1fr; }
  #empresa table, #staff-list table, #hours, #staff { display: block; min-width: 0; }
  #empresa thead, #staff-list thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  #hours tr, #staff tr { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px 12px; padding: 10px; border-bottom: 1px solid var(--border); }
  #hours tr:last-child, #staff tr:last-child { border-bottom: 0; }
  #hours th, #hours td, #staff td { padding: 0; border: 0; }
  #hours th, #staff .staff-identity { grid-column: 1 / -1; }
  #hours th { font-size: 14px; }
  #hours td[data-label]::before, #staff td[data-label]::before { content: attr(data-label); display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
  #staff .staff-identity { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
  #staff .staff-identity input { margin: 0; max-width: none; }
  #staff .staff-identity select { grid-column: 1 / -1; margin: 0; max-width: none; }
  #staff tr.group-row { display: block; padding: 0; }
  #staff .group-row th { width: 100%; display: block; padding: 8px 10px; }
  .staff-filter-controls label { flex: 1; }
  #hours input[type=time] { min-width: 79px; }
  .shift-controls label { flex: 1 1 100%; }
  .shift-controls button { max-width: 100%; }
}
@media (max-width: 340px) {
  .add-fields { grid-template-columns: 1fr; }
  .brand { font-size: 13px; gap: 6px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }


#empresa table { min-width: 875px; }
#hours input[type=number] { width: 100%; max-width: 80px; }
.coverage-controls { margin-bottom: 12px; align-items: center; }
.coverage-controls label { min-width: min(100%, 230px); }
.coverage-controls small, .muted, .table-help { color: var(--muted); }
.neutral-coverage { background: #25343b; color: #c4e3f3; }
.month-controls { align-items: end; grid-template-columns: repeat(3,minmax(0,1fr)) auto; }
.week-tile { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 8px 14px; padding: 11px 0; border-top: 1px solid var(--border); }
.week-tile h3, .week-tile p { margin: 0; }
.week-tile p { color: var(--muted); font-size: 13px; }
.week-tile details { grid-column: 1 / -1; min-width: 0; }
.week-tile summary { display: list-item; cursor: pointer; min-height: 44px; padding: 10px 0; color: var(--primary); }
.day-roster { border-top: 1px solid var(--border); padding: 9px 0; }
.day-roster h4 { margin: 0 0 5px; font-size: 14px; }
.day-roster ul { margin: 0; padding-left: 18px; }
.day-roster li { margin: 4px 0; }
.month-scroll table { min-width: max-content; }
.month-scroll th:first-child { position: sticky; left: 0; z-index: 1; min-width: 125px; }
.month-scroll thead th:first-child { z-index: 2; }
.month-scroll td, .month-scroll thead th:not(:first-child) { min-width: 64px; text-align: center; white-space: nowrap; }
.month-scroll .group-row th { position: static; text-align: left; }
.month-scroll td { font-size: 12px; font-variant-numeric: tabular-nums; }
.month-scroll .month-off { background: var(--elevated); color: var(--muted); }
.month-scroll .month-empty { color: var(--muted); }
.month-scroll .month-review { color: var(--warning); }
@media (max-width: 640px) {
  #empresa table { min-width: 0; }
  .month-controls { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .month-controls label, .month-controls button { min-width: 0; }
  .coverage-controls label { width: 100%; }
  .week-tile button { max-width: 145px; }
  #hours input, #hours select, #staff input, #staff select, .month-controls input, .month-controls select { font-size: 16px; }
  #shifts input[type=time] { font-size: 16px; }
}
@media (max-width: 360px) {
  .month-controls { grid-template-columns: 1fr; }
}


.phone-label, .phone-coverage { display: none; }
@media (max-width: 640px) {
  .wide-label, .desktop-coverage { display: none; }
  .phone-label, .phone-coverage { display: block; }
  body { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
  .masthead .topbar { min-height: 56px; }
  .steps { position: fixed; z-index: 5; inset: auto 0 0; margin: 0; padding: 5px 5px calc(5px + env(safe-area-inset-bottom)); gap: 3px; grid-template-columns: repeat(5,minmax(0,1fr)); background: var(--background); border-top: 1px solid var(--border); }
  .steps a { flex-direction: column; justify-content: center; gap: 2px; min-height: 48px; min-width: 0; padding: 2px 0; font-size: 11px; letter-spacing: -.01em; border-color: transparent; background: transparent; }
  .steps .step-number { flex: 0 0 19px; width: 19px; height: 19px; font-size: 11px; }
  .steps a:focus-visible { outline-offset: -2px; }
  .month-controls { gap: 9px; }
  .week-tile button { width: 100%; }
  .panel .section-head h2 { font-size: 20px; }
  .panel .section-head p { font-size: 14px; }
  .phone-coverage label { max-width: 100%; }
  #coverage-day-list { list-style: none; padding: 0; margin: 8px 0 0; }
  #coverage-day-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
  #coverage-day-list li:last-child { border-bottom: 0; }
  #coverage-day-list li span { min-width: 0; }
  #coverage-day-list small { display: block; color: var(--muted); overflow-wrap: anywhere; }
  #coverage-day-list li > strong { flex: 0 0 auto; padding: 6px 8px; border-radius: 6px; font-variant-numeric: tabular-nums; }
  #coverage-day-empty { margin-top: 8px; }
  #shift-table.single-day, #shift-table.single-day tbody { display: block; }
  #shift-table.single-day thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  #shift-table.single-day tr { display: block; }
  #shift-table.single-day .shift-row { padding: 9px 10px; border-bottom: 1px solid var(--border); }
  #shift-table.single-day .shift-row th { display: block; position: static; padding: 0 0 5px; font-size: 14px; border: 0; }
  #shift-table.single-day .group-row th { display: block; }
  #shift-table.single-day .daycell:not([hidden]) { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; padding: 0; }
  #shift-table.single-day .daycell label { margin: 0; }
  #shift-table.single-day .daycell .day-off, #shift-table.single-day .daycell small { grid-column: 1 / -1; }
}
