:root {
  --navy: #163E63;
  --navy-2: #102D49;
  --navy-3: #2E638B;
  --teal: #D97723;
  --teal-dark: #B95416;
  --teal-soft: #FFF2E7;
  --bg: #F3F6F9;
  --card: #FFFFFF;
  --text: #243445;
  --muted: #6B7280;
  --subtle: #94A3B8;
  --border: #DFE6ED;
  --border-strong: #D1D5DB;
  --danger: #DC2626;
  --danger-soft: #FEF2F2;
  --warning: #B45309;
  --warning-soft: #FFFBEB;
  --success: #15803D;
  --success-soft: #F0FDF4;
  --info: #2563EB;
  --info-soft: #EFF6FF;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow: 0 8px 24px rgba(15, 23, 42, .08);
  --shadow-lg: 0 18px 50px rgba(15, 23, 42, .16);
  --sidebar-width: 248px;
  --header-height: 72px;
  --content-max: 1600px;
  --focus: 0 0 0 3px rgba(217, 119, 35, .18);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: var(--bg); font-size: 15px; line-height: 1.5; }
body.is-menu-open { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { border: 0; }
img { max-width: 100%; }
svg { display: block; }

.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: none; box-shadow: var(--focus); }

/* Buttons */
.btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 750;
  line-height: 1;
  transition: transform .16s ease, background-color .16s ease, border-color .16s ease, box-shadow .16s ease, opacity .16s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--teal); color: #fff; box-shadow: 0 5px 14px rgba(217, 119, 35, .18); }
.btn-primary:hover { background: var(--teal-dark); }
.btn-secondary { background: #fff; color: var(--navy); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--border-strong); background: #fbfcfd; }
.btn-ghost { background: transparent; color: var(--navy); }
.btn-ghost:hover { background: var(--teal-soft); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { min-height: 36px; padding: 8px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* Forms */
.field { display: grid; gap: 7px; margin-bottom: 17px; }
.field label { color: var(--text); font-size: 13px; font-weight: 750; }
.field-help { color: var(--muted); font-size: 12px; }
.control, .field input, .field select, .field textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  padding: 11px 13px;
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease;
}
.field textarea { min-height: 110px; resize: vertical; }
.field select { appearance: none; padding-right: 40px; background-image: linear-gradient(45deg, transparent 50%, #64748B 50%), linear-gradient(135deg, #64748B 50%, transparent 50%); background-position: calc(100% - 16px) 19px, calc(100% - 11px) 19px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.field input::placeholder, .field textarea::placeholder { color: #9CA3AF; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--teal); box-shadow: var(--focus); }
.field input[aria-invalid="true"], .field select[aria-invalid="true"], .field textarea[aria-invalid="true"] { border-color: #FCA5A5; }
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; color: var(--muted); font-size: 13px; }
.check input { width: 17px; height: 17px; accent-color: var(--teal); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 8px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.text-link { color: var(--navy); font-weight: 750; }
.text-link:hover { color: var(--teal-dark); text-decoration: underline; text-underline-offset: 2px; }

/* Notices / feedback */
.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
}
.notice.success { background: var(--success-soft); color: #166534; border-color: #BBF7D0; }
.notice.error { background: var(--danger-soft); color: #991B1B; border-color: #FECACA; }
.notice.warning { background: var(--warning-soft); color: #92400E; border-color: #FDE68A; }
.notice.info { background: var(--info-soft); color: #1D4ED8; border-color: #BFDBFE; }

/* Login / public foundation */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, .9fr) minmax(420px, 1.1fr);
  background: #fff;
}
.login-brand {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 56px;
  background: radial-gradient(circle at 25% 20%, rgba(217, 119, 35, .18), transparent 34%), linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #fff;
}
.login-brand::after {
  content: "";
  position: absolute;
  width: 380px;
  height: 380px;
  right: -150px;
  bottom: -180px;
  border-radius: 50%;
  border: 50px solid rgba(255, 255, 255, .05);
}
.brand-inner { position: relative; z-index: 1; width: min(480px, 100%); }
.brand-logo { width: min(300px, 78%); height: auto; display: block; margin: 0 0 30px; }
.brand-title { max-width: 440px; margin: 0 0 14px; font-size: clamp(28px, 3vw, 38px); line-height: 1.12; letter-spacing: -.02em; }
.brand-text { max-width: 460px; margin: 0; color: rgba(255,255,255,.84); font-size: 16px; line-height: 1.7; }
.brand-points { display: grid; gap: 10px; margin-top: 30px; }
.brand-point { display: flex; align-items: center; gap: 10px; color: rgba(255,255,255,.9); font-size: 13px; }
.brand-point svg { color: #71e6d3; flex: 0 0 auto; }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 44px; background: #fff; }
.login-card { width: min(440px, 100%); }
.login-card-header { margin-bottom: 28px; }
.login-card-header h1 { margin: 0 0 8px; font-size: 30px; letter-spacing: -.02em; }
.login-card-header .subtitle { margin: 0; color: var(--muted); }
.login-footer { margin-top: 24px; text-align: center; color: var(--muted); font-size: 12px; }
.login-secure { display: inline-flex; align-items: center; justify-content: center; gap: 7px; margin-top: 15px; color: #64748B; font-size: 12px; }
.password-wrap { position: relative; }
.password-wrap .field input { padding-right: 48px; }
.password-toggle { position: absolute; right: 6px; top: 3px; width: 38px; height: 38px; display: grid; place-items: center; background: transparent; color: #64748B; border-radius: 7px; cursor: pointer; }
.password-toggle:hover { background: #F8FAFC; color: var(--navy); }

/* App shell */
.app-shell { min-height: 100vh; }
.sidebar {
  width: var(--sidebar-width);
  background: var(--navy);
  color: #fff;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  padding: 16px 12px 14px;
  box-shadow: 8px 0 30px rgba(0, 64, 128, .10);
}
.sidebar-brand { display: flex; align-items: center; gap: 9px; padding: 7px 9px 16px; margin-bottom: 9px; }
.sidebar-logo { display: block; width: 156px; max-height: 58px; object-fit: contain; object-position: left center; }
.sidebar-brand-mark { display: none; width: 44px; height: 44px; object-fit: contain; }
.nav { display: grid; gap: 4px; }
.nav a, .sidebar-footer a {
  position: relative;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 9px;
  color: rgba(255,255,255,.84);
  font-size: 13px;
  font-weight: 650;
  transition: background-color .16s ease, color .16s ease, transform .16s ease;
}
.nav a svg, .sidebar-footer a svg { flex: 0 0 auto; width: 18px; height: 18px; }
.nav a:hover, .nav a.active { background: var(--teal); color: #fff; }
.nav a.active { box-shadow: 0 8px 16px rgba(217,119,35,.16); }
.sidebar-spacer { flex: 1; min-height: 18px; }
.sidebar-footer { border-top: 1px solid rgba(255,255,255,.12); padding-top: 10px; display: grid; gap: 4px; }
.sidebar-toggle {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 9px;
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.86);
  cursor: pointer;
  margin-top: 4px;
}
.sidebar-toggle:hover { background: rgba(255,255,255,.1); color: #fff; }
.main { margin-left: var(--sidebar-width); min-width: 0; min-height: 100vh; }
.topbar {
  height: var(--header-height);
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(12px);
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mobile-menu-btn { display: none; }
.topbar-title { min-width: 0; color: var(--navy); font-size: 17px; font-weight: 800; white-space: nowrap; }
.topbar-search {
  flex: 1;
  max-width: 430px;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: #F8FAFC;
  color: #94A3B8;
  padding: 0 14px;
  font-size: 12px;
}
.topbar-search svg { flex: 0 0 auto; }
.topbar-search span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  position: relative;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: #fff;
  color: var(--navy);
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, transform .16s ease;
}
.icon-btn:hover { background: #F8FAFC; border-color: var(--border-strong); transform: translateY(-1px); }
.icon-badge { position: absolute; top: 1px; right: 0; min-width: 8px; height: 8px; padding: 0 2px; border-radius: 999px; background: #EF4444; border: 2px solid #fff; }
.avatar {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 50%; background: var(--teal); color: #fff; font-weight: 800;
  border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border);
}
.avatar:hover { background: var(--teal-dark); }

/* Content / cards */
.content { width: min(100%, var(--content-max)); margin: 0 auto; padding: 28px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.page-heading h1 { margin: 0; color: var(--navy); font-size: clamp(24px, 2.2vw, 30px); line-height: 1.2; letter-spacing: -.02em; }
.page-heading p { margin: 7px 0 0; color: var(--muted); }
.page-heading-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.grid { display: grid; gap: 18px; }
.section-gap { margin-top: 18px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}
.card-hover:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.soft-card { box-shadow: none; background: #F8FAFC; }
.ui-panel-text { margin: 15px 0 0; }
.section-title-gap { margin-top: 10px !important; }
.card h2, .card h3 { margin: 0 0 12px; color: var(--navy); }
.card h2 { font-size: 17px; }
.card h3 { font-size: 15px; }
.card p:last-child { margin-bottom: 0; }
.card-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-toolbar .muted { margin: 0; }
.metric-card { min-height: 138px; display: flex; flex-direction: column; justify-content: space-between; }
.metric-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.metric-label { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.metric-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; background: var(--teal-soft); color: var(--teal-dark); }
.metric-value { margin-top: 8px; color: var(--navy); font-size: 30px; font-weight: 850; letter-spacing: -.03em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.status { display: inline-flex; align-items: center; min-height: 28px; padding: 5px 9px; border-radius: 999px; font-size: 11px; line-height: 1; font-weight: 800; background: var(--info-soft); color: #1D4ED8; }
.badge { display: inline-flex; align-items: center; gap: 5px; min-height: 26px; padding: 5px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.badge-success { background: var(--success-soft); color: #166534; }
.badge-warning { background: var(--warning-soft); color: #92400E; }
.badge-danger { background: var(--danger-soft); color: #991B1B; }
.badge-info { background: var(--info-soft); color: #1D4ED8; }
.badge-neutral { background: #F1F5F9; color: #475569; }

/* Tables */
.table-wrap { width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.table { width: 100%; min-width: 680px; border-collapse: collapse; }
.table th, .table td { padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { background: #F8FAFC; color: #475569; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.table td { color: #334155; font-size: 13px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #FAFCFD; }

/* Component system */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--border); }
.tab { position: relative; min-height: 42px; padding: 10px 12px; background: transparent; color: var(--muted); font-weight: 750; white-space: nowrap; cursor: pointer; }
.tab::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; border-radius: 2px; background: transparent; }
.tab[aria-selected="true"], .tab:hover { color: var(--navy); }
.tab[aria-selected="true"]::after { background: var(--teal); }
.tab-panel[hidden] { display: none; }
.dropdown { position: relative; }
.dropdown-menu { min-width: 190px; position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; padding: 6px; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); }
.dropdown-menu a, .dropdown-menu button { width: 100%; display: flex; align-items: center; gap: 8px; padding: 9px 10px; background: transparent; color: var(--text); border-radius: 7px; text-align: left; cursor: pointer; font-size: 13px; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: #F8FAFC; }
.pagination { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; }
.pagination-actions { display: flex; gap: 5px; }
.pagination button { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 7px; background: #fff; color: var(--navy); cursor: pointer; }
.pagination button[aria-current="page"] { background: var(--teal); border-color: var(--teal); color: #fff; font-weight: 800; }
.empty { min-height: 190px; display: grid; place-items: center; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 24px; background: #FCFDFE; }
.loading-state { min-height: 160px; display: grid; place-items: center; gap: 10px; text-align: center; color: var(--muted); }
.error-state { min-height: 160px; display: grid; place-items: center; text-align: center; padding: 24px; border: 1px solid #FECACA; border-radius: var(--radius-sm); background: var(--danger-soft); color: #991B1B; }
.error-state strong { display: block; margin-bottom: 5px; color: #7F1D1D; }
.loading-spinner { width: 22px; height: 22px; border: 2px solid #D7E1E8; border-top-color: var(--teal); border-radius: 50%; animation: spin .8s linear infinite; }
.date-picker { position: relative; }
.date-picker input { padding-right: 42px; }
.confirm-dialog { width: min(460px, calc(100vw - 32px)); }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-icon { width: 46px; height: 46px; display: grid; place-items: center; margin: 0 auto 10px; border-radius: 50%; background: #EEF6F7; color: var(--teal-dark); }
.empty strong { display: block; margin-bottom: 5px; color: var(--text); font-size: 14px; }
.skeleton { position: relative; overflow: hidden; min-height: 15px; border-radius: 6px; background: #E9EEF3; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent); animation: shimmer 1.35s infinite; }
.skeleton-line { width: 100%; height: 12px; margin-bottom: 9px; }
.skeleton-line.short { width: 42%; }
@keyframes shimmer { 100% { transform: translateX(100%); } }

/* Modal / drawer / toast / confirm */
.modal-backdrop, .drawer-backdrop { position: fixed; inset: 0; z-index: 80; background: rgba(15, 23, 42, .42); display: none; }
.modal-backdrop.is-open, .drawer-backdrop.is-open { display: block; }
.modal { position: fixed; inset: 50% auto auto 50%; z-index: 90; width: min(560px, calc(100vw - 32px)); max-height: min(760px, calc(100vh - 32px)); transform: translate(-50%, -50%) scale(.98); opacity: 0; pointer-events: none; overflow: auto; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); transition: opacity .18s ease, transform .18s ease; }
.modal.is-open { opacity: 1; transform: translate(-50%, -50%) scale(1); pointer-events: auto; }
.modal-header, .modal-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; }
.modal-header { border-bottom: 1px solid var(--border); }
.modal-footer { border-top: 1px solid var(--border); justify-content: flex-end; }
.modal-body { padding: 18px; }
.modal-title { margin: 0; color: var(--navy); font-size: 17px; }
.close-btn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: #F8FAFC; color: #64748B; cursor: pointer; }
.close-btn:hover { background: #EEF2F7; color: var(--navy); }
.drawer { position: fixed; inset: 0 0 0 auto; z-index: 90; width: min(440px, 92vw); background: #fff; box-shadow: var(--shadow-lg); transform: translateX(100%); transition: transform .22s ease; overflow: auto; }
.drawer.is-open { transform: translateX(0); }
.drawer-header, .drawer-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; }
.drawer-header { border-bottom: 1px solid var(--border); }
.drawer-footer { border-top: 1px solid var(--border); justify-content: flex-end; }
.drawer-body { padding: 18px; }
.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 120; display: grid; gap: 10px; width: min(380px, calc(100vw - 32px)); }
.toast { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; padding: 12px 14px; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); }
.toast strong { display: block; margin-bottom: 2px; color: var(--text); font-size: 13px; }
.toast p { margin: 0; color: var(--muted); font-size: 12px; }
.toast-success svg { color: var(--success); }
.toast-error svg { color: var(--danger); }
.toast-info svg { color: var(--info); }

/* Install */
.install-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.install-card { width: min(640px, 100%); padding: 30px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.install-card .brand-logo { width: 180px; margin-bottom: 18px; }
.install-card h1 { margin: 0 0 8px; color: var(--navy); }
.install-card p { color: var(--muted); }
.checklist { margin: 0 0 24px; padding-left: 20px; color: var(--muted); line-height: 1.8; }

/* Mobile navigation overlay */
.mobile-sidebar-overlay { position: fixed; inset: 0; z-index: 35; display: none; background: rgba(15, 23, 42, .42); }

@media (max-width: 1180px) {
  :root { --sidebar-width: 88px; }
  .sidebar { padding-left: 8px; padding-right: 8px; }
  .sidebar-brand { justify-content: center; padding-left: 0; padding-right: 0; }
  .sidebar-logo { display: none; }
  .sidebar-brand-mark { display: block; }
  .nav a, .sidebar-footer a { justify-content: center; padding-left: 8px; padding-right: 8px; }
  .nav a span, .sidebar-footer a span, .sidebar-toggle span { display: none; }
  .sidebar-toggle { padding: 0; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { padding: 0 20px; }
  .content { padding: 22px; }
}

@media (max-width: 880px) {
  :root { --sidebar-width: 0px; --header-height: 64px; }
  .sidebar { width: 280px; transform: translateX(-100%); transition: transform .22s ease; box-shadow: 20px 0 50px rgba(15,23,42,.24); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-brand { justify-content: flex-start; padding-left: 8px; }
  .sidebar-logo { display: block; width: 156px; }
  .sidebar-brand-mark { display: none; }
  .nav a, .sidebar-footer a { justify-content: flex-start; padding-left: 12px; padding-right: 12px; }
  .nav a span, .sidebar-footer a span, .sidebar-toggle span { display: inline; }
  .sidebar-toggle { padding: 0 12px; }
  .mobile-sidebar-overlay.is-open { display: block; }
  .mobile-menu-btn { display: grid; }
  .topbar-title { font-size: 16px; }
  .topbar-search { display: none; }
}

@media (max-width: 760px) {
  .login-page { grid-template-columns: 1fr; }
  .login-brand { min-height: 300px; padding: 34px 24px 30px; }
  .brand-logo { width: 190px; margin-bottom: 22px; }
  .brand-title { font-size: 27px; }
  .brand-text { font-size: 14px; }
  .brand-points { display: none; }
  .login-panel { padding: 32px 20px 40px; }
  .login-card-header h1 { font-size: 26px; }
  .form-grid { grid-template-columns: 1fr; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .page-heading { flex-direction: column; align-items: flex-start; }
  .page-heading-actions, .page-heading-actions .btn { width: 100%; }
  .page-heading-actions .btn { justify-content: center; }
  .content { padding: 18px 14px 28px; }
  .card { padding: 16px; }
  .metric-value { font-size: 27px; }
  .topbar { padding: 0 12px; }
  .topbar-actions { gap: 6px; }
  .icon-btn, .avatar { width: 38px; height: 38px; }
  .toast-stack { right: 16px; bottom: 16px; }
}

@media (max-width: 430px) {
  .login-brand { min-height: 260px; padding: 28px 20px; }
  .login-panel { padding-left: 16px; padding-right: 16px; }
  .form-footer { flex-direction: column; align-items: stretch; }
  .form-footer .btn { width: 100%; }
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; }
  .tabs { margin-inline: -16px; padding-inline: 10px; }
}

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

/* FASE 3 — Dashboard */
.dashboard-toolbar .input-sm { min-width: 145px; }
.dashboard-chart { min-height: 220px; display: flex; align-items: flex-end; gap: 10px; padding: 20px 8px 4px; border-bottom: 1px solid var(--border); }
.dashboard-chart-bar { flex: 1 1 0; min-width: 10px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 7px; height: 190px; }
.dashboard-chart-value { font-size: 11px; font-weight: 800; color: var(--navy); }
.dashboard-chart-column { width: min(34px, 70%); min-height: 3px; height: var(--chart-height); background: var(--teal); border-radius: 7px 7px 2px 2px; }
.dashboard-chart-label { color: var(--muted); font-size: 10px; font-weight: 700; }
.status-list { display: grid; gap: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.status-list > div { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px; border-bottom: 1px solid var(--border); color: var(--text); font-size: 13px; }
.status-list > div:last-child { border-bottom: 0; }
.status-list > div > span:first-child { color: var(--muted); font-weight: 650; }
.dashboard-filter-note { margin-bottom: 18px; }
@media (max-width: 760px) {
  .dashboard-toolbar { width: 100%; }
  .dashboard-toolbar .input-sm { flex: 1; min-width: 0; }
  .dashboard-chart { gap: 5px; padding-inline: 2px; }
  .dashboard-chart-value { font-size: 9px; }
  .dashboard-chart-label { font-size: 9px; }
  .dashboard-chart-column { width: 70%; }
}

/* FASE 4 — Agenda */
.agenda-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.compact-select{min-width:110px;width:auto}.agenda-toolbar-card{padding:14px 16px}.agenda-filters{display:grid;grid-template-columns:repeat(6,minmax(120px,1fr));gap:10px;align-items:end}.agenda-filters label,.agenda-modal label,.agenda-modal .field-help{display:flex;flex-direction:column;gap:6px;font-size:12px;font-weight:700;color:#475569}.agenda-calendar-card{padding:0;overflow:hidden}.agenda-calendar{min-height:430px}.agenda-days{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));min-width:840px}.agenda-day-column{border-right:1px solid var(--border);min-height:520px}.agenda-day-column:last-child{border-right:0}.agenda-day-column header{padding:12px;border-bottom:1px solid var(--border);background:#f8fafc;color:var(--navy);text-align:center;position:sticky;top:0;z-index:2}.agenda-day-body{padding:8px;display:flex;flex-direction:column;gap:7px}.agenda-event{width:100%;border:1px solid currentColor;border-left-width:4px;border-radius:8px;padding:8px;text-align:left;background:#fff;display:flex;flex-direction:column;gap:3px;cursor:pointer;color:#2563eb}.agenda-event strong{color:#1f2937;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.agenda-event span,.agenda-event em{font-size:11px;font-style:normal;color:#64748b}.agenda-event-time{font-weight:700;color:inherit!important}.agenda-event.badge-success{color:#15803d}.agenda-event.badge-warning{color:#b45309}.agenda-event.badge-danger{color:#dc2626}.agenda-event.badge-info{color:#2563eb}.agenda-block{border:1px dashed #94a3b8;background:#f8fafc;border-radius:8px;padding:8px;display:flex;flex-direction:column;gap:3px;color:#475569;font-size:11px}.agenda-block strong{color:#334155}.agenda-no-items{padding:20px 8px;text-align:center;color:#94a3b8;font-size:12px}.agenda-month-grid{display:grid;grid-template-columns:repeat(7,minmax(110px,1fr));min-width:770px}.agenda-month-head{padding:10px;text-align:center;font-weight:700;font-size:12px;background:#f8fafc;border-bottom:1px solid var(--border);color:#475569}.agenda-month-day{min-height:125px;border-right:1px solid var(--border);border-bottom:1px solid var(--border);padding:7px;display:flex;flex-direction:column;gap:5px}.agenda-month-day.is-muted{background:#fafafa;opacity:.55}.agenda-day-number{font-weight:800;color:var(--navy);font-size:12px}.agenda-month-day .agenda-event{padding:5px;border-left-width:3px}.agenda-month-day .agenda-event strong,.agenda-month-day .agenda-event em,.agenda-month-day .agenda-event span{font-size:10px}.inline-form{display:grid;grid-template-columns:1.5fr 1.2fr 1fr auto;gap:8px;margin-bottom:16px}.form-span-2{grid-column:span 2}.field-help{font-size:11px!important;font-weight:400!important;color:#64748b!important}.soft-card{box-shadow:none!important;background:#f8fafc}.agenda-modal{width:min(760px,calc(100vw - 24px))}.agenda-modal .modal-body{max-height:calc(100vh - 180px);overflow:auto}
@media(max-width:1100px){.agenda-filters{grid-template-columns:repeat(3,minmax(120px,1fr))}.agenda-days{min-width:720px}.agenda-month-grid{min-width:700px}}
@media(max-width:760px){.agenda-actions{width:100%}.agenda-actions .btn{flex:1}.agenda-filters{grid-template-columns:1fr 1fr}.inline-form{grid-template-columns:1fr}.form-span-2{grid-column:auto}.agenda-days{grid-template-columns:1fr;min-width:0}.agenda-day-column{border-right:0;border-bottom:1px solid var(--border);min-height:180px}.agenda-day-column header{position:static}.agenda-month-grid{grid-template-columns:repeat(2,minmax(140px,1fr));min-width:0}.agenda-month-head{display:none}.agenda-month-day{min-height:150px}.agenda-toolbar-card{overflow:auto}.agenda-filters{min-width:520px}.agenda-calendar{overflow:auto}}
@media(max-width:430px){.agenda-filters{grid-template-columns:1fr;min-width:0}.agenda-actions .btn{flex:0 0 auto}.compact-select{width:100%}.agenda-modal .form-grid{grid-template-columns:1fr}}

/* FASE 5 — Pacientes */
.patient-actions{flex-wrap:wrap}.patients-toolbar{display:grid;grid-template-columns:minmax(260px,2fr) minmax(150px,1fr) minmax(180px,1fr) auto;gap:12px;align-items:end}.patients-search{min-width:0}.patients-table .patient-name-link{display:flex;flex-direction:column;gap:3px;border:0;background:none;padding:0;text-align:left;color:inherit;cursor:pointer}.patient-name-link strong{color:var(--navy)}.patient-name-link span{font-size:12px;color:#6b7280}.table-actions{display:flex;justify-content:flex-end;gap:6px}.table-actions-head{text-align:right}.pagination{display:flex;align-items:center;justify-content:flex-end;gap:10px;padding:16px 0 2px}.pagination-label{font-size:13px;color:#6b7280}.modal-wide{width:min(1080px,calc(100vw - 32px));max-height:calc(100vh - 32px)}.patient-modal-body{overflow:auto}.patient-tabs{display:flex;gap:4px;overflow-x:auto;padding:0 20px;border-bottom:1px solid #e5e7eb;background:#fff}.patient-tabs .tab{white-space:nowrap}.patient-section-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:18px}.patient-section-head h3{margin:0 0 4px}.stack-list{display:grid;gap:10px;margin-top:18px}.stack-item{display:flex;align-items:center;gap:14px;justify-content:space-between;border:1px solid #e5e7eb;border-radius:10px;padding:12px 14px;background:#fff}.stack-item>strong,.stack-item>span{display:block}.stack-item span{font-size:13px;color:#6b7280}.stack-item a{flex:0 0 auto}.patient-subform{display:grid;grid-template-columns:150px 1fr 1fr auto auto;gap:8px;align-items:center}.compact-empty{margin-top:10px}.checkbox{display:flex;align-items:center;gap:8px;min-height:42px}.checkbox input{width:16px;height:16px}.patients-table-wrap.hidden{display:none}
@media (max-width:900px){.patients-toolbar{grid-template-columns:1fr 1fr}.patients-search{grid-column:1/-1}.patient-subform{grid-template-columns:1fr 1fr}.patient-subform .btn{grid-column:1/-1;justify-self:start}.modal-wide{width:calc(100vw - 20px);max-height:calc(100vh - 20px)}}
@media (max-width:640px){.patient-actions .btn{flex:1}.patients-toolbar{grid-template-columns:1fr}.patients-table thead{display:none}.patients-table,.patients-table tbody,.patients-table tr,.patients-table td{display:block;width:100%}.patients-table tr{padding:12px 0;border-bottom:1px solid #e5e7eb}.patients-table td{border:0!important;padding:5px 0}.patients-table td:nth-child(2)::before{content:'Documento: ';font-weight:600}.patients-table td:nth-child(3)::before{content:'Telefone: ';font-weight:600}.patients-table td:nth-child(4)::before{content:'Unidade: ';font-weight:600}.patients-table td:nth-child(5)::before{content:'Status: ';font-weight:600}.table-actions{justify-content:flex-start;margin-top:4px}.patient-tabs{padding:0 12px}.patient-modal-body{padding:14px}.stack-item{align-items:flex-start;flex-direction:column}.stack-item a{align-self:flex-start}.pagination{justify-content:center}.pagination-label{font-size:12px}}

/* FASE 6 — Prontuário */
.records-patient-bar{display:grid;grid-template-columns:minmax(280px,1fr) 2fr;gap:18px;align-items:end;margin-bottom:16px}.records-patient-search{display:grid;gap:7px;font-weight:600;color:#374151}.records-patient-summary{min-height:58px;border:1px solid var(--border);border-radius:12px;background:#fff;padding:12px 14px;display:flex;flex-direction:column;justify-content:center;gap:3px}.records-patient-summary strong{color:var(--navy)}.records-patient-summary span{font-size:13px;color:#6b7280}.records-shell{display:block}.records-tabs{display:flex;gap:4px;overflow-x:auto;border-bottom:1px solid var(--border);margin-bottom:16px}.records-tabs .tab{white-space:nowrap}.record-panel>.card{min-height:220px}.clinical-form{margin-top:4px}.record-editor{font-family:Inter,system-ui,sans-serif;line-height:1.55;min-height:280px;resize:vertical}.form-actions{display:flex;justify-content:flex-end;gap:8px}.clinical-actions{display:flex;gap:7px;align-items:center;flex-wrap:wrap}.clinical-record-item{align-items:flex-start}.clinical-record-item>div:first-child{display:grid;gap:4px}.clinical-record-item>div:first-child span{display:block}.clinical-timeline{position:relative;display:grid;gap:14px;padding:8px 0 8px 22px}.clinical-timeline::before{content:"";position:absolute;left:8px;top:12px;bottom:12px;width:2px;background:#e5e7eb}.timeline-item{position:relative}.timeline-marker{position:absolute;left:-19px;top:15px;width:12px;height:12px;border-radius:50%;background:var(--brand-orange);border:3px solid #fff;box-shadow:0 0 0 1px #cbd5e1}.timeline-card{border:1px solid var(--border);border-radius:12px;padding:14px;background:#fff}.timeline-head{display:flex;justify-content:space-between;gap:12px;align-items:flex-start}.timeline-head strong{color:#1f2937}.timeline-head span,.timeline-meta{font-size:12px;color:#6b7280}.timeline-meta{margin-top:5px}.timeline-actions{margin-top:10px}.badge-success{background:#e7f7f3;color:#087f6c}.clinical-table{margin-top:18px}.notice.info{display:flex;flex-direction:column;gap:4px}.notice.warning{display:flex;flex-direction:column;gap:4px}.records-patient-bar.hidden,.records-shell.hidden{display:none}
@media (max-width:900px){.records-patient-bar{grid-template-columns:1fr}.timeline-head{flex-direction:column}.clinical-actions{justify-content:flex-start}}
@media (max-width:640px){.records-tabs{margin-inline:-12px;padding-inline:10px}.records-patient-bar{gap:12px}.clinical-form .form-span-2{grid-column:1/-1}.record-editor{min-height:220px}.timeline-card{padding:12px}.clinical-actions .btn{flex:1}.records-patient-summary{min-height:50px}}
.records-template-box{margin-top:20px;border-top:1px solid var(--border);padding-top:16px}.records-template-box summary{cursor:pointer;font-weight:700;color:var(--navy);margin-bottom:12px}.records-template-box[open] summary{margin-bottom:16px}

/* ================= FASE 7 — CONSULTAS ================= */
.consultation-grid{display:grid;grid-template-columns:minmax(280px,.85fr) minmax(420px,1.15fr);gap:18px;margin-top:18px}.consultation-toolbar{margin-bottom:18px}.consultation-tabs{display:flex;gap:6px;flex-wrap:wrap;border-bottom:1px solid var(--border,#e5e7eb);margin:0 -20px 18px;padding:0 20px}.consultation-tabs .tab-btn{border:0;background:transparent;padding:11px 14px;border-bottom:2px solid transparent;color:var(--muted,#64748b);font:inherit;cursor:pointer}.consultation-tabs .tab-btn.active{color:var(--navy);border-bottom-color:var(--brand-orange);font-weight:700}.consult-panel{min-height:120px}.consultation-summary{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}.consultation-summary .summary-item{border:1px solid var(--border,#e5e7eb);border-radius:10px;padding:14px;background:#fff}.consultation-summary strong{display:block;margin-bottom:4px}.consultation-summary span{display:block;color:var(--muted,#64748b);font-size:.9rem}.consultation-card{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;padding:13px;border:1px solid var(--border,#e5e7eb);border-radius:10px;background:#fff}.consultation-card+.consultation-card{margin-top:9px}.consultation-card .main{min-width:0}.consultation-card .title{font-weight:700}.consultation-card .meta{font-size:.86rem;color:var(--muted,#64748b);margin-top:3px}.consultation-card .actions{display:flex;gap:6px;flex-wrap:wrap;justify-content:flex-end}.chat-box{height:320px;overflow:auto;border:1px solid var(--border,#e5e7eb);border-radius:10px;padding:12px;background:#f8fafc}.chat-message{max-width:82%;padding:9px 11px;border-radius:10px;background:#fff;border:1px solid var(--border,#e5e7eb);margin-bottom:9px}.chat-message.mine{margin-left:auto;background:#eafaf6;border-color:#b8eee4}.chat-message .meta{font-size:.75rem;color:#64748b;margin-bottom:3px}.chat-form{display:grid;grid-template-columns:1fr auto;gap:8px;margin-top:10px}.check-row{display:flex;gap:8px;align-items:flex-start;line-height:1.45}.status-pill{display:inline-flex;align-items:center;border-radius:999px;padding:6px 10px;background:#eef2f7;color:#334155;font-size:.82rem;font-weight:700}.btn-danger{background:#b42318;color:#fff;border-color:#b42318}.btn-danger:hover{background:#8f1c13}.hidden{display:none!important}
@media(max-width:980px){.consultation-grid{grid-template-columns:1fr}.consultation-summary{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:640px){.consultation-summary{grid-template-columns:1fr}.consultation-card{flex-direction:column}.consultation-card .actions{justify-content:flex-start}.chat-form{grid-template-columns:1fr}.consultation-tabs{overflow-x:auto;flex-wrap:nowrap}.consultation-tabs .tab-btn{white-space:nowrap}.page-consultations .form-grid{grid-template-columns:1fr}.page-consultations .form-span-2{grid-column:auto}}

/* ================= FASE 8 — FINANCEIRO ================= */
.finance-kpis{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px;margin-bottom:18px}.finance-kpi{display:flex;flex-direction:column;gap:7px}.finance-kpi span{font-size:13px;color:#64748b}.finance-kpi strong{font-size:24px;color:var(--navy)}.finance-kpi small{font-size:12px;color:#94a3b8}.finance-toolbar-card{padding:0;overflow:hidden}.finance-tabs{display:flex;gap:4px;overflow-x:auto;padding:0 20px}.finance-tabs .tab-btn{border:0;background:transparent;padding:14px 13px;border-bottom:2px solid transparent;color:#64748b;font:inherit;cursor:pointer;white-space:nowrap}.finance-tabs .tab-btn.active{color:var(--navy);border-bottom-color:var(--brand-orange);font-weight:700}.finance-panel{margin-top:18px}.finance-grid-main{display:grid;grid-template-columns:minmax(0,2fr) minmax(280px,1fr);gap:18px}.finance-filters{display:grid;grid-template-columns:minmax(0,2fr) minmax(170px,1fr);gap:10px;margin:14px 0}.finance-list{display:grid;gap:9px}.finance-row{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:13px 14px;border:1px solid var(--border,#e5e7eb);border-radius:10px;background:#fff}.finance-row>div:first-child{min-width:0;display:grid;gap:4px}.finance-row>div:first-child span{font-size:12px;color:#64748b}.finance-row-right{display:flex;align-items:center;gap:9px;flex-wrap:wrap;justify-content:flex-end}.finance-actions{display:flex;gap:6px;flex-wrap:wrap;justify-content:flex-end}.finance-status-open{background:#eef5ff;color:#245a9b}.finance-status-overdue{background:#fff4e5;color:#9a5b00}.finance-status-paid,.finance-status-completed{background:#e7f7f3;color:#087f6c}.finance-status-cancelled{background:#f1f5f9;color:#64748b}.finance-status-pending{background:#fff7ed;color:#9a3412}.finance-status-approved{background:#e7f7f3;color:#087f6c}.finance-status-inflow{background:#e7f7f3;color:#087f6c}.finance-status-outflow{background:#fff4e5;color:#9a5b00}.finance-positive{color:#087f6c}.finance-negative{color:#b42318}.finance-delinquency{display:grid;gap:8px}.finance-delinquency-row{display:flex;justify-content:space-between;gap:12px;padding:10px 0;border-bottom:1px solid var(--border,#e5e7eb)}.finance-form-grid{grid-template-columns:repeat(2,minmax(0,1fr));margin-bottom:16px}.finance-form-grid .form-span-2{grid-column:1/-1}.finance-form-grid textarea{resize:vertical}.page-financeiro .card-toolbar{gap:14px}
@media(max-width:980px){.finance-kpis{grid-template-columns:repeat(2,minmax(0,1fr))}.finance-grid-main{grid-template-columns:1fr}}
@media(max-width:640px){.finance-kpis{grid-template-columns:1fr}.finance-tabs{padding:0 10px}.finance-filters{grid-template-columns:1fr}.finance-row{align-items:flex-start;flex-direction:column}.finance-row-right{justify-content:flex-start;width:100%}.finance-actions{justify-content:flex-start}.finance-form-grid{grid-template-columns:1fr}.finance-form-grid .form-span-2{grid-column:auto}}

/* ================= FASE 9 — CONVÊNIOS & TISS ================= */
.tiss-kpis{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px;margin-bottom:18px}.tiss-kpi{display:flex;flex-direction:column;gap:6px}.tiss-kpi span{font-size:13px;color:#64748b}.tiss-kpi strong{font-size:25px;color:var(--navy)}.tiss-kpi small{font-size:12px;color:#94a3b8}.tiss-card{padding:0;overflow:hidden}.tiss-tabs{display:flex;gap:4px;overflow-x:auto;border-bottom:1px solid var(--border,#e5e7eb);padding:0 20px}.tiss-tab{border:0;background:transparent;padding:14px 13px;border-bottom:2px solid transparent;color:#64748b;font:inherit;cursor:pointer;white-space:nowrap}.tiss-tab.active{color:var(--navy);border-bottom-color:var(--brand-orange);font-weight:700}.tiss-panel{padding:20px}.tiss-panel.hidden{display:none}.tiss-list{display:grid;gap:9px;margin-top:14px}.tiss-row{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:14px;border:1px solid var(--border,#e5e7eb);border-radius:10px;background:#fff}.tiss-row>div:first-child{min-width:0;display:grid;gap:4px}.tiss-row>div:first-child span{font-size:12px;color:#64748b}.tiss-guide-row{align-items:center}.tiss-guide-row .row-actions,.tiss-row .row-actions{display:flex;align-items:center;justify-content:flex-end;gap:7px;flex-wrap:wrap}.status-draft{background:#f1f5f9;color:#475569}.status-validated{background:#e7f7f3;color:#087f6c}.status-submitted{background:#eef5ff;color:#245a9b}.status-returned{background:#fff7ed;color:#9a3412}.status-glosa{background:#fff4e5;color:#9a5b00}.status-closed{background:#e2e8f0;color:#334155}.status-open{background:#fff4e5;color:#9a5b00}.status-appealed{background:#eef5ff;color:#245a9b}.status-accepted{background:#e7f7f3;color:#087f6c}.status-rejected{background:#fff4e5;color:#9a5b00}.section-head{display:flex;justify-content:space-between;gap:14px;align-items:center}.section-head h2{margin:0 0 4px}.section-head p{margin:0;color:#64748b;font-size:13px}.toolbar{display:flex;gap:10px;align-items:center;flex-wrap:wrap}.toolbar .input:first-child{flex:1;min-width:220px}.tiss-check-list{display:grid;gap:8px;max-height:220px;overflow:auto;padding:10px;border:1px solid var(--border,#e5e7eb);border-radius:9px;background:#f8fafc}.check-item{display:flex;gap:8px;align-items:flex-start;font-weight:500!important}.muted{color:#64748b}.modal-lg{max-width:820px}.form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.form-grid label{display:flex;flex-direction:column;gap:6px;font-size:12px;font-weight:700;color:#475569}.form-grid .form-span-2{grid-column:1/-1}.form-grid textarea{resize:vertical}
@media(max-width:900px){.tiss-kpis{grid-template-columns:repeat(2,minmax(0,1fr))}.tiss-row{align-items:flex-start;flex-direction:column}.tiss-guide-row .row-actions,.tiss-row .row-actions{justify-content:flex-start;width:100%}}
@media(max-width:640px){.tiss-kpis{grid-template-columns:1fr}.tiss-tabs{padding:0 10px}.tiss-panel{padding:14px}.section-head{align-items:flex-start;flex-direction:column}.section-head .btn{width:100%}.toolbar{display:grid;grid-template-columns:1fr}.toolbar .input:first-child{min-width:0}.form-grid{grid-template-columns:1fr}.form-grid .form-span-2{grid-column:auto}.tiss-row .row-actions .btn{flex:1}.modal-lg{width:calc(100vw - 20px)}}

/* FASE 10 — relatórios, administração, equipe e suporte */
.stack-actions{display:flex;flex-wrap:wrap;gap:10px}.section-gap{margin-top:18px}.page-heading-actions{display:flex;gap:10px;align-items:center}.table-wrap{overflow:auto}.metric-card .metric-value{min-height:38px}.form-actions{display:flex;align-items:end;gap:10px;flex-wrap:wrap}.notice{margin:12px 0}.status-list{display:grid;gap:10px}.status-list>div{display:flex;justify-content:space-between;gap:12px;padding:10px 0;border-bottom:1px solid var(--border,#e5e7eb)}
@media(max-width:760px){.grid.grid-4{grid-template-columns:1fr 1fr}.page-heading{gap:12px}.page-heading-actions,.form-actions{width:100%}.page-heading-actions .btn,.form-actions .btn{flex:1}.table{min-width:680px}}
@media(max-width:480px){.grid.grid-4{grid-template-columns:1fr}.stack-actions .btn{width:100%}}

/* FASE 11 — Relatórios */
.report-toolbar{margin-bottom:18px}.report-kpis{grid-template-columns:repeat(4,minmax(0,1fr))}.report-kpi .metric-help{margin-top:6px;color:#6b7280;font-size:12px;min-height:16px}.report-export-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}.report-export-card{border:1px solid #e5e7eb;border-radius:12px;padding:14px;background:#fff;display:flex;align-items:center;justify-content:space-between;gap:12px}.report-export-card strong{color:#1f2937}.report-export-card .stack-actions{display:flex;gap:6px}.section-heading{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:14px}.section-heading h2{margin:0 0 4px}.section-heading p{margin:0;color:#6b7280;font-size:13px}.btn-sm{padding:7px 10px;font-size:12px}.status-pill.status-queued{background:#eef2ff;color:#3730a3}.status-pill.status-running{background:#ecfeff;color:#0f766e}.status-pill.status-completed{background:#ecfdf5;color:#166534}.status-pill.status-failed{background:#fef2f2;color:#b91c1c}.status-pill.status-cancelled{background:#f3f4f6;color:#4b5563}
@media(max-width:1100px){.report-kpis{grid-template-columns:repeat(3,minmax(0,1fr))}.report-export-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:700px){.report-kpis,.report-export-grid{grid-template-columns:1fr}.report-export-card{align-items:flex-start;flex-direction:column}.section-heading{align-items:flex-start;flex-direction:column}.report-toolbar .form-actions{align-self:stretch}.report-toolbar .btn{width:100%}}

/* ================= FASE 12 — COMUNICAÇÃO ================= */
.comm-kpis{grid-template-columns:repeat(4,minmax(0,1fr))}.comm-tabs-card{overflow:hidden}.comm-tabs{display:flex;gap:4px;overflow-x:auto;border-bottom:1px solid var(--border,#e5e7eb);padding:0 20px}.comm-tab{border:0;background:transparent;padding:14px 13px;border-bottom:2px solid transparent;color:#64748b;font:inherit;cursor:pointer;white-space:nowrap}.comm-tab.active{color:var(--navy);border-bottom-color:var(--brand-orange);font-weight:700}.comm-panel{padding:20px}.comm-panel.hidden{display:none}.comm-list{display:grid;gap:8px}.comm-notification{display:flex;justify-content:space-between;gap:14px;padding:14px;border:1px solid var(--border,#e5e7eb);border-radius:10px;background:#fff}.comm-notification.unread{border-left:4px solid var(--brand-orange);background:#f8fffd}.comm-notification p{margin:5px 0;color:#475569}.comm-notification small,.comm-thread small,.comm-message small{color:#94a3b8}.comm-message-layout{display:grid;grid-template-columns:minmax(220px,.7fr) minmax(0,1.8fr);gap:14px}.comm-thread{display:flex;flex-direction:column;align-items:flex-start;gap:4px;padding:13px;border:1px solid var(--border,#e5e7eb);border-radius:10px;background:#fff;cursor:pointer;text-align:left;font:inherit}.comm-thread.active{border-color:var(--brand-orange);background:#f0fdfa}.comm-chat{min-height:420px;border:1px solid var(--border,#e5e7eb);border-radius:10px;display:grid;grid-template-rows:auto 1fr auto;overflow:hidden}.comm-chat-header{padding:13px 15px;border-bottom:1px solid var(--border,#e5e7eb);font-weight:700}.comm-chat-body{padding:14px;overflow:auto;display:grid;align-content:start;gap:9px;background:#f8fafc}.comm-message{max-width:78%;padding:10px 12px;border-radius:10px;background:#fff;border:1px solid #e5e7eb}.comm-message p{margin:5px 0;white-space:pre-wrap}.comm-chat-form{display:grid;grid-template-columns:1fr auto;gap:8px;padding:10px;border-top:1px solid var(--border,#e5e7eb)}.comm-preferences-form{max-width:760px}.nps-scale{display:grid;grid-template-columns:repeat(11,1fr);gap:6px;margin:18px 0}.nps-scale button{border:1px solid #d1d5db;background:#fff;border-radius:8px;padding:10px;cursor:pointer}.nps-scale button.selected{background:var(--navy);color:#fff;border-color:var(--navy)}.public-page{margin:0;min-height:100vh;background:#f5f7fa;font-family:Inter,system-ui,sans-serif}.public-shell{min-height:100vh;display:grid;place-items:center;padding:20px}.public-card{width:min(720px,100%);background:#fff;border:1px solid #e5e7eb;border-radius:16px;box-shadow:0 8px 30px rgba(15,23,42,.08);padding:32px}.nps-public{text-align:center}.nps-brand{font-weight:800;font-size:22px;color:var(--navy);margin-bottom:20px}.nps-public h1{margin-bottom:8px}.nps-public p{color:#64748b}.nps-public textarea{text-align:left;width:100%;margin-bottom:12px}.nps-public .btn{width:100%}.notification-badge{position:absolute;top:-3px;right:-3px;min-width:17px;height:17px;border-radius:999px;background:#d92d20;color:#fff;font-size:10px;display:grid;place-items:center}.icon-btn{position:relative}
@media(max-width:980px){.comm-kpis{grid-template-columns:repeat(2,minmax(0,1fr))}.comm-message-layout{grid-template-columns:1fr}.comm-chat{min-height:360px}}
@media(max-width:640px){.comm-kpis{grid-template-columns:1fr}.comm-tabs{padding:0 10px}.comm-panel{padding:14px}.comm-notification{align-items:flex-start;flex-direction:column}.comm-chat-form{grid-template-columns:1fr}.nps-scale{gap:3px}.nps-scale button{padding:8px 2px}.public-card{padding:22px}}

/* FASE 13 — Portal do Paciente */
.portal-body{margin:0;background:#f5f7fa;color:#1f2937;min-height:100vh;font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}.portal-shell{width:min(1180px,calc(100% - 32px));margin:0 auto;padding:32px 0 48px}.portal-brand{display:flex;align-items:center;gap:14px;margin-bottom:24px}.portal-brand img{width:170px;height:auto}.portal-brand div{display:flex;flex-direction:column;gap:4px}.portal-brand strong{color:var(--navy);font-size:18px}.portal-brand span{font-size:13px;color:#6b7280}.portal-card{background:#fff;border:1px solid #e5e7eb;border-radius:14px;box-shadow:0 8px 30px rgba(15,23,42,.06);padding:24px}.portal-card>h1{margin:0 0 8px;color:var(--navy)}.portal-form{max-width:520px;display:grid;gap:16px;margin-top:20px}.portal-form .btn{width:max-content}.portal-header{display:flex;align-items:center;justify-content:space-between;gap:16px}.portal-header h1{margin:0;color:var(--navy)}.eyebrow{margin:0 0 4px;text-transform:uppercase;letter-spacing:.08em;font-size:11px;color:var(--brand-orange-strong);font-weight:700}.portal-tabs{display:flex;gap:6px;overflow:auto;border-bottom:1px solid #e5e7eb;margin:24px -24px 20px;padding:0 24px}.portal-tabs .tab{border:0;background:transparent;padding:12px 14px;color:#64748b;white-space:nowrap;border-bottom:2px solid transparent;cursor:pointer}.portal-tabs .tab.active{color:var(--navy);border-bottom-color:var(--brand-orange);font-weight:700}.portal-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px;margin-bottom:18px}.portal-stat{border:1px solid #e5e7eb;border-radius:12px;padding:16px;display:flex;flex-direction:column;gap:8px}.portal-stat span{font-size:12px;color:#64748b}.portal-stat strong{font-size:20px;color:var(--navy)}.portal-inner-card{box-shadow:none}.portal-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:10px}.portal-message-form{display:grid;gap:10px;margin-top:18px}.portal-messages{display:grid;gap:10px;max-height:520px;overflow:auto}.portal-message{max-width:80%;padding:12px 14px;border:1px solid #e5e7eb;border-radius:12px;background:#f8fafc}.portal-message.mine{margin-left:auto;background:#effaf7;border-color:#c7eee6}.portal-message p{margin:7px 0;white-space:pre-wrap}.portal-message span{font-size:11px;color:#64748b}.portal-toast{position:fixed;right:20px;bottom:20px;padding:12px 16px;border-radius:10px;background:#1f2937;color:#fff;z-index:1000;box-shadow:0 8px 24px rgba(0,0,0,.18)}.portal-toast.success{background:#087f6d}.portal-toast.error{background:#b42318}@media(max-width:900px){.portal-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}@media(max-width:640px){.portal-shell{width:min(100% - 20px,1180px);padding:20px 0}.portal-card{padding:18px}.portal-tabs{margin-left:-18px;margin-right:-18px;padding-left:18px;padding-right:18px}.portal-grid{grid-template-columns:1fr}.portal-brand{align-items:flex-start;flex-direction:column}.portal-brand img{width:145px}.portal-header{align-items:flex-start}.portal-message{max-width:92%}}

/* FASE 13 — Portal do Paciente */
.portal-body{margin:0;background:#f5f7fa;color:#1f2937;min-height:100vh;font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}.portal-shell{width:min(1180px,calc(100% - 32px));margin:0 auto;padding:32px 0 48px}.portal-brand{display:flex;align-items:center;gap:14px;margin-bottom:24px}.portal-brand img{width:170px;height:auto}.portal-brand div{display:flex;flex-direction:column;gap:4px}.portal-brand strong{color:var(--navy);font-size:18px}.portal-brand span{font-size:13px;color:#6b7280}.portal-card{background:#fff;border:1px solid #e5e7eb;border-radius:14px;box-shadow:0 8px 30px rgba(15,23,42,.06);padding:24px}.portal-card>h1{margin:0 0 8px;color:var(--navy)}.portal-form{max-width:520px;display:grid;gap:16px;margin-top:20px}.portal-form .btn{width:max-content}.portal-header{display:flex;align-items:center;justify-content:space-between;gap:16px}.portal-header h1{margin:0;color:var(--navy)}.eyebrow{margin:0 0 4px;text-transform:uppercase;letter-spacing:.08em;font-size:11px;color:var(--brand-orange-strong);font-weight:700}.portal-tabs{display:flex;gap:6px;overflow:auto;border-bottom:1px solid #e5e7eb;margin:24px -24px 20px;padding:0 24px}.portal-tabs .tab{border:0;background:transparent;padding:12px 14px;color:#64748b;white-space:nowrap;border-bottom:2px solid transparent;cursor:pointer}.portal-tabs .tab.active{color:var(--navy);border-bottom-color:var(--brand-orange);font-weight:700}.portal-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px;margin-bottom:18px}.portal-stat{border:1px solid #e5e7eb;border-radius:12px;padding:16px;display:flex;flex-direction:column;gap:8px}.portal-stat span{font-size:12px;color:#64748b}.portal-stat strong{font-size:20px;color:var(--navy)}.portal-inner-card{box-shadow:none}.portal-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:10px}.portal-message-form{display:grid;gap:10px;margin-top:18px}.portal-messages{display:grid;gap:10px;max-height:520px;overflow:auto}.portal-message{max-width:80%;padding:12px 14px;border:1px solid #e5e7eb;border-radius:12px;background:#f8fafc}.portal-message.mine{margin-left:auto;background:#effaf7;border-color:#c7eee6}.portal-message p{margin:7px 0;white-space:pre-wrap}.portal-message span{font-size:11px;color:#64748b}.portal-toast{position:fixed;right:20px;bottom:20px;padding:12px 16px;border-radius:10px;background:#1f2937;color:#fff;z-index:1000;box-shadow:0 8px 24px rgba(0,0,0,.18)}.portal-toast.success{background:#087f6d}.portal-toast.error{background:#b42318}@media(max-width:900px){.portal-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}@media(max-width:640px){.portal-shell{width:min(100% - 20px,1180px);padding:20px 0}.portal-card{padding:18px}.portal-tabs{margin-left:-18px;margin-right:-18px;padding-left:18px;padding-right:18px}.portal-grid{grid-template-columns:1fr}.portal-brand{align-items:flex-start;flex-direction:column}.portal-brand img{width:145px}.portal-header{align-items:flex-start}.portal-message{max-width:92%}}

/* FASE 13 — gestão do portal no cadastro de pacientes */
.portal-admin-grid{display:grid;grid-template-columns:1fr 1fr;gap:20px}.portal-admin-grid h4{margin:0 0 10px;color:var(--navy)}.portal-admin-message-form{display:grid;gap:10px;margin-top:12px}@media(max-width:800px){.portal-admin-grid{grid-template-columns:1fr}}

/* FASE 13 — Portal do Paciente */
.portal-body{margin:0;background:#f5f7fa;color:#1f2937;min-height:100vh;font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}.portal-shell{width:min(1180px,calc(100% - 32px));margin:0 auto;padding:32px 0 48px}.portal-brand{display:flex;align-items:center;gap:14px;margin-bottom:24px}.portal-brand img{width:170px;height:auto}.portal-brand div{display:flex;flex-direction:column;gap:4px}.portal-brand strong{color:var(--navy);font-size:18px}.portal-brand span{font-size:13px;color:#6b7280}.portal-card{background:#fff;border:1px solid #e5e7eb;border-radius:14px;box-shadow:0 8px 30px rgba(15,23,42,.06);padding:24px}.portal-card>h1{margin:0 0 8px;color:var(--navy)}.portal-form{max-width:520px;display:grid;gap:16px;margin-top:20px}.portal-form .btn{width:max-content}.portal-header{display:flex;align-items:center;justify-content:space-between;gap:16px}.portal-header h1{margin:0;color:var(--navy)}.eyebrow{margin:0 0 4px;text-transform:uppercase;letter-spacing:.08em;font-size:11px;color:var(--brand-orange-strong);font-weight:700}.portal-tabs{display:flex;gap:6px;overflow:auto;border-bottom:1px solid #e5e7eb;margin:24px -24px 20px;padding:0 24px}.portal-tabs .tab{border:0;background:transparent;padding:12px 14px;color:#64748b;white-space:nowrap;border-bottom:2px solid transparent;cursor:pointer}.portal-tabs .tab.active{color:var(--navy);border-bottom-color:var(--brand-orange);font-weight:700}.portal-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px;margin-bottom:18px}.portal-stat{border:1px solid #e5e7eb;border-radius:12px;padding:16px;display:flex;flex-direction:column;gap:8px}.portal-stat span{font-size:12px;color:#64748b}.portal-stat strong{font-size:20px;color:var(--navy)}.portal-inner-card{box-shadow:none}.portal-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:10px}.portal-message-form{display:grid;gap:10px;margin-top:18px}.portal-messages{display:grid;gap:10px;max-height:520px;overflow:auto}.portal-message{max-width:80%;padding:12px 14px;border:1px solid #e5e7eb;border-radius:12px;background:#f8fafc}.portal-message.mine{margin-left:auto;background:#effaf7;border-color:#c7eee6}.portal-message p{margin:7px 0;white-space:pre-wrap}.portal-message span{font-size:11px;color:#64748b}.portal-toast{position:fixed;right:20px;bottom:20px;padding:12px 16px;border-radius:10px;background:#1f2937;color:#fff;z-index:1000;box-shadow:0 8px 24px rgba(0,0,0,.18)}.portal-toast.success{background:#087f6d}.portal-toast.error{background:#b42318}@media(max-width:900px){.portal-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}@media(max-width:640px){.portal-shell{width:min(100% - 20px,1180px);padding:20px 0}.portal-card{padding:18px}.portal-tabs{margin-left:-18px;margin-right:-18px;padding-left:18px;padding-right:18px}.portal-grid{grid-template-columns:1fr}.portal-brand{align-items:flex-start;flex-direction:column}.portal-brand img{width:145px}.portal-header{align-items:flex-start}.portal-message{max-width:92%}}

/* FASE 14 — Billing SaaS */
.billing-kpis{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:16px;margin-bottom:18px}.billing-kpi{display:flex;flex-direction:column;gap:7px}.billing-kpi span{font-size:12px;color:#64748b}.billing-kpi strong{font-size:21px;color:var(--navy)}.billing-kpi small{font-size:12px;color:#64748b;min-height:18px}.billing-grid-main{display:grid;grid-template-columns:minmax(0,1.4fr) minmax(320px,.8fr);gap:18px;margin-bottom:18px}.billing-subscription-card{min-width:0}.billing-actions{display:flex;gap:8px;flex-wrap:wrap;justify-content:flex-end}.billing-subscription-detail{margin-top:18px}.billing-detail-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px}.billing-detail-grid>div{border:1px solid #e5e7eb;border-radius:12px;padding:13px;background:#fff;display:flex;flex-direction:column;gap:6px;min-width:0}.billing-detail-grid span{font-size:11px;color:#64748b}.billing-detail-grid strong{font-size:14px;color:#1f2937;overflow-wrap:anywhere}.billing-usage-list{display:grid;gap:14px}.billing-usage-item{display:grid;grid-template-columns:1fr auto;gap:6px 14px;align-items:center}.billing-usage-item>div:first-child{min-width:0}.billing-usage-item strong{color:#1f2937}.billing-usage-item small{display:block;color:#64748b;margin-top:3px;overflow-wrap:anywhere}.billing-usage-value{display:flex;align-items:center;gap:8px;white-space:nowrap}.billing-meter{grid-column:1/-1;height:7px;background:#eef2f7;border-radius:999px;overflow:hidden}.billing-meter span{display:block;height:100%;background:var(--brand-orange);border-radius:inherit}.billing-tabs-card{padding:0;margin-bottom:18px}.billing-tabs{display:flex;gap:6px;overflow:auto;padding:0 18px}.billing-tabs .tab-btn{border:0;background:transparent;padding:14px 16px;color:#64748b;border-bottom:2px solid transparent;white-space:nowrap;cursor:pointer}.billing-tabs .tab-btn.active{color:var(--navy);border-bottom-color:var(--brand-orange);font-weight:700}.billing-panel{margin-bottom:18px}.billing-plan-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px}.billing-plan-card{border:1px solid #e5e7eb;border-radius:14px;padding:18px;background:#fff}.billing-plan-card.current{border-color:var(--brand-orange);box-shadow:0 0 0 1px rgba(217,119,35,.15)}.billing-plan-head{display:flex;justify-content:space-between;gap:12px;align-items:flex-start}.billing-plan-head h3{margin:0;color:var(--navy)}.billing-plan-head p{margin:6px 0 0;color:#64748b;font-size:13px;line-height:1.5}.billing-plan-prices{display:grid;gap:10px;margin-top:18px}.billing-plan-prices>div{border-top:1px solid #eef2f7;padding-top:12px;display:grid;grid-template-columns:1fr auto;gap:4px 10px;align-items:center}.billing-plan-prices strong{color:#1f2937}.billing-plan-prices span{font-size:12px;color:#64748b}.billing-plan-prices .btn{grid-column:2;grid-row:1/3}.billing-alert{margin-bottom:16px;border:1px solid #f1c7c5;background:#fff6f5;color:#8f1d18;border-radius:12px;padding:14px 16px;line-height:1.5}.billing-invoice-detail h3{margin:24px 0 10px;color:var(--navy)}.billing-invoice-detail .table-wrap{margin-top:8px}.status-pill.status-trial{background:#eef6ff;color:#245ea8}.status-pill.status-active{background:#eafaf5;color:#087f6d}.status-pill.status-past_due{background:#fff6e5;color:#9a6700}.status-pill.status-suspended,.status-pill.status-cancelled{background:#fff1f0;color:#b42318}
@media(max-width:1100px){.billing-kpis{grid-template-columns:repeat(2,minmax(0,1fr))}.billing-grid-main{grid-template-columns:1fr}.billing-detail-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.billing-plan-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:680px){.billing-kpis{grid-template-columns:1fr}.billing-detail-grid{grid-template-columns:1fr}.billing-plan-grid{grid-template-columns:1fr}.billing-actions{justify-content:flex-start}.billing-actions .btn{width:100%}.billing-usage-item{grid-template-columns:1fr}.billing-usage-value{justify-content:space-between}.billing-tabs{padding:0 10px}.billing-tabs .tab-btn{padding:12px 13px}}

/* FASE 15 — Super Admin SaaS */
.impersonation-banner{display:flex;align-items:center;justify-content:space-between;gap:16px;margin:14px 24px 0;padding:12px 14px;border:1px solid #d7e7f7;background:#f4f9ff;color:var(--navy);border-radius:12px;box-shadow:0 2px 8px rgba(15,23,42,.04)}
.impersonation-banner-text{display:flex;flex-direction:column;gap:3px;min-width:0}.impersonation-banner-text strong{font-size:13px}.impersonation-banner-text span{font-size:12px;line-height:1.45;color:#475569;overflow-wrap:anywhere}
.admin-tabs-card{padding:0;margin:0 0 18px}.admin-tabs{display:flex;gap:4px;overflow:auto;padding:0 12px}.admin-tabs .tab-btn{flex:0 0 auto;border:0;background:transparent;padding:14px 14px;color:#64748b;border-bottom:2px solid transparent;cursor:pointer;font-weight:600;white-space:nowrap}.admin-tabs .tab-btn.active{color:var(--navy);border-bottom-color:var(--brand-orange)}
.admin-toolbar-wrap{align-items:flex-start;gap:14px}.admin-filter-row{display:flex;gap:8px;flex-wrap:wrap;justify-content:flex-end}.admin-filter-row .input{min-width:150px}.admin-pagination{display:flex;justify-content:flex-end;align-items:center;gap:10px;padding:14px 0}.admin-pagination span{font-size:13px;color:#64748b}.admin-two-col{display:grid;grid-template-columns:minmax(0,1.25fr) minmax(0,1fr);gap:18px}.admin-plan-list{display:grid;gap:12px}.admin-plan-item{border:1px solid #e5e7eb;border-radius:12px;padding:14px;background:#fff}.admin-plan-item-head{display:flex;justify-content:space-between;gap:12px;align-items:flex-start}.admin-plan-item h3{margin:0;color:var(--navy)}.admin-plan-item p{margin:5px 0 0}.admin-price-chips{display:flex;flex-wrap:wrap;gap:7px;margin-top:12px}.admin-chip{display:inline-flex;align-items:center;border:1px solid #e5e7eb;border-radius:999px;padding:6px 9px;font-size:12px;color:#475569;background:#f8fafc}.admin-detail-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;margin-bottom:16px}.admin-detail-grid>div{border:1px solid #e5e7eb;border-radius:12px;padding:12px;background:#fff;display:flex;flex-direction:column;gap:5px}.admin-detail-grid span{font-size:11px;color:#64748b}.admin-detail-grid strong{font-size:14px;overflow-wrap:anywhere}.admin-modal-section-title{margin:22px 0 10px;color:var(--navy)}.admin-feature-editor{display:grid;gap:9px;max-height:55vh;overflow:auto;padding-right:4px}.admin-feature-row{display:grid;grid-template-columns:minmax(0,1fr) auto 130px;align-items:center;gap:10px;border:1px solid #e5e7eb;border-radius:10px;padding:10px 12px}.admin-feature-row span{display:flex;flex-direction:column;gap:3px;min-width:0}.admin-feature-row small{color:#64748b;overflow-wrap:anywhere}.admin-feature-row input[type="checkbox"]{width:18px;height:18px}
.admin-health-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.admin-health-item,.admin-integration-item{display:flex;justify-content:space-between;align-items:center;gap:14px;border:1px solid #e5e7eb;border-radius:12px;padding:13px;background:#fff}.admin-health-item strong,.admin-integration-item strong{color:#1f2937}.admin-integration-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.admin-integration-item{align-items:flex-start}.admin-integration-item .status-pill{flex:0 0 auto}.table-actions{display:flex;gap:6px;flex-wrap:wrap;justify-content:flex-end}.status-pill.status-inactive{background:#f1f5f9;color:#475569}.status-pill.status-warning{background:#fff6e5;color:#9a6700}.status-pill.status-critical{background:#fff1f0;color:#b42318}
@media(max-width:1100px){.admin-two-col{grid-template-columns:1fr}.admin-detail-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.admin-health-grid,.admin-integration-grid{grid-template-columns:1fr}}
@media(max-width:800px){.impersonation-banner{margin:10px 12px 0;align-items:flex-start;flex-direction:column}.impersonation-banner .btn{width:100%}.admin-toolbar-wrap{align-items:stretch}.admin-filter-row{justify-content:stretch}.admin-filter-row .input,.admin-filter-row .btn{flex:1 1 150px}.admin-feature-row{grid-template-columns:minmax(0,1fr) auto}.admin-feature-row .input{grid-column:1/-1}.admin-tabs{padding:0 6px}}
@media(max-width:680px){.admin-detail-grid{grid-template-columns:1fr}.admin-filter-row{display:grid;grid-template-columns:1fr}.admin-filter-row .input,.admin-filter-row .btn{width:100%}.admin-plan-item-head{flex-direction:column}.table-actions{justify-content:flex-start}}


/* FASE 16 — Privacidade e Segurança */
.privacy-kpis{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:16px;margin-bottom:16px}.privacy-kpi-value{display:block;font-size:28px;margin-top:8px}.privacy-grid,.security-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;margin-bottom:16px}.security-status{display:grid;gap:10px}.security-actions{display:flex;gap:8px;flex-wrap:wrap}.security-secret{display:block;padding:12px;border:1px solid var(--border,#E5E7EB);border-radius:8px;background:#f8fafc;letter-spacing:1.5px;word-break:break-all}.input-sm{min-width:130px;padding:7px 9px;font-size:12px}@media(max-width:900px){.privacy-kpis{grid-template-columns:repeat(2,minmax(0,1fr))}.privacy-grid,.security-grid{grid-template-columns:1fr}}@media(max-width:520px){.privacy-kpis{grid-template-columns:1fr}.security-actions{flex-direction:column}.security-actions .btn{width:100%}}

.settings-link-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;margin-top:16px}.settings-link-card{display:grid;gap:6px;text-decoration:none;color:inherit}.settings-link-card:hover{border-color:var(--brand-orange)}@media(max-width:700px){.settings-link-grid{grid-template-columns:1fr}}

/* FASE 17 — Sistema */
.system-kpis{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:16px;margin-bottom:18px}.system-kpi{display:flex;flex-direction:column;gap:7px}.system-kpi span{font-size:12px;color:#64748b}.system-kpi strong{font-size:24px;color:var(--navy)}.system-kpi small{font-size:12px;color:#64748b}.system-tabs-card{padding:0;margin-bottom:18px}.system-tabs{display:flex;gap:6px;overflow:auto;padding:0 18px}.system-tabs .tab-btn{border:0;background:transparent;padding:14px 16px;color:#64748b;border-bottom:2px solid transparent;white-space:nowrap;cursor:pointer}.system-tabs .tab-btn.active{color:var(--navy);border-bottom-color:var(--brand-orange);font-weight:700}.system-panel{margin-bottom:18px}.secret-display{display:grid;gap:12px}.secret-display code{display:block;word-break:break-all;background:#f8fafc;border:1px solid #e5e7eb;border-radius:10px;padding:14px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace}.system-page .table-wrap{overflow-x:auto}.system-page code{font-size:12px}@media(max-width:1000px){.system-kpis{grid-template-columns:repeat(2,minmax(0,1fr))}}@media(max-width:600px){.system-kpis{grid-template-columns:1fr}.system-tabs{padding:0 10px}.system-tabs .tab-btn{padding:12px 13px}}

/* FASE 18 — UX, Busca e Acessibilidade */
html { font-size: calc(16px * var(--font-scale, 1)); }
.skip-link{position:fixed;top:8px;left:8px;z-index:9999;padding:10px 14px;border-radius:8px;background:var(--navy);color:#fff;transform:translateY(-150%);transition:transform .15s ease;font-weight:700}.skip-link:focus{transform:translateY(0)}
.topbar-search input{border:0;outline:0;background:transparent;color:#1f2937;min-width:0;width:100%;font-size:12px}.topbar-search input::placeholder{color:#94a3b8}.topbar-search kbd{flex:0 0 auto;border:1px solid #d7dee8;border-radius:6px;background:#fff;padding:3px 6px;font-size:10px;color:#64748b}
.ux-command-modal{position:fixed;inset:0;z-index:1000}.ux-command-modal[hidden]{display:none}.ux-command-backdrop{position:absolute;inset:0;background:rgba(15,23,42,.48);backdrop-filter:blur(2px)}.ux-command-panel{position:relative;width:min(680px,calc(100vw - 28px));margin:9vh auto 0;background:#fff;border:1px solid #e5e7eb;border-radius:16px;box-shadow:0 24px 80px rgba(15,23,42,.24);overflow:hidden}.ux-command-head{display:flex;justify-content:space-between;gap:12px;padding:16px 18px 10px}.ux-command-head strong{display:block;color:var(--navy)}.ux-command-head small{display:block;color:#64748b;margin-top:2px}.ux-command-input-wrap{display:block;padding:0 18px 12px}.ux-command-input-wrap .input{min-height:46px}.ux-command-results{max-height:min(55vh,520px);overflow:auto;padding:4px 10px 10px}.ux-command-item{width:100%;display:grid;grid-template-columns:auto 1fr;align-items:center;gap:12px;text-align:left;background:#fff;border:1px solid transparent;border-radius:10px;padding:11px 10px;cursor:pointer;color:#1f2937}.ux-command-item:hover,.ux-command-item.active{background:#f5f7fa;border-color:#dbe4ee}.ux-command-item strong{display:block}.ux-command-item small{display:block;color:#64748b;margin-top:2px}.ux-command-icon{font-size:10px;text-transform:uppercase;letter-spacing:.04em;color:#087f6d;font-weight:800}.ux-command-foot{display:flex;justify-content:flex-end;gap:10px;padding:10px 18px;border-top:1px solid #eef2f7;color:#64748b;font-size:11px}.ux-command-foot span{border:1px solid #e5e7eb;border-radius:6px;padding:3px 6px}
.ux-notification-list{display:grid;gap:10px}.ux-notification{display:flex;justify-content:space-between;gap:16px;padding:14px;border:1px solid #e5e7eb;border-radius:12px;background:#fff}.ux-notification.unread{border-left:4px solid var(--brand-orange);background:#fbfffe}.ux-notification strong{color:var(--navy)}.ux-notification p{margin:5px 0;color:#475569}.ux-notification small{color:#64748b}.ux-notification>div:last-child{display:flex;gap:8px;align-items:flex-start;flex-wrap:wrap;justify-content:flex-end}
.ux-help-tabs{display:flex;gap:4px;padding:0 12px;margin-bottom:16px;overflow:auto}.ux-help-tabs .tab-btn{border:0;background:transparent;padding:14px;color:#64748b;border-bottom:2px solid transparent;white-space:nowrap;cursor:pointer;font-weight:700}.ux-help-tabs .tab-btn.active{color:var(--navy);border-bottom-color:var(--brand-orange)}.ux-help-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}.ux-help-card h2{margin:4px 0;color:var(--navy)}.ux-help-card p{margin:0;color:#64748b}.shortcut-list{display:grid;gap:10px}.shortcut-row{display:flex;align-items:center;gap:14px;padding:12px;border:1px solid #e5e7eb;border-radius:10px}.shortcut-row kbd{min-width:90px;text-align:center;border:1px solid #d7dee8;border-bottom-width:2px;border-radius:6px;padding:5px 8px;background:#f8fafc;color:#1f2937;font-family:ui-monospace,SFMono-Regular,Menlo,monospace}.shortcut-row span{color:#475569}.ux-release-list{display:grid;gap:14px}.ux-release-meta{display:flex;justify-content:space-between;gap:12px;align-items:center}.ux-release-meta time{font-size:12px;color:#64748b}.ux-release-card h2{margin:12px 0 8px;color:var(--navy)}.ux-release-body{white-space:normal;color:#475569;line-height:1.65}.ux-command-open{overflow:hidden}
html[data-reduced-motion="true"] *,html[data-reduced-motion="true"] *::before,html[data-reduced-motion="true"] *::after{scroll-behavior:auto!important;animation-duration:.001ms!important;animation-iteration-count:1!important;transition-duration:.001ms!important}.prefers-reduced-motion{display:none}
html[data-high-contrast="true"]{filter:contrast(1.08)}html[data-high-contrast="true"] .card,html[data-high-contrast="true"] .btn,html[data-high-contrast="true"] .input{border-color:#334155}html[data-high-contrast="true"] .muted,html[data-high-contrast="true"] small{color:#334155}
body { font-size: calc(15px * var(--font-scale, 1)); }
@media(max-width:700px){.ux-help-grid{grid-template-columns:1fr}.ux-notification{flex-direction:column}.ux-notification>div:last-child{justify-content:flex-start}.topbar-search{max-width:none}.topbar-search kbd{display:none}}


/* FASE 19 — PWA: instalação, atualização e conectividade */
.pwa-status-region{position:fixed;left:16px;bottom:16px;z-index:1100;display:flex;align-items:center;gap:10px;max-width:calc(100vw - 32px);pointer-events:none}
.pwa-connection{display:inline-flex;align-items:center;gap:7px;border:1px solid #E5E7EB;background:#fff;color:#1F2937;border-radius:999px;padding:7px 11px;font-size:.78rem;font-weight:700;box-shadow:0 8px 24px rgba(15,23,42,.10);pointer-events:auto}
.pwa-connection.online .pwa-dot{background:var(--brand-orange)}.pwa-connection.offline .pwa-dot{background:#dc2626}.pwa-dot{width:8px;height:8px;border-radius:50%;flex:0 0 8px}
.pwa-actions{display:flex;gap:8px;pointer-events:auto}
.pwa-action-btn{border:0;background:var(--navy);color:#fff;border-radius:999px;padding:8px 12px;font:inherit;font-size:.78rem;font-weight:700;cursor:pointer;box-shadow:0 8px 24px rgba(15,23,42,.14)}
.pwa-action-btn:hover{filter:brightness(.96)}.pwa-action-btn:focus-visible{outline:3px solid var(--brand-orange);outline-offset:2px}
@media (max-width:640px){.pwa-status-region{left:10px;right:10px;bottom:10px;max-width:none;flex-wrap:wrap}.pwa-actions{width:100%}.pwa-action-btn{flex:1}}
@media (prefers-reduced-motion:reduce){.pwa-status-region *{scroll-behavior:auto!important;transition:none!important}}

/* ================= CORREÇÕES PÓS-AUDITORIA FINAL ================= */
.profile-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px;margin-bottom:18px}.profile-context-box{display:flex;flex-direction:column;gap:4px;padding:14px;border:1px solid var(--border,#e5e7eb);border-radius:10px;background:#f8fafc}.profile-context-box strong{color:var(--navy);font-size:15px}.profile-context-box span{color:#64748b;font-size:12px}.profile-detail-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px}.profile-detail-grid>div{padding:14px;border:1px solid var(--border,#e5e7eb);border-radius:10px;background:#fff}.profile-detail-grid span{display:block;color:#64748b;font-size:12px;margin-bottom:5px}.profile-detail-grid strong{color:#1f2937}.profile-links-card{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px}.terms-card{max-width:980px}.terms-meta{padding:12px 14px;border:1px solid var(--border,#e5e7eb);border-radius:10px;background:#f8fafc;color:#475569;font-size:13px;margin-bottom:18px}.terms-content{display:grid;gap:8px}.terms-section{padding:4px 0 12px}.terms-section h2{font-size:17px;color:var(--navy);margin:14px 0 7px}.terms-section p{margin:0;color:#475569;line-height:1.7}.system-secret-card{border:1px solid #99d9cc;box-shadow:0 6px 24px rgba(217,119,35,.10)}.secret-display{display:flex;align-items:center;gap:10px;padding:14px;border:1px solid #cbd5e1;border-radius:10px;background:#0f172a;overflow:auto}.secret-display code{color:#fff;white-space:nowrap;word-break:break-all}.inline-form{display:inline-flex;margin:0}.system-post-form{display:none}
@media(max-width:900px){.profile-grid{grid-template-columns:1fr}.profile-detail-grid{grid-template-columns:1fr 1fr}.profile-links-card{grid-template-columns:1fr 1fr}}
@media(max-width:640px){.profile-detail-grid,.profile-links-card{grid-template-columns:1fr}.profile-page .form-actions .btn,.terms-page .page-heading .btn{width:100%}.terms-card{padding:16px}}

.stack-inline{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.small{font-size:.82rem}

/* MedicinOS UI Consistency Update — sidebar, account menu, PWA status and controls */
.sidebar {
  overflow: hidden;
}
.sidebar-brand {
  flex: 0 0 auto;
  padding: 10px 10px 16px;
  margin-bottom: 0;
}
.sidebar-brand-link {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  border-radius: 12px;
}
.sidebar-brand-link:focus-visible {
  box-shadow: 0 0 0 3px rgba(217,119,35,.34);
}
.sidebar-logo {
  width: min(190px, 100%);
  max-height: 84px;
  height: auto;
  object-fit: contain;
  object-position: left center;
}
.sidebar-brand-mark {
  width: 48px;
  height: 48px;
  object-fit: contain;
}
.sidebar-nav-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 0 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.22) transparent;
}
.sidebar-nav-scroll::-webkit-scrollbar { width: 5px; }
.sidebar-nav-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.22); border-radius: 999px; }
.sidebar-nav-scroll .nav { padding: 0; }
.sidebar-admin-link {
  position: relative;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  margin-top: 7px;
  border-radius: 9px;
  color: rgba(255,255,255,.84);
  font-size: 13px;
  font-weight: 650;
  background: rgba(255,255,255,.045);
  border: 1px solid rgba(255,255,255,.07);
}
.sidebar-admin-link:hover { background: rgba(217,119,35,.16); color: #fff; }
.sidebar-footer {
  flex: 0 0 auto;
  padding-top: 10px;
  margin-top: 3px;
  border-top: 1px solid rgba(255,255,255,.12);
}
.sidebar-footer a,
.sidebar-footer .sidebar-action {
  width: 100%;
}
.sidebar-action {
  position: relative;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 9px;
  color: rgba(255,255,255,.84);
  background: transparent;
  font-size: 13px;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
  transition: background-color .16s ease, color .16s ease, transform .16s ease;
}
.sidebar-action:hover { background: rgba(255,255,255,.10); color: #fff; }
.sidebar-logout:hover { background: rgba(220,38,38,.18); }
.sidebar-action:disabled { opacity: .6; cursor: wait; }

/* The three-line control stays in the header on every screen size. */
.sidebar-menu-btn {
  display: grid;
  flex: 0 0 auto;
}
.sidebar-menu-btn svg { transition: transform .18s ease; }
body.sidebar-collapsed .sidebar-menu-btn svg { transform: rotate(180deg); }
body.sidebar-collapsed .sidebar-menu-btn { border-color: rgba(0,64,128,.16); }

/* Desktop/tablet: the same control expands and collapses the real sidebar. */
@media (min-width: 881px) {
  body { --sidebar-width: 248px; }
  body.sidebar-collapsed { --sidebar-width: 88px; }
  body:not(.sidebar-collapsed) .sidebar { padding-left: 12px; padding-right: 12px; }
  body:not(.sidebar-collapsed) .sidebar-brand { justify-content: flex-start; padding-left: 10px; padding-right: 10px; }
  body:not(.sidebar-collapsed) .sidebar-brand-link { justify-content: flex-start; }
  body:not(.sidebar-collapsed) .sidebar-logo { display: block; }
  body:not(.sidebar-collapsed) .sidebar-brand-mark { display: none; }
  body:not(.sidebar-collapsed) .nav a,
  body:not(.sidebar-collapsed) .sidebar-footer a,
  body:not(.sidebar-collapsed) .sidebar-action,
  body:not(.sidebar-collapsed) .sidebar-admin-link { justify-content: flex-start; padding-left: 12px; padding-right: 12px; }
  body:not(.sidebar-collapsed) .nav a span,
  body:not(.sidebar-collapsed) .sidebar-footer a span,
  body:not(.sidebar-collapsed) .sidebar-action span,
  body:not(.sidebar-collapsed) .sidebar-admin-link span { display: inline; }
  body.sidebar-collapsed .sidebar { padding-left: 8px; padding-right: 8px; }
  body.sidebar-collapsed .sidebar-brand { justify-content: center; padding-left: 0; padding-right: 0; }
  body.sidebar-collapsed .sidebar-brand-link { justify-content: center; }
  body.sidebar-collapsed .sidebar-logo { display: none; }
  body.sidebar-collapsed .sidebar-brand-mark { display: block; }
  body.sidebar-collapsed .nav a,
  body.sidebar-collapsed .sidebar-footer a,
  body.sidebar-collapsed .sidebar-action,
  body.sidebar-collapsed .sidebar-admin-link { justify-content: center; padding-left: 8px; padding-right: 8px; }
  body.sidebar-collapsed .nav a span,
  body.sidebar-collapsed .sidebar-footer a span,
  body.sidebar-collapsed .sidebar-action span,
  body.sidebar-collapsed .sidebar-admin-link span { display: none; }
  body.sidebar-collapsed .sidebar-admin-link { margin-left: 0; margin-right: 0; }
  body.sidebar-collapsed .sidebar-menu-btn[aria-expanded="false"] { opacity: .95; }
}

/* Mobile: the header control opens the off-canvas navigation. */
@media (max-width: 880px) {
  body { --sidebar-width: 0px; }
  .sidebar { width: 280px; padding: 16px 12px 14px; }
  .sidebar-brand { padding: 10px 10px 16px; }
  .sidebar-brand-link { justify-content: flex-start; }
  .sidebar-logo { display: block; width: min(190px, 100%); max-height: 84px; }
  .sidebar-brand-mark { display: none; }
  .sidebar-nav-scroll { padding-bottom: 8px; }
  .nav a, .sidebar-footer a, .sidebar-action, .sidebar-admin-link { justify-content: flex-start; padding-left: 12px; padding-right: 12px; }
  .nav a span, .sidebar-footer a span, .sidebar-action span, .sidebar-admin-link span { display: inline; }
  .mobile-menu-btn { display: none; }
  .topbar { padding-left: 12px; }
}

/* Account dropdown: same visual language as the cards and action menus. */
.account-menu { position: relative; }
.avatar-trigger {
  position: relative;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(0,64,128,.10);
}
.avatar-chevron {
  position: absolute;
  right: -3px;
  bottom: -2px;
  width: 17px;
  height: 17px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--navy);
  color: #fff;
}
.avatar-chevron svg { width: 10px; height: 10px; }
.dropdown-menu {
  min-width: 220px;
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  z-index: 95;
  padding: 7px;
  background: rgba(255,255,255,.985);
  border: 1px solid rgba(229,231,235,.95);
  border-radius: 14px;
  box-shadow: 0 20px 48px rgba(15,23,42,.16), 0 3px 10px rgba(15,23,42,.05);
  transform-origin: top right;
  transition: opacity .14s ease, transform .14s ease, visibility .14s ease;
}
.dropdown-menu.hidden {
  display: block !important;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-5px) scale(.985);
}
.dropdown-menu.is-open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}
.dropdown-menu a,
.dropdown-menu button {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  background: transparent;
  color: var(--text);
  border-radius: 9px;
  text-align: left;
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  transition: background-color .14s ease, color .14s ease;
}
.dropdown-menu a:hover,
.dropdown-menu button:hover { background: #F5F8FC; color: var(--navy); }
.dropdown-menu .dropdown-danger:hover { background: #FEF2F2; color: #B91C1C; }
.dropdown-menu svg { color: #64748B; flex: 0 0 auto; }
.dropdown-menu a:hover svg,
.dropdown-menu button:hover svg { color: currentColor; }
.dropdown-account-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 9px 11px;
}
.dropdown-account-avatar {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--teal-soft);
  color: var(--navy);
  font-weight: 850;
}
.dropdown-account-head strong { display: block; color: var(--navy); font-size: 13px; line-height: 1.25; }
.dropdown-account-head span:not(.dropdown-account-avatar) { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.dropdown-divider { height: 1px; margin: 5px 4px; background: var(--border); }
.dropdown-danger { color: #991B1B !important; }

/* Native select controls keep the same modern field geometry. */
select.input,
select.select,
.field select,
.dashboard-toolbar select {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background-color: #fff;
  color: var(--text);
  padding: 9px 40px 9px 13px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #64748B 50%), linear-gradient(135deg, #64748B 50%, transparent 50%);
  background-position: calc(100% - 18px) 17px, calc(100% - 13px) 17px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
select.input:focus,
select.select:focus,
.field select:focus,
.dashboard-toolbar select:focus { border-color: var(--teal); box-shadow: var(--focus); }

/* PWA indicator lives in the application area, never over the fixed sidebar. */
.pwa-status-region {
  left: auto !important;
  right: 20px !important;
  bottom: 18px !important;
  z-index: 25 !important;
  max-width: min(520px, calc(100vw - 40px));
}
.pwa-actions { flex-wrap: wrap; }
.pwa-connection,
.pwa-action-btn {
  box-shadow: 0 10px 28px rgba(15,23,42,.12);
}
.pwa-action-btn { border-radius: 10px; }
.toast-stack { bottom: 86px; }

@media (max-width: 760px) {
  .pwa-status-region {
    left: 12px !important;
    right: 12px !important;
    bottom: 12px !important;
    max-width: none;
  }
  .pwa-actions { width: auto; }
  .pwa-action-btn { padding: 8px 10px; }
  .toast-stack { right: 12px; bottom: 106px; }
}


/* Unified presentation system — staff, patient portal and public screens. */
:root {
  --brand-orange: #D97723;
  --brand-orange-strong: #B95416;
  --brand-orange-tint: #FFF2E7;
  --ink: #243445;
  --surface-subtle: #F7F9FB;
  --surface-blue: #EDF4F9;
  --sidebar-surface: #102D49;
  --sidebar-ink: #CBD9E5;
  --sidebar-line: rgba(255,255,255,.11);
  --focus: 0 0 0 3px rgba(217,119,35,.2);
  --shadow-sm: 0 1px 3px rgba(16,45,73,.045);
  --shadow: 0 10px 28px rgba(16,45,73,.085);
  --shadow-lg: 0 22px 55px rgba(16,45,73,.18);
  --radius-sm: 7px;
  --radius: 8px;
  --radius-lg: 10px;
  --sidebar-width: 264px;
  --header-height: 68px;
  --content-max: 1560px;
}
html { scroll-padding-top: 84px; }
body { color: var(--ink); letter-spacing: 0; }
button, input, textarea, select { letter-spacing: 0; }
button:not(:disabled) { cursor: pointer; }
:focus-visible { outline: 2px solid var(--brand-orange); outline-offset: 2px; box-shadow: var(--focus); }

/* The same hierarchy and spacing applies to all staff view wrappers. */
.content, .page, .page-content { width: min(100%, var(--content-max)); margin: 0 auto; padding: 30px 32px 64px; min-width: 0; }
.page-header, .page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin: 0 0 24px; }
.page-header h1, .page-heading h1 { margin: 0; color: var(--navy); font-size: clamp(24px, 2.1vw, 30px); font-weight: 750; line-height: 1.2; letter-spacing: 0; }
.page-header p, .page-heading p { margin: 6px 0 0; color: var(--muted); }
.page-actions, .page-heading-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; flex-wrap: wrap; }
.card, .portal-card, .public-card, .install-card { border-color: var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card h2, .card h3, .section-heading h2 { font-weight: 720; letter-spacing: 0; }
.card-toolbar { align-items: flex-start; }
.muted { color: var(--muted); }

/* Navigation: strong blue rail, calm surfaces, orange wayfinding. */
.sidebar { background: var(--sidebar-surface); box-shadow: 4px 0 20px rgba(16,45,73,.08); }
.sidebar-brand { border-bottom: 1px solid var(--sidebar-line); margin-bottom: 12px; padding-bottom: 18px; }
.nav { gap: 2px; }
.nav-group-label { display: block; padding: 16px 12px 6px; color: #8FA8BC; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; }
.nav-group-label:first-child { padding-top: 4px; }
.nav a, .sidebar-footer a, .sidebar-action, .sidebar-admin-link { min-height: 41px; color: var(--sidebar-ink); font-weight: 600; border-radius: 6px; }
.nav a:hover, .sidebar-footer a:hover, .sidebar-action:hover, .sidebar-admin-link:hover { background: rgba(255,255,255,.095); color: #fff; }
.nav a.active, .sidebar-footer a.active { background: var(--brand-orange); color: #fff; box-shadow: none; }
.nav a.active::before { content: ''; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: #fff; }
.sidebar-footer { border-color: var(--sidebar-line); }
.sidebar-nav-scroll { scrollbar-color: rgba(255,255,255,.23) transparent; }
.topbar { background: rgba(255,255,255,.97); border-color: var(--border); box-shadow: 0 1px 5px rgba(16,45,73,.025); }
.topbar-left { min-width: 0; flex: 0 1 auto; }
.topbar-title { overflow: hidden; text-overflow: ellipsis; font-weight: 750; color: var(--navy); }
.topbar-search { max-width: 470px; border-radius: 7px; background: var(--surface-subtle); }
.topbar-actions { flex: 0 0 auto; }
.icon-btn { border-radius: 7px; }
.icon-btn:hover { background: var(--surface-blue); color: var(--navy); transform: none; }
.avatar { background: var(--navy-3); }
.avatar:hover { background: var(--navy); }

/* Standard controls without changing their attributes, names or event hooks. */
.btn { min-height: 42px; border-radius: 7px; font-weight: 700; box-shadow: none; }
.btn:hover { transform: none; }
.btn-primary { color: #fff; background: var(--navy); box-shadow: none; }
.btn-primary:hover { background: var(--navy-3); }
.btn-secondary { background: var(--card); border-color: var(--border-strong); color: var(--navy); }
.btn-secondary:hover { background: var(--surface-blue); border-color: #AFC4D5; }
.btn-ghost:hover { background: var(--surface-blue); }
.btn-danger { background: var(--danger); }
.btn-sm { min-height: 36px; }
.input, .select, .control, .field input, .field select, .field textarea,
.form-grid input:not([type='checkbox']):not([type='radio']), .form-grid select, .form-grid textarea,
.portal-form input, .portal-form select, .portal-form textarea, textarea.input {
  width: 100%; min-width: 0; min-height: 42px; padding: 9px 12px;
  border: 1px solid var(--border-strong); border-radius: 7px;
  background-color: var(--card); color: var(--ink); outline: none;
  box-shadow: none; font-size: 14px;
}
textarea.input, .form-grid textarea, .field textarea { min-height: 100px; resize: vertical; }
.input:focus, .select:focus, .control:focus, .field input:focus, .field select:focus, .field textarea:focus,
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus, .portal-form input:focus { border-color: var(--brand-orange); box-shadow: var(--focus); }
.input:disabled, .select:disabled, .field input:disabled, .field select:disabled { background: var(--surface-subtle); color: var(--muted); }
input[type='checkbox'], input[type='radio'] { accent-color: var(--navy); }
.field label, .form-grid label, .portal-form label, .agenda-filters label { color: var(--ink); font-size: 13px; font-weight: 650; }
.form-grid label, .portal-form label { min-width: 0; }
.form-grid, .portal-form { min-width: 0; }

/* Data density and readable row scanning. */
.table-wrap { border-color: var(--border); border-radius: 7px; }
.table th { background: var(--surface-blue); color: var(--navy); font-size: 11px; font-weight: 750; letter-spacing: .04em; }
.table th, .table td { padding: 13px 15px; }
.table td { color: var(--ink); }
.table tbody tr:hover td { background: var(--surface-subtle); }
.table a, .patient-name-link strong { color: var(--navy); }
.badge, .status, .status-pill { font-weight: 700; letter-spacing: 0; }
.metric-card { border-top: 3px solid var(--brand-orange); min-width: 0; }
.metric-icon, .empty-icon { background: var(--brand-orange-tint); color: var(--brand-orange-strong); }
.metric-value { font-weight: 780; letter-spacing: 0; overflow-wrap: anywhere; }
.dashboard-chart-column { background: var(--brand-orange); }
.pagination button[aria-current='page'] { background: var(--navy); border-color: var(--navy); }

/* Tabs and lists share one interaction language across modules. */
.tab[aria-selected='true']::after, .tab.active::after { background: var(--brand-orange); }
.consultation-tabs .tab-btn.active, .finance-tabs .tab-btn.active, .tiss-tab.active,
.comm-tab.active, .portal-tabs .tab.active, .billing-tabs .tab-btn.active,
.admin-tabs .tab-btn.active, .system-tabs .tab-btn.active, .ux-help-tabs .tab-btn.active { border-bottom-color: var(--brand-orange); color: var(--navy); }
.consultation-card .main { margin-left: 0; min-height: 0; }
.settings-link-card:hover, .comm-thread.active, .billing-plan-card.current { border-color: var(--brand-orange); }

/* Public entry points and patient workspace. */
.login-brand { background: linear-gradient(150deg, var(--sidebar-surface), var(--navy)); }
.login-brand::after { border-color: rgba(255,255,255,.055); }
.brand-title { letter-spacing: 0; }
.brand-point svg { color: #F8B77B; }
.login-panel { background: var(--card); }
.login-secure { color: var(--muted); }
.portal-body, .public-page { background: var(--bg); color: var(--ink); font-family: "Segoe UI", system-ui, sans-serif; }
.portal-shell { width: min(1180px, calc(100% - 40px)); }
.portal-brand { padding: 12px 0 18px; border-bottom: 1px solid var(--border); }
.portal-brand img { width: 165px; padding: 9px; background: var(--navy); border-radius: 6px; }
.portal-card > h1, .portal-header h1 { color: var(--navy); }
.portal-inner-card { box-shadow: none; }
.portal-stat { border-radius: 7px; border-top: 3px solid var(--brand-orange); }
.portal-stat strong { color: var(--navy); }
.public-card { border-top: 3px solid var(--brand-orange); }
.nps-scale button.selected { background: var(--navy); border-color: var(--navy); }
.dropdown-menu { border-radius: 8px; }
.dropdown-menu.hidden { display: block !important; }
select.input, select.select, .field select, .dashboard-toolbar select { border-radius: 7px; background-color: var(--card); border-color: var(--border-strong); }
select.input:focus, select.select:focus, .field select:focus, .dashboard-toolbar select:focus { border-color: var(--brand-orange); }

@media (min-width: 881px) {
  body { --sidebar-width: 264px; }
  body.sidebar-collapsed { --sidebar-width: 72px; }
  body.sidebar-collapsed .nav-group-label { display: none; }
  body.sidebar-collapsed .sidebar-brand { padding: 8px 0 16px; }
  body.sidebar-collapsed .sidebar-brand-mark { width: 40px; height: 40px; }
  .main { transition: margin-left .2s ease; }
  .sidebar { transition: width .2s ease; }
}
@media (max-width: 880px) {
  body { --sidebar-width: 0px; }
  .sidebar { width: min(290px, 86vw); }
  .nav-group-label { display: block; }
  .topbar { gap: 10px; }
}
@media (max-width: 760px) {
  .content, .page, .page-content { padding: 20px 16px 52px; }
  .page-header, .page-heading { align-items: flex-start; flex-direction: column; gap: 14px; }
  .page-actions, .page-heading-actions { justify-content: flex-start; max-width: 100%; }
  .topbar-title { max-width: 40vw; font-size: 15px; }
  .topbar-actions .icon-btn:first-child { display: none; }
  .login-brand { min-height: 240px; }
  .login-panel { padding-block: 36px; }
  .portal-shell { width: calc(100% - 28px); }
  .portal-brand { flex-direction: row; align-items: center; }
  .portal-brand img { width: 120px; }
  .portal-header { gap: 12px; flex-wrap: wrap; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .form-span-2 { grid-column: auto; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
}
@media (max-width: 480px) {
  .content, .page, .page-content { padding-inline: 12px; }
  .topbar { padding-inline: 10px; }
  .topbar-actions { gap: 3px; }
  .topbar-title { max-width: 32vw; }
  .portal-brand { flex-direction: column; align-items: flex-start; }
  .portal-brand img { width: 150px; }
  .form-actions, .page-actions { width: 100%; }
  .login-brand { padding: 28px 20px; }
  .login-panel { padding: 28px 18px; }
}
@media print {
  .sidebar, .topbar, .mobile-sidebar-overlay, .page-heading-actions, .page-actions { display: none !important; }
  .main { margin: 0; }
  .content, .page, .page-content { width: 100%; padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}
/* Keep scrollable data inside its grid track on narrow screens. */
.grid > *, .consultation-grid > *, .finance-grid-main > *, .billing-grid-main > *, .comm-message-layout > * { min-width: 0; }
.grid .table-wrap, .page .table-wrap, .page-content .table-wrap { max-width: 100%; }
@media (max-width: 760px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .grid.grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { min-width: 0; }
}
@media (max-width: 480px) { .grid.grid-4 { grid-template-columns: minmax(0, 1fr); } }

/* Navigation and form refinements: presentation-only, shared across views. */
.sidebar-brand,
body:not(.sidebar-collapsed) .sidebar-brand {
  justify-content: center;
  padding: 20px 12px 22px;
  margin-bottom: 10px;
  border-bottom: 0;
}
.sidebar-brand-link,
body:not(.sidebar-collapsed) .sidebar-brand-link { display: flex; width: 100%; justify-content: center; align-items: center; }
.sidebar-logo { object-position: center; }
.nav { gap: 3px; }
.sidebar-footer { border-top: 0; padding-top: 12px; }
/* Consultation uses the same content geometry as every other staff view. */
.page-consultations { width: min(100%, var(--content-max)); margin-inline: auto; padding: 30px 32px 64px; }
.page-consultations .consultation-toolbar { margin-bottom: 18px; }
.page-consultations .consultation-grid { margin-top: 0; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); }
.page-consultations .consultation-grid > * { min-width: 0; }
/* Form controls keep the same tap target, type scale and focus state in every module. */
:root { --field-height: 44px; --field-radius: 7px; --field-border: var(--border-strong); --field-placeholder: #64748B; }
:where(input:not([type='checkbox']):not([type='radio']):not([type='range']):not([type='file']):not([type='hidden']):not([type='color']), select, textarea) {
  min-width: 0;
  min-height: var(--field-height);
  border: 1px solid var(--field-border);
  border-radius: var(--field-radius);
  background-color: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  padding: 10px 13px;
  transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease;
}
:where(input:not([type='checkbox']):not([type='radio']):not([type='range']):not([type='file']):not([type='hidden']):not([type='color']), select, textarea)::placeholder { color: var(--field-placeholder); opacity: 1; }
:where(input:not([type='checkbox']):not([type='radio']):not([type='range']):not([type='file']):not([type='hidden']):not([type='color']), select, textarea):focus-visible { border-color: var(--brand-orange); outline: 2px solid var(--brand-orange); outline-offset: 1px; box-shadow: var(--focus); }
:where(input:not([type='checkbox']):not([type='radio']):not([type='range']):not([type='file']):not([type='hidden']):not([type='color']), select, textarea):disabled { background-color: var(--surface-subtle); color: var(--muted); }
.input:not(textarea), .select, .control:not(textarea),
.field input:not([type='checkbox']):not([type='radio']), .field select,
.form-grid input:not([type='checkbox']):not([type='radio']), .form-grid select,
.portal-form input:not([type='checkbox']):not([type='radio']), .portal-form select,
.dashboard-toolbar select {
  height: var(--field-height); min-height: var(--field-height);
  border-color: var(--field-border); border-radius: var(--field-radius);
  font-size: 14px; padding-block: 9px;
}
.field textarea, .form-grid textarea, .portal-form textarea, textarea.input { border-color: var(--field-border); border-radius: var(--field-radius); font-size: 14px; }
.input::placeholder, .control::placeholder, .field input::placeholder, .field textarea::placeholder, .form-grid input::placeholder, .form-grid textarea::placeholder, .portal-form input::placeholder, .portal-form textarea::placeholder { color: var(--field-placeholder); opacity: 1; }
.input:focus, .select:focus, .control:focus, .field input:focus, .field select:focus, .field textarea:focus,
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus, .portal-form input:focus, .portal-form select:focus, .portal-form textarea:focus {
  border-color: var(--brand-orange); outline: 2px solid var(--brand-orange); outline-offset: 1px; box-shadow: var(--focus);
}
:where(label:not(.sr-only):not(.check-row), .field label, .form-grid label, .portal-form label, .agenda-filters label) { color: var(--ink); font-size: 13px; font-weight: 650; }
:where(.form-grid, .portal-form, .field) > label { display: grid; align-content: start; gap: 7px; }
:where(textarea, textarea.input, .form-grid textarea, .field textarea) { min-height: 100px; resize: vertical; }
/* Keep the search field's integrated shape and avoid styling native checkboxes. */
.topbar-search input { min-height: 0; height: 100%; padding: 0; background: transparent; border: 0; box-shadow: none; }
@media (max-width: 980px) { .page-consultations .consultation-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 880px) { .sidebar-brand, body:not(.sidebar-collapsed) .sidebar-brand { padding: 20px 12px 22px; } }
@media (max-width: 760px) { .page-consultations { padding: 20px 16px 52px; } }
@media (max-width: 480px) { .page-consultations { padding-inline: 12px; } }
@media print { .page-consultations { width: 100%; padding: 0; } }


/* Ajustes proporcionais dos botões dentro de modais; preserva o Design System existente. */
.modal .modal-footer,
.modal .form-actions {
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.modal .modal-footer .btn,
.modal .form-actions .btn {
  min-height: 34px;
  padding: 7px 11px;
  font-size: 12px;
  line-height: 1.2;
  gap: 6px;
  flex: 0 1 auto;
  width: auto;
  max-width: 100%;
}
@media (max-width: 640px) {
  .modal .modal-footer,
  .modal .form-actions { width: auto; }
  .modal .modal-footer .btn,
  .modal .form-actions .btn { flex: 0 1 auto; width: auto; }
}


/* Resumo do paciente atual e do próximo: usa a paleta e os componentes existentes. */
.consult-next-patient { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0 0 14px; }
.consult-next-item { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--border, #E5E7EB); border-radius: 12px; background: var(--surface, #FFFFFF); padding: 14px 16px; }
.consult-next-item.is-current { border-left: 3px solid var(--navy, #163E63); }
.consult-next-item.is-next { border-left: 3px solid var(--teal, #D97723); }
.consult-next-item.is-upcoming { border-left: 3px solid var(--teal, #D97723); }
.consult-next-copy { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.consult-next-copy strong { color: var(--text, #1F2937); font-size: 14px; overflow-wrap: anywhere; }
.consult-next-label { color: var(--muted, #6B7280); font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.consult-next-meta { color: var(--muted, #6B7280); font-size: 12px; overflow-wrap: anywhere; }
.consult-next-empty { grid-column: 1 / -1; border: 1px dashed var(--border, #E5E7EB); border-radius: 10px; padding: 14px; color: var(--muted, #6B7280); font-size: 13px; }
.modal .modal-footer .btn, .modal .form-actions .btn, .modal .actions .btn, .modal .modal-body .btn { min-height: 34px; padding: 7px 11px; font-size: 12px; line-height: 1.25; gap: 6px; width: auto; max-width: 100%; }
.modal .modal-footer, .modal .form-actions { gap: 8px; flex-wrap: wrap; align-items: center; }
@media (max-width: 760px) { .consult-next-patient { grid-template-columns: minmax(0, 1fr); } .consult-next-item { padding: 12px; } .modal .modal-footer .btn, .modal .form-actions .btn { flex: 0 1 auto; } }


/* Ajustes finais de proporção dos botões dos modais e de leitura dos campos. */
.modal .modal-footer,
.modal .form-actions,
.modal .actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
}
.modal .modal-footer > .btn,
.modal .form-actions > .btn,
.modal .actions > .btn,
.modal .modal-body .btn:not(.icon-btn):not(.close-btn) {
  box-sizing: border-box;
  flex: 0 1 auto !important;
  width: auto !important;
  min-width: 0 !important;
  max-width: 100%;
  min-height: 32px !important;
  height: auto;
  padding: 6px 10px !important;
  font-size: 12px !important;
  line-height: 1.25 !important;
  gap: 5px;
  white-space: normal;
  overflow-wrap: anywhere;
}
.modal .modal-body,
.modal .modal-body form,
.modal .form-actions > * { min-width: 0; }
@media (max-width: 520px) {
  .modal .modal-footer,
  .modal .form-actions,
  .modal .actions { justify-content: flex-end; gap: 6px; }
  .modal .modal-footer > .btn,
  .modal .form-actions > .btn,
  .modal .actions > .btn { flex: 0 1 auto !important; }
}

.access-denied-page{min-height:100vh;display:grid;place-items:center;padding:24px;background:var(--page-bg,#F5F7FA);color:var(--ink,#1F2937)}.access-denied-card{width:min(100%,560px);padding:clamp(24px,5vw,40px);border:1px solid var(--border,#E5E7EB);border-radius:16px;background:var(--card,#fff);box-shadow:0 12px 36px rgba(15,23,42,.08);text-align:center}.access-denied-logo{display:block;width:min(220px,70%);height:auto;max-height:80px;object-fit:contain;margin:0 auto 24px;padding:10px 14px;box-sizing:border-box;border-radius:10px;background:var(--navy,#004080)}.access-denied-icon{display:grid;place-items:center;width:44px;height:44px;margin:0 auto 12px;border-radius:50%;background:#fff1f0;color:#b42318;font-size:26px;font-weight:800}.access-denied-card h1{margin:0 0 10px;color:var(--navy,#004080);font-size:clamp(22px,4vw,28px)}.access-denied-card p{line-height:1.65;margin:0 auto 12px;max-width:440px}.access-denied-help{color:var(--muted,#6B7280);font-size:13px}.access-denied-actions{display:flex;justify-content:center;flex-wrap:wrap;gap:8px;margin-top:24px}.access-denied-actions .btn{flex:0 1 auto;width:auto;min-width:0;min-height:36px;padding:8px 12px}@media(max-width:480px){.access-denied-page{padding:14px}.access-denied-actions{flex-direction:column}.access-denied-actions .btn{width:100%}}

/* Correção focalizada: contatos adicionais do paciente, mantendo o Design System existente. */
.inline-form.patient-subform{display:grid;grid-template-columns:minmax(130px,180px) minmax(220px,1fr) auto auto;align-items:center;gap:8px;margin:0 0 16px;width:100%;}
.inline-form.patient-subform .contact-add-button{width:auto;min-width:0;min-height:40px;align-self:center;flex:0 0 auto;white-space:nowrap;padding:9px 14px;}
.inline-form.patient-subform .checkbox{white-space:nowrap;margin:0;}
@media(max-width:760px){.inline-form.patient-subform{grid-template-columns:minmax(0,1fr) minmax(0,1.5fr);}.inline-form.patient-subform .checkbox{align-self:center;}.inline-form.patient-subform .contact-add-button{grid-column:auto;justify-self:start;}}

/* Integração de prescrição Memed — componentes locais, responsivos e alinhados ao Design System. */
.memed-prescription-card .card-toolbar{align-items:flex-start;flex-wrap:wrap;gap:12px;}
.memed-status{white-space:nowrap;background:#eef5ff;color:var(--navy);border:1px solid var(--border,#e5e7eb);}
.memed-message{margin:12px 0 16px;padding:12px 14px;line-height:1.55;border-radius:10px;}
.memed-prescription-actions{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin:4px 0 22px;}
.memed-prescription-actions .btn{width:auto;max-width:100%;white-space:normal;}
.memed-prescription-history{border-top:1px solid var(--border,#e5e7eb);padding-top:16px;margin-top:8px;}
.memed-prescription-history h3{margin:0 0 10px;color:var(--navy);font-size:1rem;}
.memed-prescription-history .stack-item{align-items:center;}
.memed-prescription-history .stack-item .clinical-actions{display:flex;gap:8px;flex-wrap:wrap;}
.memed-legacy-history{margin-top:18px;padding-top:14px;border-top:1px solid var(--border,#e5e7eb);}
.memed-legacy-history summary{cursor:pointer;font-weight:700;color:var(--navy);padding:4px 0;}
.memed-legacy-history>p{margin:8px 0 12px;line-height:1.5;}
@media(max-width:640px){.memed-prescription-card .card-toolbar{align-items:flex-start;flex-direction:column;}.memed-prescription-actions{align-items:stretch;flex-direction:column;}.memed-prescription-actions .btn{width:100%;}.memed-prescription-actions .muted{line-height:1.5;}}


/* Correções de contenção: preservam cores, fontes e tamanhos do Design System. */
.btn { min-width: 0; max-width: 100%; height: auto; white-space: normal; overflow-wrap: anywhere; }
.btn > svg, .icon-btn, .close-btn { flex-shrink: 0; }
.page-consultations .page-header,
.page-consultations .card-toolbar,
.tiss-page .page-heading,
.tiss-page .section-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}
.page-consultations .page-header > *,
.page-consultations .card-toolbar > *,
.tiss-page .page-heading > *,
.tiss-page .section-head > * { min-width: 0; }
.page-consultations .page-actions,
.tiss-page .page-actions { min-width: 0; max-width: 100%; }
.page-consultations .page-actions .btn,
.tiss-page .page-actions .btn { flex: 0 1 auto; }
.page-consultations .consultation-card,
.page-consultations .consult-next-item,
.tiss-page .tiss-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}
.page-consultations .consultation-card > *,
.page-consultations .consult-next-item > *,
.tiss-page .tiss-row > * { min-width: 0; }
.page-consultations .consultation-card .main,
.tiss-page .tiss-row > div:first-child { overflow-wrap: anywhere; }
.page-consultations .consultation-card .actions,
.tiss-page .row-actions { max-width: 100%; min-width: 0; }
.page-consultations .chat-form { grid-template-columns: minmax(0, 1fr) auto; }
.modal-header > :first-child { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 900px) {
  .tiss-page .tiss-row { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .page-consultations .page-header,
  .page-consultations .card-toolbar,
  .tiss-page .page-heading,
  .tiss-page .section-head { grid-template-columns: minmax(0, 1fr); }
  .page-consultations .page-actions,
  .tiss-page .page-actions { width: auto; justify-content: flex-start; }
  .page-consultations .consult-next-patient { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .page-consultations .consultation-card,
  .page-consultations .chat-form { grid-template-columns: minmax(0, 1fr); }
  .page-consultations .consultation-card .actions { justify-content: flex-start; }
  .tiss-page .row-actions .btn { flex: 0 1 auto; }
}
@media (max-width: 360px) {
  .page-consultations .consult-next-item { grid-template-columns: minmax(0, 1fr); }
  .page-consultations .consult-next-item .btn { justify-self: start; }
}

/* ==================================================================
   WhatsApp gratuito + NPS (migração 024)
   ================================================================== */
:root { --wa-green: #128C4A; --nps-detractor: #DC2626; --nps-detractor-2: #EA580C; --nps-passive: #CA8A04; --nps-promoter: #15803D; }
.wa-btn svg, .wa-btn-outline svg { flex: 0 0 auto; }
.wa-btn-outline { color: var(--wa-green); }
.wa-has-inline { position: relative; }
.wa-inline-btn { display: inline-grid; place-items: center; width: 28px; height: 28px; margin: 2px 0 4px auto; border: 1px solid var(--border); border-radius: 999px; background: #fff; color: var(--wa-green); cursor: pointer; box-shadow: var(--shadow-sm); }
.wa-inline-btn:hover, .wa-inline-btn:focus-visible { background: var(--success-soft); outline: none; border-color: var(--wa-green); }
.wa-patient-card { display: grid; gap: 2px; padding: 12px 14px; margin-bottom: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #F8FAFC; }
.wa-vars, .wa-var-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 10px 0; }
.wa-var-list { display: grid; grid-template-columns: max-content 1fr; gap: 8px 12px; }
.wa-var-chip { border: 1px dashed var(--navy-3); background: #fff; color: var(--navy); border-radius: 999px; padding: 4px 10px; font: 600 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; cursor: pointer; }
.wa-var-chip:hover { background: #EEF4FA; }
.wa-preview { display: grid; gap: 6px; margin-top: 8px; }
.wa-preview > div { white-space: pre-wrap; padding: 12px 14px; border-radius: 10px 10px 10px 2px; background: #E7F8EE; border: 1px solid #C7EBD5; color: #0F2E1C; font-size: 14px; max-height: 220px; overflow: auto; }
.wa-history { margin-top: 14px; }
.wa-history summary { cursor: pointer; color: var(--navy); font-weight: 700; }
.wa-history ul { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
.wa-template-body { max-width: 420px; white-space: pre-wrap; color: var(--muted); font-size: 13px; }
.wa-queue-card .page-actions { flex-wrap: wrap; }
.text-danger { color: var(--danger); }

.nps-logo { display: block; max-width: 180px; margin: 0 auto 18px; }
.nps-question { font-size: 16px; line-height: 1.5; }
.nps-scale-colored button { font-weight: 800; color: #fff; border: 2px solid transparent; transition: transform .12s ease, box-shadow .12s ease; }
.nps-scale-colored button.nps-detractor { background: var(--nps-detractor); }
.nps-scale-colored button.nps-detractor[data-score="5"], .nps-scale-colored button.nps-detractor[data-score="6"] { background: var(--nps-detractor-2); }
.nps-scale-colored button.nps-passive { background: var(--nps-passive); }
.nps-scale-colored button.nps-promoter { background: var(--nps-promoter); }
.nps-scale-colored button:hover { transform: translateY(-2px); }
.nps-scale-colored button.selected { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(22, 62, 99, .25); transform: translateY(-2px) scale(1.06); background-clip: padding-box; }
.nps-scale-colored button.nps-detractor.selected { background: var(--nps-detractor); }
.nps-scale-colored button.nps-passive.selected { background: var(--nps-passive); }
.nps-scale-colored button.nps-promoter.selected { background: var(--nps-promoter); }
.nps-scale-legend { display: flex; justify-content: space-between; margin: -10px 0 18px; color: var(--muted); font-size: 12px; }
.nps-comment-label { display: block; text-align: left; font-weight: 700; color: var(--navy); margin-bottom: 6px; }
.nps-thanks { padding: 10px 0; }
.nps-thanks-icon { width: 64px; height: 64px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 999px; background: var(--success-soft); color: var(--success); font-size: 30px; font-weight: 800; }

.nps-bars { display: grid; gap: 14px; }
.nps-bar-row { display: grid; grid-template-columns: 110px 1fr 120px; gap: 12px; align-items: center; }
.nps-bar-row strong { text-align: right; color: var(--navy); }
.nps-bar-track { height: 16px; border-radius: 999px; background: #EEF2F6; overflow: hidden; }
.nps-bar { height: 100%; width: 0; border-radius: 999px; transition: width .4s ease; }
.nps-bar-promoter, .nps-stack-promoter { background: var(--nps-promoter); }
.nps-bar-passive, .nps-stack-passive { background: var(--nps-passive); }
.nps-bar-detractor, .nps-stack-detractor { background: var(--nps-detractor); }
.nps-stack { display: flex; height: 14px; margin: 12px 0 8px; border-radius: 999px; overflow: hidden; background: #EEF2F6; }
.nps-stack span { display: block; height: 100%; }
.nps-score-pill { display: inline-grid; place-items: center; min-width: 30px; height: 30px; border-radius: 999px; color: #fff; font-weight: 800; }
.nps-score-pill.nps-promoter { background: var(--nps-promoter); }
.nps-score-pill.nps-passive { background: var(--nps-passive); }
.nps-score-pill.nps-detractor { background: var(--nps-detractor); }

@media (max-width: 640px) {
  .nps-scale-colored { grid-template-columns: repeat(6, 1fr); gap: 6px; }
  .nps-scale-colored button { padding: 12px 2px; }
  .nps-bar-row { grid-template-columns: 80px 1fr; }
  .nps-bar-row strong { grid-column: 1 / -1; text-align: left; font-size: 13px; }
  .wa-var-list { grid-template-columns: 1fr; }
  .wa-queue-card .page-actions, .wa-queue-card .page-actions .btn { width: 100%; }
}

/* ==========================================================================
   Proporção equilibrada dos botões de ação (todas as telas)
   Mantém cores, raios e tipografia do Design System; ajusta apenas
   altura, largura mínima, espaçamento e quebra em telas menores.
   ========================================================================== */
.btn { min-width: 0; white-space: nowrap; text-align: center; }
.btn-sm { min-height: 34px; min-width: 84px; padding: 7px 12px; font-size: 13px; gap: 6px; border-radius: var(--radius-sm); }
.btn-danger { border-color: transparent; }
.btn-danger:hover { filter: brightness(.94); }
.btn svg { flex: 0 0 auto; }

.table-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 6px; }
.table-actions .btn-sm { flex: 0 0 auto; }
td.table-actions { white-space: normal; min-width: 0; }

.page-heading-actions { gap: 10px; }
.page-heading-actions .btn { min-width: 120px; }
.form-actions .btn { min-width: 120px; }
.card-toolbar > .btn, .card-toolbar .btn-sm { flex: 0 0 auto; }

@media (max-width: 1024px) {
  td.table-actions { min-width: 220px; }
  .table-actions { justify-content: flex-start; }
}

@media (max-width: 640px) {
  .btn { min-height: 44px; }
  .btn-sm { min-height: 40px; min-width: 0; padding: 8px 10px; }
  td.table-actions { min-width: 0; }
  .table-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); width: 100%; gap: 8px; }
  .table-actions .btn-sm { width: 100%; }
  .page-heading-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); width: 100%; }
  .page-heading-actions .btn { width: 100%; min-width: 0; }
  .form-actions .btn { min-width: 0; }
}

@media (max-width: 380px) {
  .table-actions { grid-template-columns: 1fr 1fr; }
  .page-heading-actions { grid-template-columns: 1fr; }
}
