:root {
  --green-950: #0d3f29;
  --green-900: #105235;
  --green-800: #176b45;
  --green-700: #1f7a50;
  --green-600: #2b8f60;
  --green-200: #bfe7d1;
  --green-100: #dcf5e8;
  --green-50: #f0faf5;
  --lime: #7bc82b;
  --ink: #18231d;
  --muted: #66766d;
  --line: #dbe8e1;
  --surface: #ffffff;
  --surface-2: #f4f8f6;
  --danger: #b42318;
  --warning: #9a6700;
  --info: #175cd3;
  --shadow: 0 18px 45px rgba(11, 70, 43, 0.10);
  --shadow-sm: 0 8px 24px rgba(11, 70, 43, 0.08);
  --radius: 18px;
  --radius-sm: 12px;
  --logo: url('/assets/logo-instituto.png');
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--surface-2);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
img { max-width: 100%; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.nowrap { white-space: nowrap; }
.stack { display: grid; gap: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; justify-content: space-between; gap: 16px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--green-950);
  font-weight: 650;
  line-height: 1.05;
  text-decoration: none;
  white-space: nowrap;
}
.brand-logo strong { font-size: 1.08em; }
.logo-image {
  display: block;
  width: 48px;
  height: 48px;
  object-fit: contain;
}
.logo-fallback { font-weight: 800; color: var(--green-900); }

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 11px;
  min-height: 42px;
  padding: 10px 16px;
  font-weight: 750;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--green-800); color: #fff; box-shadow: 0 8px 22px rgba(23, 107, 69, .2); }
.btn-primary:hover { background: var(--green-900); }
.btn-secondary { background: #fff; border-color: var(--line); color: var(--green-900); }
.btn-soft { background: var(--green-50); border-color: var(--green-200); color: var(--green-900); }
.btn-danger { background: #fff1f0; border-color: #f6c7c2; color: var(--danger); }
.btn-ghost { background: transparent; color: inherit; }
.btn-sm { min-height: 34px; padding: 7px 10px; font-size: .84rem; }
.btn-block { width: 100%; }

.field { display: grid; gap: 7px; }
.field label, .field-label { font-weight: 750; font-size: .91rem; }
.field small { color: var(--muted); line-height: 1.45; }
.input, .select, .textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.textarea { min-height: 110px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--green-600);
  box-shadow: 0 0 0 4px rgba(43, 143, 96, .12);
}
.input-error { border-color: var(--danger) !important; }
.error-text { color: var(--danger); font-size: .82rem; }
.checkbox-line { display: flex; gap: 10px; align-items: flex-start; line-height: 1.45; }
.checkbox-line input { margin-top: 4px; }

.card {
  background: var(--surface);
  border: 1px solid rgba(219, 232, 225, .9);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px;
}
.card-compact { padding: 16px; border-radius: 14px; }
.card-title { margin: 0 0 6px; font-size: 1.1rem; }
.card-subtitle { margin: 0; color: var(--muted); line-height: 1.5; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-weight: 700;
  font-size: .76rem;
}
.badge-success { background: #eaf8f0; color: #166b45; border-color: #bde5ce; }
.badge-warning { background: #fff7df; color: var(--warning); border-color: #f4df9b; }
.badge-danger { background: #fff0ef; color: var(--danger); border-color: #f4cbc6; }
.badge-info { background: #edf4ff; color: var(--info); border-color: #c9dcff; }

.toast-region { position: fixed; top: 18px; right: 18px; z-index: 10000; display: grid; gap: 10px; width: min(390px, calc(100vw - 36px)); }
.toast { background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--green-700); border-radius: 12px; box-shadow: var(--shadow); padding: 14px 16px; animation: toast-in .2s ease; }
.toast.error { border-left-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

/* Public */
.public-shell { min-height: 100vh; background: linear-gradient(135deg, rgba(16,82,53,.97), rgba(23,107,69,.91)), radial-gradient(circle at 80% 20%, rgba(123,200,43,.25), transparent 35%); }
.public-header { width: min(1180px, calc(100% - 36px)); margin: auto; padding: 26px 0; display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.public-header .brand-logo { color: #fff; }
.public-header .logo-image { filter: brightness(0) invert(1); }
.public-header .btn-secondary { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.28); color: #fff; }
.hero { width: min(1180px, calc(100% - 36px)); margin: auto; padding: 65px 0 100px; display: grid; grid-template-columns: 1.1fr .9fr; gap: 50px; align-items: center; color: #fff; }
.hero h1 { font-size: clamp(2.6rem, 5vw, 5.2rem); line-height: .98; letter-spacing: -.045em; margin: 0 0 24px; }
.hero p { font-size: 1.16rem; line-height: 1.7; color: rgba(255,255,255,.88); max-width: 700px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 30px; }
.hero .btn-primary { background: #fff; color: var(--green-900); }
.hero .btn-secondary { background: transparent; color: #fff; border-color: rgba(255,255,255,.45); }
.hero-panel { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.22); border-radius: 26px; padding: 26px; backdrop-filter: blur(18px); box-shadow: 0 30px 80px rgba(0,0,0,.18); }
.hero-feature { display: grid; grid-template-columns: 50px 1fr; gap: 15px; padding: 18px 0; border-bottom: 1px solid rgba(255,255,255,.14); }
.hero-feature:last-child { border-bottom: 0; }
.hero-feature-icon { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 15px; background: rgba(255,255,255,.14); font-size: 1.35rem; }
.hero-feature strong { display: block; margin-bottom: 4px; }
.hero-feature span { color: rgba(255,255,255,.75); font-size: .92rem; line-height: 1.45; }

.login-page { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-brand { padding: 55px; color: #fff; background: linear-gradient(145deg, rgba(13,63,41,.98), rgba(31,122,80,.94)), radial-gradient(circle at 20% 20%, rgba(123,200,43,.28), transparent 32%); display: flex; flex-direction: column; justify-content: space-between; }
.login-brand .brand-logo { color: #fff; }
.login-brand .logo-image { filter: brightness(0) invert(1); }
.login-brand h1 { font-size: clamp(2.6rem, 5vw, 5rem); line-height: 1; margin: 20px 0; letter-spacing: -.04em; }
.login-brand p { color: rgba(255,255,255,.8); font-size: 1.05rem; line-height: 1.7; max-width: 650px; }
.login-card-wrap { display: grid; place-items: center; padding: 32px; background: #f7faf8; }
.login-card { width: min(460px, 100%); }
.login-card h2 { font-size: 2rem; margin: 0 0 8px; }
.login-card form { margin-top: 28px; display: grid; gap: 18px; }

.form-public-page { min-height: 100vh; background: linear-gradient(180deg, var(--green-50), #fff 40%); }
.form-public-header { width: min(980px, calc(100% - 32px)); margin: auto; padding: 26px 0; display: flex; justify-content: space-between; align-items: center; }
.form-public-main { width: min(820px, calc(100% - 32px)); margin: auto; padding: 24px 0 70px; }
.form-intro { text-align: center; margin-bottom: 30px; }
.form-intro h1 { font-size: clamp(2rem, 4vw, 3.4rem); letter-spacing: -.035em; margin: 0 0 12px; color: var(--green-950); }
.form-intro p { color: var(--muted); line-height: 1.65; max-width: 680px; margin: auto; }
.dynamic-form { display: grid; gap: 20px; }
.form-section { display: grid; gap: 18px; }
.file-note { padding: 12px 14px; background: var(--green-50); border: 1px solid var(--green-200); border-radius: 10px; font-size: .84rem; color: var(--green-900); }
.success-panel { text-align: center; padding: 55px 28px; }
.success-icon { width: 70px; height: 70px; display: grid; place-items: center; border-radius: 50%; margin: 0 auto 20px; background: var(--green-100); color: var(--green-900); font-size: 2rem; }

.availability-grid { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.availability-grid table { width: 100%; border-collapse: collapse; min-width: 520px; }
.availability-grid th, .availability-grid td { padding: 10px; text-align: center; border-bottom: 1px solid var(--line); }
.availability-grid th:first-child, .availability-grid td:first-child { text-align: left; font-weight: 700; }
.availability-grid tr:last-child td { border-bottom: 0; }

/* App */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 270px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 22px 16px; background: var(--green-950); color: #fff; }
.sidebar .brand-logo { color: #fff; margin: 0 10px 24px; }
.sidebar .logo-image { filter: brightness(0) invert(1); }
.sidebar-profile { padding: 14px; margin: 0 4px 18px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); border-radius: 14px; }
.sidebar-profile strong { display: block; }
.sidebar-profile span { color: rgba(255,255,255,.66); font-size: .82rem; }
.nav { display: grid; gap: 6px; }
.nav a, .nav button { width: 100%; border: 0; color: rgba(255,255,255,.76); background: transparent; text-decoration: none; border-radius: 11px; padding: 11px 12px; display: flex; align-items: center; gap: 11px; text-align: left; font-weight: 650; }
.nav a:hover, .nav a.active, .nav button:hover { color: #fff; background: rgba(255,255,255,.1); }
.nav-icon { width: 22px; text-align: center; }
.sidebar-footer { margin-top: 28px; padding: 14px 10px; color: rgba(255,255,255,.5); font-size: .75rem; }
.main { min-width: 0; }
.topbar { height: 74px; position: sticky; top: 0; z-index: 100; background: rgba(244,248,246,.88); backdrop-filter: blur(14px); border-bottom: 1px solid rgba(219,232,225,.8); display: flex; align-items: center; padding: 0 30px; gap: 14px; }
.menu-toggle { display: none; border: 0; background: #fff; border-radius: 10px; width: 42px; height: 42px; }
.page-title { font-weight: 850; font-size: 1.08rem; }
.topbar-user { margin-left: auto; color: var(--muted); font-size: .88rem; }
.content { padding: 30px; width: min(1500px, 100%); margin: auto; }
.content-header { margin-bottom: 24px; }
.content-header h1 { margin: 0 0 7px; font-size: clamp(1.8rem, 3vw, 2.7rem); letter-spacing: -.035em; }
.content-header p { margin: 0; color: var(--muted); line-height: 1.55; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.metric { padding: 18px; background: #fff; border: 1px solid var(--line); border-radius: 15px; box-shadow: var(--shadow-sm); }
.metric-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: var(--green-50); color: var(--green-900); margin-bottom: 12px; }
.metric strong { display: block; font-size: 1.8rem; letter-spacing: -.04em; }
.metric span { color: var(--muted); font-size: .84rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.data-table { width: 100%; border-collapse: collapse; min-width: 780px; }
.data-table th { background: #f7faf8; color: var(--muted); font-size: .77rem; text-transform: uppercase; letter-spacing: .04em; text-align: left; padding: 13px 15px; border-bottom: 1px solid var(--line); }
.data-table td { padding: 14px 15px; border-bottom: 1px solid #edf3ef; vertical-align: top; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fbfdfc; }
.table-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty-state strong { color: var(--ink); display: block; font-size: 1.05rem; margin-bottom: 6px; }

.toolbar { display: flex; align-items: end; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar-filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.toolbar .field { min-width: 180px; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.detail-item { padding: 13px; border: 1px solid var(--line); border-radius: 11px; background: #fafcfb; }
.detail-item span { display: block; color: var(--muted); font-size: .76rem; margin-bottom: 4px; }
.detail-item strong { display: block; word-break: break-word; }

.match-list { display: grid; gap: 12px; }
.match-card { border: 1px solid var(--line); border-radius: 13px; padding: 15px; display: grid; grid-template-columns: 70px 1fr auto; gap: 14px; align-items: center; }
.match-score { width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center; background: var(--green-50); color: var(--green-900); font-size: 1.15rem; font-weight: 850; }

.form-builder-list { display: grid; gap: 14px; }
.builder-field { display: grid; grid-template-columns: 1.1fr .8fr .7fr auto; gap: 10px; align-items: end; padding: 13px; background: #f8fbf9; border: 1px solid var(--line); border-radius: 12px; }
.builder-field .field { min-width: 0; }
.builder-field-options { grid-column: 1 / -1; }

.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; }
.status-dot.ok { background: var(--green-600); }
.status-dot.warn { background: #e3a008; }
.status-dot.bad { background: var(--danger); }

.loader { width: 28px; height: 28px; border: 3px solid var(--green-100); border-top-color: var(--green-700); border-radius: 50%; animation: spin .7s linear infinite; }
.loading-box { min-height: 180px; display: grid; place-items: center; }
@keyframes spin { to { transform: rotate(360deg); } }

.dialog { border: 0; border-radius: 20px; padding: 0; width: min(760px, calc(100vw - 28px)); max-height: calc(100vh - 28px); box-shadow: 0 30px 90px rgba(0,0,0,.24); }
.dialog.wide { width: min(1050px, calc(100vw - 28px)); }
.dialog::backdrop { background: rgba(7, 28, 18, .62); backdrop-filter: blur(3px); }
.dialog-head { padding: 20px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 15px; position: sticky; top: 0; background: #fff; z-index: 2; }
.dialog-head h2 { margin: 0; font-size: 1.25rem; }
.dialog-close { border: 0; background: var(--surface-2); width: 38px; height: 38px; border-radius: 10px; }
.dialog-body { padding: 22px; overflow-y: auto; }
.dialog-actions { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; position: sticky; bottom: 0; background: #fff; }

@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .hero { grid-template-columns: 1fr; }
  .hero-panel { max-width: 720px; }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .login-page { grid-template-columns: 1fr; }
  .login-brand { min-height: 340px; padding: 30px; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 1000; width: 270px; transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: grid; place-items: center; }
  .content { padding: 22px 16px; }
  .topbar { padding: 0 16px; }
  .detail-grid { grid-template-columns: 1fr; }
  .builder-field { grid-template-columns: 1fr; }
  .builder-field-options { grid-column: auto; }
}
@media (max-width: 560px) {
  .metrics { grid-template-columns: 1fr; }
  .hero { padding-top: 35px; }
  .public-header { align-items: flex-start; }
  .public-header .brand-logo span { font-size: .9rem; }
  .match-card { grid-template-columns: 56px 1fr; }
  .match-card .btn { grid-column: 1 / -1; }
  .match-score { width: 52px; height: 52px; }
}

/* Módulos clínicos */
.plan-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:18px;margin:20px 0}.module-card{display:block;text-decoration:none;color:inherit;transition:.18s ease}.module-card:hover{transform:translateY(-2px);box-shadow:0 18px 38px rgba(13,74,49,.12)}.module-card h2{margin:0 0 8px}.plan-price{font-size:28px;font-weight:900;color:var(--green-800);margin:18px 0}.plan-price small{font-size:13px;font-weight:600;color:var(--muted)}.locked-panel,.warning-panel{text-align:center;padding:38px;max-width:760px;margin:30px auto}.warning-panel{border-left:5px solid #d99823;text-align:left}.check-line,.switch-line{display:flex;align-items:flex-start;gap:10px;margin:18px 0}.record-row{width:100%;border:1px solid var(--line);background:#fff;border-radius:14px;padding:14px 16px;display:flex;align-items:center;justify-content:space-between;text-align:left;cursor:pointer}.record-row:hover{border-color:var(--green-600);background:#f7fbf9}.record-row span{display:flex;flex-direction:column;gap:4px}.record-text{min-height:280px}.btn[disabled]{opacity:.55;cursor:not-allowed}.status-dot.pending{background:#d99823}@media print{.sidebar,.topbar,.btn,.content-header p{display:none!important}.main{margin:0!important}.content{padding:0!important}.card{box-shadow:none;border:1px solid #ddd}}


/* Planos clínicos: benefícios e alinhamento visual */
.subscription-plan-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 390px;
}
.subscription-plan-card > div:first-child {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.plan-benefit {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.58;
}
.plan-benefit strong {
  display: block;
  margin-bottom: 8px;
  color: var(--green-950);
  font-size: .92rem;
}
.plan-benefit p { margin: 0; }
@media (max-width: 680px) {
  .subscription-plan-card { min-height: auto; }
}
