/* MedByte — design system
   Mobile-first; alvos de toque ≥ 44px; texto 16px para não dar zoom no iPhone. */

:root {
  --bg: #f3f7f6;
  --surface: #ffffff;
  --surface-2: #f6faf9;
  --border: #dfe8e6;
  --border-strong: #c9d7d4;
  --text: #0d2226;
  --text-2: #45605f;
  --text-3: #7f9896;

  --brand: #0a736e;
  --brand-600: #075a56;
  --brand-dark: #0a2e33;
  --brand-bright: #3fd0c4;
  --accent: #11958e;
  --coral: #ff6a3d;
  --logo-blue: #1747a6;
  --brand-50: #e9f2f0;
  --brand-100: #c6e4df;

  --blue: #2563eb;   --blue-50: #eaf1fe;
  --amber: #b45309;  --amber-50: #fdf3e2;
  --red: #c2410c;    --red-50: #fdeee6;
  --danger: #dc2626; --danger-50: #fdecec;
  --green: #15803d;  --green-50: #e8f6ed;
  --violet: #6d28d9; --violet-50: #f1ebfd;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 27, 45, .05), 0 2px 8px rgba(15, 27, 45, .04);
  --shadow-lg: 0 10px 30px rgba(15, 27, 45, .12);
  --sidebar: 248px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.55rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 .75rem; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75;
        stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }

/* ---------- Layout ---------- */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 18px 14px;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--brand); color: #fff;
              display: grid; place-items: center; font-weight: 800; letter-spacing: -.03em; }
.brand-name { font-weight: 700; font-size: 1.05rem; }
.brand-sub { font-size: .78rem; color: var(--text-3); line-height: 1.2; max-width: 160px;
             overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: var(--radius-sm);
         color: var(--text-2); font-weight: 550; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--brand-50); color: var(--brand-600); }
.nav .badge { margin-left: auto; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; }
.user-chip .name { font-weight: 600; font-size: .9rem; line-height: 1.2; }
.user-chip .role { font-size: .78rem; color: var(--text-3); }

.main { margin-left: var(--sidebar); padding: 28px 32px 48px; max-width: calc(1240px + var(--sidebar)); }
.topbar { display: none; }
.tabbar { display: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
             flex-wrap: wrap; margin-bottom: 22px; }
.page-head .sub { color: var(--text-2); margin-top: 4px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); font-weight: 550;
             margin-bottom: 10px; font-size: .9rem; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spacer { flex: 1; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
        box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px;
             padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { display: flex; align-items: center; gap: 8px; }
.card-body { padding: 16px 20px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2);
             border-radius: 0 0 var(--radius) var(--radius); }
.sticky { position: sticky; top: 16px; }

.stat { padding: 16px 18px; }
.stat .label { color: var(--text-2); font-size: .85rem; font-weight: 550; display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 1.8rem; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }
.stat a { color: inherit; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
       padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
       background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
       text-decoration: none !important; white-space: nowrap; transition: background .12s, border-color .12s, transform .05s; }
.btn:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); border-color: var(--brand-600); }
.btn-soft { background: var(--brand-50); border-color: transparent; color: var(--brand-600); }
.btn-soft:hover { background: var(--brand-100); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; color: var(--text); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-50); border-color: var(--danger); }
.btn-lg { min-height: 52px; padding: 0 22px; font-size: 1.02rem; border-radius: 12px; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .88rem; }
.btn-block { width: 100%; }
.btn-icon { width: 44px; padding: 0; }
.btn-icon.btn-sm { width: 36px; }
button[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
form.inline { display: inline; margin: 0; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: .88rem; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: .8rem; color: var(--text-3); }
.input, .select, .textarea {
  width: 100%; min-height: 46px; padding: 10px 13px; font: inherit; font-size: 16px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: border-color .12s, box-shadow .12s; appearance: none;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%238392a7' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
          background-repeat: no-repeat; background-position: right 10px center; padding-right: 38px; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand);
                                                box-shadow: 0 0 0 3px var(--brand-100); }
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px 16px; }
.col-12 { grid-column: span 12; } .col-8 { grid-column: span 8; } .col-6 { grid-column: span 6; }
.col-4 { grid-column: span 4; } .col-3 { grid-column: span 3; } .col-2 { grid-column: span 2; }
.form-section { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3);
                font-weight: 700; margin: 8px 0 -4px; grid-column: span 12; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 20px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; font-weight: 500; }
.check input { width: 20px; height: 20px; accent-color: var(--brand); }
.search-box { position: relative; }
.search-box .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.search-box .input { padding-left: 42px; }

/* chips de seleção (exames comuns) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 14px;
             border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface);
             cursor: pointer; font-weight: 500; font-size: .92rem; user-select: none; }
.chip input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip input:focus-visible + span { box-shadow: 0 0 0 3px var(--brand-100); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px;
         font-size: .76rem; font-weight: 650; background: var(--surface-2); color: var(--text-2);
         border: 1px solid var(--border); white-space: nowrap; }
.badge-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.b-agendado { background: var(--surface-2); color: var(--text-2); }
.b-confirmado { background: var(--blue-50); color: var(--blue); border-color: transparent; }
.b-chegou { background: var(--violet-50); color: var(--violet); border-color: transparent; }
.b-em_atendimento { background: var(--amber-50); color: var(--amber); border-color: transparent; }
.b-atendido { background: var(--green-50); color: var(--green); border-color: transparent; }
.b-faltou, .b-cancelado { background: var(--danger-50); color: var(--danger); border-color: transparent; }
.b-pendente, .b-processando, .b-sem_ia { background: var(--blue-50); color: var(--blue); border-color: transparent; }
.b-revisar { background: var(--amber-50); color: var(--amber); border-color: transparent; }
.b-concluido { background: var(--green-50); color: var(--green); border-color: transparent; }
.b-erro { background: var(--danger-50); color: var(--danger); border-color: transparent; }
.b-alto { background: var(--red-50); color: var(--red); border-color: transparent; }
.b-baixo { background: var(--blue-50); color: var(--blue); border-color: transparent; }
.b-alert { background: var(--danger-50); color: var(--danger); border-color: transparent; }
.b-count { background: var(--coral); color: #fff; border: 0; height: 20px; min-width: 20px; justify-content: center; padding: 0 6px; }

/* ---------- Avatar ---------- */
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none;
          background: var(--brand-50); color: var(--brand-600); font-weight: 700; font-size: .9rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.15rem; }
.avatar-sm { width: 32px; height: 32px; font-size: .78rem; }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li + li, .list > a + a { border-top: 1px solid var(--border); }
.list-item { display: flex; align-items: center; gap: 10px; padding: 7px 16px; min-height: 44px; color: inherit; }
a.list-item:hover { background: var(--surface-2); text-decoration: none; }
.list-item .title { font-weight: 600; line-height: 1.3; }
.list-item .meta { font-size: .8rem; line-height: 1.3; color: var(--text-2); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .avatar:not(.avatar-lg), .list-link .avatar:not(.avatar-lg) { width: 32px; height: 32px; font-size: .78rem; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 36px 20px; text-align: center; color: var(--text-2); }
.empty .icon { width: 40px; height: 40px; color: var(--text-3); margin-bottom: 8px; stroke-width: 1.5; }

/* ---------- Agenda ---------- */
.day-nav { display: flex; align-items: center; gap: 8px; }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.week a { display: flex; flex-direction: column; align-items: center; padding: 8px 4px; border-radius: 12px;
          color: var(--text-2); border: 1px solid transparent; }
.week a:hover { background: var(--surface); text-decoration: none; border-color: var(--border); }
.week .wd { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.week .dn { font-size: 1.2rem; font-weight: 700; color: var(--text); }
.week .cnt { font-size: .72rem; height: 16px; }
.week a.sel { background: var(--brand); color: #fff; }
.week a.sel .dn { color: #fff; }
.week a.is-today:not(.sel) .dn { color: var(--brand); }

.appt { display: flex; gap: 12px; padding: 8px 16px; align-items: center; }
.appt + .appt { border-top: 1px solid var(--border); }
.appt-time { width: 58px; flex: none; text-align: center; }
.appt-time .t { font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.appt-time .d { font-size: .75rem; color: var(--text-3); }
.appt-bar { width: 4px; align-self: stretch; border-radius: 4px; background: var(--border-strong); flex: none; }
.appt.s-confirmado .appt-bar { background: var(--blue); }
.appt.s-chegou .appt-bar { background: var(--violet); }
.appt.s-em_atendimento .appt-bar { background: var(--amber); }
.appt.s-atendido .appt-bar { background: var(--green); }
.appt.s-faltou .appt-bar, .appt.s-cancelado .appt-bar { background: var(--danger); }
.appt.s-cancelado .appt-main, .appt.s-faltou .appt-main { opacity: .55; }
.appt-main { flex: 1; min-width: 0; }
.appt-main .title { font-weight: 650; font-size: 1.02rem; }
.appt-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.slot-free { display: flex; align-items: center; gap: 12px; padding: 5px 16px; color: var(--text-3); }
.slot-free + .appt, .appt + .slot-free, .slot-free + .slot-free { border-top: 1px dashed var(--border); }
.slot-free a { color: var(--text-3); font-weight: 550; display: inline-flex; align-items: center; gap: 6px; }
.slot-free a:hover { color: var(--brand); }

.status-menu { position: relative; }
.status-menu summary { list-style: none; cursor: pointer; }
.status-menu summary::-webkit-details-marker { display: none; }
.status-menu .menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface);
                     border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
                     padding: 6px; min-width: 190px; z-index: 20; }
.status-menu .menu button { display: flex; width: 100%; align-items: center; gap: 8px; border: 0; background: none;
                            font: inherit; padding: 10px 12px; border-radius: 8px; cursor: pointer; text-align: left; }
.status-menu .menu button:hover { background: var(--surface-2); }

/* Próximo paciente (home) */
.hero { background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand) 100%); color: #fff; border: 0;
        border-radius: 18px; padding: 22px 24px; box-shadow: var(--shadow-lg); }
.hero .eyebrow { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; opacity: .8; font-weight: 700; }
.hero .who { font-size: 1.45rem; font-weight: 700; margin: 6px 0 2px; letter-spacing: -.01em; }
.hero .meta { opacity: .88; }
.hero .btn-light { background: #fff; color: var(--brand-600); border-color: #fff; }
.hero .btn-light:hover { background: #f0fbfa; }
.hero .btn-outline { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); }
.hero .btn-outline:hover { background: rgba(255,255,255,.1); }
.hero-empty { background: var(--surface); color: var(--text); border: 1px dashed var(--border-strong); box-shadow: none; }

/* ---------- Prontuário ---------- */
.patient-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.patient-head .info { flex: 1; min-width: 220px; }
.patient-head .name { font-size: 1.4rem; font-weight: 700; letter-spacing: -.01em; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--text-2); font-size: .92rem; margin-top: 4px; }
.facts span { display: inline-flex; align-items: center; gap: 5px; }
.alert-box { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--danger-50);
             color: #8a1c1c; font-weight: 550; align-items: flex-start; }
.alert-box .icon { color: var(--danger); margin-top: 1px; }
.info-box { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--blue-50);
            color: #1e3a8a; align-items: flex-start; }
.warn-box { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--amber-50);
            color: #7c2d12; align-items: flex-start; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; font-size: .94rem; }
.kv dt { color: var(--text-3); font-weight: 550; }
.kv dd { margin: 0; white-space: pre-line; }
.pre { white-space: pre-line; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto;
        scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 12px 14px; color: var(--text-2); font-weight: 600; border-bottom: 2px solid transparent;
          margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--brand-600); border-color: var(--brand); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 26px; }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 8px; bottom: -4px; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ""; position: absolute; left: 1px; top: 4px; width: 12px; height: 12px; border-radius: 50%;
                      background: var(--surface); border: 2px solid var(--brand); }
.timeline .when { font-size: .82rem; color: var(--text-3); font-weight: 600; }

/* ---------- Evolução de exames ---------- */
.evo { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.evo-item { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1px solid var(--border);
            border-radius: 12px; background: var(--surface); cursor: pointer; text-align: left; font: inherit;
            color: inherit; transition: border-color .12s, box-shadow .12s; }
.evo-item:hover { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
.evo-item.out { border-color: #f3c9b4; background: #fffaf7; }
.evo-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.evo-name { font-weight: 600; font-size: .9rem; color: var(--text-2); }
.evo-val { display: flex; align-items: baseline; gap: 6px; }
.evo-val .v { font-size: 1.3rem; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.evo-val .u { font-size: .8rem; color: var(--text-3); }
.evo-bottom { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.evo-meta { font-size: .76rem; color: var(--text-3); }
.trend { display: inline-flex; align-items: center; gap: 2px; font-size: .78rem; font-weight: 700; }
.trend.up, .trend.down { color: var(--text-2); } .trend.flat { color: var(--text-3); }
.spark { width: 96px; height: 28px; overflow: visible; }
.spark polyline { fill: none; stroke: var(--brand); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { fill: var(--brand); }
.evo-item.out .spark polyline { stroke: var(--red); } .evo-item.out .spark circle { fill: var(--red); }
.evo-compact .evo { grid-template-columns: 1fr; }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3);
            font-weight: 700; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.table td { padding: 7px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.out td { background: #fffaf7; }
.table .input { min-height: 38px; padding: 6px 10px; }

/* ---------- Atendimento ---------- */
.consult-grid { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 20px; align-items: start; }
.vitals { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.vitals .input { text-align: center; font-weight: 600; }
.vitals label { font-size: .75rem; text-align: center; }
.save-state { font-size: .85rem; color: var(--text-3); display: inline-flex; align-items: center; gap: 6px; }
.save-state.saving { color: var(--amber); }
.save-state.saved { color: var(--green); }
.save-state.error { color: var(--danger); }
.consult-bar { position: sticky; bottom: 0; background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
               border-top: 1px solid var(--border); padding: 12px 0; margin-top: 16px; z-index: 5;
               display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.doc-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border);
            border-radius: 12px; }
.doc-card + .doc-card { margin-top: 8px; }
.doc-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex: none;
            background: var(--violet-50); color: var(--violet); }
.doc-icon.rx { background: var(--green-50); color: var(--green); }

.rx-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) 160px 44px; gap: 10px; align-items: start;
          padding: 14px 0; border-top: 1px solid var(--border); }
.rx-row:first-child { border-top: 0; }
.rx-row .n { font-weight: 700; color: var(--text-3); padding-top: 12px; }
.rx-row .grow { display: flex; flex-direction: column; gap: 8px; }

/* Upload */
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
            border: 2px dashed var(--border-strong); border-radius: 16px; padding: 36px 20px; text-align: center;
            background: var(--surface-2); cursor: pointer; transition: border-color .12s, background .12s; }
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: var(--brand-50); }
.dropzone .icon { width: 40px; height: 40px; color: var(--brand); stroke-width: 1.6; }
.dropzone input { display: none; }
.file-list { list-style: none; padding: 0; margin: 12px 0 0; }
.file-list li { display: flex; gap: 8px; align-items: center; padding: 8px 0; font-size: .92rem; }

/* Flash */
.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; font-weight: 550; }
.flash-success { background: var(--green-50); color: #14532d; }
.flash-error { background: var(--danger-50); color: #7f1d1d; }
.flash-info { background: var(--blue-50); color: #1e3a8a; }
.flash .x { margin-left: auto; background: none; border: 0; cursor: pointer; color: inherit; opacity: .6; padding: 0; }

/* Modal (gráfico de evolução) */
.modal { position: fixed; inset: 0; background: rgba(15, 27, 45, .45); display: none; align-items: center;
         justify-content: center; padding: 16px; z-index: 100; }
.modal.open { display: flex; }
.modal-box { background: var(--surface); border-radius: 18px; width: min(760px, 100%); max-height: 92vh; overflow: auto;
             box-shadow: var(--shadow-lg); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 20px 6px; }
.modal-body { padding: 8px 20px 20px; }
.chart-box { position: relative; height: 300px; }

/* Autocomplete */
.ac { position: relative; }
.ac-menu { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--border);
           border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 40; overflow: hidden; display: none; }
.ac-menu.open { display: block; }
.ac-menu button { display: flex; flex-direction: column; align-items: flex-start; width: 100%; padding: 11px 14px;
                  border: 0; background: none; font: inherit; text-align: left; cursor: pointer; }
.ac-menu button + button { border-top: 1px solid var(--border); }
.ac-menu button:hover, .ac-menu button.hl { background: var(--brand-50); }
.ac-menu .s { font-size: .82rem; color: var(--text-3); }
.picked { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--brand-100);
          background: var(--brand-50); border-radius: 12px; }

/* Login */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { background: linear-gradient(155deg, var(--brand-dark) 0%, #0b4f50 60%, var(--brand) 100%); color: #fff; padding: 48px;
             display: flex; flex-direction: column; justify-content: space-between; }
.auth-side h2 { font-size: 2rem; font-weight: 700; line-height: 1.2; max-width: 420px; letter-spacing: -.02em; }
.auth-side ul { list-style: none; padding: 0; margin: 24px 0 0; display: flex; flex-direction: column; gap: 12px; opacity: .92; }
.auth-side li { display: flex; gap: 10px; align-items: center; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 380px; }

/* ---------- Responsivo ---------- */
@media (max-width: 1100px) {
  .split, .consult-grid { grid-template-columns: 1fr; }
  .sticky { position: static; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  body { font-size: 15.5px; }
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 16px 16px calc(92px + env(safe-area-inset-bottom, 0px)); }
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 25;
            padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; background: rgba(244,246,249,.92);
            backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
  .topbar .brand-mark { width: 32px; height: 32px; font-size: .9rem; }
  .topbar .title { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
            background: rgba(255,255,255,.96); backdrop-filter: blur(10px); border-top: 1px solid var(--border);
            padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px)); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; color: var(--text-3);
              font-size: .7rem; font-weight: 600; position: relative; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a.active { color: var(--brand); }
  .tabbar .icon { width: 24px; height: 24px; }
  .tabbar .b-count { position: absolute; top: 0; left: 55%; height: 17px; min-width: 17px; font-size: .68rem; }
  h1 { font-size: 1.3rem; }
  .page-head { margin-bottom: 16px; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .form-grid > [class*="col-"] { grid-column: span 12; }
  .form-grid > .col-3.m-half, .form-grid > .col-4.m-half, .form-grid > .col-2.m-half { grid-column: span 6; }
  .form-actions .btn { flex: 1; }
  .card-head, .card-body, .card-pad { padding-left: 16px; padding-right: 16px; }
  .list-item { padding: 8px 14px; }
  .appt { padding: 8px 14px; gap: 10px; flex-wrap: wrap; }
  .appt-actions { width: 100%; justify-content: flex-start; padding-left: 72px; }
  .vitals { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .rx-row { grid-template-columns: 22px minmax(0, 1fr) 40px; }
  .rx-row .qty { grid-column: 2; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .hero { padding: 18px; }
  .hero .who { font-size: 1.25rem; }
  .stat .value { font-size: 1.5rem; }
  .consult-bar { bottom: calc(68px + env(safe-area-inset-bottom, 0px)); margin-left: -16px; margin-right: -16px; padding: 10px 16px; }
  .consult-bar .btn { flex: 1; }
  .hide-mobile { display: none !important; }
}
@media (min-width: 861px) { .show-mobile { display: none !important; } }

@media print {
  .sidebar, .topbar, .tabbar, .no-print { display: none !important; }
  .main { margin: 0; padding: 0; }
}

/* ---------- Marca MedByte ---------- */
.brand-logo { width: 38px; height: 38px; object-fit: contain; flex: none; }
.brand-name span, .auth-wordmark span { color: var(--accent); }
.brand-name small, .auth-wordmark small { font-size: .62em; font-weight: 700; letter-spacing: .14em; color: var(--text-3); margin-left: 2px; }
.auth-wordmark { font-size: 1.6rem; font-weight: 800; letter-spacing: -.01em; color: #e9f2f0; }
.auth-wordmark span { color: var(--brand-bright); }
.auth-wordmark small { color: rgba(233, 242, 240, .6); }
.auth-side .icon { color: var(--brand-bright); }
.auth-side h2 { color: #fff; }
.auth-logo { display: block; width: 100%; max-width: 260px; height: auto; margin: 0 auto 24px; }
.nav a.active { position: relative; }
.nav a.active::before { content: ""; position: absolute; left: -14px; top: 50%; width: 6px; height: 18px; margin-top: -9px;
                        border-radius: 0 4px 4px 0; background: var(--coral); }
.icon .acc { fill: var(--coral); stroke: none; }
.hero .eyebrow::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--coral);
                         margin-right: 8px; vertical-align: 1px; }
.topbar .brand-logo { width: 32px; height: 32px; }

/* ---------- Financeiro ---------- */
.money-in { color: var(--green); }
.money-out { color: var(--danger); }
.text-danger { color: var(--danger); }
.b-aberto { background: var(--amber-50); color: var(--amber); border-color: transparent; }
.b-parcial { background: var(--violet-50); color: var(--violet); border-color: transparent; }
.b-pago { background: var(--green-50); color: var(--green); border-color: transparent; }
a.badge:hover { text-decoration: none; filter: brightness(.96); }
.btn-receive { background: var(--coral); border-color: var(--coral); color: #fff; }
.btn-receive:hover { background: #ec5a2e; border-color: #ec5a2e; }
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; margin-top: 6px; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.total-box { min-height: 46px; display: flex; align-items: center; gap: 8px; padding: 0 13px; border-radius: var(--radius-sm);
             background: var(--brand-50); font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.input-money { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.charge-row { display: grid; grid-template-columns: minmax(150px, 1.1fr) minmax(0, 1.4fr) 70px 120px 44px; gap: 8px; align-items: center; }
.period-form .input { width: auto; min-height: 40px; }
.stat.is-selected { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
details.more summary { cursor: pointer; color: var(--brand); font-weight: 600; font-size: .92rem; }
.menu .menu-link { display: block; padding: 10px 12px; border-radius: 8px; color: var(--text); }
.menu .menu-link:hover { background: var(--surface-2); text-decoration: none; }
.fin-mini { display: flex; justify-content: space-between; gap: 12px; text-decoration: none !important; color: inherit; }
.fin-mini .value { font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
tfoot td { background: var(--surface-2); }
@media (max-width: 860px) {
  .charge-row { grid-template-columns: 1fr 70px 110px 40px; }
  .charge-row [data-pick] { grid-column: 1 / -1; }
  .period-form .input { flex: 1; }
}
@media print {
  .tabs, .period-form, .page-head .actions { display: none !important; }
  .card { box-shadow: none; }
}

/* ---------- Importação de pasta com IA ---------- */
.b-sem_paciente { background: var(--violet-50); color: var(--violet); border-color: transparent; }
a.warn-box { color: inherit; text-decoration: none; }
a.warn-box:hover { filter: brightness(.98); }
.progress { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 8px 0; }
.progress-bar { height: 100%; width: 0; background: var(--brand); border-radius: 999px; transition: width .3s ease; }
.file-list.compact { max-height: 260px; overflow-y: auto; }
.merge-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.merge-card { display: block; border: 2px solid var(--border); border-radius: 14px; padding: 16px; cursor: pointer; }
.merge-card:has(input:checked) { border-color: var(--brand); background: var(--brand-50); }
.merge-card input { accent-color: var(--brand); width: 18px; height: 18px; }
.dup-group { border-top: 1px solid var(--border); }
.dup-group:first-child { border-top: 0; }
@media (max-width: 640px) { .merge-grid { grid-template-columns: 1fr; } }
/* ---------- Tirzepatida ---------- */
.text-success { color: var(--green); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
.segmented { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 9px; font-weight: 600; font-size: .9rem; color: var(--text-2); cursor: pointer; }
.segmented input:checked + span { background: var(--surface); color: var(--brand); box-shadow: 0 1px 3px rgba(10, 46, 51, .12); }
.segmented input:focus-visible + span { box-shadow: 0 0 0 3px var(--brand-100); }
.segmented-sm span { min-height: 30px; padding: 0 10px; font-size: .82rem; }
.calc-box { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; min-height: 42px; padding: 0 14px; border-radius: 10px; background: var(--brand-50); color: var(--text-2); }
.calc-box strong { color: var(--brand); font-size: 1.05rem; margin-left: 4px; }
.tirz-split { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); gap: 16px; align-items: start; }
.body-map { display: grid; grid-template-columns: minmax(0, 1fr) 120px minmax(0, 1fr); gap: 6px; align-items: center; padding: 14px 12px 16px; }
.body-col { display: flex; flex-direction: column; gap: 12px; }
.body-col:last-child { text-align: right; }
.body-figure svg { width: 100%; height: auto; display: block; }
.body-figure .sil { fill: var(--brand-100); }
.body-figure .muscle { fill: var(--brand); opacity: .22; }
.body-figure .visceral { fill: var(--coral); opacity: .28; }
.body-figure .m-line { stroke: var(--brand-dark); stroke-width: 1.6; stroke-dasharray: 4 3; opacity: .55; }
.body-callout { padding: 8px 10px; border-radius: 10px; background: var(--surface-2); }
.body-callout .lbl { font-size: .74rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .02em; }
.body-callout .val { font-size: 1.15rem; font-weight: 750; line-height: 1.25; }
.body-callout .val small { font-size: .72rem; font-weight: 600; color: var(--text-3); margin-left: 2px; }
.body-callout .delta { font-size: .76rem; font-weight: 650; }
.body-callout .delta.good { color: var(--green); }
.body-callout .delta.bad { color: var(--red); }
.body-callout.hl-waist, .body-callout.hl-hip { border-left: 3px solid var(--brand-dark); }
.body-col:last-child .body-callout.hl-waist, .body-col:last-child .body-callout.hl-hip { border-left: 0; border-right: 3px solid var(--brand-dark); }
.body-callout.hl-visceral { border-left: 3px solid var(--coral); }
.body-callout.hl-muscle { border-right: 3px solid var(--brand); }
.tirz-split > *, .tirz-charts > * { min-width: 0; }
.tirz-charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.chart-title { font-weight: 650; font-size: .9rem; margin-bottom: 6px; }
.chart-box.sm { height: 210px; }
.note-row td { border-top: 0 !important; padding-top: 0 !important; }
@media (max-width: 1100px) { .tirz-split { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 640px) {
  .tirz-charts { grid-template-columns: 1fr; }
  .body-map { grid-template-columns: minmax(0, 1fr) 84px minmax(0, 1fr); padding: 10px 8px; }
  .body-callout .lbl { font-size: .66rem; letter-spacing: 0; overflow-wrap: anywhere; }
  .tirz-split .card-head { flex-wrap: wrap; }
  .body-callout { padding: 6px 7px; }
  .body-callout .val { font-size: 1rem; }
}
/* ---------- Revisão em lote de exames ---------- */
.list-item:has(> .list-link) { padding: 0; gap: 0; }
.list-link { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 7px 16px; min-height: 44px; color: inherit; }
.list-link:hover { background: var(--surface-2); text-decoration: none; }
.list-item.has-check > .bulk-check { width: 20px; height: 20px; margin-left: 16px; flex: 0 0 auto; accent-color: var(--brand); }
.list-item.has-check > .list-link { padding-left: 12px; }
.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; position: sticky; top: 8px; z-index: 5; }
.bulk-bar .check { min-height: 32px; }
@media (max-width: 640px) {
  .list-link { padding: 8px 14px; }
  .list-item.has-check > .bulk-check { margin-left: 14px; }
  .bulk-bar .row-wrap { margin-left: 0 !important; width: 100%; }
}
/* ---------- Tirzepatida: planilha ---------- */
.g-wrap { max-height: calc(100vh - 260px); overflow: auto; }
.g-table { border-collapse: separate; border-spacing: 0; min-width: 1180px; }
.g-table thead th { position: sticky; top: 0; z-index: 2; background: var(--surface); white-space: nowrap; font-size: .74rem; padding: 10px 6px; }
.g-table td { padding: 3px 4px !important; border-top: 1px solid var(--border); vertical-align: middle; }
.g-table .g-n { width: 34px; text-align: right; padding-right: 8px !important; font-size: .8rem; }
.g-in { width: 100%; min-width: 64px; height: 34px; padding: 0 8px; border: 1px solid transparent; border-radius: 7px; background: var(--surface-2); font: inherit; font-size: .9rem; color: var(--text); text-align: right; }
.g-in:hover { border-color: var(--border); }
.g-in:focus { outline: none; border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 3px var(--brand-50); }
.g-date { min-width: 108px; text-align: left; }
.g-dose { min-width: 72px; text-align: left; padding-right: 4px; }
.g-notes { min-width: 180px; text-align: left; }
.g-calc { white-space: nowrap; color: var(--text-2); min-width: 130px; }
.g-x label { display: inline-flex; align-items: center; gap: 4px; color: var(--text-3); cursor: pointer; }
.g-x input { accent-color: var(--danger); }
tr.g-del td { opacity: .45; }
tr.g-del .g-in { text-decoration: line-through; }
tr.g-err td { background: var(--danger-50); }
tr.g-err-msg td { border-top: 0; color: var(--danger); font-size: .82rem; font-weight: 600; padding-bottom: 8px !important; background: var(--danger-50); }
.g-actions { position: sticky; bottom: 0; background: var(--bg, #f3f7f6); padding: 12px 0; z-index: 3; }
kbd { font: inherit; font-size: .8em; padding: 1px 5px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); }

/* ---------- Triagem ocular (experimental) ---------- */
.et-steps { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.et-cam { position: relative; aspect-ratio: 4 / 3; border-radius: var(--radius-sm); overflow: hidden; background: var(--brand-dark); }
.et-cam video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.et-cam-off { position: absolute; inset: 0; display: grid; place-items: center; color: var(--brand-100); font-size: .9rem; }
.et-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); flex: none; }
.et-dot.on { background: var(--green); }
.et-dot.off { background: var(--danger); }
.et-timeline { width: 100%; height: 28px; border-radius: 6px; background: var(--surface-2); display: block; }
.et-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 6px; }
.et-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.et-k-geo { background: var(--violet); }
.et-k-soc { background: var(--accent); }
.et-k-mid { background: var(--border-strong); }
.et-k-lost { background: var(--danger-50); border: 1px solid var(--danger); }
.et-verdict { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; }
.et-verdict.high { background: var(--violet-50); color: var(--violet); }
.et-verdict.low { background: var(--green-50); color: var(--green); }
.et-verdict.inc { background: var(--amber-50); color: var(--amber); }
.et-verdict div { color: var(--text); }
.et-stage { position: fixed; inset: 0; z-index: 1000; background: #000; display: flex; gap: 2vw; cursor: none;
            user-select: none; }
.et-pane { flex: 1; position: relative; overflow: hidden; display: grid; place-items: center; }
.et-pane > video, .et-pane > canvas { width: 100%; height: 100%; object-fit: contain; display: block; }
.et-stage > .et-social, .et-stage > .et-geo { display: none; }
.et-demo { color: #fff; text-align: center; font-size: 1.6rem; font-weight: 700; padding: 20px; }
.et-target { position: absolute; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%;
             background: radial-gradient(circle, #fff 0 14%, #ff6a3d 15% 38%, #ffd23f 39% 60%, #3fd0c4 61% 100%);
             animation: et-pulse .7s ease-in-out infinite alternate; transition: left .45s ease, top .45s ease; }
@keyframes et-pulse { from { transform: scale(.75) rotate(0deg); } to { transform: scale(1.15) rotate(40deg); } }
.et-msg { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 1.4rem;
          font-weight: 650; text-align: center; padding: 24px; background: rgba(0, 0, 0, .6); }