/* ============================================================================
   SENTINELA — Design System
   Easy Networks

   Paleta e tipografia conforme docs/gemini.md §2 e §6.
   Implementa o padrão de tela de listagem da especificação:
   cabeçalho com ação primária · linha de KPIs · tabela · modal.
   ============================================================================ */

:root {
  /* Paleta oficial (docs/gemini.md §2) */
  --bg:            #FDFBF7;
  --surface:       #FFFFFF;
  --surface-alt:   #F5F2EC;
  --ink:           #191970;
  --ink-soft:      #4A4A7A;
  --ink-mute:      #8A86A0;
  --accent:        #4021DA;
  --accent-hover:  #3417B8;
  --accent-soft:   rgba(64, 33, 218, .07);
  --gold:          #C9A455;

  --rule:          #E8E4DB;
  --rule-strong:   #D4CFC4;

  --sidebar:       #0F0F2E;
  --sidebar-hover: rgba(255, 255, 255, .05);

  /* Semânticas — independentes do acento */
  --ok:       #16A34A;  --ok-bg:   rgba(22, 163, 74, .10);
  --warn:     #B8900A;  --warn-bg: rgba(184, 144, 10, .12);
  --crit:     #DC2626;  --crit-bg: rgba(220, 38, 38, .09);
  --info:     #2563EB;  --info-bg: rgba(37, 99, 235, .09);

  --shadow-sm: 0 1px 2px rgba(25, 25, 112, .05);
  --shadow:    0 1px 3px rgba(25, 25, 112, .06), 0 8px 24px rgba(25, 25, 112, .07);
  --shadow-lg: 0 20px 50px rgba(15, 15, 46, .22);

  --font:      'Plus Jakarta Sans', 'Poppins', system-ui, sans-serif;
  --font-body: 'Poppins', system-ui, sans-serif;

  /* Bézier cúbico obrigatório (docs/gemini.md §6) */
  --ease:  cubic-bezier(0.32, 0.72, 0, 1);
  --t-fast: 180ms var(--ease);
  --t-mid:  280ms var(--ease);

  --sidebar-w: 236px;
  --topbar-h:  60px;
  --radius:    10px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.55;
  color: var(--ink-soft);
  background: var(--bg);
  display: flex;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font); color: var(--ink); font-weight: 700; }

/* Só revela a interface depois do guard de autenticação */
body { opacity: 0; transition: opacity var(--t-mid); }
body.auth-checked { opacity: 1; }

::selection { background: var(--accent-soft); color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ============================================================================
   SIDEBAR — 7 grupos da especificação
   ============================================================================ */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100dvh;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 40;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.14) transparent;
}
#sidebar::-webkit-scrollbar { width: 6px; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 3px; }

/* O logo já traz o nome da empresa; nada de texto ao lado repetindo-o. */
.sb-brand {
  padding: 20px 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sb-brand img {
  max-width: 100%;
  height: 40px;
  width: auto;
  object-fit: contain;
}

.sb-nav { flex: 1; padding: 8px 0 16px; }

.sb-group + .sb-group { margin-top: 2px; }

.sb-group-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 18px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .5);
  transition: color var(--t-fast);
  text-align: left;
}
.sb-group-head:hover { color: rgba(255, 255, 255, .85); }
.sb-group-head.is-open { color: rgba(255, 255, 255, .92); }
.sb-group-head svg { flex-shrink: 0; opacity: .75; }

.sb-chevron {
  margin-left: auto;
  transition: transform var(--t-fast);
  opacity: .5;
}
.sb-group-head.is-open .sb-chevron { transform: rotate(180deg); }

.sb-items {
  overflow: hidden;
  max-height: 0;
  transition: max-height var(--t-mid);
}
.sb-items.is-open { max-height: 520px; }

.sb-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px 8px 25px;
  background: none;
  border: none;
  border-left: 2px solid transparent;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 12.5px;
  color: rgba(255, 255, 255, .58);
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
  text-align: left;
}
.sb-item:hover { background: var(--sidebar-hover); color: rgba(255, 255, 255, .9); }
.sb-item.is-active {
  background: rgba(64, 33, 218, .3);
  border-left-color: var(--gold);
  color: #fff;
  font-weight: 500;
}
.sb-item svg { flex-shrink: 0; opacity: .65; }
.sb-item.is-active svg { opacity: 1; }

.sb-foot {
  margin-top: auto;
  padding: 11px 14px;
  border-top: 1px solid rgba(255, 255, 255, .07);
  background: rgba(0, 0, 0, .18);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.sb-avatar {
  width: 33px; height: 33px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sb-user { flex: 1; min-width: 0; }
.sb-user-name {
  font-size: 12.5px; font-weight: 600; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sb-user-mail {
  font-size: 10px; color: rgba(255, 255, 255, .4);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sb-logout {
  background: none; border: none; cursor: pointer;
  color: rgba(255, 255, 255, .4);
  padding: 5px; border-radius: 6px;
  display: flex; transition: color var(--t-fast), background var(--t-fast);
}
.sb-logout:hover { color: #F87171; background: rgba(248, 113, 113, .12); }

/* ============================================================================
   ÁREA PRINCIPAL
   ============================================================================ */
#main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

#topbar {
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  flex-shrink: 0;
}
.tb-title { font-size: 16px; font-weight: 700; line-height: 1.2; }
.tb-crumb { font-size: 11.5px; color: var(--ink-mute); }

.hamburger {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none; border: none; cursor: pointer;
  padding: 6px;
}
.hamburger span {
  width: 18px; height: 2px; border-radius: 1px;
  background: var(--ink);
  transition: transform var(--t-fast), opacity var(--t-fast);
}

#content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 22px 24px 40px;
}

.screen { display: none; }
.screen.is-active { display: block; animation: screen-in 300ms var(--ease); }

@keyframes screen-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ============================================================================
   PADRÃO DE TELA — cabeçalho com ação primária
   ============================================================================ */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.page-head-txt { min-width: 0; }
.page-head h2 { font-size: 19px; font-weight: 800; letter-spacing: -.2px; }
.page-head p { font-size: 12.5px; color: var(--ink-mute); margin-top: 2px; }

/* ============================================================================
   BOTÕES
   ============================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 15px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast),
              border-color var(--t-fast), transform var(--t-fast),
              box-shadow var(--t-fast);
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { flex-shrink: 0; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(64, 33, 218, .22);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 4px 14px rgba(64, 33, 218, .32);
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--rule-strong);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

.btn-ghost { background: transparent; color: var(--ink-mute); }
.btn-ghost:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); }

.btn-danger { background: var(--crit); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #B91C1C; }

.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-icon { padding: 7px; border-radius: 7px; }

/* ============================================================================
   KPIs — 3 a 4 cards, número em destaque
   ============================================================================ */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 13px;
  margin-bottom: 20px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 15px 17px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.kpi.is-ok   { border-top-color: var(--ok); }
.kpi.is-warn { border-top-color: var(--warn); }
.kpi.is-crit { border-top-color: var(--crit); }

.kpi-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 5px;
}
.kpi-value {
  font-family: var(--font);
  font-size: 25px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.kpi.is-ok   .kpi-value { color: var(--ok); }
.kpi.is-warn .kpi-value { color: var(--warn); }
.kpi.is-crit .kpi-value { color: var(--crit); }
.kpi-sub { font-size: 11px; color: var(--ink-mute); margin-top: 3px; }

/* ============================================================================
   FILTROS
   ============================================================================ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 11px 14px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}

.filter-btns { display: flex; gap: 4px; }

.filter-btn {
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all var(--t-fast);
}
.filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.filter-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.search-input {
  flex: 1;
  min-width: 180px;
  max-width: 320px;
  padding: 7px 12px;
  border: 1px solid var(--rule-strong);
  border-radius: 7px;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--ink);
  background: var(--surface);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-input::placeholder { color: var(--ink-mute); }

/* ============================================================================
   TABELA
   ============================================================================ */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}
.filter-bar + .table-wrap { border-radius: 0 0 var(--radius) var(--radius); }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 640px;
}

table.data thead th {
  background: var(--surface-alt);
  font-family: var(--font);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--rule-strong);
  white-space: nowrap;
}
table.data th.num, table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }

table.data tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--rule);
  color: var(--ink-soft);
  vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background var(--t-fast); }
table.data tbody tr:hover { background: var(--accent-soft); }

table.data td.strong { font-weight: 600; color: var(--ink); }

.row-actions { display: flex; gap: 5px; justify-content: flex-end; }

.empty-state {
  padding: 46px 20px;
  text-align: center;
  color: var(--ink-mute);
}
.empty-state-title {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 4px;
}
.empty-state p { font-size: 12.5px; margin-bottom: 14px; }

/* ============================================================================
   BADGES DE STATUS
   ============================================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before {
  content: '';
  width: 5px; height: 5px; border-radius: 50%;
  background: currentColor;
}
.badge-ok      { background: var(--ok-bg);   color: var(--ok); }
.badge-warn    { background: var(--warn-bg); color: var(--warn); }
.badge-crit    { background: var(--crit-bg); color: var(--crit); }
.badge-info    { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: rgba(138,134,160,.12); color: var(--ink-mute); }

/* ============================================================================
   MODAL — abre sobre a tela atual
   ============================================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 46, .55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-mid);
}
.modal-overlay.is-open { opacity: 1; pointer-events: auto; }

.modal {
  background: var(--surface);
  border-radius: 14px;
  width: 100%;
  max-width: 620px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  transform: translateY(10px) scale(.98);
  transition: transform var(--t-mid);
}
.modal-overlay.is-open .modal { transform: none; }
.modal.is-wide { max-width: 840px; }

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}
.modal-head h3 { font-size: 16px; font-weight: 800; }
.modal-head p { font-size: 12px; color: var(--ink-mute); margin-top: 1px; }

.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--ink-mute);
  padding: 5px; border-radius: 6px;
  display: flex; flex-shrink: 0;
  transition: color var(--t-fast), background var(--t-fast);
}
.modal-close:hover { background: var(--surface-alt); color: var(--ink); }

.modal-body { padding: 18px 20px; overflow-y: auto; flex: 1; }

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  padding: 14px 20px;
  border-top: 1px solid var(--rule);
  background: var(--surface-alt);
  flex-shrink: 0;
}

/* ============================================================================
   FORMULÁRIOS — obrigatórios com asterisco e validação antes do submit
   ============================================================================ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.form-grid .col-span-2 { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 5px; }

.field label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.field label .req { color: var(--crit); margin-left: 2px; }

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--ink);
  background: var(--surface);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.field textarea { resize: vertical; min-height: 78px; }

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field input::placeholder, .field textarea::placeholder { color: var(--ink-mute); }

.field.has-error input,
.field.has-error select,
.field.has-error textarea {
  border-color: var(--crit);
  box-shadow: 0 0 0 3px var(--crit-bg);
}

.field-error {
  font-size: 11px;
  color: var(--crit);
  font-weight: 500;
  min-height: 0;
}

.form-section-title {
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--accent);
  padding-bottom: 6px;
  margin: 6px 0 12px;
  border-bottom: 1px solid var(--rule);
  grid-column: 1 / -1;
}

/* ============================================================================
   PAINEL — bloco de conteúdo com cabeçalho
   ============================================================================ */
.painel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 18px;
}

.painel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 13px 16px;
  border-bottom: 1px solid var(--rule);
  background: var(--surface-alt);
}
.painel-head h3 { font-size: 14px; font-weight: 700; }
.painel-head p { font-size: 11.5px; color: var(--ink-mute); margin-top: 1px; }

.painel-corpo { padding: 16px; }

.cols-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}
.cols-2 .painel { margin-bottom: 0; }

.destaque-num { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.destaque-num strong {
  font-family: var(--font);
  font-size: 30px;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.destaque-num span { font-size: 12.5px; color: var(--ink-mute); }

.nota {
  font-size: 12px;
  color: var(--ink-mute);
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--rule);
}

/* ============================================================================
   GRÁFICO DE BARRAS
   ============================================================================ */
.graf { display: flex; flex-direction: column; gap: 13px; }

.graf-legenda { display: flex; gap: 15px; flex-wrap: wrap; }
.graf-leg-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--ink-soft);
}
.graf-leg-item i { width: 9px; height: 9px; border-radius: 2px; }

.graf-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 190px;
  padding-top: 8px;
  overflow-x: auto;
}

.graf-col {
  flex: 1;
  min-width: 46px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
}

.graf-barras {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
}

.graf-barra {
  width: 100%;
  max-width: 20px;
  border-radius: 3px 3px 0 0;
  transition: opacity var(--t-fast);
}
.graf-barra:hover { opacity: .78; }

.graf-rotulo {
  text-align: center;
  font-size: 10.5px;
  color: var(--ink-mute);
  white-space: nowrap;
}
.graf-col.is-destaque .graf-rotulo { color: var(--accent); font-weight: 700; }

/* ============================================================================
   BARRA DE PROGRESSO ROTULADA
   ============================================================================ */
.prog { margin-bottom: 13px; }
.prog:last-child { margin-bottom: 0; }

.prog-topo {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
}
.prog-rotulo {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.prog-valor {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.prog-trilha {
  height: 7px;
  background: var(--surface-alt);
  border-radius: 4px;
  overflow: hidden;
}
.prog-preenchido {
  height: 100%;
  border-radius: 4px;
  transition: width 600ms var(--ease);
}
.prog-pct { font-size: 10.5px; color: var(--ink-mute); margin-top: 3px; }

/* ============================================================================
   EFETUAR PAGAMENTO
   ============================================================================ */
.pag-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 16px;
  align-items: start;
}
.pag-grid .painel { margin-bottom: 0; }

.pag-lista { max-height: 520px; overflow-y: auto; }

.pag-conta {
  width: 100%;
  display: block;
  text-align: left;
  padding: 12px 15px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--rule);
  border-left: 3px solid transparent;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background var(--t-fast), border-color var(--t-fast);
}
.pag-conta:last-child { border-bottom: none; }
.pag-conta:hover { background: var(--accent-soft); }
.pag-conta.is-sel {
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.pag-conta-topo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  margin-bottom: 2px;
}
.pag-conta-desc {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pag-conta-meta { font-size: 11px; color: var(--ink-mute); }
.pag-conta-valor {
  font-family: var(--font);
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.pag-resumo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 13px 15px;
  background: var(--surface-alt);
  border-radius: 9px;
  margin-bottom: 16px;
}
.pag-resumo span {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 2px;
}
.pag-resumo strong {
  font-family: var(--font);
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.pag-acoes {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
}

@media (max-width: 940px) {
  .pag-grid { grid-template-columns: 1fr; }
  .pag-lista { max-height: 320px; }
}

/* ============================================================================
   AGENDA — calendário mensal e lista do dia
   ============================================================================ */
/* O calendário é compacto e de largura previsível; a lista do dia é o lado
   que cresce com o conteúdo e fica com a folga. */
.agenda-grid {
  display: grid;
  grid-template-columns: minmax(280px, 400px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.cal-card, .dia-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.cal-head {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--rule);
}
.cal-titulo {
  font-family: var(--font);
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
  margin-right: auto;
}
.cal-titulo span { color: var(--ink-mute); font-weight: 600; }

/* A grade é limitada e centralizada: esticada na largura do painel, cada dia
   viraria um bloco enorme com o número perdido no meio. */
.cal-semana,
.cal-grade {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  max-width: 360px;
  margin: 0 auto;
  width: 100%;
}

.cal-semana { padding: 10px 8px 4px; }
.cal-semana span {
  text-align: center;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-mute);
}

.cal-grade {
  gap: 1px;
  padding: 2px 8px 14px;
}

/* Altura fixa e modesta — sem aspect-ratio, que amarrava a altura à largura */
.cal-cel {
  min-height: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 2px 0;
  border: none;
  background: none;
  cursor: pointer;
  font-family: var(--font-body);
}
.cal-cel.is-vazia { cursor: default; }

/* O estado vive no número, não na célula inteira: a seleção fica discreta */
.cal-num {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  transition: background var(--t-fast), color var(--t-fast);
}

.cal-cel:not(.is-vazia):hover .cal-num { background: var(--accent-soft); color: var(--accent); }

.cal-cel.is-hoje .cal-num {
  box-shadow: inset 0 0 0 1.5px var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.cal-cel.is-sel .cal-num {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  box-shadow: none;
}

.cal-pontos { display: flex; align-items: center; gap: 2px; height: 4px; }
.cal-pontos i {
  width: 3.5px; height: 3.5px;
  border-radius: 50%;
  background: var(--accent);
}
.cal-pontos em {
  font-size: 8px;
  font-style: normal;
  font-weight: 700;
  color: var(--ink-mute);
}
.cal-cel.is-sel .cal-pontos i { background: var(--accent); }

.dia-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--rule);
  background: var(--surface-alt);
}
.dia-titulo { font-family: var(--font); font-size: 14px; font-weight: 800; color: var(--ink); }
.dia-sub { font-size: 11.5px; color: var(--ink-mute); }

.dia-lista { display: flex; flex-direction: column; max-height: 520px; overflow-y: auto; }

.atend {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto auto;
  gap: 11px;
  align-items: center;
  padding: 11px 14px;
  border-bottom: 1px solid var(--rule);
  transition: background var(--t-fast);
}
.atend:last-child { border-bottom: none; }
.atend:hover { background: var(--accent-soft); }

.atend-hora {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
}
.atend-hora strong {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.atend-hora span { font-size: 10px; color: var(--ink-mute); }

.atend-corpo { min-width: 0; }
.atend-servico {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.atend-meta {
  font-size: 11.5px;
  color: var(--ink-mute);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.atend-lado { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.atend-valor {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ok);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 1080px) {
  .agenda-grid { grid-template-columns: 1fr; }
  .dia-lista { max-height: none; }
}

@media (max-width: 560px) {
  .atend { grid-template-columns: 48px minmax(0, 1fr) auto; }
  .atend .row-actions { grid-column: 2 / -1; justify-content: flex-start; }
}

/* ============================================================================
   ITENS DE SERVIÇO DA OS — seção repetível dentro do modal
   ============================================================================ */
.os-itens-lista { display: flex; flex-direction: column; gap: 9px; }

.os-item {
  display: grid;
  grid-template-columns: minmax(150px, 2.2fr) minmax(110px, 1.3fr)
                         minmax(110px, 1.3fr) 68px 110px 32px;
  gap: 9px;
  align-items: start;
  padding: 11px;
  background: var(--surface-alt);
  border: 1px solid var(--rule);
  border-radius: 9px;
}

.os-item .field label {
  font-size: 9.5px;
  letter-spacing: .04em;
}
.os-item .field input,
.os-item .field select {
  padding: 7px 9px;
  font-size: 12.5px;
}
.os-item .field-error { font-size: 10px; }

.os-item-del {
  align-self: center;
  margin-top: 13px;
  color: var(--ink-mute);
}
.os-item-del:hover { color: var(--crit); background: var(--crit-bg); }

.os-itens-rodape {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 13px;
  padding-top: 13px;
  border-top: 1px solid var(--rule);
}

.os-total {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin-left: auto;
}
.os-total span {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.os-total strong {
  font-family: var(--font);
  font-size: 19px;
  font-weight: 800;
  color: var(--ok);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 760px) {
  .os-item {
    grid-template-columns: 1fr 1fr;
  }
  .os-item-desc { grid-column: 1 / -1; }
  .os-item-del { grid-column: 2; justify-self: end; margin-top: 0; }
}

/* ============================================================================
   DASHBOARD — listas dos painéis
   ============================================================================ */
.dash-lista { display: flex; flex-direction: column; }

.dash-item {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  padding: 10px 15px;
  border-bottom: 1px solid var(--rule);
}
.dash-item:last-child { border-bottom: none; }

.dash-item-data {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
}
.dash-item-data strong {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
}
.dash-item-data span { font-size: 10.5px; color: var(--ink-mute); }

.dash-item-qtd {
  font-family: var(--font);
  font-size: 17px;
  font-weight: 800;
  color: var(--warn);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.dash-item-qtd.is-crit { color: var(--crit); }

.dash-item-corpo { min-width: 0; }
.dash-item-t {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dash-item-d {
  font-size: 11px;
  color: var(--ink-mute);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ============================================================================
   CONFIGURAÇÕES — perfil, segurança e horários
   ============================================================================ */
.perfil-topo {
  display: flex;
  align-items: center;
  gap: 13px;
  padding-bottom: 15px;
  margin-bottom: 15px;
  border-bottom: 1px solid var(--rule);
}
.perfil-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-family: var(--font);
  font-size: 17px;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.perfil-nome { font-family: var(--font); font-size: 16px; font-weight: 700; color: var(--ink); }
.perfil-mail { font-size: 12.5px; color: var(--ink-mute); }

.def-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  font-size: 12.5px;
}
.def-list dt { font-weight: 600; color: var(--ink-soft); }
.def-list dd { color: var(--ink); margin: 0; word-break: break-all; }

.mono {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: .92em;
}

.seg-lista { display: flex; flex-direction: column; gap: 11px; }
.seg-item {
  padding: 11px 13px;
  background: var(--surface-alt);
  border-radius: 8px;
  border-left: 3px solid var(--accent);
}
.seg-item-t { font-size: 12.5px; font-weight: 700; color: var(--ink); }
.seg-item-d { font-size: 12px; color: var(--ink-mute); margin-top: 1px; }

.lista-bullets { margin: 0; padding-left: 18px; font-size: 13px; }
.lista-bullets li { margin-bottom: 6px; }
.lista-bullets li:last-child { margin-bottom: 0; }

.horarios { display: flex; flex-direction: column; gap: 8px; }
.horario-linha {
  display: grid;
  grid-template-columns: 84px 1fr auto 1fr;
  gap: 9px;
  align-items: center;
}
.horario-dia { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.horario-sep { font-size: 11.5px; color: var(--ink-mute); }
.horario-linha input {
  padding: 7px 10px;
  border: 1px solid var(--rule-strong);
  border-radius: 7px;
  font-family: var(--font-body);
  font-size: 12.5px;
  color: var(--ink);
  background: var(--surface);
  width: 100%;
}
.horario-linha input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ============================================================================
   ELEMENTOS DE APOIO
   ============================================================================ */
.tag-chip {
  display: inline-block;
  padding: 2px 7px;
  margin: 0 3px 3px 0;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 600;
}

.link-ext {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color var(--t-fast);
}
.link-ext:hover { border-bottom-color: var(--accent); }

code {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: .9em;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 1px 5px;
  border-radius: 4px;
}

@media (max-width: 560px) {
  .horario-linha { grid-template-columns: 70px 1fr auto 1fr; gap: 6px; }
  .def-list { grid-template-columns: 1fr; gap: 3px 0; }
  .def-list dd { margin-bottom: 8px; }
}

/* ============================================================================
   TOAST
   ============================================================================ */
#toast-host {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 9px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  min-width: 260px;
  max-width: 380px;
  padding: 13px 16px;
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: toast-in 320ms var(--ease);
  pointer-events: auto;
}
.toast.is-ok   { border-left-color: var(--ok); }
.toast.is-crit { border-left-color: var(--crit); }
.toast.is-out  { animation: toast-out 240ms var(--ease) forwards; }

.toast-title { font-family: var(--font); font-size: 13px; font-weight: 700; color: var(--ink); }
.toast-msg   { font-size: 12px; color: var(--ink-mute); margin-top: 1px; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateX(24px); }
}

/* ============================================================================
   ESTADOS DE CARREGAMENTO
   ============================================================================ */
.skeleton {
  background: linear-gradient(90deg, var(--surface-alt) 25%, #EDE9E0 50%, var(--surface-alt) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 5px;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

.wip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 11px;
  min-height: 340px;
  text-align: center;
  color: var(--ink-mute);
}
.wip-icon {
  width: 54px; height: 54px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.wip-title { font-family: var(--font); font-size: 16px; font-weight: 700; color: var(--ink-soft); }
.wip-sub { font-size: 13px; max-width: 340px; }
.wip-tag {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 11px;
  border-radius: 20px;
}

/* ============================================================================
   RESPONSIVO
   ============================================================================ */
.sidebar-scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 46, .5);
  z-index: 39;
  opacity: 0;
  transition: opacity var(--t-mid);
}

@media (max-width: 900px) {
  #sidebar {
    position: fixed;
    top: 0; left: 0;
    transform: translateX(-100%);
    transition: transform var(--t-mid);
    box-shadow: 4px 0 30px rgba(0, 0, 0, .3);
  }
  #sidebar.is-open { transform: none; }

  .sidebar-scrim.is-open { display: block; opacity: 1; }

  .hamburger { display: flex; }

  #content { padding: 18px 15px 34px; }

  .modal { max-height: 92vh; }

  #toast-host { left: 15px; right: 15px; bottom: 15px; }
  .toast { max-width: none; }
}
