:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #eef4fa;
  --text: #17212b;
  --muted: #687789;
  --primary: #0f4c81;
  --primary-dark: #08365f;
  --light-blue: #bfe4ff;
  --dark-blue: #123f68;
  --border: #dce5ee;
  --danger: #b42318;
  --success: #087443;
  --shadow: 0 18px 45px rgba(19, 46, 75, .10);
  --radius: 18px;
}
* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 8px; color: var(--primary); font-size: .78rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(1.75rem, 4vw, 2.65rem); line-height: 1.08; }
h2 { font-size: 1.1rem; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .04em; }
.brand-centered { justify-content: center; margin-bottom: 24px; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: var(--primary); color: white; }
.landing-shell { min-height: 100vh; display: flex; flex-direction: column; }
.landing-header { display: flex; align-items: center; justify-content: space-between; padding: 22px clamp(20px, 5vw, 70px); }
.admin-link { color: var(--muted); font-size: .82rem; font-weight: 700; padding: 10px 12px; border-radius: 10px; }
.admin-link:hover { background: var(--surface); color: var(--primary); }
.landing-content { width: min(720px, calc(100% - 32px)); margin: auto; text-align: center; padding: 32px 0 80px; }
.consultorio-card { width: min(480px, 100%); margin: 28px auto 0; padding: 35px; border: 1px solid var(--border); border-radius: 28px; background: linear-gradient(145deg, #fff, #edf5fb); box-shadow: var(--shadow); color: var(--text); display: flex; flex-direction: column; align-items: center; gap: 8px; transition: .2s ease; }
.consultorio-card:hover { transform: translateY(-3px); border-color: #9cc7e9; }
.consultorio-card > span:nth-child(2) { font-size: 1.7rem; font-weight: 800; }
.consultorio-card small { color: var(--muted); }
.consultorio-icon { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: white; font-size: 1.8rem; }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; }
.back-link { position: absolute; top: 24px; left: 24px; color: var(--muted); }
.auth-card { width: min(430px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 26px; padding: 34px; box-shadow: var(--shadow); }
.stack-form { display: grid; gap: 16px; }
label { display: grid; gap: 7px; font-size: .88rem; font-weight: 700; color: #364557; }
input, select { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: white; color: var(--text); outline: none; }
input:focus, select:focus { border-color: #74aeda; box-shadow: 0 0 0 4px rgba(15,76,129,.09); }
.button { min-height: 44px; padding: 10px 16px; border: 0; border-radius: 12px; font-weight: 800; }
.button.primary { background: var(--primary); color: white; }
.button.primary:hover { background: var(--primary-dark); }
.button.secondary { background: #e9f1f8; color: var(--primary); }
.button.danger-outline { background: transparent; color: var(--danger); border: 1px solid #f0b3ae; }
.button-link { display: inline-grid; place-items: center; text-decoration: none; }
.button.small { min-height: 34px; padding: 7px 10px; font-size: .8rem; }
.text-button { background: none; border: 0; padding: 0; color: var(--primary); font-weight: 750; }
.form-error { color: var(--danger); font-size: .9rem; }
.toast { position: fixed; right: 18px; bottom: 18px; max-width: min(420px, calc(100vw - 36px)); padding: 13px 16px; border-radius: 12px; background: #17212b; color: white; opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s; z-index: 100; }
.toast.visible { opacity: 1; transform: translateY(0); }
.modal { position: fixed; inset: 0; z-index: 80; background: rgba(8, 25, 42, .56); display: grid; place-items: center; padding: 20px; }
.modal-card { position: relative; width: min(460px, 100%); border-radius: 22px; background: white; padding: 32px; text-align: center; box-shadow: var(--shadow); }
.modal-close { position: absolute; top: 12px; right: 14px; border: 0; background: none; font-size: 1.5rem; color: var(--muted); }
.spinner { width: 36px; height: 36px; margin: 0 auto 18px; border: 4px solid #dbe9f4; border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 18px; background: #0c2f4e; color: white; display: flex; flex-direction: column; }
.sidebar .brand-mark { background: white; color: var(--primary); }
.nav-list { display: grid; gap: 6px; margin-top: 36px; }
.nav-item { display: block; width: 100%; text-align: left; border: 0; border-radius: 11px; background: transparent; color: #d5e2ee; padding: 12px 14px; font-weight: 700; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.12); color: white; }
.sidebar-footer { margin-top: auto; display: grid; gap: 3px; padding: 14px; background: rgba(255,255,255,.08); border-radius: 14px; }
.sidebar-footer small { color: #bcd0df; }
.sidebar-footer .text-button { color: white; text-align: left; margin-top: 8px; }
.main-panel { padding: 34px clamp(20px, 4vw, 56px) 60px; min-width: 0; }
.mobile-topbar { display: none; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 24px; }
.page-heading h1 { margin-bottom: 0; }
.status-badge { padding: 9px 12px; border-radius: 999px; font-size: .82rem; font-weight: 800; }
.status-badge.neutral { background: #e8edf2; color: #506173; }
.status-badge.enabled { background: #d8f5e7; color: var(--success); }
.grid { display: grid; gap: 18px; }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: 0 7px 24px rgba(23, 56, 88, .05); }
.panel-card + .panel-card, .list-card, .approval-card { margin-top: 18px; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.helper { margin: 12px 0 0; color: var(--muted); font-size: .84rem; }
.inline-form { display: flex; gap: 10px; }
.inline-form input { flex: 1; }
.summary-box { margin-top: 14px; padding: 13px; border-radius: 12px; background: var(--surface-soft); color: var(--muted); min-height: 48px; }
.card-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.counter { display: inline-grid; place-items: center; min-width: 30px; height: 30px; border-radius: 999px; background: #eaf2f8; color: var(--primary); font-weight: 800; }
.patients-list, .compact-list, .professional-patient-list { display: grid; gap: 10px; }
.empty-state { padding: 25px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: 14px; }
.patient-admin-row, .compact-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px; border: 1px solid var(--border); border-radius: 13px; background: white; }
.patient-admin-row.final { opacity: .42; background: transparent; }
.row-main { min-width: 0; }
.row-main strong { display: block; overflow-wrap: anywhere; }
.row-main small { color: var(--muted); }
.row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.icon-button { min-width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--border); background: white; }
.status-panel { display: grid; gap: 12px; }
.connection-dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: #b8c2cc; margin-right: 8px; }
.connection-dot.online { background: #17a461; box-shadow: 0 0 0 5px rgba(23,164,97,.12); }
.professional-shell { width: min(900px, calc(100% - 28px)); margin: 0 auto; padding-bottom: 60px; }
.professional-header { min-height: 78px; display: flex; align-items: center; justify-content: space-between; }
.professional-heading { margin: 28px 0; }
.professional-patient { padding: 18px; border-radius: 16px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 14px; transition: .2s; }
.professional-patient.new { background: var(--light-blue); color: #101820; }
.professional-patient.called { background: var(--dark-blue); color: white; }
.professional-patient.final { background: transparent; color: #6f7a85; border: 1px dashed #bfc9d2; opacity: .48; }
.professional-patient h3 { margin: 0; font-size: 1.18rem; }
.professional-patient small { opacity: .8; }
.professional-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.professional-patient.called .button.secondary { background: rgba(255,255,255,.14); color: white; }
.professional-patient.called .button.primary { background: white; color: var(--primary-dark); }
@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: -280px; z-index: 50; width: 250px; transition: left .2s; }
  .sidebar.open { left: 0; }
  .main-panel { padding: 18px 16px 50px; }
  .mobile-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
  .two-columns { grid-template-columns: 1fr; }
  .page-heading { align-items: center; }
  .professional-patient { grid-template-columns: 1fr; }
  .professional-actions { justify-content: stretch; }
  .professional-actions .button { flex: 1; }
}
@media (max-width: 520px) {
  .landing-header { padding: 18px; }
  .admin-link { font-size: .74rem; }
  .landing-content { padding-bottom: 40px; }
  .consultorio-card { padding: 28px 20px; }
  .auth-card { padding: 26px 20px; }
  .inline-form { flex-direction: column; }
  .patient-admin-row, .compact-row { align-items: flex-start; flex-direction: column; }
  .row-actions { justify-content: flex-start; width: 100%; }
}
