/* Horário Staples — one neutral palette, one accent, system fonts. */
:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --panel: #f5f5f3;
  --text: #17181a;
  --muted: #6c7078;
  --faint: #a4a8ae;
  --line: #e7e7e4;
  --track: #ececea;
  --fill: #b9bcc1;
  --accent: #cc0000;
  --accent-text: #ffffff;
  --accent-soft: #fdeeee;
  --shadow: 0 12px 40px rgba(0, 0, 0, .18);
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111214;
    --panel: #191b1e;
    --text: #ececed;
    --muted: #9a9ea6;
    --faint: #62666d;
    --line: #26292d;
    --track: #212327;
    --fill: #4d5158;
    --accent: #ff5a4f;
    --accent-text: #1a0605;
    --accent-soft: #2a1716;
    --shadow: 0 12px 40px rgba(0, 0, 0, .6);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.grow { flex: 1; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text);
  font-weight: 550; font-size: 14px; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--panel); }
.btn.icon { width: 36px; padding: 0; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--accent); }
.btn:disabled { opacity: .45; cursor: default; }

.seg { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); }
.seg button { height: 30px; padding: 0 12px; border-radius: 6px; font-size: 14px; font-weight: 550; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--bg); color: var(--text); box-shadow: 0 0 0 1px var(--line); }
.seg.small button { height: 26px; padding: 0 10px; font-size: 13px; }

/* ---------- header ---------- */
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line); padding: calc(10px + env(safe-area-inset-top)) 0 10px; }
.bar { display: flex; align-items: center; gap: 10px; }
.bar h1 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; margin-right: 2px; }
.clock { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 14px; font-weight: 550; }
.clock .ic { width: 15px; height: 15px; }

.datebar { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.date {
  position: relative; flex: 1; min-width: 0; height: 36px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
  font-weight: 600;
}
.date:hover { background: var(--panel); }
.date .ic { color: var(--muted); }
.date span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 8px; }
.strip button { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 0 6px; border-radius: 8px; position: relative; }
.strip small { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.strip b { font-size: 16px; font-weight: 600; }
.strip button:hover { background: var(--panel); }
.strip button.today b { color: var(--accent); }
.strip button.sel { background: var(--text); }
.strip button.sel small, .strip button.sel b { color: var(--bg); }
.strip button.sel.today { background: var(--accent); }
.strip button.sel.today small, .strip button.sel.today b { color: var(--accent-text); }

/* ---------- day view ---------- */
main { padding-top: 14px; padding-bottom: calc(48px + env(safe-area-inset-bottom)); }
.empty { padding: 56px 0; text-align: center; color: var(--muted); }
.summary-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 32px; color: var(--muted); font-size: 14px; }

.group { margin-top: 18px; }
.group h2 { display: flex; align-items: baseline; gap: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.group h2 span { font-weight: 500; color: var(--faint); }

.row { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--line); }
.row-main {
  flex: 1; min-width: 0; text-align: left; padding: 11px 0;
  display: grid; align-items: center; column-gap: 12px; row-gap: 7px;
  grid-template-columns: 1fr auto;
  grid-template-areas: "who hours" "bar bar" "note note";
}
.who { grid-area: who; display: flex; align-items: center; gap: 8px; min-width: 0; }
.name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.key { display: inline-flex; color: var(--faint); }
.key .ic { width: 14px; height: 14px; }
.hours { grid-area: hours; font-weight: 550; white-space: nowrap; }
.note { grid-area: note; font-size: 13px; color: var(--muted); }
.note b { font-weight: 550; }

.dot { display: none; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--faint); }
.row[class*="is-"] .dot { display: block; }
.is-on .dot { background: var(--accent); }

/* Working-now figure */
.worker { width: 24px; height: 24px; flex: none; margin: -4px -2px -4px -4px; fill: none; stroke: var(--text); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; overflow: visible; }
.worker circle { fill: var(--text); stroke: none; }
.worker .swing { stroke: var(--accent); transform-origin: 7.5px 9.5px; transform: rotate(8deg); }
.worker .rock { stroke: var(--faint); }
.worker .spark { stroke: var(--accent); stroke-width: 1.4; opacity: 0; }
/* The motion is the signal ("working now"), so it runs even with reduced-motion set. */
.worker .swing { animation: swing 1.1s cubic-bezier(.45, .05, .55, .95) infinite; }
.worker .spark { animation: spark 1.1s ease-out infinite; }
@keyframes swing { 0%, 100% { transform: rotate(-34deg); } 45%, 55% { transform: rotate(14deg); } }
@keyframes spark { 0%, 44%, 80%, 100% { opacity: 0; transform: translateY(1px); } 52% { opacity: 1; transform: none; } }
.is-lunch .dot { background: transparent; box-shadow: inset 0 0 0 2px var(--accent); }
.is-on .note b, .is-lunch .note b { color: var(--text); }
.is-later .name, .is-done .name, .is-later .hours, .is-done .hours { color: var(--muted); }

.bar-wrap { grid-area: bar; }
.row .bar { grid-area: bar; position: relative; display: block; height: 4px; border-radius: 2px; background: var(--track); }
.row .bar i { position: absolute; top: 0; bottom: 0; }
.row .bar .fill { background: var(--fill); border-radius: 2px; }
.is-on .bar .fill, .is-lunch .bar .fill { background: var(--text); }
.is-done .bar .fill { opacity: .5; }
.row .bar .gap { background: var(--track); box-shadow: 0 0 0 1.5px var(--bg); }
.row .bar .now { width: 2px; margin-left: -1px; top: -4px; bottom: -4px; background: var(--accent); border-radius: 1px; }

.lunch-btn { flex: none; width: 36px; }
.btn.lunch-btn { border-color: transparent; color: var(--faint); }
.btn.lunch-btn:hover { color: var(--text); }
.btn.lunch-btn.set { color: var(--accent); }

.away { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); column-gap: 28px; }
.away button { width: 100%; display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); text-align: left; color: var(--muted); }
.away em { font-style: normal; color: var(--faint); }
.away button:hover span { color: var(--text); }

@media (min-width: 760px) {
  .row-main {
    grid-template-columns: minmax(150px, 210px) 104px minmax(120px, 1fr) minmax(190px, 250px);
    grid-template-areas: "who hours bar note";
    column-gap: 18px; padding: 12px 0;
  }
  .row:hover { background: color-mix(in srgb, var(--panel) 60%, transparent); }
}

/* ---------- week view ---------- */
.week-scroll { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.week { width: 100%; border-collapse: collapse; font-size: 13px; }
.week th, .week td { padding: 0; border-bottom: 1px solid var(--line); text-align: center; font-weight: 400; }
.week thead th { border-bottom-color: var(--text); }
.week thead button { display: flex; flex-direction: column; align-items: center; width: 100%; padding: 4px 0 6px; }
.week thead small { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.week thead b { font-size: 15px; font-weight: 600; }
.week thead .today b { color: var(--accent); }
.week td { height: 44px; min-width: 40px; }
.week td.today { background: var(--accent-soft); }
.week .t { display: block; line-height: 1.25; }
.week em { font-style: normal; color: var(--faint); font-size: 12px; }
.week tbody th[scope] { position: sticky; left: 0; background: var(--bg); text-align: left; }
.week tbody th button { display: flex; align-items: center; gap: 6px; width: 100%; height: 44px; padding-right: 8px; font-weight: 600; text-align: left; white-space: nowrap; }
.week tbody th .ic { width: 13px; height: 13px; color: var(--faint); }
.week .full { display: none; }
.week .sec th { padding: 16px 0 5px; text-align: left; font-size: 12px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); position: sticky; left: 0; }
.week .total { display: none; color: var(--muted); padding-left: 8px; text-align: right; }

@media (min-width: 760px) {
  .week { font-size: 14px; }
  .week .t { display: inline; }
  .week .t + .t::before { content: "–"; }
  .week em { font-size: 13px; }
  .week .full { display: inline; }
  .week .short { display: none; }
  .week .total { display: table-cell; }
  .week thead th.total { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; vertical-align: bottom; padding-bottom: 8px; }
  .week tbody tr:not(.sec):hover > * { background: var(--panel); }
  .week tbody tr:not(.sec):hover > td.today { background: var(--accent-soft); }
}
@media (max-width: 400px) {
  .week { font-size: 12px; }
  .week td { min-width: 37px; }
}

/* ---------- dialogs ---------- */
.dlg {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  padding: 18px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--bg); color: var(--text); box-shadow: var(--shadow);
}
.dlg.narrow { width: min(420px, calc(100vw - 24px)); }
.dlg::backdrop { background: rgba(0, 0, 0, .45); }
.dlg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.dlg-head h2 { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.dlg-head p { margin-top: 2px; color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.dlg-head p .ic { width: 14px; height: 14px; }
@media (max-width: 560px) {
  .dlg { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 16px 16px 0 0; border-width: 1px 0 0; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  .dlg.narrow, .dlg.cal { width: 100vw; }
}

/* Declared after the phone rule above, so it must not apply there (it would un-stretch the sheet). */
@media (min-width: 561px) { .dlg.cal { width: 340px; } }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 12px; }
.cal-grid .dow { text-align: center; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding-bottom: 4px; }
.cal-grid button { height: 40px; border-radius: 8px; font-weight: 550; }
.cal-grid button:hover:not(:disabled) { background: var(--panel); }
.cal-grid button:disabled { color: var(--faint); opacity: .5; cursor: default; }
.cal-grid button.today { color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-grid button.sel, .cal-grid button.sel:hover { background: var(--text); color: var(--bg); box-shadow: none; }
.cal-grid button.sel.today, .cal-grid button.sel.today:hover { background: var(--accent); color: var(--accent-text); }
.month-nav strong { font-weight: 650; }
.month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.month .dow { text-align: center; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding-bottom: 3px; }
.month .cell { min-height: 58px; padding: 4px 2px; border-radius: 7px; background: var(--panel); display: flex; flex-direction: column; align-items: center; font-size: 12px; line-height: 1.25; }
.month .cell b { font-size: 11px; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
.month .cell.off, .month .cell.none { background: none; box-shadow: inset 0 0 0 1px var(--line); }
.month .cell em { font-style: normal; color: var(--faint); font-size: 11px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.month .cell.today { box-shadow: inset 0 0 0 2px var(--accent); }
.month .cell.today b { color: var(--accent); }
.month .t { display: block; }
.month-sum { margin-top: 12px; color: var(--muted); font-size: 14px; text-align: center; }

.field { margin-bottom: 14px; }
.lbl { display: block; margin-bottom: 6px; font-size: 12px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { height: 34px; min-width: 62px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; font-weight: 550; }
.chips button:hover { background: var(--panel); }
.chips button[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.other { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--muted); font-size: 14px; }
input[type="text"], input[type="password"], input[type="date"], input[type="time"], select, textarea {
  height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
}
textarea { height: auto; padding: 10px; }
.summary { min-height: 40px; color: var(--muted); font-size: 14px; }
.actions { display: flex; align-items: center; gap: 8px; margin-top: 6px; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50;
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 10px;
  background: var(--text); color: var(--bg); font-size: 14px; font-weight: 550; box-shadow: var(--shadow);
}

@media (prefers-reduced-motion: no-preference) {
  .btn, .seg button, .strip button, .chips button { transition: background-color .12s, color .12s; }
}
