/* =========================================================
   PsiSaúde — Design System
   Tokens, layout, componentes
   ========================================================= */

/* Transição suave ao trocar tema */
*, *::before, *::after { transition: background-color .2s ease, border-color .2s ease, color .15s ease; }

/* --- Tokens (modo claro) --- */
:root {
  --brand:     #2B5545;
  --accent:    #3D8B6E;
  --success:   #2E7A52;
  --warn:      #C07E2A;
  --danger:    #C44B4B;
  --purple:    #7B5EA8;
  --bg:        #F5F2EE;
  --surface:   #FFFFFF;
  --surface2:  #EDEBE6;
  --border:    #E0DCD5;
  --text:      #272218;
  --text2:     #7A7068;
  --text3:     #B0A99E;
  --sidebar-w: 228px;
  color-scheme: light;
}

/* --- Modo escuro (sistema) --- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:      #191510;
    --surface: #231C16;
    --surface2:#2C2419;
    --border:  #3D3025;
    --text:    #EBE4DC;
    --text2:   #9A9082;
    --text3:   #5A5248;
    --brand:   #1E4538;
    color-scheme: dark;
  }
}

/* --- Modo escuro (explícito) --- */
:root[data-theme="dark"] {
  --bg:      #191510;
  --surface: #231C16;
  --surface2:#2C2419;
  --border:  #3D3025;
  --text:    #EBE4DC;
  --text2:   #9A9082;
  --text3:   #5A5248;
  --brand:   #1E4538;
  color-scheme: dark;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  overflow: hidden;
  height: 100%;
}

/* ===================== SIDEBAR ===================== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--brand);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform .22s ease;
}
.sb-logo { padding: 20px 18px 16px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sb-logo h1 { font-family: 'Lora', serif; font-size: 18px; font-weight: 600; color: #fff; letter-spacing: -.3px; }
.sb-logo span { font-size: 10.5px; color: rgba(255,255,255,.4); display: block; margin-top: 1px; }
.sb-sec {
  font-size: 9.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1px; color: rgba(255,255,255,.33); padding: 13px 18px 4px;
}
.sb-nav { flex: 1; overflow-y: auto; padding: 5px 0; }
.ni {
  display: flex; align-items: center; gap: 9px; padding: 8px 18px;
  color: rgba(255,255,255,.62); cursor: pointer; font-size: 13px;
  border-left: 3px solid transparent; transition: all .14s; user-select: none;
}
.ni:hover  { background: rgba(255,255,255,.07); color: #fff; }
.ni.active { background: rgba(255,255,255,.11); color: #fff; border-left-color: var(--success); font-weight: 500; }
.ni svg { width: 15px; height: 15px; flex-shrink: 0; }
.ni .badge-new {
  font-size: 9.5px; background: var(--success); color: #fff;
  padding: 1px 6px; border-radius: 8px; margin-left: auto; font-weight: 600;
}
.sb-foot { padding: 10px 14px; border-top: 1px solid rgba(255,255,255,.1); }
.u-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.u-av {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--success), #4A90D9);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: #fff; flex-shrink: 0;
}
.u-name { font-size: 12px; font-weight: 500; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.u-role { font-size: 10.5px; color: rgba(255,255,255,.42); }
.lgpd-badge {
  display: flex; align-items: center; gap: 5px;
  background: rgba(91,185,144,.15); border: 1px solid rgba(91,185,144,.3);
  border-radius: 6px; padding: 5px 8px;
  font-size: 10.5px; color: rgba(255,255,255,.7);
}
.lgpd-badge svg { width: 11px; height: 11px; color: var(--success); flex-shrink: 0; }

/* ===================== TOPBAR ===================== */
.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 52px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0; z-index: 10;
}
.tb-title { font-family: 'Lora', serif; font-size: 15.5px; font-weight: 600; color: var(--text); }
.tb-right { display: flex; align-items: center; gap: 9px; }
.trial-pill {
  background: linear-gradient(135deg, #E8A444, #C87A20);
  color: #fff; padding: 4px 12px; border-radius: 20px;
  font-size: 11px; font-weight: 500; white-space: nowrap;
}
.icon-btn {
  width: 31px; height: 31px; display: flex; align-items: center; justify-content: center;
  background: none; border: 1px solid var(--border); border-radius: 7px;
  cursor: pointer; color: var(--text2); transition: all .12s; position: relative;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.nd {
  position: absolute; top: 5px; right: 5px; width: 6px; height: 6px;
  border-radius: 50%; background: var(--danger); border: 1.5px solid var(--surface);
}
.menu-btn {
  width: 31px; height: 31px; display: none; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer; color: var(--text2); border-radius: 6px;
}
.menu-btn:hover { background: var(--surface2); }
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 190; }

/* ===================== CONTENT ===================== */
.cw { flex: 1; overflow-y: auto; padding: 20px 24px; }
.page { display: none; }
.page.active { display: block; }
.page-login-wrap.active { display: flex; align-items: center; justify-content: center; min-height: 80vh; }

/* ===================== BOTÕES ===================== */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 14px; border-radius: 7px; font-size: 13px; font-weight: 500;
  cursor: pointer; border: none; font-family: 'DM Sans', sans-serif;
  transition: all .13s; text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #3a7fc8; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #4aaa80; }
.btn-purple { background: var(--purple); color: #fff; }
.btn-purple:hover { background: #7a5ec8; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text2); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text2); }
.btn-ghost:hover { background: var(--surface2); }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-xs { padding: 3px 9px; font-size: 11.5px; }

/* ===================== CARDS ===================== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.card-hd {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 13px; font-weight: 600; color: var(--text); }
.card-body { padding: 16px; }

/* Cabeçalho de página */
.ph { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.ph h2 { font-family: 'Lora', serif; font-size: 17px; font-weight: 600; color: var(--text); }
.ph-sub { font-size: 11.5px; color: var(--text3); margin-top: 1px; }

/* ===================== KPIs ===================== */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.kpi-lbl { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text3); }
.kpi-val { font-size: 23px; font-weight: 700; color: var(--text); margin: 5px 0 3px; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-val.sm { font-size: 18px; }
.kpi-d { font-size: 11px; color: var(--success); display: flex; align-items: center; gap: 3px; }
.kpi-d.neu { color: var(--text3); }

/* ===================== LISTA DE AGENDAMENTOS ===================== */
.appt-list { display: flex; flex-direction: column; }
.ai { display: flex; align-items: center; gap: 9px; padding: 8px 9px; border-radius: 7px; cursor: pointer; transition: background .1s; }
.ai:hover { background: var(--surface2); }
.ai-time { font-size: 11px; font-weight: 600; color: var(--text2); width: 38px; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.ai-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.ai-info { flex: 1; min-width: 0; }
.ai-name { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-sub { font-size: 11px; color: var(--text3); }

/* ===================== BADGES ===================== */
.badge { display: inline-flex; align-items: center; font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 500; white-space: nowrap; }
.b-ok   { background: #E5F5EE; color: #287A52; }
.b-warn { background: #FEF4E5; color: #9A6010; }
.b-err  { background: #FDEAEA; color: #A83838; }
.b-info { background: #E8EFF9; color: #2E5FA0; }
.b-pur  { background: #F0EAFF; color: #6B48C8; }
.b-neu  { background: var(--surface2); color: var(--text3); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .b-ok   { background: rgba(91,185,144,.14); color: #7DDBA8; }
  :root:not([data-theme="light"]) .b-warn { background: rgba(232,164,68,.14); color: #E8B870; }
  :root:not([data-theme="light"]) .b-err  { background: rgba(217,106,106,.14); color: #F09090; }
  :root:not([data-theme="light"]) .b-info { background: rgba(74,144,217,.14); color: #7ABCF8; }
  :root:not([data-theme="light"]) .b-pur  { background: rgba(139,110,217,.14); color: #C0A0FF; }
}
:root[data-theme="dark"] .b-ok   { background: rgba(91,185,144,.14); color: #7DDBA8; }
:root[data-theme="dark"] .b-warn { background: rgba(232,164,68,.14); color: #E8B870; }
:root[data-theme="dark"] .b-err  { background: rgba(217,106,106,.14); color: #F09090; }
:root[data-theme="dark"] .b-info { background: rgba(74,144,217,.14); color: #7ABCF8; }
:root[data-theme="dark"] .b-pur  { background: rgba(139,110,217,.14); color: #C0A0FF; }

/* ===================== TABELA ===================== */
.tw { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 520px; }
th {
  text-align: left; font-size: 10.5px; font-weight: 600; color: var(--text3);
  text-transform: uppercase; letter-spacing: .5px; padding: 9px 12px;
  border-bottom: 1px solid var(--border);
}
td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface2); }
.c-av {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: #fff; flex-shrink: 0;
}

/* ===================== INPUTS ===================== */
.inp {
  font-family: 'DM Sans', sans-serif; font-size: 13px;
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 7px;
  background: var(--surface); color: var(--text); outline: none; transition: border-color .13s;
}
.inp:focus { border-color: var(--accent); }
textarea.inp { resize: vertical; min-height: 90px; line-height: 1.5; }

/* ===================== TABS ===================== */
.tab-row { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab {
  padding: 8px 16px; font-size: 13px; font-weight: 500; color: var(--text2);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all .13s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ===================== CALENDÁRIO ===================== */
.cal-grid {
  display: grid; grid-template-columns: 48px repeat(7, 1fr);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
.cdh {
  text-align: center; padding: 8px 3px; font-size: 10px; font-weight: 600; color: var(--text2);
  border-bottom: 1px solid var(--border); background: var(--surface2);
  text-transform: uppercase; letter-spacing: .4px;
}
.cdn { font-size: 14px; font-weight: 700; color: var(--text); display: block; margin-top: 2px; }
.cdh.today .cdn {
  background: var(--accent); color: #fff; width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 12px; margin: 2px auto 1px;
}
.cdh.today { color: var(--accent); }
.ctc { border-right: 1px solid var(--border); }
.ctl {
  height: 52px; display: flex; align-items: flex-start; justify-content: center; padding-top: 4px;
  font-size: 10px; color: var(--text3); border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums;
}
.cc {
  height: 52px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  position: relative; cursor: pointer; transition: background .1s;
}
.cc:hover { background: var(--surface2); }
.cc.t { background: rgba(74,144,217,.04); }
.cev { position: absolute; inset: 3px; border-radius: 5px; padding: 3px 6px; font-size: 10px; font-weight: 500; overflow: hidden; cursor: grab; line-height: 1.3; transition: opacity .15s; }
.cev:active { cursor: grabbing; }
.cev.dragging { opacity: .3; pointer-events: none; }
.cc.drag-over { background: rgba(74,144,217,.14) !important; outline: 2px dashed var(--accent); outline-offset: -2px; }

/* POPOVER DE EVENTO */
.evt-pop {
  position: fixed; z-index: 1500; width: 252px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.24); overflow: hidden;
  animation: toastIn .18s ease forwards;
}
.evt-pop-hd {
  padding: 13px 14px 10px; border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
}
.evt-pop-name { font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.25; }
.evt-pop-sub  { font-size: 11.5px; color: var(--text2); margin-top: 3px; }
.evt-pop-rows { padding: 10px 14px; display: flex; flex-direction: column; gap: 7px; }
.evt-pop-row  { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--text2); }
.evt-pop-row span:first-child { font-size: 14px; flex-shrink: 0; width: 18px; text-align: center; }
.evt-pop-ft   { padding: 9px 14px 13px; border-top: 1px solid var(--border); display: flex; gap: 6px; }
.evt-pop-ft .btn { font-size: 11.5px; padding: 5px 10px; }
.cev-g { background: #D8F0E6; color: #1E6E42; }
.cev-b { background: #DAE8F8; color: #1F4E85; }
.cev-o { background: #FDE8C8; color: #8A5010; }
.cev-v { background: #EDE0FF; color: #5A30A0; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cev-g { background: rgba(91,185,144,.18); color: #7DDBA8; }
  :root:not([data-theme="light"]) .cev-b { background: rgba(74,144,217,.18); color: #8ABDF8; }
  :root:not([data-theme="light"]) .cev-o { background: rgba(232,164,68,.18); color: #F0B868; }
  :root:not([data-theme="light"]) .cev-v { background: rgba(139,110,217,.18); color: #C0A0FF; }
}
:root[data-theme="dark"] .cev-g { background: rgba(91,185,144,.18); color: #7DDBA8; }
:root[data-theme="dark"] .cev-b { background: rgba(74,144,217,.18); color: #8ABDF8; }
:root[data-theme="dark"] .cev-o { background: rgba(232,164,68,.18); color: #F0B868; }
:root[data-theme="dark"] .cev-v { background: rgba(139,110,217,.18); color: #C0A0FF; }

/* ===================== FINANCEIRO ===================== */
.fin-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 12px; margin-bottom: 18px; }
.fin-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; display: flex; align-items: center; gap: 12px; }
.fi { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.fi-g { background: #E5F5EE; color: #287A52; }
.fi-r { background: #FDEAEA; color: #A83838; }
.fi-b { background: #E8EFF9; color: #2E5FA0; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .fi-g { background: rgba(91,185,144,.15); }
  :root:not([data-theme="light"]) .fi-r { background: rgba(217,106,106,.15); }
  :root:not([data-theme="light"]) .fi-b { background: rgba(74,144,217,.15); }
}
:root[data-theme="dark"] .fi-g { background: rgba(91,185,144,.15); }
:root[data-theme="dark"] .fi-r { background: rgba(217,106,106,.15); }
:root[data-theme="dark"] .fi-b { background: rgba(74,144,217,.15); }
.fin-amt { font-size: 18px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.1; }
.fin-amt.pos { color: #287A52; }
.fin-amt.neg { color: #A83838; }
.fin-lbl { font-size: 10.5px; color: var(--text2); }

/* ===================== RELATÓRIOS ===================== */
.rel-item { padding: 7px 10px; border-radius: 6px; color: var(--text2); font-size: 13px; cursor: pointer; transition: background .15s; }
.rel-item:hover { background: var(--surface2); }
.rel-item.active { background: var(--surface2); color: var(--accent); font-weight: 500; }
.pront-sess-item { padding: 9px 12px; cursor: pointer; border-left: 3px solid transparent; transition: background .15s; }
.pront-sess-item:hover { background: var(--surface2); }
.pront-sess-item.pront-sess-ativo { border-left-color: var(--accent); background: var(--surface2); }

/* ── Portal do Paciente ── */
.port-layout { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.port-side { width: 240px; flex-shrink: 0; }
.port-main { flex: 1; min-width: 280px; }
.port-doc-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 22px 18px; }
.port-avatar { width: 64px; height: 64px; border-radius: 50%; background: linear-gradient(135deg,#5BB990,#4A90D9); display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; color: #fff; flex-shrink: 0; }
.port-modal-row { display: flex; gap: 6px; margin-top: 14px; }
.port-modal-btn { flex: 1; padding: 8px 6px; border: 1.5px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text2); font-size: 12px; font-weight: 500; cursor: pointer; text-align: center; transition: all .15s; }
.port-modal-btn.ativo { border-color: var(--accent); background: #E8F5EE; color: var(--accent); }
.port-modal-btn:hover:not(.ativo) { border-color: var(--accent); color: var(--accent); }

/* Stepper */
.port-stepper { display: flex; align-items: center; gap: 0; margin-bottom: 22px; }
.port-step { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 500; color: var(--text3); flex-shrink: 0; }
.port-step.ativo { color: var(--accent); }
.port-step.concluido { color: var(--success); }
.port-step-num { width: 24px; height: 24px; border-radius: 50%; border: 2px solid currentColor; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.port-step-sep { flex: 1; height: 1px; background: var(--border); min-width: 16px; max-width: 40px; }

/* Calendário do portal */
.port-cal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.port-cal-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.port-cal-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 2px; padding: 10px; }
.port-cal-dow { font-size: 11px; font-weight: 600; color: var(--text3); text-align: center; padding: 4px 0; }
.port-cal-day { aspect-ratio: 1; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 13px; cursor: default; color: var(--text3); position: relative; }
.port-cal-day.disponivel { color: var(--text); cursor: pointer; font-weight: 500; }
.port-cal-day.disponivel:hover { background: var(--surface2); }
.port-cal-day.disponivel::after { content: ''; position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%); width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
.port-cal-day.hoje { font-weight: 700; }
.port-cal-day.selecionado { background: var(--accent) !important; color: #fff !important; }
.port-cal-day.selecionado::after { background: rgba(255,255,255,.6); }
.port-cal-day.passado { opacity: .35; }

/* Slots de horário */
.port-slots-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.port-slot { padding: 11px 8px; border-radius: 9px; text-align: center; font-size: 13px; font-weight: 600; border: 1.5px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; transition: all .15s; }
.port-slot:hover:not(.ocupado):not(.selecionado) { border-color: var(--accent); color: var(--accent); background: #E8F5EE; }
.port-slot.selecionado { background: var(--accent); border-color: var(--accent); color: #fff; }
.port-slot.ocupado { background: var(--surface2); border-color: var(--border); color: var(--text3); cursor: not-allowed; text-decoration: line-through; opacity: .55; }

/* Stepper content box */
.port-box { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }

/* Confirmação */
.port-confirm-card { background: linear-gradient(135deg, #1E4538, #2B6E50); border-radius: 14px; padding: 28px; color: #fff; text-align: center; }
.port-confirm-row { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.1); border-radius: 9px; padding: 11px 14px; margin-top: 10px; text-align: left; }

.rel-stat { background: var(--surface2); border-radius: 8px; padding: 14px; text-align: center; }
.rel-stat-num { font-size: 26px; font-weight: 700; line-height: 1.1; }
.rel-stat-lbl { font-size: 11px; color: var(--text2); margin-top: 2px; }
.rel-bar-wrap { display: flex; flex-direction: column; gap: 8px; }
.rel-bar-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.rel-bar-lbl { width: 28px; color: var(--text3); flex-shrink: 0; }
.rel-bar-track { flex: 1; height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.rel-bar-fill { height: 100%; border-radius: 4px; transition: width .4s; }
.rel-bar-val { width: 55px; text-align: right; font-weight: 600; color: var(--text); flex-shrink: 0; }
.rel-row-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.rel-row-item:last-child { border-bottom: none; }

/* ===================== IA CHIP ===================== */
.ai-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px;
  border-radius: 20px; font-size: 12px; font-weight: 500; cursor: pointer;
  background: linear-gradient(135deg, #7B52D9, #4A90D9); color: #fff;
  border: none; font-family: 'DM Sans', sans-serif; transition: opacity .13s;
}
.ai-chip:hover { opacity: .88; }
.ai-chip svg { width: 13px; height: 13px; }

/* ===================== ESCALAS ===================== */
.scale-card { border: 1px solid var(--border); border-radius: 8px; padding: 13px; cursor: pointer; transition: border-color .12s; display: flex; flex-direction: column; gap: 4px; }
.scale-card:hover { border-color: var(--accent); }
.scale-name { font-size: 13px; font-weight: 500; color: var(--text); }
.scale-desc { font-size: 11px; color: var(--text3); }
.scale-tag { font-size: 10px; padding: 2px 7px; border-radius: 8px; display: inline-flex; align-self: flex-start; margin-top: 2px; }

/* ===================== PRONTUÁRIO ===================== */
.note-area { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.note-section { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.note-section:last-child { border-bottom: none; }
.note-label { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text3); margin-bottom: 6px; display: flex; align-items: center; gap: 5px; }
.note-label span { font-size: 9.5px; background: var(--surface2); color: var(--text3); padding: 1px 6px; border-radius: 8px; font-weight: 500; text-transform: none; letter-spacing: 0; }

/* ===================== PORTAL / TELE ===================== */
.portal-card { background: linear-gradient(135deg, #2D4A6F, #4A90D9); border-radius: 10px; padding: 18px; color: #fff; display: flex; align-items: center; gap: 14px; }
.portal-icon { width: 44px; height: 44px; background: rgba(255,255,255,.15); border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.tele-card { background: linear-gradient(135deg, #1A5E3A, #2A9E62); border-radius: 10px; padding: 18px; color: #fff; display: flex; align-items: center; gap: 14px; }

/* ===================== GRID UTILITÁRIO ===================== */
.dg { display: grid; grid-template-columns: 1fr 1.5fr; gap: 14px; }

/* ===================== RESPONSIVO ===================== */
@media (max-width: 640px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-228px); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .cw { padding: 14px 15px; }
  .topbar { padding: 0 15px; }
  .dg { grid-template-columns: 1fr; }
  .menu-btn { display: flex !important; }
  .form-row { grid-template-columns: 1fr; }
  .modal { margin: 12px; }
}

/* ===================== MODAIS ===================== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.3); transform: translateY(16px);
  transition: transform .2s; margin: 16px;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-hd {
  padding: 18px 20px 14px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0;
  background: var(--surface); z-index: 1;
}
.modal-hd h3 { font-family: 'Lora', serif; font-size: 16px; font-weight: 600; color: var(--text); }
.modal-close {
  width: 28px; height: 28px; border-radius: 50%; border: none; background: var(--surface2);
  color: var(--text2); font-size: 18px; cursor: pointer; display: flex;
  align-items: center; justify-content: center; line-height: 1; flex-shrink: 0;
}
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 13px; }
.modal-ft {
  padding: 12px 20px 16px; display: flex; justify-content: flex-end; gap: 8px;
  border-top: 1px solid var(--border); position: sticky; bottom: 0;
  background: var(--surface);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-label { font-size: 11.5px; font-weight: 500; color: var(--text2); }
.form-group .inp { width: 100%; }

/* ===================== TOASTS ===================== */
.toast-container {
  position: fixed; bottom: 20px; right: 20px; z-index: 2000;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 15px; display: flex; align-items: center; gap: 10px;
  box-shadow: 0 4px 24px rgba(0,0,0,.22); font-size: 13px; color: var(--text);
  min-width: 240px; max-width: 340px; pointer-events: all;
  animation: toastIn .25s ease forwards;
}
.toast.t-success { border-left: 3px solid var(--success); }
.toast.t-error   { border-left: 3px solid var(--danger); }
.toast.t-info    { border-left: 3px solid var(--accent); }
.toast.t-warn    { border-left: 3px solid var(--warn); }
.toast-icon { font-size: 15px; flex-shrink: 0; }
.toast-msg { flex: 1; line-height: 1.35; }
.toast-out { animation: toastOut .22s ease forwards; }
@keyframes toastIn  { from { opacity:0; transform:translateX(24px); } to { opacity:1; transform:translateX(0); } }
@keyframes toastOut { from { opacity:1; transform:translateX(0); } to { opacity:0; transform:translateX(24px); } }

/* ===================== CALENDÁRIO — VISTA MÊS ===================== */
.cal-month-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden;
}
.cmh {
  text-align: center; padding: 8px 4px; font-size: 10px; font-weight: 600;
  color: var(--text2); text-transform: uppercase; letter-spacing: .4px;
  background: var(--surface2); border-bottom: 1px solid var(--border);
}
.cmd {
  min-height: 72px; padding: 5px;
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .1s; position: relative;
}
.cmd:hover { background: var(--surface2); }
.cmd:nth-child(7n) { border-right: none; }
.cmd-empty { background: color-mix(in srgb, var(--surface2) 70%, transparent); pointer-events: none; }
.cmd-num {
  font-size: 11.5px; font-weight: 600; color: var(--text2);
  display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
}
.cmd-today .cmd-num {
  background: var(--accent); color: #fff; border-radius: 50%; font-size: 11px;
}
.cmd-dots { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.cmd-dot   { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.cmd-dot-v { background: var(--purple); }
.cmd-dot-o { background: var(--warn); }

/* ===================== CALENDÁRIO — VISTA DIA ===================== */
.cal-day-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.cal-day-title {
  padding: 12px 16px; font-size: 14px; font-weight: 600; color: var(--text);
  border-bottom: 1px solid var(--border); background: var(--surface2); text-transform: capitalize;
}
.cal-day-slot {
  display: grid; grid-template-columns: 52px 1fr;
  border-bottom: 1px solid var(--border); min-height: 52px;
}
.cal-day-slot:last-child { border-bottom: none; }
.cal-day-time {
  display: flex; align-items: flex-start; justify-content: center; padding-top: 6px;
  font-size: 10.5px; color: var(--text3);
  border-right: 1px solid var(--border); background: var(--surface2);
}
.cal-day-cell { position: relative; cursor: pointer; padding: 4px 6px; transition: background .1s; }
.cal-day-cell:hover { background: var(--surface2); }

/* ===================== MÊS PICKER ===================== */
.mes-picker {
  position: fixed; z-index: 1600;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 13px; box-shadow: 0 8px 36px rgba(0,0,0,.28);
  padding: 12px; width: 216px;
  animation: toastIn .15s ease forwards;
}
.mes-picker-hd {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; padding: 0 2px;
}
.mes-picker-ano { font-size: 14px; font-weight: 600; color: var(--text); }
.mes-picker-nav {
  background: none; border: none; cursor: pointer;
  color: var(--text2); font-size: 18px; padding: 2px 8px;
  border-radius: 7px; line-height: 1; font-family: inherit;
}
.mes-picker-nav:hover { background: var(--surface2); color: var(--text); }
.mes-picker-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.mes-picker-m {
  background: none; border: 1px solid transparent; border-radius: 8px;
  padding: 9px 4px; font-size: 12px; font-weight: 500;
  color: var(--text2); cursor: pointer; transition: background .1s, color .1s;
  text-align: center; font-family: inherit;
}
.mes-picker-m:hover { background: var(--surface2); color: var(--text); border-color: var(--border); }
.mes-picker-m.active { background: var(--accent); color: #fff; border-color: transparent; }
