:root {
  color-scheme: light;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #eef7f7;
  color: #123332;
  --teal: #006b6b;
  --teal-dark: #005959;
  --teal-soft: #e1f0f0;
  --red: #c62828;
  --muted: #526b6a;
  --border: rgba(0, 107, 107, .18);
  --surface: rgba(255, 255, 255, .94);
  --shadow: 0 24px 70px rgba(0, 73, 73, .14);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(0, 150, 150, .20), transparent 34rem),
    linear-gradient(145deg, #f7ffff, #e4f2f2);
}

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

button {
  min-height: 48px;
  padding: 11px 18px;
  border: 0;
  border-radius: 14px;
  background: var(--teal);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

button:hover:not(:disabled) { background: var(--teal-dark); }
button:disabled { cursor: not-allowed; opacity: .58; }
button.secondary { background: var(--teal-soft); color: var(--teal-dark); }
button.danger { background: #fdecea; color: #8c1d18; }
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(0, 107, 107, .28);
  outline-offset: 2px;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-height: 50px;
  padding: 11px 13px;
  border: 1px solid #9fc7c7;
  border-radius: 14px;
  background: #fff;
  color: inherit;
}

textarea { resize: vertical; }
input:disabled,
select:disabled,
textarea:disabled { background: #eef4f4; color: var(--muted); }

.eyebrow {
  margin: 0 0 8px;
  color: var(--red);
  font-size: .76rem;
  font-weight: 850;
  letter-spacing: .15em;
  text-transform: uppercase;
}

h1,
h2,
h3 { color: var(--teal); }
h2 { margin: 0; font-size: clamp(1.9rem, 5vw, 2.8rem); line-height: 1.05; letter-spacing: -.035em; }
h3 { margin: 0 0 8px; }

/* Login */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(100%, 560px);
  padding: clamp(28px, 6vw, 48px);
  border: 1px solid var(--border);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin: 0;
  font-size: clamp(2.4rem, 10vw, 4.4rem);
  line-height: .95;
  letter-spacing: -.05em;
}

.lead { margin: 22px 0; font-size: 1.08rem; line-height: 1.65; }

.status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 16px;
  background: #fff7e6;
  color: #6b4a00;
  font-weight: 700;
}

.status-dot {
  width: 11px;
  height: 11px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #e59a00;
}

.form { display: grid; gap: 16px; margin-top: 24px; }
.form h2 { font-size: 1.8rem; }
.form input { font-size: 1.1rem; letter-spacing: .06em; }
.note { margin: 18px 0 0; color: var(--muted); line-height: 1.6; }
.error { min-height: 1.4em; margin: 0; color: #b3261e; font-weight: 700; }

/* App shell */
.app-shell { min-height: 100vh; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(16px, 4vw, 42px);
  border-bottom: 1px solid var(--border);
  background: rgba(247, 255, 255, .92);
  backdrop-filter: blur(14px);
}

.brand-block .eyebrow { margin-bottom: 2px; }
.brand { margin: 0; color: var(--teal); font-size: 1.55rem; font-weight: 900; letter-spacing: -.04em; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sync-pill {
  padding: 8px 11px;
  border-radius: 999px;
  background: #fff7e6;
  color: #6b4a00;
  font-size: .86rem;
  font-weight: 800;
  white-space: nowrap;
}

.sync-pill[data-state="online"] { background: #e5f4ea; color: #14532d; }
.sync-pill[data-state="syncing"],
.sync-pill[data-state="connecting"] { background: #e8f0fe; color: #174ea6; }
.sync-pill[data-state="offline"],
.sync-pill[data-state="error"] { background: #fdecea; color: #8c1d18; }

.menu-wrap { position: relative; }
.menu-button { min-width: 92px; }

.main-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(320px, calc(100vw - 32px));
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 22px 55px rgba(0, 73, 73, .22);
}

.session-summary {
  margin: 2px 4px 12px;
  color: var(--muted);
  font-weight: 750;
  line-height: 1.45;
}

.menu-items { display: grid; gap: 6px; }
.menu-items button {
  width: 100%;
  min-height: 46px;
  text-align: left;
  background: transparent;
  color: var(--teal-dark);
}
.menu-items button:hover,
.menu-items button[aria-current="page"] { background: var(--teal-soft); }
.menu-sign-out {
  width: 100%;
  margin-top: 10px;
  background: #fdecea;
  color: #8c1d18;
}

.app-main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: clamp(22px, 4vw, 44px) clamp(16px, 4vw, 42px) 56px;
}

.banner {
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 16px;
  font-weight: 750;
  line-height: 1.5;
}
.banner-error { background: #fdecea; color: #8c1d18; }
.banner-success { background: #e5f4ea; color: #14532d; }

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.section-lead { margin: 10px 0 0; color: var(--muted); line-height: 1.6; }

.notice,
.empty-state {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(255, 255, 255, .78);
  line-height: 1.6;
}
.notice { margin-bottom: 18px; background: #fff7e6; border-color: rgba(229, 154, 0, .35); }
.empty-state p { margin: 0; color: var(--muted); }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card,
.panel-card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 12px 34px rgba(0, 73, 73, .08);
}

.metric-card p { margin: 0; color: var(--muted); font-weight: 750; }
.metric-card strong { display: block; margin-top: 8px; color: var(--teal); font-size: 2.2rem; line-height: 1; }
.metric-card span { display: block; margin-top: 8px; color: var(--muted); line-height: 1.45; }

.panel-grid {
  display: grid;
  grid-template-columns: 1.35fr .85fr;
  gap: 14px;
}

.role-table { width: 100%; border-collapse: collapse; }
.role-table th,
.role-table td { padding: 10px 8px; border-bottom: 1px solid #dcebea; text-align: left; }
.role-table th:last-child,
.role-table td:last-child,
.role-table th:nth-last-child(2),
.role-table td:nth-last-child(2) { text-align: right; }
.role-table tr:last-child td { border-bottom: 0; }

.quick-actions { display: grid; gap: 10px; margin-top: 14px; }
.muted { color: var(--muted); line-height: 1.6; }

.filters {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(255, 255, 255, .78);
}
.filters-compact { grid-template-columns: 2fr 1fr; }
.list-count { color: var(--muted); font-weight: 750; }

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

.record-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 12px 34px rgba(0, 73, 73, .08);
}
.record-card.is-inactive { opacity: .72; }

.record-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.record-heading h3 { margin: 0; font-size: 1.18rem; line-height: 1.3; }
.record-subtitle { margin: 5px 0 0; color: var(--muted); line-height: 1.45; }

.badge {
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 999px;
  background: #e5f4ea;
  color: #14532d;
  font-size: .8rem;
  font-weight: 850;
}
.badge.inactive { background: #eceff1; color: #455a64; }
.badge.warning { background: #fff7e6; color: #6b4a00; }

.detail-list {
  display: grid;
  gap: 7px;
  margin: 0;
  color: #2d4a49;
  line-height: 1.5;
}
.detail-list div { display: grid; grid-template-columns: 128px 1fr; gap: 10px; }
.detail-list dt { color: var(--muted); font-weight: 800; }
.detail-list dd { margin: 0; overflow-wrap: anywhere; }

.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: auto;
}
.record-actions button { min-height: 44px; padding: 9px 14px; }

/* Dialogs/forms */
.form-dialog {
  width: min(680px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: #fff;
  color: inherit;
  box-shadow: var(--shadow);
}
.form-dialog-wide { width: min(880px, calc(100vw - 28px)); }
.form-dialog::backdrop { background: rgba(6, 42, 42, .48); backdrop-filter: blur(3px); }

.record-form {
  display: grid;
  gap: 18px;
  max-height: calc(100vh - 28px);
  overflow: auto;
  padding: clamp(20px, 4vw, 32px);
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.dialog-heading h2 { font-size: 1.9rem; }
.icon-button {
  width: 46px;
  min-height: 46px;
  padding: 0;
  border-radius: 50%;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-size: 1.6rem;
  line-height: 1;
}

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

fieldset {
  margin: 0;
  padding: 16px;
  border: 1px solid #cfe3e3;
  border-radius: 18px;
}
legend { padding: 0 7px; color: var(--teal-dark); font-weight: 850; }
.field-hint { margin: 6px 0 12px; color: var(--muted); line-height: 1.5; }

.check-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}
.check-label,
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 9px 11px;
  border: 1px solid #cfe3e3;
  border-radius: 13px;
  background: #fbfefe;
  font-weight: 700;
}
.check-label input,
.checkbox-label input {
  width: 20px;
  min-height: 20px;
  flex: 0 0 auto;
  accent-color: var(--teal);
}

.post-groups { display: grid; gap: 16px; }
.post-group h3 { font-size: 1rem; }
.post-group .check-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.form-errors {
  padding: 14px 16px;
  border-radius: 16px;
  background: #fdecea;
  color: #8c1d18;
  line-height: 1.55;
}
.form-errors ul { margin: 0; padding-left: 20px; }

.dialog-actions {
  flex-wrap: wrap;
  position: sticky;
  bottom: -32px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 0 -32px -32px;
  padding: 16px 32px;
  border-top: 1px solid #dcebea;
  background: rgba(255, 255, 255, .96);
}

@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel-grid,
  .record-list { grid-template-columns: 1fr; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters label:first-child { grid-column: span 2; }
  .post-group .check-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .auth-shell { padding: 14px; }
  .app-header { align-items: flex-start; }
  .brand { font-size: 1.3rem; }
  .header-actions { flex-direction: column; align-items: flex-end; gap: 7px; }
  .sync-pill { font-size: .78rem; }
  .menu-button { min-width: 82px; min-height: 44px; }
  .section-heading { flex-direction: column; }
  .section-heading > button { width: 100%; }
  .dashboard-grid,
  .filters,
  .filters-compact,
  .form-grid { grid-template-columns: 1fr; }
  .filters label:first-child,
  .span-2 { grid-column: auto; }
  .check-grid,
  .post-group .check-grid { grid-template-columns: 1fr 1fr; }
  .detail-list div { grid-template-columns: 1fr; gap: 1px; }
  .dialog-actions { margin-inline: -20px; padding-inline: 20px; }
  .dialog-actions button { flex: 1; }
  .role-table th,
  .role-table td { padding-inline: 4px; font-size: .92rem; }
}

/* Escala */
.notice-danger { background: #fdecea; border-color: rgba(198, 40, 40, .35); color: #8c1d18; }
.schedule-controls,
.schedule-toolbar {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr auto auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(255, 255, 255, .78);
}
.schedule-toolbar { grid-template-columns: 1fr auto; }
.schedule-shortcuts { display: flex; gap: 7px; }
.schedule-shortcuts button { min-height: 50px; padding-inline: 12px; }
.schedule-summary { margin-bottom: 14px; }
.schedule-alerts { display: grid; gap: 10px; margin-bottom: 14px; }
.schedule-alerts .notice { margin: 0; }
.schedule-days { display: grid; gap: 14px; }
.schedule-day {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 12px 34px rgba(0, 73, 73, .08);
}
.schedule-day-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 12px;
}
.schedule-day-heading h3 { margin: 0; font-size: 1.25rem; text-transform: capitalize; }
.coverage-gap {
  margin: 0 0 12px;
  padding: 12px 14px;
  border: 2px solid var(--red);
  border-radius: 14px;
  background: #fdecea;
  color: #8c1d18;
  font-weight: 800;
  line-height: 1.55;
}
.schedule-table-wrap { overflow-x: auto; }
.schedule-table { width: 100%; min-width: 760px; border-collapse: collapse; }
.schedule-table th,
.schedule-table td { padding: 10px 8px; border-bottom: 1px solid #dcebea; text-align: left; vertical-align: top; }
.schedule-table th { color: var(--muted); font-size: .86rem; text-transform: uppercase; letter-spacing: .04em; }
.schedule-table tr:last-child td { border-bottom: 0; }
.schedule-table .is-off { color: var(--muted); }
.schedule-table .is-absent,
.schedule-table .is-unassigned { background: #fff7e6; }
.assignment-status { font-weight: 850; }
.assignment-status.work { color: #14532d; }
.assignment-status.off,
.assignment-status.closed { color: var(--muted); }
.assignment-status.absent,
.assignment-status.unassigned { color: #8c1d18; }
.assignment-note { display: block; margin-top: 4px; color: #8c1d18; font-size: .9rem; line-height: 1.45; }
.schedule-edit-button { min-height: 42px; padding: 8px 12px; white-space: nowrap; }
.own-schedule-card {
  padding: clamp(20px, 4vw, 32px);
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.own-schedule-list { display: grid; gap: 10px; margin-top: 18px; }
.own-schedule-day {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 14px;
  border: 1px solid #dcebea;
  border-radius: 16px;
  background: #fbfefe;
}
.own-schedule-day h3 { margin: 0 0 5px; text-transform: capitalize; }
.own-schedule-day p { margin: 0; color: var(--muted); line-height: 1.55; }

@media (max-width: 900px) {
  .schedule-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .schedule-shortcuts,
  #schedule-generate { grid-column: span 2; }
  .schedule-shortcuts button { flex: 1; }
}

@media (max-width: 620px) {
  .schedule-controls,
  .schedule-toolbar { grid-template-columns: 1fr; }
  .schedule-shortcuts,
  #schedule-generate { grid-column: auto; }
  .schedule-day { padding: 14px; }
  .schedule-day-heading { flex-direction: column; }
  .schedule-table { min-width: 680px; }
  .own-schedule-day { grid-template-columns: 1fr; }
}

/* Afastamentos, coberturas e calendário */
.subsection-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin: 34px 0 18px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}
.subsection-heading h3 { margin: 0; font-size: 1.65rem; }
.operations-filters { grid-template-columns: 2fr repeat(5, minmax(0, 1fr)); }
.badge.cancelled { background: #fdecea; color: #8c1d18; }
.record-card.is-cancelled { opacity: .72; }
.calendar-kind {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--red);
  font-size: .76rem;
  font-weight: 850;
  letter-spacing: .12em;
  text-transform: uppercase;
}

@media (max-width: 900px) {
  .operations-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .subsection-heading { flex-direction: column; }
  .subsection-heading > button { width: 100%; }
  .operations-filters { grid-template-columns: 1fr; }
}

/* Imagem e compartilhamento da escala */
.schedule-image-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 12px 34px rgba(0, 73, 73, .08);
}
.schedule-image-panel h3 { margin: 0; font-size: 1.35rem; }
.schedule-image-panel .muted { margin: 0; }
.schedule-image-controls {
  display: grid;
  grid-template-columns: minmax(240px, 1.4fr) repeat(4, minmax(150px, 1fr));
  gap: 10px;
  align-items: end;
}
.schedule-image-controls button { min-height: 50px; }
.schedule-image-status {
  min-height: 1.5em;
  margin: 0;
  color: var(--muted);
  font-weight: 750;
  line-height: 1.5;
}
.schedule-image-status.is-error { color: #b3261e; }
.schedule-image-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}
.own-schedule-card .schedule-image-status { margin-top: 10px; }

@media (max-width: 900px) {
  .schedule-image-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .schedule-image-controls label { grid-column: span 2; }
}

@media (max-width: 620px) {
  .schedule-image-controls { grid-template-columns: 1fr; }
  .schedule-image-controls label { grid-column: auto; }
  .schedule-image-actions button { flex: 1 1 100%; }
}

/* Histórico e auditoria */
.history-list { gap: 12px; }
.history-card { padding: 18px; }
.history-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}
.history-summary { margin: 14px 0 0; line-height: 1.6; }
.history-reason {
  margin: 10px 0 0;
  padding: 11px 13px;
  border-radius: 13px;
  background: #fff7e6;
  color: #6b4a00;
  line-height: 1.55;
}
.history-details { margin-top: 14px; }
.history-details summary {
  min-height: 44px;
  padding: 10px 0;
  color: var(--teal-dark);
  font-weight: 850;
  cursor: pointer;
}
.history-details .detail-list { margin-top: 4px; }
.history-load-more {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin-top: 18px;
  text-align: center;
}
.history-load-more .field-hint { max-width: 760px; }

@media (max-width: 620px) {
  .history-card { padding: 16px; }
  .history-badges { justify-content: flex-start; }
  .history-load-more button { width: 100%; }
}

/* Exportação e recuperação administrativa */
.recovery-panel {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}
.recovery-heading { margin-bottom: 0; }
.recovery-panel .notice { margin-bottom: 0; }
.recovery-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.recovery-card {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, .78);
}
.recovery-card h4 { margin: 0; color: var(--teal); font-size: 1.15rem; }
.recovery-card .muted { margin: 0; }
.recovery-status {
  min-height: 1.5em;
  margin: 0;
  color: var(--muted);
  font-weight: 750;
  line-height: 1.55;
}
.recovery-status.is-error { color: #b3261e; }
.recovery-preview,
.recovery-report {
  display: grid;
  gap: 14px;
}
.recovery-summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
.recovery-summary-grid .metric-card { padding: 14px; }
.recovery-summary-grid .metric-card strong { font-size: 1.7rem; }
.recovery-table-wrap { overflow-x: auto; }
.recovery-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}
.recovery-table th,
.recovery-table td {
  padding: 9px 8px;
  border-bottom: 1px solid #dcebea;
  text-align: right;
}
.recovery-table th:first-child,
.recovery-table td:first-child { text-align: left; }
.recovery-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
  line-height: 1.55;
}
.recovery-confirm {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(229, 154, 0, .45);
  border-radius: 18px;
  background: #fff7e6;
}
.recovery-confirm button { justify-self: start; }

@media (max-width: 900px) {
  .recovery-summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .recovery-grid,
  .recovery-summary-grid { grid-template-columns: 1fr; }
  .recovery-card button,
  .recovery-confirm button { width: 100%; }
}
