/* --- painéis laterais ----------------------------------------------------------- */
#drawer .shade {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(4, 6, 10, 0.62);
  animation: fade 0.15s ease-out;
}
.sheet {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  display: flex;
  flex-direction: column;
  width: min(600px, 100%);
  border-left: 1px solid var(--line-2);
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: slide 0.2s ease-out;
}
.sheet.wide {
  width: min(920px, 100%);
}
.sheet > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-5) var(--s-5) var(--s-5);
  border-bottom: 1px solid var(--line);
}
.sheet > header h2 {
  font-size: var(--fs-5);
  margin-top: 2px;
}
.sheet > header > button {
  width: var(--h-3);
  padding: 0;
  border-color: transparent;
  background: none;
  color: var(--muted);
}
.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-5);
  overscroll-behavior: contain;
}
.sheet > footer {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.sheet > footer > span {
  flex: 1;
}
@keyframes slide {
  from {
    transform: translateX(32px);
    opacity: 0;
  }
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
.form fieldset {
  margin: 0 0 var(--s-6);
  padding: 0;
  border: 0;
  min-width: 0;
}
.form fieldset > .field + .field,
.form fieldset > .field + .interval,
.form fieldset > .interval + .switch,
.form fieldset > .switch + .field {
  margin-top: var(--s-4);
}
/* v5.17.0 (P15): o mesmo espaço nos formulários sem fieldset («Nova cópia», «Nova ligação») */
.form > :is(.field, .copia-hours, .check-line, p) + :is(.field, .copia-hours, .check-line) {
  margin-top: var(--s-4);
}
.form legend {
  margin-bottom: var(--s-4);
  padding: 0;
  font-size: var(--fs-1);
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}
.form fieldset > p.small {
  margin: calc(var(--s-2) * -1) 0 var(--s-4);
}
.grid-2,
.grid-3 {
  display: grid;
  gap: var(--s-4) var(--s-4);
}
.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.span-2 {
  grid-column: 1 / -1;
}
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  padding: 3px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-2);
  background: var(--bg);
}
.segmented label {
  position: relative;
}
.segmented input,
.cat-grid input,
.check-chip input,
.choice input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  min-height: 0;
  pointer-events: none;
}
.segmented span {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-1);
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
}
.segmented label.good span::before,
.segmented label.warn span::before,
.segmented label.bad span::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.segmented input:checked + span {
  background: var(--surface-3);
  color: var(--ink);
  box-shadow: 0 1px 0 var(--line-2);
}
.segmented label.good input:checked + span {
  color: var(--good);
}
.segmented label.warn input:checked + span {
  color: var(--warn);
}
.segmented label.bad input:checked + span {
  color: var(--bad);
}
.segmented input:focus-visible + span,
.cat-grid input:focus-visible + span,
.check-chip input:focus-visible + span,
.choice input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: var(--s-3);
}
.cat-grid label {
  position: relative;
}
.cat-grid span {
  display: block;
  padding: var(--s-3) var(--s-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-2);
  background: var(--bg);
  text-align: center;
  cursor: pointer;
}
.cat-grid input:checked + span {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 650;
}
.chip-checks {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
}
.check-chip {
  position: relative;
}
.check-chip span {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-4);
  border: 1px solid var(--line-2);
  border-radius: var(--r-pill);
  background: var(--bg);
  cursor: pointer;
}
.check-chip .ico {
  display: none;
  width: 14px;
  height: 14px;
}
.check-chip input:checked + span {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.check-chip input:checked + span .ico {
  display: block;
}
.choice-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.choice {
  position: relative;
}
.choice > span {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: var(--s-3);
  padding: var(--s-4) var(--s-4);
  border: 1px solid var(--line-2);
  border-radius: var(--r-2);
  background: var(--bg);
  cursor: pointer;
}
.choice > span small {
  grid-column: 2;
  color: var(--muted);
}
.choice input:checked + span {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.interval {
  display: flex;
  align-items: flex-end;
  gap: var(--s-4);
  flex-wrap: wrap;
}
.interval .field {
  width: 180px;
}
.quick {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
}
.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  cursor: pointer;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.switch span {
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  border: 1px solid var(--line-2);
  transition: background 0.15s;
}
.switch span::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.15s;
}
.switch input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
}
.switch input:checked + span::after {
  transform: translateX(16px);
  background: var(--accent-ink);
}
.switch input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.transfer-from {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s-3) var(--s-3);
  margin-bottom: var(--s-3);
  padding: var(--s-4) var(--s-4);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--surface-2);
}
.transfer-from .kicker {
  display: inline;
}
.transfer-from .ico {
  color: var(--accent);
}
.transfer-from + .muted {
  margin-bottom: var(--s-4);
}
.form-index {
  display: flex;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-5);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--surface);
}
.form-index button {
  flex: none;
  min-height: var(--h-2);
  padding: var(--s-1) var(--s-4);
  border-radius: var(--r-pill);
  font-size: var(--fs-2);
}
.form-index button.on {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.form-section {
  scroll-margin-top: 12px;
  padding: var(--s-5) 0;
  border-top: 1px solid var(--line);
}
.form-section:first-child {
  padding-top: 0;
  border-top: 0;
}
.form-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}
.form-section-head h3 {
  font-size: var(--fs-4);
}
.form-section-head button {
  min-height: var(--h-2);
}
.form-section > p.small {
  margin: calc(var(--s-2) * -1) 0 var(--s-3);
}
/* v5.17.0 (P07): o registo de manutenção mostra o essencial; o resto fica em «Mais detalhes». */
.more-details > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  min-height: 48px;
  list-style: none;
  cursor: pointer;
}
.more-details > summary::-webkit-details-marker {
  display: none;
}
.more-details > summary > span {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.more-details > summary b {
  font-size: var(--fs-4);
}
.more-details > summary small {
  color: var(--muted);
}
.more-details > summary .chev {
  flex: none;
  transition: transform 0.15s;
}
.more-details[open] > summary {
  margin-bottom: var(--s-4);
}
.more-details[open] > summary .chev {
  transform: rotate(90deg);
}
.more-details > .form-section:last-child {
  padding-bottom: 0;
}
.repeat {
  padding: var(--s-4) var(--s-4) var(--s-4);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--surface-2);
}
.repeat + .repeat {
  margin-top: var(--s-3);
}
.repeat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-3);
}
.repeat textarea {
  min-height: 60px;
}

/* --- menu contextual, avisos ------------------------------------------------------ */
.popmenu {
  position: absolute;
  z-index: 60;
  display: flex;
  flex-direction: column;
  min-width: 210px;
  padding: var(--s-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-3);
  background: var(--surface-2);
  box-shadow: var(--shadow);
  animation: fade 0.1s ease-out;
}
.popmenu button {
  justify-content: flex-start;
  gap: var(--s-3);
  border: 0;
  background: none;
  font-weight: 500;
}
.popmenu button:hover {
  background: var(--surface-3);
}
.popmenu button.danger {
  color: var(--bad);
}
.popmenu.as-sheet {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: 8px;
  padding: var(--s-3);
  border-radius: var(--r-3);
}
.popmenu.as-sheet button {
  min-height: 48px;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 70;
  transform: translateX(-50%);
  padding: var(--s-3) var(--s-5);
  border: 1px solid var(--line-2);
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--ink);
  font-weight: 650;
  box-shadow: var(--shadow);
  animation: fade 0.15s ease-out;
}
/* v6.36.0 (9.9): o aviso «… apagado · Desfazer» do apagar, com o botão (44 px de alvo). */
.toast-desfazer {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  max-width: calc(100% - 24px);
  padding-block: var(--s-1);
  padding-inline-end: var(--s-1);
}
.toast-desfazer button {
  min-height: 44px;
  border-radius: var(--r-pill);
}
#update-banner {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 65;
  display: flex;
  align-items: center;
  gap: var(--s-4);
  max-width: calc(100% - 40px);
  padding: var(--s-4) var(--s-4) var(--s-4) var(--s-5);
  border: 1px solid var(--accent);
  border-radius: var(--r-3);
  background: var(--surface-2);
  box-shadow: var(--shadow);
}
/* v5.4.0 (fase 28): o que mudou noutro dispositivo, no painel que deu conflito. */
.conflict-box {
  margin: 0 0 var(--s-5);
  padding: var(--s-4) var(--s-5);
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  border-radius: var(--r-2);
  background: var(--warn-soft);
  overflow-wrap: anywhere;
}
.conflict-box p {
  margin: 0 0 var(--s-3);
}
.conflict-box ul {
  margin: 0 0 var(--s-3);
  padding-left: var(--s-5);
}
.conflict-title {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  color: var(--warn);
}
.conflict-field {
  display: grid;
  gap: var(--s-2);
  margin: 0 0 var(--s-4);
  padding: 0;
  border: 0;
  min-width: 0;
}
.conflict-field legend {
  margin-bottom: var(--s-2);
  font-weight: 650;
}
.conflict-field legend small {
  font-weight: 400;
  color: var(--muted);
}
.conflict-field label {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-2);
  background: var(--surface);
  cursor: pointer;
}
.conflict-field label:has(input:checked) {
  border-color: var(--warn);
}
.conflict-field input {
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 2px 0 0;
  padding: 0;
  flex: none;
  accent-color: var(--warn);
}
.conflict-field span {
  display: grid;
  flex: 1;
  gap: 2px;
  min-width: 0;
  white-space: pre-wrap;
}
.conflict-field span b {
  font-size: var(--fs-1);
  color: var(--muted);
  white-space: normal;
}
