/* ---------- Componentes base ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; font-weight: 600;
  transition: transform .15s var(--ease), box-shadow .15s var(--ease), background .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary { background: var(--primary); color: var(--primary-contrast); border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 13px; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: 13px; color: var(--text-muted); }
.input {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); outline: none; }
.hint { font-size: 12.5px; color: var(--text-muted); }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; margin-bottom: 14px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.card.interactive:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.card h2 { font-size: 16px; margin-bottom: 14px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--lavender-soft); color: var(--primary); }
.badge.sage { background: var(--sage-soft); color: var(--success); }
.badge.warn { background: color-mix(in srgb, var(--warning) 18%, transparent); color: var(--warning); }

.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 14px; border: 1px solid transparent; }
.alert.error { background: color-mix(in srgb, var(--danger) 12%, transparent); border-color: color-mix(in srgb, var(--danger) 35%, transparent); color: var(--danger); }
.alert.ok { background: var(--sage-soft); border-color: color-mix(in srgb, var(--success) 35%, transparent); color: var(--success); }
.alert.warn { background: color-mix(in srgb, var(--warning) 14%, transparent); border-color: color-mix(in srgb, var(--warning) 35%, transparent); color: var(--warning); }
.alert.info { background: var(--lavender-soft); color: var(--primary); }
.hidden { display: none !important; }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; transition: grid-template-columns .25s var(--ease); }
.app.collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

.sidebar {
  background: linear-gradient(180deg, var(--blue-900), var(--blue-700)); color: #dfe3fa;
  padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; font-weight: 700; font-size: 18px; color: #fff; white-space: nowrap; }
.brand-mark { width: 34px; height: 34px; flex: none; border-radius: 10px; background: #fff; display: grid; place-items: center; padding: 3px; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand-plate { align-self: flex-start; background: #fff; border-radius: 16px; padding: 14px 22px; box-shadow: 0 6px 24px rgba(0,0,0,.18); }
.brand-plate img { display: block; width: min(260px, 60vw); height: auto; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: inherit; text-decoration: none;
  white-space: nowrap; transition: background .15s, transform .15s var(--ease);
}
.nav-link:hover { background: rgba(255, 255, 255, .08); transform: translateX(2px); }
.nav-link.active { background: rgba(255, 255, 255, .15); color: #fff; font-weight: 600; }
.nav-link svg { width: 20px; height: 20px; flex: none; }
.nav-sep { height: 1px; background: rgba(255, 255, 255, .12); margin: 10px 6px; }
.app.collapsed .nav-label, .app.collapsed .brand-text { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 24px;
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; position: relative; transition: transform .15s var(--ease); }
.icon-btn:hover { transform: translateY(-1px); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .dot { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 99px; background: var(--danger); color: #fff; font-size: 11px; display: grid; place-items: center; }
.search { flex: 1; max-width: 460px; position: relative; }
.search-results { position: absolute; top: 44px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); overflow: hidden; }
.search-results a { display: block; padding: 10px 14px; text-decoration: none; color: var(--text); }
.search-results a:hover, .search-results a:focus { background: var(--surface-2); }
.spacer { flex: 1; }

.menu { position: absolute; right: 0; top: 46px; min-width: 210px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 6px; transform-origin: top right; animation: pop .16s var(--ease); z-index: 30; }
.menu button { display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; background: none; border-radius: 8px; cursor: pointer; }
.menu button:hover { background: var(--surface-2); }
.menu .who { padding: 8px 12px; font-size: 13px; color: var(--text-muted); border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu-wrap { position: relative; }

.content { padding: 28px; max-width: 1280px; width: 100%; margin: 0 auto; }
.page-enter { animation: pageIn .32s var(--ease); }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; }
.page-head p { margin: 4px 0 0; color: var(--text-muted); }

/* ---------- Dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi .label { font-size: 13px; color: var(--text-muted); }
.kpi .value { font-size: 32px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; }
.kpi .sub { font-size: 12.5px; color: var(--text-muted); }
.kpi.accent { border-top: 3px solid var(--accent); }
.kpi.sage { border-top: 3px solid var(--sage); }
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.list .meta { font-size: 12.5px; color: var(--text-muted); }
.empty { text-align: center; padding: 28px 12px; color: var(--text-muted); }
.empty h3 { color: var(--text); margin-bottom: 6px; }

.chart { width: 100%; height: 190px; display: block; }
.chart .bar { fill: var(--accent); transform-box: fill-box; transform-origin: bottom; animation: grow .7s var(--ease) both; }
.chart .bar.done { fill: var(--sage); }
.chart text { fill: var(--text-muted); font-size: 10px; }
.chart .grid { stroke: var(--border); stroke-dasharray: 3 4; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; background: var(--accent); }
.legend i.done { background: var(--sage); }

.skeleton { border-radius: 10px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.3s infinite; min-height: 20px; }
.skeleton.kpi-sk { height: 104px; }
.skeleton.block { height: 240px; }

/* ---------- Modais / toasts ---------- */
.overlay { position: fixed; inset: 0; background: rgba(4, 16, 40, .55); display: grid; place-items: center; z-index: 100; animation: fade .18s; padding: 16px; }
.modal { background: var(--surface); border-radius: var(--radius); width: min(520px, 100%); max-height: 90vh; overflow: auto; padding: 24px; box-shadow: var(--shadow-lg); animation: pop .22s var(--ease); }
.modal h2 { margin-bottom: 12px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.leaving { opacity: 0; transition: opacity .15s; }
.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 10px; z-index: 200; }
.toast { background: var(--blue-900); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); animation: toastIn .3s var(--ease); max-width: 340px; border-left: 4px solid var(--lavender); }
.toast.error { border-color: var(--danger); }
.toast.success { border-color: var(--sage); }

/* ---------- Segurança / tabelas ---------- */
.stack { display: grid; gap: 16px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); }
.tbl th { color: var(--text-muted); font-weight: 600; font-size: 12.5px; }
.table-wrap { overflow-x: auto; }
code.secret { display: block; padding: 10px; background: var(--surface-2); border-radius: 8px; word-break: break-all; font-size: 14px; letter-spacing: .08em; user-select: all; }

/* ---------- Login ---------- */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { background: linear-gradient(150deg, var(--blue-900), var(--blue-500) 70%, var(--lavender)); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-hero::after { content: ""; position: absolute; width: 420px; height: 420px; right: -120px; bottom: -120px; border-radius: 50%; background: radial-gradient(circle, rgba(143, 181, 146, .55), transparent 70%); }
.auth-hero h1 { font-size: 38px; max-width: 14ch; }
.auth-hero p { max-width: 42ch; opacity: .85; }
.auth-panel { display: grid; place-items: center; padding: 32px; }
.auth-card { width: min(420px, 100%); animation: pageIn .4s var(--ease); }
.auth-card h2 { font-size: 24px; margin-bottom: 6px; }
.auth-card .sub { color: var(--text-muted); margin-bottom: 20px; }
.links { display: flex; justify-content: space-between; margin-top: 14px; font-size: 14px; }
.links button { background: none; border: 0; color: var(--primary); cursor: pointer; padding: 0; text-decoration: underline; }

/* ---------- Animações ---------- */
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes toastIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ---------- Responsivo ---------- */
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
}
@media (max-width: 760px) {
  .app, .app.collapsed { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 50; width: 270px; transform: translateX(-100%); transition: transform .25s var(--ease); }
  .app.nav-open .sidebar { transform: none; }
  .app.collapsed .nav-label, .app.collapsed .brand-text { display: inline; }
  .content { padding: 18px 14px; }
  .topbar { padding: 10px 14px; }
}

/* Fase 2: pacientes e agenda */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .input { width: auto; min-width: 200px; flex: 1 1 240px; max-width: 420px; }
.toolbar select.input { flex: 0 0 auto; min-width: 140px; }
.week-label { margin-left: 6px; }
.pager { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.pager .meta, .meta { font-size: 12.5px; color: var(--text-muted); }
.row-actions { text-align: right; white-space: nowrap; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.form-grid .full, .form-grid .alert { grid-column: 1 / -1; }
.form-grid .actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.modal.wide { width: min(680px, 100%); }
.modal .actions.wrap { flex-wrap: wrap; justify-content: flex-start; }
.agenda { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.agenda .day h2 { text-transform: capitalize; font-size: 14px; }
.agenda .day.today { border-color: var(--primary); }
.appt { padding: 0; }
.appt-btn { all: unset; box-sizing: border-box; flex: 1; cursor: pointer; padding: 10px 12px; border-radius: 10px; }
.appt-btn:focus-visible { outline: 2px solid var(--primary); }
.appt.muted .appt-btn { opacity: .6; }
.appt .badge { margin-right: 10px; }
.check-field .check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; color: var(--text); }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

/* Fase 2B: processo clínico */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tab { all: unset; box-sizing: border-box; cursor: pointer; padding: 10px 14px; font-weight: 600; font-size: 14px; color: var(--text-muted); border-bottom: 2px solid transparent; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.clinical-text { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); border-radius: 10px; padding: 14px; margin: 12px 0; max-height: 50vh; overflow: auto; line-height: 1.55; }
.modal h3 { font-size: 13px; color: var(--text-muted); margin: 12px 0 4px; }
.modal select.input { margin-bottom: 10px; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--border); display: grid; gap: 14px; }
.timeline li { display: grid; grid-template-columns: 130px 1fr; gap: 12px; position: relative; }
.timeline li::before { content: ''; position: absolute; left: -21px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.timeline .tl-appointment::before { background: var(--success); }
.timeline .tl-plan::before { background: var(--warning); }
.timeline .tl-patient_created::before { background: var(--text-muted); }
.tl-date { font-size: 12.5px; color: var(--text-muted); }
@media (max-width: 560px) { .timeline li { grid-template-columns: 1fr; gap: 2px; } }

/* Fase 3A: finanças */
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: var(--surface-2); }
.list li.muted { opacity: .6; }

/* Fase 3B: documentos */
.tbl tr.muted td { opacity: .55; }

/* Fase 3C: formulários */
.qrow { border: 1px solid var(--border, #ddd); border-radius: 10px; padding: 10px; margin-bottom: 10px; display: grid; gap: 8px; }
.qmain { display: grid; grid-template-columns: 1fr 160px auto; gap: 8px; align-items: center; }
.qextra { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.qctl { display: flex; gap: 6px; justify-content: flex-end; }
.scale-row { display: flex; gap: 6px; flex-wrap: wrap; }
.multi { display: grid; gap: 4px; }
dl.kv { display: grid; grid-template-columns: 1fr 2fr; gap: 6px 14px; margin: 12px 0; }
dl.kv dt { font-weight: 600; color: var(--muted, #667); } dl.kv dd { margin: 0; white-space: pre-wrap; }
@media (max-width: 600px) { .qmain { grid-template-columns: 1fr; } dl.kv { grid-template-columns: 1fr; } }

/* Fase 3E: relatórios (reutiliza .kpis/.kpi do painel) */
.grid-eq { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 16px; }
.rp-card { margin-bottom: 16px; }

/* Fase 4A: avaliações */
.as-item { border: 1px solid var(--border, #ddd); border-radius: 10px; padding: 10px 12px; margin: 0 0 10px; }
.as-item legend { font-weight: 600; padding: 0 6px; }
.as-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px; }
.as-opt { display: flex; gap: 6px; align-items: center; padding: 6px 8px; border-radius: 8px; background: var(--surface-2); cursor: pointer; }
.as-score { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.as-total { font-size: 2rem; font-weight: 700; }
.as-apply { display: flex; gap: 8px; flex-wrap: wrap; }

/* Fase 4B: recursos */
.res-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.res-card { text-align: left; cursor: pointer; display: grid; gap: 6px; align-content: start; font: inherit; color: inherit; }
.res-card:hover { transform: translateY(-2px); }
.res-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.res-text { white-space: pre-wrap; background: var(--surface-2); border-radius: 10px; padding: 12px 14px; margin: 10px 0; max-height: 50vh; overflow: auto; }

/* Fase 4C: tarefas */
.task { align-items: flex-start; gap: 12px; }
.task input[type=checkbox] { width: 20px; height: 20px; margin-top: 3px; flex: none; }
.task-main { flex: 1; min-width: 0; display: grid; gap: 4px; }
.task-badges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.task-done .task-main strong { text-decoration: line-through; opacity: .6; }

/* Fase 5: portal do paciente */
.res-text { white-space: pre-wrap; line-height: 1.6; margin: 12px 0; }

/* Fase 8: páginas legais */
.legal-body { background: var(--bg, #f6f7fb); }
.legal { max-width: 760px; margin: 0 auto; padding: 32px 20px 64px; line-height: 1.65; }
.legal h1 { margin: 16px 0 4px; }
.legal h2 { font-size: 17px; margin: 24px 0 6px; }
.legal ul { padding-left: 20px; }
.legal-back { display: inline-block; margin-bottom: 12px; }

/* =====================================================================
   Fase 9: camada visual "Papel e Fita" (formal + criativa, com movimento)
   ===================================================================== */

/* Títulos editoriais */
.page-head h1 { font-size: 32px; font-weight: 600; }
.page-head h1::after { content: ""; display: block; width: 44px; height: 3px; margin-top: 10px; border-radius: 3px; background: var(--ribbon); transform-origin: left; animation: ribbonIn .7s var(--ease) both .15s; }
.page-head p { font-size: 15px; }
.card h2 { font-size: 15px; font-weight: 650; letter-spacing: -.005em; }

/* Botões */
.btn { border-color: var(--border-strong); box-shadow: var(--shadow-sm); transition: transform .18s var(--ease), box-shadow .18s var(--ease), background .18s, border-color .18s, filter .18s; }
.btn:hover { border-color: var(--accent); }
.btn-primary { background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 88%, #fff), var(--primary)); border: 0; box-shadow: var(--glow); }
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 14px 32px -8px color-mix(in srgb, var(--primary) 70%, transparent); }
.btn-ghost { box-shadow: none; }
.btn-danger:hover { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, transparent); }

/* Campos */
.input { border-color: var(--border-strong); background: var(--surface); }
.input:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--border-strong)); }
.field label { letter-spacing: .01em; }

/* Cartões: linha fina, relevo suave, entrada em cascata */
.card { border-color: var(--border); box-shadow: var(--shadow); }
.card.interactive:hover, .res-card:hover { box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.stagger > * { animation: rise .5s var(--ease) both; }
.stagger > *:nth-child(1) { animation-delay: .02s; } .stagger > *:nth-child(2) { animation-delay: .06s; }
.stagger > *:nth-child(3) { animation-delay: .10s; } .stagger > *:nth-child(4) { animation-delay: .14s; }
.stagger > *:nth-child(5) { animation-delay: .18s; } .stagger > *:nth-child(6) { animation-delay: .22s; }
.stagger > *:nth-child(7) { animation-delay: .26s; } .stagger > *:nth-child(n+8) { animation-delay: .30s; }
.kpis, .res-grid, .agenda, .grid-eq, .cols, .stack { --_s: 1; }
.kpis > *, .res-grid > *, .agenda > *, .grid-eq > *, .cols > *, .stack > * { animation: rise .5s var(--ease) both; }
.kpis > *:nth-child(2), .res-grid > *:nth-child(2), .agenda > *:nth-child(2), .grid-eq > *:nth-child(2), .cols > *:nth-child(2), .stack > *:nth-child(2) { animation-delay: .05s; }
.kpis > *:nth-child(3), .res-grid > *:nth-child(3), .agenda > *:nth-child(3), .grid-eq > *:nth-child(3), .cols > *:nth-child(3), .stack > *:nth-child(3) { animation-delay: .10s; }
.kpis > *:nth-child(4), .res-grid > *:nth-child(4), .agenda > *:nth-child(4), .grid-eq > *:nth-child(4), .stack > *:nth-child(4) { animation-delay: .15s; }
.kpis > *:nth-child(5), .res-grid > *:nth-child(5), .agenda > *:nth-child(5), .stack > *:nth-child(5) { animation-delay: .20s; }
.kpis > *:nth-child(n+6), .res-grid > *:nth-child(n+6), .agenda > *:nth-child(n+6), .stack > *:nth-child(n+6) { animation-delay: .25s; }

/* KPIs com número em serifa e fita no topo */
.kpi { position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--ribbon); opacity: .0; transition: opacity .25s; }
.kpi:hover::before { opacity: 1; }
.kpi.accent, .kpi.sage { border-top-width: 1px; }
.kpi.accent::before, .kpi.sage::before { opacity: 1; }
.kpi.accent::before { background: var(--accent); } .kpi.sage::before { background: var(--sage); }
.kpi .label { font-size: 12.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.kpi .value { font-family: var(--font-display); font-weight: 600; font-size: 38px; line-height: 1.1; font-variant-numeric: tabular-nums; }

/* Distintivos */
.badge { letter-spacing: .01em; border: 1px solid color-mix(in srgb, currentColor 18%, transparent); }

/* Listas e tabelas */
.list li { background: var(--surface-2); border: 1px solid transparent; transition: transform .18s var(--ease), border-color .18s, background .18s; }
.list li:hover { transform: translateX(3px); border-color: var(--border-strong); }
.tbl th { text-transform: uppercase; letter-spacing: .06em; font-size: 11.5px; padding-bottom: 10px; border-bottom: 1px solid var(--border-strong); }
.tbl tbody tr { transition: background .15s; }
.tbl tbody tr:hover td { background: color-mix(in srgb, var(--lavender-soft) 55%, transparent); }
.tbl td { padding: 12px 8px; }
.tbl tbody tr { animation: rowIn .4s var(--ease) both; }
.tbl tbody tr:nth-child(2) { animation-delay: .03s; } .tbl tbody tr:nth-child(3) { animation-delay: .06s; }
.tbl tbody tr:nth-child(4) { animation-delay: .09s; } .tbl tbody tr:nth-child(5) { animation-delay: .12s; }
.tbl tbody tr:nth-child(n+6) { animation-delay: .15s; }

/* Barra lateral: mais profundidade e indicador animado */
.sidebar { background:
  radial-gradient(120% 60% at 0% 0%, rgba(154, 152, 214, .22), transparent 60%),
  radial-gradient(100% 50% at 100% 100%, rgba(143, 181, 146, .18), transparent 60%),
  linear-gradient(180deg, var(--blue-900), var(--blue-700)); border-right: 1px solid rgba(255, 255, 255, .06); }
.brand { font-family: var(--font-display); font-weight: 600; letter-spacing: -.01em; font-size: 20px; }
.nav-link { position: relative; font-size: 14.5px; color: #cfd5f3; transition: background .18s, transform .18s var(--ease), color .18s; }
.nav-link svg { transition: transform .25s var(--spring); opacity: .85; }
.nav-link:hover { color: #fff; }
.nav-link:hover svg { transform: scale(1.12) rotate(-4deg); opacity: 1; }
.nav-link.active { background: linear-gradient(90deg, rgba(255, 255, 255, .18), rgba(255, 255, 255, .06)); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08); }
.nav-link.active::before { content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0; background: var(--ribbon); background-size: 100% 300%; animation: ribbonY 1.6s var(--ease) both; }
.nav-link.active svg { opacity: 1; color: #fff; }

/* Barra superior */
.topbar { background: color-mix(in srgb, var(--bg) 78%, transparent); backdrop-filter: blur(14px) saturate(1.4); border-bottom-color: color-mix(in srgb, var(--border) 80%, transparent); }
.icon-btn { border-color: var(--border-strong); box-shadow: var(--shadow-sm); transition: transform .18s var(--ease), border-color .18s, box-shadow .18s; }
.icon-btn:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.icon-btn:active { transform: scale(.94); }
.menu { animation: pop .2s var(--ease); }

/* Alertas com barra lateral */
.alert { border-left-width: 3px; }

/* Modais com desfoque e mola */
.overlay { backdrop-filter: blur(6px); background: rgba(4, 16, 40, .5); }
.modal { border: 1px solid var(--border); animation: popSpring .38s var(--spring); }
.modal h2 { font-family: var(--font-display); font-weight: 600; font-size: 22px; }

/* Toasts */
.toast { font-weight: 500; backdrop-filter: blur(8px); animation: toastIn .45s var(--spring); }
.toast.leaving { transform: translateX(24px); transition: opacity .18s, transform .18s; }

/* Tabs com indicador */
.tab { position: relative; transition: color .18s; }
.tab::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--ribbon); transform: scaleX(0); transform-origin: left; transition: transform .3s var(--ease); }
.tab.active { border-bottom-color: transparent; }
.tab.active::after, .tab:hover::after { transform: scaleX(1); }

/* Linha do tempo */
.timeline li::before { box-shadow: 0 0 0 4px var(--bg); }
.timeline li { animation: rowIn .45s var(--ease) both; }

/* Agenda */
.agenda .day.today { box-shadow: 0 0 0 1px var(--primary), var(--shadow); }
.agenda .day h2 { font-family: var(--font-display); font-size: 16px; font-weight: 600; }
.appt-btn { transition: background .15s; }
.appt-btn:hover { background: color-mix(in srgb, var(--lavender-soft) 60%, transparent); }

/* Gráfico: barras com cantos e brilho */
.chart .bar { fill: color-mix(in srgb, var(--accent) 70%, transparent); }
.chart .bar.done { fill: var(--sage); }

/* Esqueleto mais suave */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, color-mix(in srgb, var(--border) 70%, var(--surface)) 37%, var(--surface-2) 63%); background-size: 400% 100%; }

/* Login: hero com fitas animadas */
.auth-hero { isolation: isolate; background:
  radial-gradient(60% 50% at 80% 90%, rgba(143, 181, 146, .45), transparent 70%),
  radial-gradient(50% 45% at 15% 15%, rgba(154, 152, 214, .35), transparent 70%),
  linear-gradient(150deg, var(--blue-900), var(--blue-700) 60%, var(--blue-500)); }
.auth-hero::after { display: none; }
.auth-hero h1 { font-family: var(--font-display); font-weight: 500; font-size: 46px; line-height: 1.08; max-width: 12ch; letter-spacing: -.03em; animation: rise .8s var(--ease) both .1s; }
.auth-hero p { animation: rise .8s var(--ease) both .25s; }
.auth-hero .brand-plate { animation: rise .7s var(--ease) both; }
.ribbons { position: absolute; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.ribbons i { position: absolute; left: -10%; width: 130%; height: 140px; border-radius: 999px; filter: blur(.2px); opacity: .5; transform: rotate(-14deg); animation: drift 14s ease-in-out infinite alternate; }
.ribbons i:nth-child(1) { top: 52%; background: linear-gradient(90deg, transparent, rgba(154, 152, 214, .55), transparent); }
.ribbons i:nth-child(2) { top: 64%; height: 90px; background: linear-gradient(90deg, transparent, rgba(143, 181, 146, .55), transparent); animation-duration: 18s; animation-delay: -4s; }
.ribbons i:nth-child(3) { top: 76%; height: 60px; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .22), transparent); animation-duration: 22s; animation-delay: -9s; }
.auth-panel { background: radial-gradient(70% 50% at 50% 0%, color-mix(in srgb, var(--lavender-soft) 70%, transparent), transparent 70%), var(--bg); }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 36px 32px; box-shadow: var(--shadow); }
.auth-card h2 { font-family: var(--font-display); font-weight: 600; font-size: 28px; }

/* Páginas legais */
.legal h1 { font-size: 36px; } .legal h2 { font-family: var(--font-display); font-weight: 600; }

/* Animações novas */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes rowIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
@keyframes ribbonIn { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes ribbonY { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes popSpring { from { opacity: 0; transform: scale(.92) translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes drift { from { transform: rotate(-14deg) translateX(-4%); } to { transform: rotate(-10deg) translateX(4%); } }
@keyframes pageIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Mudança de tema suave */
.theme-fade, .theme-fade *, .theme-fade *::before, .theme-fade *::after { transition: background-color .35s, color .35s, border-color .35s, box-shadow .35s !important; }
.kpi { display: flex; flex-direction: column; }
.kpi .label { min-height: 2.6em; display: flex; align-items: flex-start; line-height: 1.3; }
.kpi .value { margin-top: auto; }
.btn, a.btn { text-decoration: none; }
.agenda .day h2 { text-transform: none; }
.agenda .day h2::first-letter { text-transform: uppercase; }
.appt { position: relative; padding-left: 4px; }
.appt::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--accent); }
.appt-btn { display: block; padding-left: 14px; }
.appt-btn strong { display: block; white-space: nowrap; font-variant-numeric: tabular-nums; font-size: 13px; color: var(--text-muted); letter-spacing: .02em; margin-bottom: 1px; }
.appt-btn { font-weight: 600; }
.appt-btn .meta { font-weight: 400; }
.appt .badge { flex: none; margin-right: 4px; }
.kpi .value { margin-top: 2px; font-size: clamp(26px, 2.4vw, 36px); white-space: nowrap; }
.appt { flex-wrap: wrap; align-items: flex-start; }
.appt-btn { flex: 1 1 100%; padding-bottom: 4px; }
.appt .badge { margin: 0 0 10px 14px; }

/* Registo: plano escolhido no site */
.plan-chip { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; margin-bottom: 16px; border-radius: 12px; background: var(--lavender-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); font-size: 14px; animation: rise .4s var(--ease) both; }
.plan-chip-k { font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); font-weight: 600; }
