:root {
  --bg: #f4f7f7;
  --surface: #ffffff;
  --surface-2: #eef6f5;
  --text: #16302d;
  --muted: #64748b;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --danger: #b42318;
  --warning: #a15c00;
  --success: #067647;
  --border: #d7e2e1;
  --shadow: 0 12px 35px rgba(15, 118, 110, .09);
  --radius: 16px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif; color: var(--text); background: var(--bg); }
button, input, select, textarea { font: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; }
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(145deg, #e6f4f1, #f8fbfb); }
.login-card { width: min(420px, 100%); background: var(--surface); padding: 32px; border-radius: 24px; box-shadow: var(--shadow); }
.login-card h1 { margin: 14px 0 4px; }
.brand-mark { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 18px; background: var(--primary); color: white; font-weight: 800; font-size: 22px; }
.brand-mark.small { width: 42px; height: 42px; border-radius: 13px; font-size: 17px; }
.stack { display: grid; gap: 16px; margin-top: 24px; }
label { display: grid; gap: 7px; font-weight: 650; font-size: 14px; }
input, select, textarea { width: 100%; border: 1px solid var(--border); border-radius: 11px; padding: 12px 13px; background: white; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(15,118,110,.14); border-color: var(--primary); }
textarea { min-height: 90px; resize: vertical; }
.btn { border: 0; border-radius: 11px; padding: 11px 15px; font-weight: 750; cursor: pointer; }
.btn.primary { background: var(--primary); color: white; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.secondary { background: var(--surface-2); color: var(--primary-dark); }
.btn.danger { background: #fee4e2; color: var(--danger); }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.full { width: 100%; }
.icon-btn { border: 0; background: transparent; cursor: pointer; font-size: 20px; padding: 8px; border-radius: 10px; }
.app { min-height: 100vh; display: grid; grid-template-columns: 260px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; background: #0d3431; color: white; padding: 22px 16px; display: flex; flex-direction: column; gap: 24px; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; }
.sidebar-brand small { display: block; opacity: .7; }
.nav { display: grid; gap: 7px; }
.nav button { text-align: left; border: 0; background: transparent; color: #d9efec; padding: 12px 14px; border-radius: 11px; cursor: pointer; font-weight: 700; }
.nav button.active, .nav button:hover { background: rgba(255,255,255,.12); color: white; }
.sidebar-footer { margin-top: auto; }
.user-summary { font-size: 13px; margin: 0 4px 12px; color: #d9efec; }
.main { min-width: 0; }
.topbar { background: rgba(255,255,255,.88); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); min-height: 86px; display: flex; align-items: center; gap: 12px; padding: 18px 28px; position: sticky; top: 0; z-index: 5; }
.topbar h2 { margin: 0; }
.topbar p { margin: 4px 0 0; }
.content { padding: 28px; }
.grid { display: grid; gap: 18px; }
.grid.cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: 0 5px 18px rgba(20,50,48,.04); }
.metric strong { font-size: 30px; display: block; margin-top: 8px; }
.toolbar { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .grow { flex: 1 1 260px; }
.table-wrap { overflow: auto; background: white; border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; min-width: 840px; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { background: #f8fbfb; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 9px; font-size: 12px; font-weight: 800; background: #edf2f2; }
.badge.success { color: var(--success); background: #dcfae6; }
.badge.warning { color: var(--warning); background: #fff1cc; }
.badge.danger { color: var(--danger); background: #fee4e2; }
.badge.info { color: #175cd3; background: #dbeafe; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { padding: 34px; text-align: center; color: var(--muted); }
.modal { width: min(680px, calc(100% - 24px)); border: 0; border-radius: 20px; padding: 0; box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(8,30,28,.55); }
.modal-card { padding: 0; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; }
#modalBody { padding: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 15px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 100; background: #101f1d; color: white; padding: 12px 16px; border-radius: 11px; opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.mobile-only { display: none; }
.patient-summary { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin-bottom: 18px; }
.patient-summary .mini { padding: 14px; background: var(--surface-2); border-radius: 13px; }
.patient-summary strong { display: block; margin-top: 5px; }
@media (max-width: 1050px) { .grid.cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 760px) {
  .app { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 20; transform: translateX(-100%); transition: .2s; }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: inline-flex; }
  .topbar { padding: 14px 16px; min-height: 74px; }
  .content { padding: 16px; padding-bottom: 90px; }
  .grid.cards, .patient-summary { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .toolbar .btn { flex: 1; }
  .card { padding: 16px; }
  .login-card { padding: 24px; }
}
@media (max-width: 430px) { .grid.cards, .patient-summary { grid-template-columns: 1fr; } }

/* Ajustes de formulários e acompanhamento */
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-weight: 700;
  cursor: pointer;
}
.check-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  min-width: 20px;
  margin: 0;
  padding: 0;
  accent-color: var(--primary);
}
.sidebar-footer .btn.ghost {
  color: #ffffff;
  border-color: rgba(255,255,255,.45);
  background: rgba(255,255,255,.08);
}
.sidebar-footer .btn.ghost:hover { background: rgba(255,255,255,.16); }
.followup-form { display: grid; gap: 14px; }
.condition-banner {
  border-radius: 12px;
  padding: 13px 15px;
  background: #e8f3ff;
  border: 1px solid #b8d7ff;
  color: #174ea6;
}
.procedure-block {
  display: grid;
  gap: 12px;
  padding: 14px 15px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: #fbfdfd;
}
.procedure-fields { display: grid; gap: 12px; }
.procedure-date { margin-left: 30px; }
.patient-identification {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.patient-summary .mini small { display: block; margin-top: 6px; font-weight: 650; }
.status-ok { background: #ecfdf3 !important; border-color: #abefc6 !important; }
.status-warning { background: #fffaeb !important; border-color: #fedf89 !important; }
.status-overdue { background: #fff1f0 !important; border-color: #fda29b !important; color: #912018; }
td.status-overdue, td.status-warning, td.status-ok { border-left: 4px solid transparent; }
td.status-overdue { border-left-color: #d92d20; }
td.status-warning { border-left-color: #f79009; }
td.status-ok { border-left-color: #12b76a; }
td.status-overdue small, td.status-warning small, td.status-ok small { display: block; margin-top: 4px; font-weight: 700; }
.row-overdue td { background: #fff7f6; }
@media (max-width: 760px) {
  .procedure-date { margin-left: 0; }
  .check-row { min-height: 48px; }
}

/* Minha conta */
.account-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; max-width: 980px; }
.account-grid h3 { margin-top: 0; }
.compact-stack { margin-top: 16px; }
button:disabled { opacity: .65; cursor: wait; }
@media (max-width: 760px) { .account-grid { grid-template-columns: 1fr; } }

.login-options{display:grid;gap:10px;margin:2px 0 4px}.login-options .check-row{justify-content:flex-start;font-weight:500}.login-status{min-height:20px;margin:12px 0 0}.version-label{display:block;text-align:center;margin-top:12px;color:#6b7280}.login-card .check-row input{width:18px;height:18px;flex:0 0 18px;margin:0}.login-card .check-row span{line-height:1.25}
