/* ============ Tema ============ */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e6eaf2;
  --primary: #0d9488;
  --primary-600: #0f766e;
  --primary-soft: #ccfbf1;
  --accent: #6366f1;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 10px 30px rgba(15, 23, 42, .06);
  --bs-body-font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --bs-body-color: var(--text);
  --bs-body-bg: var(--bg);
  --bs-border-color: var(--line);
  --bs-link-color: var(--primary-600);
  --bs-link-hover-color: var(--primary);
}
[data-bs-theme="dark"] {
  --bg: #0b1220;
  --surface: #111a2e;
  --surface-2: #162038;
  --text: #e6eaf4;
  --muted: #94a3b8;
  --line: #22304f;
  --primary: #2dd4bf;
  --primary-600: #5eead4;
  --primary-soft: #0f3d3a;
  --accent: #818cf8;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-border-color: var(--line);
}

body { background: var(--bg) radial-gradient(900px 400px at 100% -10%, color-mix(in srgb, var(--primary) 10%, transparent), transparent) no-repeat; color: var(--text); font-size: .94rem; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, h5 { letter-spacing: -.01em; font-weight: 600; }
.text-muted { color: var(--muted) !important; }
a { text-underline-offset: 3px; }

/* ============ Barra superior ============ */
.appbar { position: sticky; top: 0; z-index: 1030; background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.appbar-inner { max-width: 1480px; margin: 0 auto; padding: .65rem 1.25rem; display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--text); font-weight: 700; font-size: 1.15rem; }
.brand-mark { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--primary), var(--accent)); box-shadow: 0 6px 16px color-mix(in srgb, var(--primary) 40%, transparent); }
.nav-pills-app { display: flex; gap: .25rem; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
.nav-pills-app > li > a { display: flex; align-items: center; gap: .45rem; padding: .5rem .9rem; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 500; transition: .15s; }
.nav-pills-app > li > a:hover { background: var(--surface-2); color: var(--text); }
.nav-pills-app > li > a.active { background: var(--primary-soft); color: var(--primary-600); }
.dropdown-toggle::after { margin-left: .15rem; }
.dropdown-menu { border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: .4rem; background: var(--surface); }
.dropdown-item { border-radius: 8px; padding: .5rem .75rem; display: flex; gap: .6rem; align-items: center; color: var(--text); }
.dropdown-item:hover { background: var(--surface-2); }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); display: grid; place-items: center; transition: .15s; }
.icon-btn:hover { color: var(--text); border-color: var(--primary); }
.user-chip { display: flex; align-items: center; gap: .55rem; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: .25rem .8rem .25rem .3rem; color: var(--text); font-weight: 500; }
.user-avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), var(--primary)); color: #fff; font-weight: 600; font-size: .85rem; }

.page { max-width: 1480px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }

/* ============ Componentes base ============ */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.btn { border-radius: 10px; font-weight: 500; padding: .5rem 1rem; transition: .15s; }
.btn-sm { padding: .35rem .75rem; border-radius: 9px; }
.btn-primary { --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: var(--primary-600); --bs-btn-hover-border-color: var(--primary-600);
  --bs-btn-active-bg: var(--primary-600); --bs-btn-active-border-color: var(--primary-600); --bs-btn-disabled-bg: var(--primary); --bs-btn-disabled-border-color: var(--primary);
  --bs-btn-color: #fff; --bs-btn-hover-color: #fff; --bs-btn-active-color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--primary) 28%, transparent); }
[data-bs-theme="dark"] .btn-primary { --bs-btn-color: #04201d; --bs-btn-hover-color: #04201d; --bs-btn-active-color: #04201d; }
.btn-outline-primary { --bs-btn-color: var(--primary-600); --bs-btn-border-color: color-mix(in srgb, var(--primary) 45%, var(--line)); --bs-btn-hover-bg: var(--primary-soft);
  --bs-btn-hover-color: var(--primary-600); --bs-btn-hover-border-color: var(--primary); --bs-btn-active-bg: var(--primary-soft); --bs-btn-active-color: var(--primary-600); }
.btn-outline-secondary { --bs-btn-color: var(--muted); --bs-btn-border-color: var(--line); --bs-btn-hover-bg: var(--surface-2); --bs-btn-hover-color: var(--text); --bs-btn-hover-border-color: var(--line);
  --bs-btn-active-bg: var(--primary-soft); --bs-btn-active-color: var(--primary-600); --bs-btn-active-border-color: var(--primary); }
.btn-outline-danger { --bs-btn-border-color: color-mix(in srgb, #ef4444 40%, var(--line)); }
.form-control, .form-select { border-radius: 10px; border-color: var(--line); background-color: var(--surface); padding: .55rem .8rem; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent); background-color: var(--surface); }
.form-control-sm, .form-select-sm { padding: .35rem .65rem; border-radius: 9px; }
.form-label { font-weight: 500; font-size: .85rem; color: var(--muted); margin-bottom: .3rem; }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.table { --bs-table-bg: transparent; --bs-table-hover-bg: var(--surface-2); --bs-table-border-color: var(--line); }
.table thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; background: var(--surface-2); border-bottom: 1px solid var(--line); padding: .8rem .9rem; white-space: nowrap; }
.card.table-responsive { overflow: hidden; }
.modal-content { border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 30px 80px rgba(15, 23, 42, .25); background: var(--surface); }
.modal-header, .modal-footer { border-color: var(--line); }
.alert { border-radius: 12px; border: 1px solid var(--line); }
.alert-info { background: color-mix(in srgb, var(--primary) 10%, var(--surface)); color: var(--text); border-color: color-mix(in srgb, var(--primary) 30%, var(--line)); }
.badge { font-weight: 500; border-radius: 999px; padding: .38em .7em; }
.nav-pills .nav-link { border-radius: 10px; color: var(--muted); font-weight: 500; }
.nav-pills .nav-link.active { background: var(--primary-soft); color: var(--primary-600); }
.pagination { --bs-pagination-border-radius: 9px; --bs-pagination-active-bg: var(--primary); --bs-pagination-active-border-color: var(--primary); --bs-pagination-color: var(--muted); --bs-pagination-bg: var(--surface); --bs-pagination-border-color: var(--line); }
.list-group-item { background: var(--surface); border-color: var(--line); }
.page h2.fw-light, .page h2.m-0 { font-size: 1.6rem; font-weight: 700 !important; }
.agenda-title { color: var(--text); font-weight: 700; font-size: 1.25rem; }

/* ============ Agenda ============ */
.legend { display: flex; flex-wrap: wrap; gap: .5rem; font-size: .8rem; }
.legend span { display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .65rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.legend i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid; display: inline-block; margin: 0; }
#today-list div { padding: .35rem .5rem; border-radius: 8px; background: var(--surface-2); margin-bottom: .3rem; }
#today-list div:last-child { margin-bottom: 0; }
.fc { --fc-border-color: var(--line); --fc-page-bg-color: var(--surface); --fc-neutral-bg-color: var(--surface-2); --fc-today-bg-color: color-mix(in srgb, var(--primary) 8%, transparent);
  --fc-now-indicator-color: #ef4444; --fc-small-font-size: .8em; font-family: var(--bs-body-font-family); }
.fc .fc-col-header-cell { background: var(--surface-2); padding: .5rem 0; }
.fc .fc-col-header-cell-cushion { color: var(--muted); font-weight: 600; text-decoration: none; text-transform: uppercase; font-size: .72rem; letter-spacing: .06em; }
.fc .fc-day-today .fc-col-header-cell-cushion { color: var(--primary-600); }
.fc .fc-timegrid-slot { height: 3.2em; }
.fc .fc-timegrid-slot-label-cushion { font-size: .78rem; color: var(--muted); }
.fc-theme-standard td, .fc-theme-standard th, .fc-theme-standard .fc-scrollgrid { border-color: var(--line); }
.fc-event { border-width: 0 0 0 4px !important; border-radius: 10px !important; box-shadow: 0 1px 3px rgba(15, 23, 42, .12); cursor: pointer; font-size: .78rem; transition: transform .12s, box-shadow .12s; }
.fc-event { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; } /* segurar o dedo não seleciona texto nem abre menu */
.fc-event.fc-event-dragging, .fc-event.fc-event-selected { box-shadow: 0 8px 22px rgba(15, 23, 42, .35); }
.fc-event:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(15, 23, 42, .18); }
.ev { padding: 3px 6px; line-height: 1.3; overflow: hidden; color: #0f172a; }
.ev-top { display: flex; justify-content: space-between; align-items: center; gap: .3rem; }
.ev-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .85; }
.ev-edit { opacity: .45; margin-left: 3px; }
.ev-edit:hover { opacity: 1; }
/* celular: lápis maior e com área de toque ampliada (sem aumentar a altura do evento) */
@media (pointer: coarse) {
  .ev-edit { opacity: 1; font-size: 1.15rem; padding: 10px 8px; margin: -10px -4px -10px 2px; }
}
.ev-red { color: #dc2626; }
.ev-green { color: #15803d; }

/* ============ Pacientes ============ */
.pac-table td { padding: .75rem .9rem; vertical-align: middle; }
.mini-avatar { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; color: #fff; font-size: .78rem; font-weight: 600; }
.name-cell { max-width: 420px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.name-cell a:hover { color: var(--primary-600) !important; }
.btn-edit { width: 34px; height: 34px; padding: 0; border-radius: 10px; background: var(--primary-soft); color: var(--primary-600); border: 0; }
.btn-edit:hover { background: var(--primary); color: #fff; }

/* ============ Prontuário ============ */
.avatar { width: 112px; height: 112px; border-radius: 32px; color: #fff; font-size: 2.6rem; font-weight: 600; display: grid; place-items: center; box-shadow: 0 14px 30px rgba(15, 23, 42, .2); }
.side-menu { gap: .35rem; display: flex; flex-direction: column; }
.side-menu .list-group-item { border: 1px solid var(--line); border-radius: 12px !important; background: var(--surface); color: var(--muted); font-weight: 500; display: flex; gap: .6rem; align-items: center; }
.side-menu .list-group-item:hover { color: var(--text); border-color: var(--primary); }
.side-menu .list-group-item.active { background: var(--primary-soft); color: var(--primary-600); border-color: color-mix(in srgb, var(--primary) 40%, var(--line)); }
.patient-bar { background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 9%, var(--surface)), var(--surface) 55%); }
.patient-bar b { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.btn-main { min-width: 200px; padding: .7rem 1.2rem; font-weight: 600; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; letter-spacing: .02em; }
.tag-pill { background: var(--primary-soft); color: var(--primary-600); }
.tag-x { font-size: .5rem; vertical-align: middle; filter: none; opacity: .6; }
.tabs-row { display: flex; gap: .5rem; overflow-x: auto; padding: .25rem .1rem .6rem; scrollbar-width: thin; }
.tab-card { flex: 0 0 auto; padding: .6rem 1.1rem; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); text-decoration: none; font-weight: 500; font-size: .88rem; transition: .15s; white-space: nowrap; }
.tab-card:hover { color: var(--text); border-color: var(--primary); }
.tab-card.active { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--primary) 30%, transparent); }
[data-bs-theme="dark"] .tab-card.active { color: #04201d; }
.tab-card.locked { opacity: .7; }
.tl-item { display: flex; gap: 1rem; margin-bottom: 1.1rem; }
.date-box { flex: 0 0 62px; text-align: center; border-radius: 14px; font-weight: 700; height: fit-content; padding: .45rem 0; line-height: 1.15; color: #fff; background: linear-gradient(160deg, var(--primary), var(--accent)); }
.date-box div:first-child { font-size: 1.35rem; }
.date-box div:nth-child(2) { font-size: .7rem; letter-spacing: .08em; }
.date-box .yr { border-top: 1px solid rgba(255, 255, 255, .35); margin: .3rem .5rem 0; padding-top: .2rem; font-size: .7rem; font-weight: 500; }
.tl-card { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 14px; padding: .9rem 1.1rem; background: var(--surface-2); }
.ev-body { border: 1px solid var(--line); border-radius: 12px; padding: .85rem 1rem; text-align: left; background: var(--surface); }
.session-note { background: color-mix(in srgb, #f59e0b 14%, var(--surface)); border: 1px dashed #f59e0b; border-radius: 10px; padding: .5rem .75rem; }
.version { border-left: 3px solid var(--line); padding-left: .75rem; }
.empty-box { background: var(--surface-2); border: 1px dashed var(--line); padding: 2rem; font-size: 1.05rem; color: var(--muted); border-radius: 14px; text-align: center; }

/* ============ Login ============ */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center; padding: 4rem; color: #fff;
  background: radial-gradient(600px 400px at 20% 10%, rgba(255, 255, 255, .18), transparent), linear-gradient(145deg, #0f766e, #4f46e5); }
.login-hero::after { content: ''; position: absolute; width: 520px; height: 520px; right: -160px; bottom: -180px; border-radius: 50%; background: rgba(255, 255, 255, .08); }
.login-hero h1 { font-size: 2.4rem; font-weight: 700; max-width: 14ch; line-height: 1.15; }
.login-hero p { max-width: 38ch; opacity: .85; }
.login-hero .brand-mark { width: 52px; height: 52px; font-size: 1.5rem; background: rgba(255, 255, 255, .2); box-shadow: none; }
.login-panel { display: grid; place-items: center; padding: 2rem; }
.login-card { width: min(380px, 100%); }
@media (max-width: 860px) { .login-wrap { grid-template-columns: 1fr; } .login-hero { padding: 2rem; min-height: 220px; } .login-hero h1 { font-size: 1.6rem; } }

/* ============ Responsivo e impressão ============ */
@media (max-width: 767px) {
  .appbar-inner { gap: .75rem; }
  .nav-pills-app { flex-direction: column; margin-top: .75rem; }
  .page { padding: 1rem .75rem 2.5rem; }
  .tl-item { flex-direction: column; gap: .5rem; }
  .date-box { flex-basis: auto; display: flex; gap: .4rem; justify-content: center; padding: .35rem .8rem; width: fit-content; }
  .date-box .yr { border: 0; margin: 0; padding: 0; }
}
@media print { .appbar, aside, .tabs-row, .btn { display: none !important; } body { background: #fff; } }

/* ============ Fase 2: bloqueios, painel, listas ============ */
.fc .blk { background-image: repeating-linear-gradient(45deg, transparent 0 6px, rgba(255, 255, 255, .35) 6px 12px); opacity: .55; }
.kpi { padding: 1.1rem 1.25rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); height: 100%; }
.kpi .kpi-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.kpi .kpi-value { font-size: 1.9rem; font-weight: 700; line-height: 1.2; }
.kpi .kpi-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-600); font-size: 1.2rem; }
.kpi.warn .kpi-ico { background: #fef3c7; color: #b45309; }
.kpi.bad .kpi-ico { background: #fee2e2; color: #b91c1c; }
.kpi.info .kpi-ico { background: #e0e7ff; color: #4338ca; }
.list-clean { list-style: none; margin: 0; padding: 0; }
.list-clean li { display: flex; align-items: center; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.list-clean li:last-child { border-bottom: 0; }
.bar-track { height: 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), var(--accent)); }
.section-title { font-size: 1rem; font-weight: 600; margin-bottom: .75rem; display: flex; align-items: center; gap: .5rem; }
/* galeria de anexos */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .75rem; }
.gallery figure { margin: 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--surface-2); }
.gallery img, .gallery video { width: 100%; height: 150px; object-fit: cover; display: block; background: #000; }
.gallery figcaption { padding: .4rem .6rem; font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar .brand-name { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
