:root {
  --blue: #0d6efd;
  --blue-dark: #0b2447;
  --blue-navy: #001f3f;
  --gold: #f5c542;
  --bg-body: #f4f6fb;
  --bg-card: #ffffff;
  --border-soft: #e1e4ee;
  --text-main: #111827;
  --text-muted: #6b7280;
  --danger: #dc3545;
  --success: #198754;
  --shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.12);
}

/* RESET BÁSICO */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  width: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #0b2447 0, #001428 35%, #020617 70%) fixed;
  color: var(--text-main);
}

/* LINKS */
a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* UTILITÁRIOS */
.hidden {
  display: none !important;
}

.full-width {
  grid-column: 1 / -1;
}

.placeholder {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.muted {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.subsection-title {
  font-weight: 600;
  color: var(--blue-dark);
  margin-top: 10px;
  margin-bottom: 4px;
}

/* BOTÕES */
.btn {
  border-radius: 999px;
  border: none;
  font-size: 0.9rem;
  padding: 0.55rem 1.3rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 500;
  transition: all 0.15s ease-in-out;
  background: #e5e7eb;
  color: #111827;
}

.btn i {
  font-size: 0.9rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--blue), #1d4ed8);
  color: #fff;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover {
  filter: brightness(1.05);
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.45);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #e5e7eb;
  color: #111827;
}

.btn-secondary:hover {
  background: #d1d5db;
}

.btn-outline {
  background: transparent;
  color: var(--blue);
  border: 1px solid rgba(37, 99, 235, 0.4);
}

.btn-outline:hover {
  background: rgba(37, 99, 235, 0.06);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: rgba(148, 163, 184, 0.2);
  color: var(--text-main);
}

.btn-link {
  background: none;
  border: none;
  color: var(--blue);
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-size: 0.9rem;
}

.btn-link:hover {
  text-decoration: underline;
}

.btn-icon {
  border-radius: 999px;
  background: transparent;
  border: none;
  color: #e5e7eb;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}

.btn-icon:hover {
  background: rgba(148, 163, 184, 0.25);
  transform: translateY(-1px);
}

.btn.small {
  padding: 0.3rem 0.9rem;
  font-size: 0.8rem;
}

.btn.full-width {
  width: 100%;
}

/* INPUTS E FORMULÁRIOS */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.input-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.input-group input,
.input-group select,
.input-group textarea {
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
  background-color: #f9fafb;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.8);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.2);
  background-color: #ffffff;
}

.input-group textarea {
  resize: vertical;
}

/* ERROS */
.error-message {
  color: var(--danger);
  font-size: 0.8rem;
  margin-top: 0.4rem;
}

/* APP ROOT */
#app {
  width: 100%;
  height: 100%;
  max-width: none;
}

/* TELAS */
.screen {
  width: 100%;
  height: 100%;
  display: none;
}

.screen.active {
  display: block;
}

/* LOGIN */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.login-wrapper {
  max-width: 440px;
  width: 100%;
}

.login-card {
  background: radial-gradient(circle at top left, rgba(59, 130, 246, 0.25), transparent 60%),
              linear-gradient(135deg, rgba(15, 23, 42, 0.96), rgba(15, 23, 42, 0.98));
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  padding: 2.1rem 2rem 1.8rem;
  color: #e5e7eb;
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(129, 140, 248, 0.7), rgba(244, 244, 245, 0.05));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.login-logo-area {
  display: flex;
  justify-content: center;
  margin-bottom: 1.3rem;
}

.login-logo {
  width: 80px;
  height: 80px;
  padding: 3px;
  box-shadow: 0 12px 30px rgba(234, 179, 8, 0.5);
}

.login-logo img {
  width: 100%;
  height: 100%;
}

.login-card h2 {
  text-align: center;
  font-size: 1.4rem;
  margin-bottom: 1.6rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

#login-form .input-group label {
  color: #9ca3af;
}

#login-form .input-group input {
  background: rgba(15, 23, 42, 0.85);
  border-color: rgba(148, 163, 184, 0.5);
  color: #e5e7eb;
}

#login-form .input-group input:focus {
  border-color: rgba(59, 130, 246, 0.9);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.4);
}

/* LAYOUT PRINCIPAL */
#main-screen {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  height: 100vh;
  width: 100%;
  background: radial-gradient(circle at top, #0b2447 0, #020617 60%);
}

#main-screen.sidebar-collapsed {
  grid-template-columns: 82px minmax(0, 1fr);
}

/* SIDEBAR */
#sidebar {
  background: radial-gradient(circle at top, #0b2447 0, #020617 55%);
  border-right: 1px solid rgba(148, 163, 184, 0.3);
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  padding: 1.3rem 1rem;
  position: relative;
  overflow: hidden;
}

#sidebar::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.08), transparent 55%);
  pointer-events: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
  padding-inline: 0.4rem;
}

.sidebar-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: radial-gradient(circle at 30% 20%, #facc15, #f97316);
  padding: 2px;
  box-shadow: 0 8px 20px rgba(234, 179, 8, 0.5);
}

.sidebar-logo img {
  border-radius: 10px;
}

.sidebar-title {
  display: flex;
  flex-direction: column;
}

.app-name {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.75rem;
}

.app-subtitle {
  font-size: 0.7rem;
  color: #9ca3af;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: auto;
  padding-inline: 0.2rem;
}

.nav-item {
  border-radius: 12px;
  border: none;
  background: transparent;
  color: #e5e7eb;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.7rem;
  cursor: pointer;
  font-size: 0.9rem;
  position: relative;
  transition: background 0.15s ease, transform 0.08s ease, box-shadow 0.15s ease, color 0.15s ease;
}

.nav-item i {
  width: 22px;
  text-align: center;
  font-size: 1rem;
}

.nav-item span {
  white-space: nowrap;
}

.nav-item::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid transparent;
  transition: border-color 0.15s ease;
}

.nav-item:hover {
  background: radial-gradient(circle at left, rgba(37, 99, 235, 0.22), transparent 60%);
  transform: translateY(-1px);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.18), rgba(56, 189, 248, 0.12));
  color: #f9fafb;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.75);
}

.nav-item.active::before {
  border-color: rgba(56, 189, 248, 0.7);
}

/* Sidebar colapsada */
#main-screen.sidebar-collapsed #sidebar {
  padding-inline: 0.5rem;
}

#main-screen.sidebar-collapsed .sidebar-title {
  display: none;
}

#main-screen.sidebar-collapsed .nav-item {
  justify-content: center;
  padding-inline: 0.3rem;
}

#main-screen.sidebar-collapsed .nav-item span {
  display: none;
}

/* Footer sidebar */
.sidebar-footer {
  padding-top: 1rem;
  border-top: 1px solid rgba(148, 163, 184, 0.35);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.user-mini {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.user-mini-icon {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 20%, #22c55e, #16a34a);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #e5e7eb;
  font-size: 0.9rem;
}

.user-mini-info {
  display: flex;
  flex-direction: column;
  font-size: 0.75rem;
}

.user-mini-info small {
  color: #9ca3af;
  font-size: 0.7rem;
}

.sidebar-footer .btn-ghost {
  justify-content: flex-start;
  padding-inline: 0.5rem;
  font-size: 0.85rem;
}

#main-screen.sidebar-collapsed .user-mini-info,
#main-screen.sidebar-collapsed .sidebar-footer .btn-ghost span {
  display: none;
}

/* MAIN CONTENT */
#main-content {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(15, 23, 42, 0.98));
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  color: var(--text-main);
}

/* TOPBAR */
.topbar {
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.35);
  color: #e5e7eb;
  position: relative;
  z-index: 10;
}

.topbar::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top, rgba(56, 189, 248, 0.12), transparent 65%);
  pointer-events: none;
}

#page-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-left: 0.5rem;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.clinic-label {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.25rem 0.8rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.65);
  color: #e5e7eb;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.88rem;
}

.topbar-user i {
  font-size: 1.3rem;
}

/* ÁREA DE MÓDULOS */
#modules-container {
  flex: 1;
  width: 100%;
  padding: 1.2rem 1.5rem 1.2rem;
  overflow-y: auto;
  background: radial-gradient(circle at top left, rgba(37, 99, 235, 0.15), transparent 60%),
              radial-gradient(circle at bottom right, rgba(2, 6, 23, 0.9), rgba(15, 23, 42, 1));
}

.module {
  display: none;
  width: 100%;
}

.module.active {
  display: block;
}

.module-header {
  margin-bottom: 1rem;
}

.module-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
  color: #e5e7eb;
}

/* CARDS */
.card {
  background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.86), rgba(15, 23, 42, 0.95));
  border-radius: 18px;
  padding: 1rem 1rem 1.2rem;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(148, 163, 184, 0.35);
  margin-bottom: 1rem;
  color: #e5e7eb;
  position: relative;
}

.card.subtle {
  background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.92), rgba(15, 23, 42, 0.98));
  box-shadow: 0 8px 25px rgba(15, 23, 42, 0.7);
}

.card.full-width {
  grid-column: 1 / -1;
}

.card-header-inline {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.9rem;
}

.card-header-inline.small {
  margin-bottom: 0.5rem;
}

.card-header-inline h3,
.card-header-inline h4 {
  font-size: 1rem;
  font-weight: 600;
}

.card-header-inline .card-header-actions {
  margin-left: auto;
  display: flex;
  gap: 0.4rem;
}

/* TOOLBAR */
.toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.7rem;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.toolbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.toolbar-title {
  font-weight: 500;
}

/* CAIXA DE BUSCA */
.search-box {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.7);
  color: #9ca3af;
  min-width: 220px;
}

.search-box input {
  border: none;
  background: transparent;
  color: #e5e7eb;
  font-size: 0.9rem;
  width: 100%;
}

.search-box input::placeholder {
  color: #6b7280;
}

.search-box input:focus {
  outline: none;
}

/* TABELAS */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  margin-top: 0.4rem;
}

.table-wrapper.compact {
  margin-top: 0.2rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  color: #e5e7eb;
}

.data-table thead {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.98), rgba(15, 23, 42, 1));
}

.data-table th,
.data-table td {
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid rgba(31, 41, 55, 0.9);
  text-align: left;
  white-space: nowrap;
}

.data-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9ca3af;
}

.data-table tbody tr:nth-child(even) {
  background: rgba(15, 23, 42, 0.95);
}

.data-table tbody tr:hover {
  background: rgba(37, 99, 235, 0.1);
}

.data-table.small th,
.data-table.small td {
  padding: 0.3rem 0.45rem;
}

.table-secondary-text {
  display: block;
  font-size: 0.72rem;
  color: #9ca3af;
  font-weight: 400;
  white-space: normal;
}

/* AÇÕES NA TABELA */
.table-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.icon-btn {
  border-radius: 999px;
  border: none;
  padding: 0.28rem;
  background: transparent;
  cursor: pointer;
  color: #9ca3af;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
  background: rgba(148, 163, 184, 0.15);
  color: #e5e7eb;
}

.icon-btn.danger {
  color: #f87171;
}

.icon-btn.danger:hover {
  background: rgba(248, 113, 113, 0.15);
}

/* FORM GRID */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.75rem 1rem;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.static-value {
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
  background-color: rgba(15, 23, 42, 0.9);
  color: #e5e7eb;
  font-weight: 600;
}

/* DETALHES DO PACIENTE */
.detalhes-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.5fr) minmax(0, 1.5fr);
  gap: 0.75rem;
}

.detalhes-card {
  background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.92), rgba(15, 23, 42, 0.96));
  border-radius: 16px;
  padding: 0.8rem 0.9rem 0.9rem;
  border: 1px solid rgba(148, 163, 184, 0.4);
}

.detalhes-card.full-width {
  grid-column: 1 / -1;
}

.detalhes-card h4 {
  font-size: 0.9rem;
  font-weight: 600;
  color: #e5e7eb;
  margin-bottom: 0.5rem;
}

.details-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 0.35rem;
  padding-block: 0.15rem;
}

.details-label {
  font-size: 0.8rem;
  color: #9ca3af;
}

.details-value {
  font-size: 0.88rem;
}

.details-value.multiline {
  white-space: pre-wrap;
}

/* DASHBOARD */
.dashboard-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.7rem;
  margin-bottom: 0.9rem;
}

.dashboard-summary-card {
  background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.9), rgba(15, 23, 42, 0.98));
  border-radius: 16px;
  padding: 0.7rem 0.9rem;
  border: 1px solid rgba(148, 163, 184, 0.4);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.dashboard-summary-card.destaque {
  border-color: rgba(56, 189, 248, 0.8);
}

.summary-label {
  font-size: 0.75rem;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.summary-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: #e5e7eb;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.7fr);
  gap: 0.9rem;
}

.dashboard-card {
  background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.9), rgba(15, 23, 42, 0.98));
  border-radius: 18px;
  padding: 0.9rem 1rem 1rem;
  border: 1px solid rgba(148, 163, 184, 0.4);
  box-shadow: var(--shadow-soft);
  color: #e5e7eb;
}

.dashboard-card.full-width {
  grid-column: 1 / -1;
}

.dashboard-card h3 {
  font-size: 0.95rem;
  margin-bottom: 0.4rem;
}

.module-header-between {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.favorites-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.3rem;
}

.favorites-list li button {
  width: 100%;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.9);
  padding: 0.45rem 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  color: #e5e7eb;
  font-size: 0.88rem;
  transition: background 0.15s ease, transform 0.08s ease;
}

.favorites-list li button:hover {
  background: rgba(37, 99, 235, 0.2);
  transform: translateY(-1px);
}

.favorites-list li button i {
  width: 20px;
  text-align: center;
}

/* Pacientes recentes no dashboard */
.dashboard-recent-patients {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.3rem;
}

.dashboard-recent-patient {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.9);
  padding: 0.5rem 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  color: #e5e7eb;
  font-size: 0.85rem;
  text-align: left;
  transition: background 0.15s ease, transform 0.08s ease;
}

.dashboard-recent-patient:hover {
  background: rgba(37, 99, 235, 0.18);
  transform: translateY(-1px);
}

.dashboard-recent-patient span {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.dashboard-recent-patient small {
  color: #9ca3af;
  font-size: 0.72rem;
}

/* Agenda dia no dashboard */
.agenda-dia-list {
  margin-top: 0.2rem;
  max-height: 260px;
  overflow-y: auto;
}

.agenda-item {
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.4);
  padding: 0.4rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin-bottom: 0.3rem;
}

.dashboard-agenda-item {
  position: relative;
}

.dashboard-agenda-actions {
  position: absolute;
  top: 0.35rem;
  right: 0.4rem;
}

.agenda-item-time {
  font-size: 0.78rem;
  color: #9ca3af;
}

.agenda-item-main {
  font-size: 0.9rem;
}

.agenda-item-sub {
  font-size: 0.78rem;
  color: #9ca3af;
}

/* AGENDA */
.agenda-calendar {
  margin-top: 0.5rem;
}

.calendar-grid.agenda-month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.calendar-header {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: #9ca3af;
  text-align: center;
  padding: 0.3rem 0;
}

.calendar-day {
  min-height: 90px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(15, 23, 42, 0.85);
  padding: 0.3rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.calendar-day.empty {
  background: transparent;
  border: none;
  cursor: default;
}

.calendar-day.is-today {
  border-color: rgba(56, 189, 248, 0.85);
}

.calendar-day-number {
  font-size: 0.78rem;
  color: #9ca3af;
}

.calendar-events {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.calendar-event {
  border: none;
  border-radius: 6px;
  background: rgba(37, 99, 235, 0.35);
  color: #e5e7eb;
  font-size: 0.68rem;
  padding: 0.15rem 0.3rem;
  display: flex;
  justify-content: space-between;
  gap: 0.3rem;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calendar-more {
  font-size: 0.65rem;
  color: #9ca3af;
}

.agenda-week-grid {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 0.4rem;
}

.agenda-week-date {
  display: flex;
  flex-direction: column;
  padding: 0.4rem;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.agenda-week-date.is-today {
  border-color: rgba(56, 189, 248, 0.85);
}

.agenda-week-appointments {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding-bottom: 0.4rem;
}

.agenda-day-view {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.agenda-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.agenda-day-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* Botões toggle view */
.btn-group {
  display: inline-flex;
  border-radius: 999px;
  padding: 2px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.7);
}

.btn-toggle {
  border-radius: 999px;
  padding: 0.25rem 0.8rem;
  font-size: 0.8rem;
  border: none;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.btn-toggle.active {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.85), rgba(129, 140, 248, 0.9));
  color: #f9fafb;
}

/* FINANCEIRO */
.financeiro-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.6fr);
  gap: 0.9rem;
}

.financeiro-resumo {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
  margin-top: 0.4rem;
}

.resumo-item {
  background: rgba(15, 23, 42, 0.95);
  border-radius: 12px;
  padding: 0.5rem 0.7rem;
  border: 1px solid rgba(148, 163, 184, 0.6);
}

.resumo-item .label {
  font-size: 0.78rem;
  color: #9ca3af;
}

.resumo-item .value {
  font-weight: 600;
  margin-top: 0.15rem;
}

.resumo-item.destaque {
  border-color: rgba(56, 189, 248, 0.8);
}

#fin-saldo.positive {
  color: #4ade80;
}

#fin-saldo.negative {
  color: #f87171;
}

.financial-type {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.financial-type.revenue {
  background: rgba(74, 222, 128, 0.18);
  color: #4ade80;
}

.financial-type.expense {
  background: rgba(248, 113, 113, 0.18);
  color: #f87171;
}

.value-positive {
  color: #4ade80;
  font-weight: 600;
}

.value-negative {
  color: #f87171;
  font-weight: 600;
}

/* CONFIGURAÇÕES */
.config-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.1fr);
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.config-grid > .card.full-width {
  grid-column: 1 / -1;
}

.favoritos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.6rem;
  margin-top: 0.4rem;
}

.check-pill {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  cursor: pointer;
  font-size: 0.85rem;
}

.check-pill input {
  accent-color: var(--blue);
}

#config-clinic-logo-preview {
  max-width: 140px;
  max-height: 140px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  object-fit: contain;
  background: rgba(15, 23, 42, 0.9);
  padding: 0.3rem;
}

/* USUÁRIOS */
.status-active {
  color: #4ade80;
  font-weight: 600;
  font-size: 0.8rem;
}

.status-inactive {
  color: #f87171;
  font-weight: 600;
  font-size: 0.8rem;
}

/* MODALS */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.76);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-content {
  background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.96), rgba(15, 23, 42, 0.98));
  border-radius: 18px;
  padding: 0.9rem 1rem 1.1rem;
  border: 1px solid rgba(148, 163, 184, 0.55);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.85);
  max-height: 90vh;
  overflow-y: auto;
  color: #e5e7eb;
}

.modal-content.medium {
  width: min(550px, 96vw);
}

.modal-content.large {
  width: min(800px, 96vw);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.7rem;
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

/* MENSAGENS GLOBAIS DO SISTEMA */
.application-message {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999;
  padding: 0.65rem 1.1rem;
  border-radius: 12px;
  font-size: 0.85rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  color: #ffffff;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.5);
  max-width: 320px;
}

.application-message-error {
  border-color: rgba(248, 113, 113, 0.8);
  background: rgba(127, 29, 29, 0.95);
}

.application-message-success {
  border-color: rgba(74, 222, 128, 0.8);
  background: rgba(20, 83, 45, 0.95);
}

/* ELEMENTOS RESTRITOS A ADMIN (controlado via JS) */
.admin-only.hidden {
  display: none !important;
}

/* APLICAÇÃO OCUPADA */
body.application-busy {
  cursor: progress;
}

/* RESPONSIVIDADE */
@media (max-width: 1024px) {
  #main-screen {
    grid-template-columns: 78px minmax(0, 1fr);
  }

  .sidebar-title {
    display: none;
  }

  .nav-item {
    justify-content: center;
  }

  .nav-item span {
    display: none;
  }

  .sidebar-footer .user-mini-info,
  .sidebar-footer .btn-ghost span {
    display: none;
  }

  .detalhes-grid {
    grid-template-columns: minmax(0, 1.8fr) minmax(0, 1.5fr);
  }

  .financeiro-layout {
    grid-template-columns: 1fr;
  }

  .config-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  #modules-container {
    padding-inline: 0.9rem;
  }

  .topbar {
    padding-inline: 0.8rem;
  }

  .topbar-right {
    gap: 0.6rem;
  }

  .clinic-label {
    display: none;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detalhes-grid {
    grid-template-columns: 1fr;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-right {
    margin-left: 0;
    justify-content: flex-end;
  }

  .search-box {
    width: 100%;
  }

  .financeiro-resumo {
    grid-template-columns: 1fr;
  }

  .agenda-week-grid {
    grid-template-columns: 1fr;
  }

  #main-screen.sidebar-mobile-open #sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 240px;
    z-index: 60;
  }
}

@media (max-width: 600px) {
  .card {
    padding-inline: 0.8rem;
  }

  .data-table th,
  .data-table td {
    padding-inline: 0.4rem;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-summary-grid {
    grid-template-columns: 1fr;
  }
}

/* IMPRESSÃO – esconder navegação e manter cards/tabelas limpos */
@media print {
  body {
    background: #ffffff !important;
  }

  #sidebar,
  .topbar,
  .toolbar,
  .btn,
  .btn-icon,
  .modal {
    display: none !important;
  }

  #modules-container {
    padding: 0 !important;
  }

  .module {
    display: block !important;
  }

  .card,
  .detalhes-card {
    box-shadow: none !important;
    background: #ffffff !important;
    color: #000000 !important;
    border: 1px solid #d1d5db !important;
  }

  .data-table th {
    background: #e5e7eb !important;
    color: #111827 !important;
  }
}

/* CONTROLE CORRETO DAS TELAS */
#login-screen,
#main-screen {
  display: none;
}

#login-screen.active {
  display: flex;
}

#main-screen.active {
  display: grid;
}