/* ═══════════════════════════════════════════════════
   CARD
═══════════════════════════════════════════════════ */
.card {
  background: var(--glass); border: 1px solid var(--border);
  border-radius: var(--r); overflow: hidden;
  transition: var(--t); position: relative;
  backdrop-filter: blur(16px);
}
.card::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.02) 0%, transparent 60%);
  pointer-events: none;
}
.card:hover { border-color: var(--border-act); box-shadow: var(--shadow-glow), var(--shadow-card); transform: translateY(-2px); }
.card.no-hover:hover { transform: none; border-color: var(--border); box-shadow: none; }
.card-h {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid rgba(247,215,145,0.04);
}
.card-title {
  font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 9px;
}
.card-title i { color: var(--gold); font-size: 14px; }
.card-body { padding: 22px; }
.card-action {
  font-size: 12px; color: var(--gold); background: none;
  border: 1px solid rgba(247,215,145,0.15); border-radius: 20px;
  padding: 5px 14px; cursor: pointer; transition: var(--t); font-family: inherit; font-weight: 500;
}
.card-action:hover { background: rgba(247,215,145,0.08); }

/* ═══════════════════════════════════════════════════
   KPI
═══════════════════════════════════════════════════ */
.kpi {
  background: var(--glass); border: 1px solid var(--border);
  border-radius: var(--r); padding: 22px;
  transition: var(--t); position: relative; overflow: hidden; cursor: default;
}
.kpi::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent-a, var(--gold)), var(--accent-b, var(--gold-dark)));
  opacity: 0.7;
}
.kpi::after {
  content: ''; position: absolute; bottom: -30px; right: -20px;
  width: 100px; height: 100px; border-radius: 50%;
  background: var(--accent-a, var(--gold)); opacity: 0.04; transition: var(--t);
}
.kpi:hover { border-color: var(--accent-border, var(--border-act)); transform: translateY(-3px); box-shadow: var(--shadow-card); }
.kpi:hover::after { transform: scale(1.5); opacity: 0.07; }
.kpi-icon-wrap {
  width: 42px; height: 42px; border-radius: var(--r-sm);
  background: var(--accent-bg, rgba(247,215,145,0.09));
  border: 1px solid var(--accent-border, rgba(247,215,145,0.12));
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--accent-a, var(--gold)); margin-bottom: 16px;
}
.kpi-val {
  font-size: 30px; font-weight: 800; color: var(--text);
  font-variant-numeric: tabular-nums; line-height: 1;
  margin-bottom: 6px;
}
.kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-bottom: 10px; }
.kpi-delta {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 20px;
}
.kpi-delta.up   { color: #34d399; background: rgba(52,211,153,0.1); }
.kpi-delta.down { color: #f87171; background: rgba(248,113,113,0.1); }
.kpi-delta.neu  { color: var(--text-muted); background: rgba(122,144,144,0.1); }

/* ═══════════════════════════════════════════════════
   HERO CARD (Dashboard)
═══════════════════════════════════════════════════ */
.hero-card {
  background: linear-gradient(135deg, rgba(28,58,58,0.5) 0%, rgba(22,47,47,0.3) 50%, rgba(196,154,36,0.08) 100%);
  border: 1px solid var(--border-act);
  border-radius: 22px; padding: 32px 36px;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  margin-bottom: 28px; overflow: hidden; position: relative;
}
.hero-card::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, transparent 50%);
  pointer-events: none;
}
.hero-card::after {
  content: ''; position: absolute; right: -60px; top: -60px;
  width: 240px; height: 240px;
  background: radial-gradient(circle, rgba(247,215,145,0.08) 0%, transparent 70%);
  border-radius: 50%; pointer-events: none;
}
.hero-text h1 { font-family: 'Playfair Display', serif; font-size: 30px; font-weight: 700; margin-bottom: 8px; line-height: 1.2; }
.hero-text h1 em { color: var(--gold); font-style: italic; }
.hero-text p { font-size: 14px; color: var(--text-muted); line-height: 1.6; max-width: 380px; }
.hero-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 20px; font-size: 11.5px; font-weight: 600;
  background: var(--glass); border: 1px solid var(--border); color: var(--text-muted);
  cursor: default;
}
.chip.active  { background: rgba(247,215,145,0.08); border-color: rgba(247,215,145,0.2); color: var(--gold); }
.chip.success { background: rgba(52,211,153,0.08); border-color: rgba(52,211,153,0.2); color: var(--success); }
.chip.danger  { background: rgba(248,113,113,0.08); border-color: rgba(248,113,113,0.2); color: var(--danger); }
.hero-visual { display: flex; flex-direction: column; align-items: center; }
.ring-chart { position: relative; }
.ring-chart svg { transform: rotate(-90deg); }
.ring-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-val { font-size: 28px; font-weight: 800; }
.ring-sub { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-top: 2px; }
.period-filter {
  display: flex; gap: 4px; background: rgba(247,215,145,0.04);
  border: 1px solid var(--border); padding: 3px; border-radius: var(--r-sm);
  margin-bottom: 20px; width: fit-content;
}
.period-btn {
  padding: 6px 14px; border-radius: 8px; font-size: 11.5px; font-weight: 600;
  color: var(--text-muted); cursor: pointer; transition: var(--t);
  border: none; background: none; font-family: inherit;
}
.period-btn.active { background: rgba(247,215,145,0.12); color: var(--gold); }

/* ═══════════════════════════════════════════════════
   BAR CHART
═══════════════════════════════════════════════════ */
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 140px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.bar-track { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; width: 100%; position: relative; }
.bar-fill {
  width: 100%; border-radius: 5px 5px 0 0;
  background: linear-gradient(180deg, var(--gold-vivid), var(--gold-dark));
  transform-origin: bottom; animation: barGrow 0.8s var(--ease) both;
  position: relative; cursor: pointer; transition: filter 0.2s;
}
.bar-fill:hover { filter: brightness(1.2); }
.bar-fill.alt { background: linear-gradient(180deg, rgba(247,215,145,0.25), rgba(247,215,145,0.1)); }
.bar-fill::after {
  content: attr(data-val); position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%);
  font-size: 10px; font-weight: 700; color: var(--gold); opacity: 0; transition: opacity 0.15s; white-space: nowrap;
}
.bar-fill:hover::after { opacity: 1; }
.bar-label { font-size: 10px; color: var(--text-dim); font-weight: 500; }
@keyframes barGrow { from { transform: scaleY(0); } to { transform: scaleY(1); } }

/* ═══════════════════════════════════════════════════
   SKELETON / SHIMMER
═══════════════════════════════════════════════════ */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}
.sk {
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.6s infinite linear;
  border-radius: 6px;
  display: inline-block;
}
.sk-line  { height: 13px; border-radius: 6px; }
.sk-text  { height: 16px; border-radius: 6px; }
.sk-val   { height: 28px; border-radius: 8px; }
.sk-block { height: 80px; border-radius: 10px; width: 100%; }
.sk-bar   { border-radius: 6px 6px 0 0; width: 100%; }
.sk-circle{ border-radius: 50%; }

/* ═══════════════════════════════════════════════════
   PROGRESS BAR
═══════════════════════════════════════════════════ */
.prog-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.prog-label { font-size: 12.5px; color: var(--text); width: 110px; flex-shrink: 0; }
.prog-track { flex: 1; height: 6px; border-radius: 3px; background: rgba(247,215,145,0.06); overflow: hidden; }
.prog-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold));
  animation: progGrow 1s var(--ease) both; transform-origin: left;
}
@keyframes progGrow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.prog-val { font-size: 12px; font-weight: 700; color: var(--text); width: 44px; text-align: right; }

/* ═══════════════════════════════════════════════════
   TABLE
═══════════════════════════════════════════════════ */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl thead { border-bottom: 1px solid var(--border); }
.tbl thead th {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--text-dim); font-weight: 600; padding: 16px 16px 12px;
  text-align: left;
}
.tbl tbody td { padding: 13px 16px; border-bottom: 1px solid rgba(247,215,145,0.03); vertical-align: middle; }
.tbl tbody tr { transition: var(--t); cursor: pointer; }
.tbl tbody tr:hover { background: var(--glass-hover); }
.tbl tbody tr:hover td:first-child { padding-left: 20px; }
.table-wrapper { overflow-x: auto; }

/* ═══════════════════════════════════════════════════
   BADGES / PILLS
═══════════════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600;
}
.badge-gold    { background: rgba(247,215,145,0.1); color: var(--gold); border: 1px solid rgba(247,215,145,0.15); }
.badge-success { background: rgba(52,211,153,0.1);  color: var(--success); }
.badge-danger  { background: rgba(248,113,113,0.1); color: var(--danger); }
.badge-info    { background: rgba(96,165,250,0.1);  color: var(--info); }
.badge-warning { background: rgba(251,191,36,0.1);  color: var(--warning); }
.badge-muted   { background: rgba(122,144,144,0.08); color: var(--text-muted); }
.badge-purple  { background: rgba(192,132,252,0.1);  color: var(--purple); }
.pulse {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%; position: relative;
}
.pulse::before { content: ''; position: absolute; inset: 0; border-radius: 50%; animation: pulseRing 1.5s ease-out infinite; }
.pulse.green { background: var(--success); }
.pulse.green::before { background: var(--success); }
.pulse.amber { background: var(--warning); }
.pulse.amber::before { background: var(--warning); }
@keyframes pulseRing { 0% { transform: scale(1); opacity: 0.8; } 100% { transform: scale(2.2); opacity: 0; } }
@keyframes pulse { 0%,100% { opacity: 0.4; } 50% { opacity: 0.8; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════════
   SCHEDULE / AGENDA
═══════════════════════════════════════════════════ */
.schedule { display: flex; flex-direction: column; gap: 0; }
.schedule-slot { display: flex; align-items: flex-start; gap: 16px; padding: 10px 0; border-bottom: 1px solid rgba(247,215,145,0.03); }
.slot-time { font-size: 11.5px; color: var(--text-dim); width: 44px; flex-shrink: 0; padding-top: 3px; }
.slot-line { display: flex; flex-direction: column; align-items: center; width: 16px; flex-shrink: 0; }
.slot-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; border: 2px solid var(--border); background: var(--bg2); }
.slot-dot.filled { background: var(--gold); border-color: var(--gold); box-shadow: 0 0 8px rgba(247,215,145,0.4); }
.slot-vline { flex: 1; width: 1px; background: var(--border); min-height: 24px; }
.slot-card { flex: 1; padding: 10px 14px; border-radius: var(--r-sm); background: var(--glass-hover); border: 1px solid var(--border); transition: var(--t); cursor: pointer; }
.slot-card:hover { border-color: var(--border-act); }
.slot-card.highlight { background: rgba(247,215,145,0.06); border-color: rgba(247,215,145,0.14); }
.slot-name { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.slot-meta { font-size: 11.5px; color: var(--text-muted); }
.slot-empty { flex: 1; color: var(--text-dim); font-size: 12px; padding-top: 4px; }
.day-pills { display: grid; grid-template-columns: repeat(7,1fr); gap: 8px; margin-bottom: 20px; }
.day-pill {
  text-align: center; padding: 12px 8px; border-radius: var(--r-sm);
  background: var(--glass); border: 1px solid var(--border);
  cursor: pointer; transition: var(--t);
}
.day-pill:hover { border-color: var(--border-act); }
.day-pill.today { background: rgba(247,215,145,0.08); border-color: rgba(247,215,145,0.25); }
.day-pill.active { background: rgba(247,215,145,0.14); border-color: var(--gold); }
.day-pill.active .day-pill-name { color: var(--gold); }
.day-pill.active .day-pill-num  { color: var(--gold); }
.day-pill.inactive { opacity: 0.45; pointer-events: none; }
.day-pill-name { font-size: 9.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
.day-pill.today .day-pill-name { color: var(--gold); }
.day-pill-num { font-size: 18px; font-weight: 800; }
.day-pill.today .day-pill-num { color: var(--gold); }
.day-dot { width: 6px; height: 6px; border-radius: 50%; margin: 6px auto 0; }
.day-dot.gold  { background: var(--gold); box-shadow: 0 0 6px var(--gold); }
.day-dot.green { background: var(--success); }

/* ═══════════════════════════════════════════════════
   MINI STAT
═══════════════════════════════════════════════════ */
.mstat {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--glass);
  transition: var(--t); cursor: default;
}
.mstat:hover { border-color: var(--border-act); background: var(--glass-hover); }
.mstat-icon { width: 36px; height: 36px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
.mstat-body { flex: 1; min-width: 0; }
.mstat-val { font-size: 18px; font-weight: 800; }
.mstat-lbl { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* ═══════════════════════════════════════════════════
   TABS
═══════════════════════════════════════════════════ */
.tabs {
  display: flex; gap: 4px; background: rgba(247,215,145,0.03);
  border: 1px solid var(--border); padding: 4px; border-radius: 12px;
  width: fit-content; margin-bottom: 20px; flex-wrap: wrap;
}
.tab {
  padding: 8px 18px; border-radius: 9px; font-size: 12.5px; font-weight: 600;
  color: var(--text-muted); cursor: pointer; transition: var(--t);
  border: none; background: none; font-family: inherit;
  display: flex; align-items: center; gap: 6px;
}
.tab:hover { color: var(--text); }
.tab.active { background: rgba(247,215,145,0.1); color: var(--gold); }

/* ═══════════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px;
  border-radius: var(--r-sm); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: var(--t); border: none; font-family: inherit;
}
.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: var(--teal); box-shadow: 0 4px 16px rgba(247,215,145,0.2);
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); box-shadow: 0 8px 24px rgba(247,215,145,0.3); }
.btn-ghost { background: var(--glass); color: var(--gold); border: 1px solid rgba(247,215,145,0.15); }
.btn-ghost:hover { background: var(--glass-hover); }
.btn-secondary { background: var(--glass); color: var(--text-muted); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--glass-hover); color: var(--text); border-color: var(--border-act); }
.btn-danger { background: rgba(248,113,113,0.1); color: var(--danger); border: 1px solid rgba(248,113,113,0.2); }
.btn-danger:hover { background: rgba(248,113,113,0.2); }
.btn-sm { padding: 7px 14px; font-size: 12px; }

/* ═══════════════════════════════════════════════════
   FORM
═══════════════════════════════════════════════════ */
.form-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-muted); font-weight: 600; margin-bottom: 6px; display: block;
}
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 14px; border-radius: var(--r-sm);
  background: var(--glass); border: 1px solid var(--border);
  color: var(--text); font-size: 13px; font-family: inherit; outline: none;
  transition: var(--t);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--border-act); background: var(--glass-hover);
  box-shadow: 0 0 0 3px rgba(247,215,145,0.06);
}
.form-select option { background: #0d1a1a; }
.form-textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.form-grid-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.form-group { margin-bottom: 14px; }
.upload-area {
  border: 2px dashed rgba(247,215,145,0.15); border-radius: var(--r);
  padding: 28px; text-align: center; transition: var(--t); cursor: pointer;
}
.upload-area:hover { border-color: rgba(247,215,145,0.3); background: rgba(247,215,145,0.03); }

/* ═══════════════════════════════════════════════════
   PATIENT HERO
═══════════════════════════════════════════════════ */
.patient-hero {
  display: flex; align-items: center; gap: 24px; padding: 24px 24px 20px;
  background: linear-gradient(135deg, rgba(28,58,58,0.3), transparent);
  border-radius: var(--r) var(--r) 0 0; border-bottom: 1px solid var(--border);
}
.patient-avatar {
  width: 64px; height: 64px; border-radius: 16px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--teal-mid), #2d5a5e);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 800; color: var(--gold);
  border: 2px solid rgba(247,215,145,0.15);
}
.patient-meta { flex: 1; }
.patient-meta h2 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.patient-meta .sub { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.patient-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.patient-kpi-row {
  display: grid; grid-template-columns: repeat(4,1fr);
  border-top: 1px solid var(--border);
}
.patient-kpi-cell {
  padding: 16px 20px; text-align: center; border-right: 1px solid var(--border);
}
.patient-kpi-cell:last-child { border-right: none; }
.patient-kpi-val { font-size: 22px; font-weight: 800; }
.patient-kpi-lbl { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* ═══════════════════════════════════════════════════
   LAUDOS
═══════════════════════════════════════════════════ */
.laudo-card {
  display: flex; align-items: center; gap: 12px; padding: 14px;
  border-radius: var(--r-sm); cursor: pointer; border-left: 3px solid transparent;
  background: var(--glass); margin-bottom: 6px; transition: var(--t);
}
.laudo-card:hover { background: var(--glass-hover); }
.laudo-card.rascunho  { border-left-color: var(--warning); background: rgba(251,191,36,0.04); }
.laudo-card.revisao   { border-left-color: var(--info);    background: rgba(96,165,250,0.04); }
.laudo-card.finalizado{ border-left-color: var(--success); background: rgba(52,211,153,0.04); }

/* ═══════════════════════════════════════════════════
   FINANCEIRO — big numbers
═══════════════════════════════════════════════════ */
.big-num { font-size: 32px; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1; }
.big-num small { font-size: 14px; color: var(--text-muted); font-weight: 500; vertical-align: super; margin-right: 3px; }

/* ═══════════════════════════════════════════════════
   FLOATING ACTION BUTTON
═══════════════════════════════════════════════════ */
.fab {
  position: fixed; bottom: 28px; right: 28px; z-index: 500;
  width: 50px; height: 50px; border-radius: 14px;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--teal); cursor: pointer;
  box-shadow: 0 8px 24px rgba(247,215,145,0.35); border: none; transition: var(--t);
}
.fab:hover { transform: scale(1.1) rotate(10deg); }

/* ═══════════════════════════════════════════════════
   AVATAR ROW
═══════════════════════════════════════════════════ */
.avatar-row { display: flex; }
.avatar-sm {
  width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--bg2);
  background: linear-gradient(135deg, var(--teal-mid), #2d5a5e);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: var(--gold); margin-left: -6px;
}
.avatar-sm:first-child { margin-left: 0; }

/* ═══════════════════════════════════════════════════
   MODAL
═══════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 4000;
  background: rgba(0,0,0,0.78);
  display: none; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; animation: fadeIn 0.18s ease; }

/* Quando qualquer modal está aberto: remove backdrop-filter da sidebar
   para evitar que crie stacking context separado que vaza pelo overlay */
body.modal-open .sidebar {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* Overlay do agenda-modal */
#agendaModalOverlay {
  position: fixed; inset: 0; z-index: 4000;
  background: rgba(0,0,0,0.78);
  display: none;
}
.modal-box {
  background: var(--surface); border: 1px solid var(--border-act);
  border-radius: var(--r); width: 560px; max-width: 92vw; max-height: 88vh;
  overflow: hidden; display: flex; flex-direction: column;
  box-shadow: 0 32px 96px rgba(0,0,0,0.7), 0 0 0 1px rgba(247,215,145,0.08);
  animation: scaleIn 0.22s var(--ease);
}
.modal-box.wide { width: 780px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.modal-title i { color: var(--gold); }
.modal-close { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 16px; transition: var(--t); }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 24px; border-top: 1px solid var(--border); }

/* ═══════════════════════════════════════════════════
   TOAST
═══════════════════════════════════════════════════ */
.toasts { position: fixed; top: 76px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px;
  background: rgba(14,24,22,0.96); border: 1px solid var(--border);
  border-radius: var(--r-sm); min-width: 280px; max-width: 340px;
  backdrop-filter: blur(20px); box-shadow: var(--shadow-card);
  animation: toastIn 0.4s var(--ease) both; pointer-events: all;
  transition: opacity 0.3s, transform 0.3s;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
.toast-body { flex: 1; }
.toast-title { font-size: 13px; font-weight: 600; }
.toast-msg   { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.toast-close { color: var(--text-dim); cursor: pointer; font-size: 13px; background: none; border: none; }
.toast-close:hover { color: var(--text); }

/* ═══════════════════════════════════════════════════
   COMMAND PALETTE
═══════════════════════════════════════════════════ */
.palette-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(10px);
  display: none; align-items: flex-start; justify-content: center;
  padding-top: 14vh;
}
.palette-overlay.open { display: flex; animation: fadeIn 0.15s ease; }
.palette-box {
  width: 560px; max-width: 92vw;
  background: rgba(10,20,20,0.97); border: 1px solid var(--border-act);
  border-radius: 20px; overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6); animation: scaleIn 0.2s var(--ease);
}
.palette-input { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.palette-input i { color: var(--gold); font-size: 16px; }
.palette-input input { flex: 1; background: none; border: none; outline: none; font-size: 16px; color: var(--text); font-family: inherit; }
.palette-input input::placeholder { color: var(--text-dim); }
.palette-results { padding: 8px; max-height: 320px; overflow-y: auto; }
.palette-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  border-radius: var(--r-sm); cursor: pointer; transition: var(--t); color: var(--text-muted); font-size: 13.5px;
}
.palette-item:hover, .palette-item.sel { background: rgba(247,215,145,0.07); color: var(--gold); }
.palette-item i { width: 20px; text-align: center; color: var(--gold); font-size: 14px; }
.palette-item kbd { margin-left: auto; font-size: 10px; color: var(--text-dim); background: rgba(247,215,145,0.05); border: 1px solid var(--border); padding: 2px 7px; border-radius: 5px; }
.palette-footer { padding: 10px 22px; border-top: 1px solid var(--border); display: flex; gap: 16px; font-size: 11px; color: var(--text-dim); }
.palette-footer kbd { background: rgba(247,215,145,0.05); border: 1px solid var(--border); padding: 1px 6px; border-radius: 4px; }

/* ═══════════════════════════════════════════════════
   SECTION: ROLE-BASED
═══════════════════════════════════════════════════ */
/* RBAC — controlado por body.role-* definido em applyRBAC() */
[data-role-only]                                              { display: none !important; }
body.role-super_admin  [data-role-only~="super_admin"]        { display: unset !important; }
body.role-psicologo    [data-role-only~="psicologo"]          { display: unset !important; }
body.role-suporte      [data-role-only~="suporte"]            { display: unset !important; }
body.role-estagiario   [data-role-only~="estagiario"]         { display: unset !important; }
[data-role-hide]                                              { }
body.role-super_admin  [data-role-hide~="super_admin"]        { display: none !important; }
body.role-psicologo    [data-role-hide~="psicologo"]          { display: none !important; }
body.role-suporte      [data-role-hide~="suporte"]            { display: none !important; }
body.role-estagiario   [data-role-hide~="estagiario"]         { display: none !important; }

/* ═══════════════════════════════════════════════════
   RESPONSIVE — MOBILE (≤768px)
═══════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Forms: all grids collapse */
  .form-grid-2, .form-grid-3, .form-grid-4 { grid-template-columns: 1fr !important; }

  /* Modal: near full-screen */
  .modal-box {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 96vh !important;
    border-radius: 20px 20px 0 0;
    position: fixed;
    bottom: 0;
    margin: 0;
  }
  .modal-overlay { align-items: flex-end; }

  /* Patient hero: stack on mobile */
  .patient-hero { flex-direction: column; align-items: flex-start; gap: 14px; padding: 16px; }
  .patient-avatar { width: 52px; height: 52px; font-size: 18px; }
  .patient-meta h2 { font-size: 17px; }

  /* Patient KPI row: 2 columns */
  .patient-kpi-row { grid-template-columns: 1fr 1fr; }
  .patient-kpi-cell { padding: 12px 14px; }
  .patient-kpi-val { font-size: 18px; }

  /* Tables: horizontal scroll */
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tbl { min-width: 500px; }

  /* Tabs: scroll horizontally */
  .tabs { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 2px; }
  .tab { flex-shrink: 0; }

  /* KPI card: slightly smaller */
  .kpi { padding: 16px; }
  .kpi-val { font-size: 24px; }
  .kpi-icon-wrap { width: 36px; height: 36px; font-size: 15px; margin-bottom: 12px; }

  /* Cards: reduce padding */
  .card-body { padding: 14px; }
  .card-h { padding: 14px 16px; }

  /* FAB: bigger tap target on mobile */
  .fab { bottom: 20px; right: 16px; width: 54px; height: 54px; border-radius: 16px; }

  /* Toast: full width */
  .toasts { right: 8px; left: 8px; }
  .toast { min-width: unset; max-width: 100%; }

  /* Period filter: scrollable */
  .period-filter { overflow-x: auto; max-width: 100%; }

  /* Buttons: full width in form context */
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; justify-content: center; }
}

