/* ============================================================
   ClineWise — Portal do Paciente
   Segue o design system de index-landing-page.html
   ============================================================ */

/* ============================================================
   ClineWise — Design System Base (compartilhado entre painéis)
   Deriva dos tokens visuais de index-landing-page.html
   Fontes: Inter (corpo) + Space Grotesk (display/números)
   ============================================================ */

/* ---------- Reset & base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: #05071a;
  color: #e5e7f0;
  line-height: 1.55;
  overflow-x: hidden;
  min-height: 100vh;
  position: relative;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- Variables ---------- */
:root {
  --bg-0: #05071a;
  --bg-1: #0a0e27;
  --bg-2: #11163a;
  --surface: rgba(20, 26, 60, 0.55);
  --surface-2: rgba(28, 36, 78, 0.65);
  --surface-solid: #0e1230;
  --border: rgba(99, 102, 241, 0.18);
  --border-strong: rgba(99, 102, 241, 0.45);
  --text: #e8ebff;
  --text-dim: #9aa3c7;
  --text-muted: #6b7299;
  --brand: #22d3ee;
  --brand-2: #6366f1;
  --brand-3: #a855f7;
  --accent: #10b981;
  --accent-2: #34d399;
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --info: #38bdf8;
  --info-bg: rgba(56, 189, 248, 0.12);
  --success-bg: rgba(16, 185, 129, 0.12);
  --grad-primary: linear-gradient(135deg, #22d3ee 0%, #6366f1 50%, #a855f7 100%);
  --grad-accent: linear-gradient(135deg, #10b981 0%, #22d3ee 100%);
  --grad-text: linear-gradient(135deg, #67e8f9 0%, #818cf8 50%, #c084fc 100%);
  --grad-text-2: linear-gradient(135deg, #34d399 0%, #67e8f9 100%);
  --shadow-glow: 0 0 60px rgba(99, 102, 241, 0.35);
  --shadow-card: 0 24px 60px -20px rgba(0, 0, 0, 0.55), 0 8px 24px -8px rgba(99, 102, 241, 0.18);
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-2xl: 32px;
  --container: 1440px;
  --header-h: 68px;
  --sidebar-w: 264px;
  --sidebar-w-collapsed: 76px;
}

/* ---------- Background 3D canvas ---------- */
#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.6;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.35);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 102, 241, 0.55);
  background-clip: padding-box;
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.35) transparent;
}

::selection {
  background: rgba(99, 102, 241, 0.4);
  color: #fff;
}

/* ---------- Focus ---------- */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Typography helpers ---------- */
.grad-text {
  background: var(--grad-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  display: inline-block;
}

.grad-text-2 {
  background: var(--grad-text-2);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  display: inline-block;
}

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brand);
  background: rgba(34, 211, 238, 0.08);
  border: 1px solid rgba(34, 211, 238, 0.25);
  border-radius: 999px;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.num, .font-display {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
}

a {
  color: var(--brand);
}

/* ============================================================
   APP SHELL — layout padrão dos painéis internos
   Estrutura esperada:
   #app
     .app-shell
       aside.app-sidebar
       div.app-main
         header.app-topbar
         main.app-content
   ============================================================ */

#app {
  position: relative;
  z-index: 2;
  min-height: 100vh;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.app-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: rgba(9, 12, 32, 0.85);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  transition: width 0.25s ease;
}

.app-sidebar.collapsed {
  width: var(--sidebar-w-collapsed);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  text-decoration: none;
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-brand .brand-mark {
  flex-shrink: 0;
  filter: drop-shadow(0 4px 10px rgba(34, 211, 238, 0.4));
}

.sidebar-brand .brand-name-accent {
  background: var(--grad-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
}

.sidebar-section-label {
  padding: 16px 12px 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sidebar-nav {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav a,
.sidebar-nav button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--r-md);
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
  white-space: nowrap;
  font-family: inherit;
}

.sidebar-nav a svg,
.sidebar-nav button svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  max-width: 18px;
  max-height: 18px;
  aspect-ratio: 1;
}

.sidebar-nav a:hover,
.sidebar-nav button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-nav a.active,
.sidebar-nav button.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.22), rgba(34, 211, 238, 0.1));
  border-color: var(--border-strong);
  box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.15);
}

.sidebar-nav .badge-count {
  margin-left: auto;
}

.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 0.2s;
}

.sidebar-user:hover {
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Main area ---------- */
.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  background: rgba(5, 7, 26, 0.72);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid var(--border);
}

.topbar-toggle {
  display: none;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  cursor: pointer;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.topbar-search {
  flex: 1;
  max-width: 420px;
  position: relative;
}

.topbar-search input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  transition: border-color 0.2s, background 0.2s;
}

.topbar-search input:focus {
  outline: none;
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.06);
}

.topbar-search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.icon-btn > svg { width: 18px; height: 18px; max-width: 18px; max-height: 18px; flex: 0 0 18px; }

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  border-color: var(--border-strong);
}

.icon-btn .dot-alert {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 2px var(--bg-1);
}

.app-content {
  flex: 1;
  padding: 28px 28px 60px;
  position: relative;
  z-index: 2;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.page-head h1 {
  font-size: clamp(22px, 2.6vw, 28px);
  font-weight: 700;
  margin-bottom: 4px;
}

.page-head p {
  color: var(--text-dim);
  font-size: 14px;
}

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

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.breadcrumbs a {
  color: var(--text-muted);
  text-decoration: none;
}

.breadcrumbs a:hover {
  color: var(--text-dim);
}

.breadcrumbs .sep {
  opacity: 0.5;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  position: relative;
  white-space: nowrap;
  user-select: none;
}

/* Ícones inline dos botões não podem herdar o tamanho padrão do SVG. */
.btn > svg {
  display: block;
  width: 16px;
  height: 16px;
  max-width: 16px;
  max-height: 16px;
  flex: 0 0 16px;
}

/* Mantém o CTA de nova consulta compacto, inclusive dentro de .page-actions. */
.page-actions > .btn.cw-new-appointment-btn,
.cw-new-appointment-btn {
  width: auto;
  max-width: 100%;
  min-height: 32px;
  flex: 0 0 auto;
  align-self: flex-start;
}

.btn:disabled,
.btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-sm {
  padding: 7px 13px;
  font-size: 12.5px;
}

.btn-lg {
  padding: 13px 24px;
  font-size: 15px;
  border-radius: 999px;
}

.btn-block {
  width: 100%;
}

.btn-icon-only {
  padding: 9px;
  aspect-ratio: 1;
}

.btn-primary {
  color: #061025;
  background: linear-gradient(135deg, #67e8f9 0%, #818cf8 100%);
  box-shadow: 0 8px 20px -6px rgba(99, 102, 241, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 26px -6px rgba(99, 102, 241, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.btn-secondary {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.3);
}

.btn-ghost {
  color: var(--text-dim);
  background: transparent;
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.btn-success {
  color: #042c1e;
  background: linear-gradient(135deg, #34d399, #10b981);
  box-shadow: 0 8px 20px -6px rgba(16, 185, 129, 0.45);
}

.btn-danger {
  color: #fff;
  background: linear-gradient(135deg, #f87171, #ef4444);
  box-shadow: 0 8px 20px -6px rgba(239, 68, 68, 0.45);
}

.btn-danger-outline {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-danger-outline:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.2);
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  backdrop-filter: blur(10px);
  padding: 22px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-header h3 {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--text);
}

.card-header .card-subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.card-hover {
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.3s, box-shadow 0.3s;
}

.card-hover:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: 0 20px 40px -18px rgba(99, 102, 241, 0.35);
}

/* Stat / KPI cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  position: relative;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.stat-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--grad-primary);
  color: #fff;
  margin-bottom: 14px;
  box-shadow: 0 10px 20px -8px rgba(99, 102, 241, 0.5);
}

.stat-card-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.stat-card-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.stat-card-trend {
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.stat-card-trend.up {
  color: var(--accent-2);
}

.stat-card-trend.down {
  color: var(--danger);
}

/* ============================================================
   BADGES / STATUS PILLS
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 999px;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge-success {
  color: var(--accent-2);
  background: var(--success-bg);
}

.badge-warning {
  color: var(--warning);
  background: var(--warning-bg);
}

.badge-danger {
  color: #fca5a5;
  background: var(--danger-bg);
}

.badge-info {
  color: var(--info);
  background: var(--info-bg);
}

.badge-neutral {
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.06);
}

.badge-neutral::before {
  background: var(--text-muted);
}

.badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  background: var(--grad-primary);
  color: #fff;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

label,
.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
}

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.form-error {
  font-size: 12px;
  color: var(--danger);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="date"],
input[type="time"],
input[type="search"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.2s, background 0.2s;
}

textarea {
  resize: vertical;
  min-height: 90px;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.06);
}

input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%239aa3c7' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 34px;
}

/* Checkbox / radio / switch */
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--brand-2);
  cursor: pointer;
}

.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-track {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background 0.25s;
  cursor: pointer;
}

.switch-track::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  top: 2px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.25s;
}

.switch input:checked + .switch-track {
  background: var(--grad-accent);
  border-color: transparent;
}

.switch input:checked + .switch-track::before {
  transform: translateX(18px);
}

.input-icon-wrap {
  position: relative;
}

.input-icon-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;   /* adicionar */
  height: 16px;  /* adicionar */
  color: var(--text-muted);
  pointer-events: none;
}

.input-icon-wrap input {
  padding-left: 36px;
}

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
}

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

.data-table thead th {
  text-align: left;
  padding: 13px 16px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.data-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr {
  transition: background 0.15s;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.data-table .cell-muted {
  color: var(--text-muted);
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.pagination-btns {
  display: flex;
  gap: 6px;
}

.pagination-btns button {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s, color 0.2s;
}

.pagination-btns button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.pagination-btns button.active {
  background: var(--grad-primary);
  color: #061025;
  border-color: transparent;
  font-weight: 700;
}

.pagination-btns button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ============================================================
   AVATAR
   ============================================================ */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--grad-primary);
  color: #fff;
  font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
  flex-shrink: 0;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-sm {
  width: 28px;
  height: 28px;
  font-size: 11px;
}

.avatar-md {
  width: 36px;
  height: 36px;
  font-size: 13px;
}

.avatar-lg {
  width: 56px;
  height: 56px;
  font-size: 18px;
}

/* ============================================================
   TABS
   ============================================================ */
.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
}

.tab-btn {
  padding: 11px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s;
  font-family: inherit;
}

.tab-btn:hover {
  color: var(--text-dim);
}

.tab-btn.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

/* ============================================================
   MODAL / DIALOG
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 4, 16, 0.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 200;
  opacity: 0;
  animation: modalFadeIn 0.2s ease forwards;
}

@keyframes modalFadeIn {
  to { opacity: 1; }
}

.modal {
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-card);
  transform: translateY(12px) scale(0.98);
  animation: modalPopIn 0.25s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes modalPopIn {
  to { transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 17px;
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-dim);
  cursor: pointer;
}

.modal-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.modal-body {
  padding: 22px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
}

/* ============================================================
   DROPDOWN
   ============================================================ */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
  padding: 6px;
  z-index: 60;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.18s, transform 0.18s, visibility 0.18s;
}

.dropdown-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-menu a,
.dropdown-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  font-size: 13.5px;
  color: var(--text-dim);
  text-decoration: none;
  background: transparent;
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}

.dropdown-menu a:hover,
.dropdown-menu button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 4px;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast-wrap {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
  font-size: 13.5px;
  color: var(--text);
  animation: toastIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast.success { border-left: 3px solid var(--accent); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info { border-left: 3px solid var(--info); }

/* ============================================================
   EMPTY STATE / LOADER
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  margin-bottom: 16px;
  color: var(--text-dim);
}

.empty-state h4 {
  font-size: 16px;
  color: var(--text);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 13.5px;
  max-width: 340px;
  margin-bottom: 16px;
}

.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.09) 37%, rgba(255,255,255,0.04) 63%);
  background-size: 400% 100%;
  animation: skeletonLoad 1.4s ease infinite;
  border-radius: var(--r-sm);
}

@keyframes skeletonLoad {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   TOOLTIP
   ============================================================ */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: 6px 10px;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s, transform 0.18s, visibility 0.18s;
  pointer-events: none;
  z-index: 80;
}

[data-tooltip]:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* ============================================================
   REVEAL ANIMATION (reuso do padrão da landing)
   ============================================================ */
.reveal {
  opacity: 0;
  transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.reveal[data-reveal="up"] {
  transform: translateY(24px);
}

.reveal.in {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-dim { color: var(--text-dim); }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.hidden { display: none !important; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Responsive: app shell ---------- */
@media (max-width: 1024px) {
  .app-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s ease;
  }

  .app-sidebar.open {
    transform: translateX(0);
  }

  .topbar-toggle {
    display: inline-flex;
  }

  .sidebar-scrim {
    position: fixed;
    inset: 0;
    background: rgba(2, 3, 10, 0.6);
    z-index: 39;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s, visibility 0.25s;
  }

  .sidebar-scrim.open {
    opacity: 1;
    visibility: visible;
  }

  .topbar-search {
    display: none;
  }
}

/* Fallback responsivo comum a todas as páginas do portal do paciente. */
.sidebar-scrim { display: none; }
.app-main, .app-content { min-width: 0; }
@media (prefers-reduced-motion: no-preference) { .app-content > * { animation: cw-main-enter .34s cubic-bezier(.22, 1, .36, 1) both; } .card, .btn, .icon-btn { transition: transform .2s ease, box-shadow .2s ease, background .2s ease; } .card:hover { transform: translateY(-2px); } }
@keyframes cw-main-enter { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 1024px) { .sidebar-scrim { display: block; } .app-topbar { padding-inline: clamp(14px, 3vw, 24px); } .app-content { padding: clamp(18px, 3vw, 28px) clamp(14px, 3vw, 28px) 48px; } .table-wrap { max-width: 100%; overscroll-behavior-inline: contain; } }
@media (max-width: 700px) { .stats-grid, .form-row { grid-template-columns: 1fr !important; } .form-row { display: grid; } .page-actions { width: 100%; } .page-actions > .btn { flex: 1 1 160px; justify-content: center; } .data-table { min-width: 620px; } .modal-overlay { padding: 10px; align-items: flex-end; } .modal { width: 100%; max-height: calc(100dvh - 20px); } }
@media (max-width: 420px) { .app-content { padding: 16px 12px 36px; } .app-topbar { gap: 10px; padding-inline: 12px; } .topbar-title { overflow: hidden; text-overflow: ellipsis; } .page-actions > .btn { flex-basis: 100%; } }

/* Autoagendamento público: leitura e toque confortáveis em telas pequenas. */
.booking-page {
  padding-bottom: max(40px, env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 12% 4%, rgba(34, 211, 238, .14), transparent 29rem),
    radial-gradient(circle at 90% 20%, rgba(168, 85, 247, .13), transparent 27rem);
}

.booking-container { width: min(100%, 640px); }

.booking-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.booking-progress {
  padding: 13px 15px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: rgba(11, 16, 42, .52);
}

.booking-progress-copy { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--text-muted); }
.booking-progress-copy strong { color: var(--text-dim); font-weight: 650; }
.booking-progress-track { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin-top: 10px; }
.booking-progress-track span { height: 4px; border-radius: 999px; background: rgba(255, 255, 255, .1); transition: background .25s ease, box-shadow .25s ease; }
.booking-progress-track .is-done { background: var(--brand-2); }
.booking-progress-track .is-current { background: var(--brand); box-shadow: 0 0 12px rgba(34, 211, 238, .7); }

.booking-card {
  box-shadow: var(--shadow-card);
  border-color: rgba(129, 140, 248, .26);
}

.booking-card h3 { font-size: clamp(20px, 4vw, 24px); }
.booking-slots .btn { min-height: 42px; justify-content: center; }

/* CTA é intencionalmente compacto em desktop, sem a aparência de faixa. */
.booking-continue {
  display: flex;
  width: min(100%, 300px);
  min-height: 46px;
  margin: 24px 0 0 auto;
  padding-inline: 22px;
  font-size: 14px;
  border-radius: 12px;
}

.booking-continue svg { width: 18px; height: 18px; flex: 0 0 18px; }
.booking-continue:disabled { background: rgba(129, 140, 248, .17); color: var(--text-muted); border-color: rgba(129, 140, 248, .18); box-shadow: none; opacity: 1; }

@media (max-width: 520px) {
  .booking-page { padding: 16px 12px 36px !important; }
  .booking-card { padding: 20px !important; border-radius: var(--r-lg); }
  .booking-slots { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  .booking-page .appt-card { padding: 14px; gap: 12px; }
  .booking-page .appt-meta { gap: 5px; }
  .booking-progress-copy { font-size: 11.5px; }
  .booking-continue { width: 100%; margin-top: 20px; }
}

@media (max-width: 350px) {
  .booking-slots { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}

@media (max-width: 640px) {
  .app-content {
    padding: 20px 16px 48px;
  }

  .page-head {
    flex-direction: column;
    align-items: stretch;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ============================================================
   PORTAL DO PACIENTE — componentes específicos
   Agendamentos, prontuário, exames, telemedicina
   ============================================================ */

/* Appointment cards */
.appt-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: 12px;
}

.appt-date-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  flex-shrink: 0;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(34, 211, 238, 0.1));
  border: 1px solid var(--border-strong);
}

.appt-date-block .appt-day {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

.appt-date-block .appt-month {
  font-size: 10.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

.appt-info {
  flex: 1;
  min-width: 0;
}

.appt-info .appt-title {
  font-weight: 600;
  color: var(--text);
  font-size: 14.5px;
}

.appt-info .appt-meta {
  font-size: 12.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 3px;
}

.appt-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* Telemedicine call card */
.telemed-card {
  position: relative;
  padding: 26px;
  border-radius: var(--r-xl);
  background: linear-gradient(160deg, rgba(28, 36, 78, 0.85), rgba(15, 19, 50, 0.95));
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  text-align: center;
}

.telemed-card .telemed-glow {
  position: absolute;
  top: -60px;
  right: -60px;
  width: 220px;
  height: 220px;
  background: var(--grad-primary);
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.35;
}

.telemed-card .avatar-lg {
  margin: 0 auto 14px;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

.telemed-card h3 {
  font-size: 18px;
  margin-bottom: 4px;
}

.telemed-card .telemed-time {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 18px;
}

/* Health timeline (histórico / prontuário resumido) */
.timeline {
  position: relative;
  padding-left: 26px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: 24px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -26px;
  top: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-1);
  border: 2px solid var(--brand-2);
}

.timeline-item.done::before {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--success-bg);
}

.timeline-date {
  font-size: 11.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.timeline-title {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}

.timeline-desc {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 3px;
}

/* Exames / documentos anexados */
.doc-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.02);
  margin-bottom: 8px;
}

.doc-card .doc-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--r-sm);
  background: var(--info-bg);
  color: var(--info);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.doc-card .doc-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}

.doc-card .doc-date {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Bottom nav (mobile app-like para paciente) */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(9, 12, 32, 0.92);
  backdrop-filter: blur(20px) saturate(140%);
  border-top: 1px solid var(--border);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  justify-content: space-around;
}

.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 10.5px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  transition: color 0.2s;
}

.bottom-nav a.active {
  color: var(--brand);
}

@media (max-width: 1024px) {
  .app-content {
    padding-bottom: 90px;
  }

  .bottom-nav {
    display: flex;
  }

  .app-sidebar {
    display: none;
  }
}

/* Boas-vindas / greeting card */
.greeting-card {
  padding: 24px;
  border-radius: var(--r-xl);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.16), rgba(34, 211, 238, 0.06));
  border: 1px solid var(--border-strong);
  margin-bottom: 24px;
}

.greeting-card h2 {
  font-size: 22px;
  margin-bottom: 6px;
}

.greeting-card p {
  color: var(--text-dim);
  font-size: 14px;
}
