.panel-header {
  display: flex;
  min-height: 78px;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem max(1.25rem, calc((100vw - 1240px) / 2));
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.panel-brand, .panel-header-actions, .panel-row, .panel-section-heading {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.panel-brand { font-family: var(--font-display); font-size: 1.35rem; line-height: 1; }
.panel-brand img { object-fit: contain; }
.panel-brand small { display: block; margin-top: 0.25rem; color: var(--primary); font: 700 0.65rem var(--font-sans); letter-spacing: 0.15em; text-transform: uppercase; }
.panel-header-actions { color: var(--muted-foreground); font-size: 0.85rem; }
.panel-shell { max-width: var(--container); min-height: calc(100vh - 78px); margin: auto; padding: 2.5rem 1.25rem 6rem; }
.panel-message { min-height: 1.5rem; color: var(--primary); font-weight: 700; }
.panel-message.is-error { color: #ff9a91; }
.panel-auth-card, .panel-card { border: 1px solid var(--border); border-radius: 1rem; background: var(--surface-2); }
.panel-auth-card { max-width: 32rem; margin: 5vh auto; padding: clamp(1.25rem, 4vw, 2.5rem); }
.panel-auth-card h1, .panel-intro h1 { margin-block: 0.6rem 1rem; font-size: clamp(2.4rem, 7vw, 4.4rem); }
.panel-auth-card p, .panel-intro p, .panel-section > p, .panel-card > p { color: var(--muted-foreground); }
.panel-intro { display: flex; align-items: start; justify-content: space-between; gap: 1rem; margin-bottom: 1.75rem; }
.panel-demo { padding: 0.5rem 0.75rem; border: 1px solid var(--primary); border-radius: 999px; color: var(--primary); font-size: 0.7rem; font-weight: 800; text-transform: uppercase; }
.panel-nav { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 2rem; border-bottom: 1px solid var(--border); }
.panel-nav button { min-height: 44px; padding: 0.7rem 1rem; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--muted-foreground); cursor: pointer; font-size: 0.82rem; font-weight: 700; }
.panel-nav button[aria-current="page"] { border-bottom-color: var(--primary); color: var(--foreground); }
.panel-section { display: grid; gap: 1.5rem; }
.panel-section h2 { font-size: clamp(2rem, 5vw, 3rem); }
.panel-section h3, .panel-card h3 { margin-bottom: 1rem; font-size: 1.45rem; line-height: 1.15; }
.panel-section-heading { flex-wrap: wrap; justify-content: space-between; }
.panel-row { flex-wrap: wrap; align-items: end; }
.panel-grid { display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); align-items: start; }
.panel-card { padding: clamp(1.15rem, 3vw, 1.75rem); }
.panel-form { display: grid; gap: 1rem; }
.panel-form label, .panel-filters label, .panel-section-heading label, .account-edit label { display: grid; flex: 1 1 170px; gap: 0.35rem; min-width: 0; color: var(--muted-foreground); font-size: 0.8rem; font-weight: 700; }
.panel-form input, .panel-form select, .panel-form textarea, .panel-filters select, .panel-section-heading input, .panel-section-heading select, .account-edit input, .account-edit select, #invite-result input {
  width: 100%; min-height: 44px; padding: 0.65rem 0.8rem; border: 1px solid rgba(255,255,255,.22);
  border-radius: 0.5rem; background: var(--surface-3); color: var(--foreground); font: 500 0.95rem var(--font-sans);
}
.panel-form textarea { resize: vertical; }
.panel-form .panel-check { display: flex; align-items: center; gap: 0.6rem; color: var(--foreground); }
.panel-check input { width: 1.1rem; min-height: 1.1rem; accent-color: var(--primary); }
.panel-form .btn { justify-self: start; }
.panel-list, .panel-calendar { display: grid; gap: 0.8rem; }
.panel-calendar { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); align-items: start; }
.panel-day { min-height: 9rem; padding: 1rem; border: 1px solid var(--border); border-radius: 0.75rem; background: var(--surface-2); }
.panel-day h3 { margin-bottom: 1rem; color: var(--primary); text-transform: capitalize; }
.panel-day > p { color: var(--muted-foreground); }
.panel-occurrence, .panel-list-item { display: grid; gap: 0.5rem; padding: 1rem; border: 1px solid var(--border); border-radius: 0.7rem; background: var(--surface-2); }
.panel-occurrence + .panel-occurrence { margin-top: 0.75rem; }
.panel-occurrence strong, .panel-list-item strong { color: var(--foreground); font-size: 0.95rem; }
.panel-occurrence span, .panel-list-item span, .panel-occurrence small { color: var(--muted-foreground); font-size: 0.82rem; }
.panel-occurrence button, .panel-list-item button { width: fit-content; min-height: 38px; padding: 0.4rem 0.8rem; border: 1px solid rgba(255,255,255,.25); border-radius: 0.5rem; background: transparent; color: var(--foreground); cursor: pointer; font-size: 0.8rem; font-weight: 700; }
.panel-occurrence button:hover, .panel-list-item button:hover { border-color: var(--primary); color: var(--primary); }
button:disabled { opacity: 0.55; cursor: wait; }
#exception-form, #catalog-form, #account-form, #settings-form, #password-form { max-width: 48rem; }
#invite-result input { font-size: 0.76rem; }
#mfa-uri, #mfa-recovery-codes { width: 100%; padding: 0.7rem; border: 1px solid rgba(255,255,255,.22); border-radius: 0.5rem; background: var(--surface-3); color: var(--foreground); font: 500 0.85rem var(--font-sans); overflow-wrap: anywhere; }
#mfa-recovery-codes { margin-bottom: 1rem; font-family: ui-monospace, monospace; line-height: 1.65; }

@media (max-width: 760px) {
  .panel-header { align-items: start; }
  .panel-header-actions { flex-direction: column; align-items: end; gap: 0.25rem; }
  .panel-header-actions .btn { min-height: 40px; }
  .panel-intro { flex-direction: column; }
  .panel-grid { grid-template-columns: 1fr; }
  .panel-nav { flex-wrap: nowrap; overflow-x: auto; }
  .panel-nav button { flex: 0 0 auto; }
  .panel-section-heading .panel-row { width: 100%; }
  .panel-section-heading .panel-row .btn { flex: 1 1 auto; padding-inline: 0.7rem; }
  .panel-section-heading input[type="date"] { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* Minha Agenda: a rotina recorrente é editada como blocos de meia hora. */
.weekly-agenda { gap: 1.25rem; }
.weekly-agenda-state { color: var(--primary); font-size: .84rem; font-weight: 800; }
.weekly-agenda-state.is-error { color: #ff9a91; }
.weekly-agenda-controls, .weekly-tools { display: flex; flex-wrap: wrap; gap: .7rem; align-items: center; }
.weekly-agenda-controls > label { display: grid; min-width: 220px; gap: .35rem; color: var(--muted-foreground); font-size: .8rem; font-weight: 700; }
.weekly-agenda-controls select { min-height: 42px; padding: .55rem .7rem; border: 1px solid rgba(255,255,255,.22); border-radius: .5rem; background: var(--surface-3); color: var(--foreground); font: 500 .9rem var(--font-sans); }
.weekly-mode-toggle { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .35rem; max-width: 620px; padding: .3rem; border: 1px solid var(--border); border-radius: .75rem; background: var(--surface-2); }
.weekly-mode-toggle button { display: grid; min-width: 0; min-height: 52px; gap: .12rem; padding: .55rem .8rem; border: 0; border-radius: .5rem; background: transparent; color: var(--muted-foreground); cursor: pointer; text-align: left; }
.weekly-mode-toggle strong { font: 800 .84rem var(--font-sans); }
.weekly-mode-toggle span { overflow: hidden; font-size: .68rem; text-overflow: ellipsis; white-space: nowrap; }
.weekly-mode-toggle button[aria-pressed="true"] { background: var(--primary); color: var(--primary-foreground); }
.weekly-routine-view:not([hidden]) { display: grid; gap: 1.25rem; }
.weekly-tool-card { display: grid; gap: 1rem; }
.weekly-tool-card-heading { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .75rem 1rem; }
.weekly-tool-card-heading h3 { margin-bottom: .45rem; }
.weekly-tool-card p, .weekly-grid-help { color: var(--muted-foreground); font-size: .84rem; }
.weekly-tools { align-items: stretch; }
.weekly-tool { display: grid; min-width: 148px; min-height: 70px; gap: .2rem; padding: .75rem .85rem; border: 1px solid var(--border); border-radius: .7rem; background: var(--surface-3); color: var(--foreground); cursor: pointer; text-align: left; }
.weekly-tool strong { font: 800 .88rem var(--font-sans); }
.weekly-tool span { color: var(--muted-foreground); font-size: .72rem; }
.weekly-tool[aria-pressed="true"] { outline: 2px solid var(--primary); outline-offset: 2px; }
.weekly-tool.is-free[aria-pressed="true"] { border-color: #61d492; background: rgba(53, 169, 100, .16); }
.weekly-tool.is-group[aria-pressed="true"] { border-color: var(--primary); background: rgba(255,195,0,.14); }
.weekly-tool.is-clear[aria-pressed="true"] { border-color: #ff9a91; background: rgba(255,120,110,.12); }
.weekly-grid-area { min-width: 0; }
.weekly-save-status { min-height: 1rem; margin: 0 0 .55rem; color: var(--muted-foreground); font-size: .74rem; font-weight: 600; }
.weekly-save-status.is-error { color: #ff9a91; }
.weekly-retry { margin: 0 0 .55rem; padding: 0; border: 0; background: none; color: var(--primary); font: 600 .74rem var(--font-sans); text-decoration: underline; cursor: pointer; }
.weekly-grid-wrap { overflow: auto; padding-left: 34px; border: 1px solid var(--border); border-radius: .8rem; background: var(--surface-2); }
.weekly-grid tbody th { position: relative; }
.weekly-hour-add, .weekly-line-remove { position: absolute; top: 50%; width: 26px; height: 26px; padding: 0; border: 1px solid var(--border); border-radius: .35rem; background: var(--surface-3); color: var(--primary); cursor: pointer; font: 800 1rem var(--font-sans); opacity: 0; transform: translateY(-50%); }
.weekly-hour-add, .weekly-line-remove { left: -31px; }
.weekly-line-remove { right: auto; }
.weekly-grid tbody tr:hover .weekly-hour-add, .weekly-grid tbody th:focus-within .weekly-hour-add, .weekly-hour-add:focus-visible,
.weekly-grid tbody th:hover .weekly-line-remove, .weekly-grid tbody th:focus-within .weekly-line-remove, .weekly-line-remove:focus-visible { opacity: 1; }
.weekly-hour-add:focus-visible, .weekly-line-remove:focus-visible, .weekly-line-choices button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.weekly-line-remove[hidden] { display: none; }
.weekly-intermediate-row { background: rgba(255,255,255,.025); }
.weekly-intermediate-row th small { display: block; color: var(--muted-foreground); font-size: .61rem; font-weight: 600; }
.weekly-intermediate-row .weekly-cell { min-height: 46px; }
.weekly-line-choices { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.weekly-line-choices button { min-height: 34px; padding: .25rem .55rem; border: 1px solid var(--border); border-radius: .4rem; background: var(--surface-3); color: var(--foreground); cursor: pointer; font: 700 .72rem var(--font-sans); white-space: nowrap; }
.weekly-line-choices button:hover { border-color: var(--primary); color: var(--primary); }
.weekly-line-choices [data-weekly-line-cancel] { min-width: 34px; padding: 0; border: 0; background: none; color: var(--primary); font-size: 1.15rem; }
.weekly-line-choices [data-weekly-line-cancel]:hover { border: 0; color: var(--primary); }
.weekly-grid { min-width: 810px; width: 100%; border-collapse: collapse; table-layout: fixed; }
.weekly-grid th, .weekly-grid td { min-width: 96px; padding: 0; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.weekly-grid .weekly-choice-row { height: 64px; }
.weekly-grid .weekly-choice-row > th,
.weekly-grid .weekly-choice-row > .weekly-choice-options { padding: 14px .5rem; vertical-align: middle; }
.weekly-grid .weekly-choice-row > th { padding-inline: .25rem; }
.weekly-grid .weekly-choice-row > .weekly-choice-options { min-width: 0; }
.weekly-grid tr > :first-child { width: 72px; min-width: 72px; border-left: 0; color: var(--primary); font-size: .75rem; font-weight: 800; text-align: center; }
.weekly-grid thead th { height: 56px; padding: .4rem; color: var(--primary); font-size: .75rem; text-align: center; }
.weekly-grid thead th span { display: block; color: var(--foreground); font-size: .68rem; font-weight: 600; }
.weekly-cell { display: grid; width: 100%; min-height: 52px; place-content: center; gap: .15rem; padding: .25rem; border: 0; background: transparent; color: var(--muted-foreground); cursor: pointer; font: 700 .74rem var(--font-sans); text-align: center; }
.weekly-cell small { display: block; max-width: 100%; overflow: hidden; color: currentColor; font-size: .64rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.weekly-cell:hover { background: rgba(255,255,255,.06); }
.weekly-cell:focus-visible, .weekly-tool:focus-visible, .weekly-view-toggle button:focus-visible { outline: 2px solid var(--primary); outline-offset: -3px; }
.weekly-cell.is-free { background: rgba(53,169,100,.24); color: #b8f6cf; }
.weekly-cell.is-group { background: rgba(255,195,0,.18); color: var(--primary); }
.weekly-cell.is-partial { box-shadow: inset 0 0 0 1px currentColor; }
.weekly-cell.is-draft { box-shadow: inset 0 0 0 2px rgba(255,255,255,.45); }
.weekly-cell.is-weekly-override { box-shadow: inset 0 0 0 2px rgba(255,195,0,.75); }
.weekly-cell.is-weekly-override small { display: block; margin-top: .2rem; font-size: .68rem; font-weight: 800; }
.weekly-cell.is-unavailable { cursor: not-allowed; }
.weekly-cell.is-unavailable:not(.is-free):not(.is-group) { background: rgba(255,255,255,.035); }
.weekly-exception-layout { display: grid; grid-template-columns: minmax(210px, 248px) minmax(0, 1fr); gap: 1rem; align-items: start; }
.weekly-exception-editor { display: grid; min-width: 0; gap: 1.25rem; }
.weekly-week-picker { display: grid; position: sticky; top: .75rem; min-width: 0; gap: .8rem; padding: .9rem; }
.weekly-week-picker h3 { margin-bottom: .3rem; font-size: 1rem; }
.weekly-week-picker p { color: var(--muted-foreground); font-size: .76rem; }
.weekly-week-list { display: grid; max-height: 23rem; gap: .35rem; overflow-y: auto; overscroll-behavior: contain; padding: .1rem .25rem .1rem .1rem; scrollbar-gutter: stable; }
.weekly-week-option { display: grid; width: 100%; min-height: 52px; gap: .2rem; padding: .55rem .65rem; border: 1px solid var(--border); border-radius: .55rem; background: var(--surface-3); color: var(--foreground); cursor: pointer; text-align: left; touch-action: manipulation; }
.weekly-week-option > span { font: 800 .82rem var(--font-sans); }
.weekly-week-option small { display: flex; min-height: 1rem; flex-wrap: wrap; gap: .25rem .45rem; color: var(--muted-foreground); font-size: .64rem; font-weight: 700; }
.weekly-week-option .has-adjustments { color: var(--primary); }
.weekly-week-option[aria-selected="true"] { border-color: var(--primary); background: rgba(255,195,0,.14); box-shadow: inset 3px 0 0 var(--primary); }
.weekly-week-option:focus-visible, .weekly-mode-toggle button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.weekly-restore { min-height: 40px; white-space: nowrap; }
.weekly-restore:disabled { cursor: not-allowed; opacity: .48; }
.weekly-mobile-day { display: none; }
@media (max-width: 760px) {
  .weekly-agenda-controls { align-items: stretch; }
  .weekly-agenda-controls > label { flex: 1 1 100%; }
  .weekly-mode-toggle { max-width: none; }
  .weekly-exception-layout { grid-template-columns: minmax(0, 1fr); }
  .weekly-week-picker { position: static; }
  .weekly-week-list { max-height: 13rem; }
  .weekly-tool-card-heading { grid-template-columns: minmax(0, 1fr); justify-items: start; }
  .weekly-tool { min-width: min(100%, 145px); flex: 1 1 145px; }
  .weekly-mobile-day { display: grid; gap: .3rem; margin-bottom: .7rem; color: var(--muted-foreground); font-size: .78rem; font-weight: 800; }
  .weekly-mobile-day select { min-height: 42px; padding: .55rem .7rem; border: 1px solid rgba(255,255,255,.22); border-radius: .5rem; background: var(--surface-3); color: var(--foreground); }
  .weekly-grid-wrap { overflow: hidden; padding-left: 36px; }
  .weekly-grid { min-width: 0; }
  .weekly-grid th, .weekly-grid td { display: none; }
  .weekly-grid tr > :first-child, .weekly-grid th.is-mobile-day, .weekly-grid td.is-mobile-day { display: table-cell; }
  .weekly-grid tr > :first-child { width: 64px; min-width: 64px; }
  .weekly-cell { min-height: 56px; }
  .weekly-hour-add, .weekly-line-remove { opacity: 1; width: 28px; height: 28px; }
  .weekly-hour-add, .weekly-line-remove { left: -33px; }
  .weekly-grid .weekly-choice-row > .weekly-choice-options { display: table-cell; padding-inline: .4rem; }
  .weekly-line-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) 38px; width: 100%; gap: .25rem; }
  .weekly-line-choices button { width: 100%; min-width: 0; min-height: 38px; padding: .25rem; font-size: .68rem; }
  .weekly-line-choices [data-weekly-line-cancel] { min-width: 0; font-size: 1.25rem; }
}
@media (max-width: 390px) {
  .weekly-mode-toggle { grid-template-columns: minmax(0, 1fr); }
  .weekly-mode-toggle button { min-height: 46px; }
}
@media (hover: none) { .weekly-hour-add, .weekly-line-remove { opacity: 1; } }
