:root {
  --page: #f6fafc;
  --surface: #ffffff;
  --surface-soft: #f0f7f8;
  --surface-blue: #eef6ff;
  --ink: #0f1f2e;
  --text: #26394d;
  --muted: #66788c;
  --line: #dfe9ef;
  --line-strong: rgba(5, 179, 152, 0.34);
  --cyan: #05b398;
  --cyan-dark: #047d70;
  --blue: #2364d2;
  --green: #0f9f69;
  --amber: #c78310;
  --danger: #c94f4f;
  --gradient: linear-gradient(135deg, #2364d2 0%, #05b398 58%, #57b84f 100%);
  --shadow-soft: 0 18px 50px rgba(20, 58, 87, 0.08);
  --shadow-card: 0 10px 28px rgba(20, 58, 87, 0.08);
  --radius: 18px;
  --font-display: "Outfit", sans-serif;
  --font-body: "Plus Jakarta Sans", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font-body);
  background:
    radial-gradient(circle at 9% 8%, rgba(5, 179, 152, 0.12), transparent 28%),
    radial-gradient(circle at 92% 4%, rgba(35, 100, 210, 0.12), transparent 24%),
    linear-gradient(180deg, #ffffff 0%, var(--page) 52%, #eef6f7 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.is-hidden {
  display: none !important;
}

.portal-auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(390px, 0.72fr);
}

.auth-hero {
  min-height: 100vh;
  padding: 42px clamp(28px, 5vw, 78px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 34px;
  position: relative;
  overflow: hidden;
}

.auth-hero::before {
  content: "";
  position: absolute;
  width: 560px;
  height: 560px;
  right: -180px;
  top: -120px;
  border-radius: 48px;
  background: linear-gradient(135deg, rgba(35, 100, 210, 0.12), rgba(5, 179, 152, 0.1));
  transform: rotate(12deg);
}

.auth-hero::after {
  content: "";
  position: absolute;
  left: 9%;
  bottom: 14%;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: rgba(5, 179, 152, 0.08);
  filter: blur(10px);
}

.brand-mark,
.sidebar-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  position: relative;
  z-index: 1;
}

.brand-mark img,
.sidebar-brand img {
  width: 38px;
  height: 38px;
}

.auth-copy {
  max-width: 780px;
  position: relative;
  z-index: 1;
}

.eyebrow,
.panel-kicker,
.section-title span,
.topbar-kicker,
.result-header span {
  display: inline-block;
  margin-bottom: 11px;
  color: var(--cyan-dark);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.auth-copy h1 {
  max-width: 820px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 6vw, 5.9rem);
  line-height: 0.95;
  letter-spacing: -0.045em;
}

.auth-copy p {
  max-width: 690px;
  margin-top: 24px;
  color: var(--muted);
  font-size: 1.06rem;
  line-height: 1.8;
}

.auth-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 28px;
}

.primary-action,
.secondary-action {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  padding: 0 20px;
  font-weight: 900;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, filter 0.2s ease;
}

.primary-action {
  border: 0;
  color: #ffffff;
  background: var(--gradient);
  box-shadow: 0 16px 32px rgba(5, 179, 152, 0.22);
}

.primary-action:hover {
  transform: translateY(-2px);
  filter: brightness(1.04);
  box-shadow: 0 20px 38px rgba(5, 179, 152, 0.28);
}

.secondary-action {
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
}

.secondary-action:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-card);
}

.solution-strip {
  width: min(780px, 100%);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 34px;
}

.solution-strip div,
.preview-card,
.preview-document,
.auth-card,
.tool-panel,
.result-panel,
.single-panel,
.credit-wallet,
.privacy-note,
.lgpd-reminder {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow-card);
}

.solution-strip div {
  min-height: 118px;
  padding: 18px;
  border-radius: 16px;
}

.solution-strip strong,
.solution-strip span,
.privacy-note strong,
.privacy-note span,
.lgpd-reminder strong,
.lgpd-reminder span {
  display: block;
}

.solution-strip strong {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1rem;
  margin-bottom: 7px;
}

.solution-strip span {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.auth-preview {
  width: min(700px, 100%);
  display: grid;
  grid-template-columns: 0.66fr 1px 1fr;
  gap: 18px;
  align-items: center;
  padding: 18px;
  border: 1px solid rgba(5, 179, 152, 0.16);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
  position: relative;
  z-index: 1;
}

.preview-card,
.preview-document {
  border-radius: 16px;
  padding: 16px;
}

.preview-card span,
.preview-card small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.preview-card strong {
  display: block;
  margin: 6px 0;
  color: var(--cyan-dark);
  font-family: var(--font-display);
  font-size: 3.1rem;
  line-height: 1;
}

.preview-line {
  width: 1px;
  height: 126px;
  background: var(--line);
}

.preview-document {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.preview-document + .preview-document {
  margin-top: 10px;
}

.preview-document b {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 10px;
  background: rgba(5, 179, 152, 0.1);
  color: var(--cyan-dark);
}

.preview-document span {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.auth-panel {
  min-height: 100vh;
  padding: 28px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.66);
  border-left: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.auth-card {
  width: min(450px, 100%);
  padding: 30px;
  border-radius: 24px;
}

.auth-card h2,
.section-title h2,
.result-header h2,
.topbar h1 {
  color: var(--ink);
  font-family: var(--font-display);
  letter-spacing: -0.025em;
}

.auth-card h2 {
  font-size: 2rem;
}

.auth-card p,
.section-title p,
.topbar-subtitle {
  color: var(--muted);
  line-height: 1.7;
}

.auth-card p {
  margin: 10px 0 24px;
}

.login-form,
.clinical-form {
  display: grid;
  gap: 16px;
}

.secure-auth-box {
  display: grid;
  gap: 14px;
  margin: 20px 0 18px;
  padding: 16px;
  border: 1px solid rgba(5, 179, 152, 0.2);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(5, 179, 152, 0.08), rgba(35, 100, 210, 0.05)), #ffffff;
}

.secure-auth-box strong,
.secure-auth-box span {
  display: block;
}

.secure-auth-box strong {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1rem;
  margin-bottom: 4px;
}

.secure-auth-box span {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.55;
}

.secure-auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.secure-auth-actions .primary-action,
.secure-auth-actions .secondary-action {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  font-size: 0.86rem;
}

.secure-user-button {
  display: flex;
  justify-content: flex-start;
}

.demo-login-fallback {
  margin-top: 10px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
}

label {
  display: grid;
  gap: 7px;
  color: #28405a;
  font-size: 0.83rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  background: #fbfdff;
  color: var(--ink);
  padding: 12px 13px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #9aacbb;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 4px rgba(5, 179, 152, 0.1);
  background: #ffffff;
}

.privacy-note,
.lgpd-reminder {
  margin-top: 18px;
  padding: 14px 15px;
  border-color: rgba(5, 179, 152, 0.18);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(5, 179, 152, 0.08), rgba(35, 100, 210, 0.04)), #ffffff;
}

.privacy-note strong,
.lgpd-reminder strong {
  color: var(--ink);
  font-size: 0.86rem;
  margin-bottom: 4px;
}

.privacy-note span,
.lgpd-reminder span {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.55;
}

.privacy-note a,
.lgpd-reminder a,
.terms-gate a {
  color: var(--cyan-dark);
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.preauth-terms a,
.demo-terms-check a,
.terms-check a {
  color: var(--blue);
  font-weight: 900;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-decoration-color: rgba(5, 179, 152, 0.45);
  text-underline-offset: 4px;
  border-radius: 6px;
  transition: color 0.2s ease, background 0.2s ease, text-decoration-color 0.2s ease, box-shadow 0.2s ease;
}

.preauth-terms a:hover,
.demo-terms-check a:hover,
.terms-check a:hover,
.preauth-terms a:focus-visible,
.demo-terms-check a:focus-visible,
.terms-check a:focus-visible {
  color: var(--cyan-dark);
  background: rgba(5, 179, 152, 0.1);
  text-decoration-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(5, 179, 152, 0.08);
  outline: none;
}

.terms-gate {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  padding: 15px;
  border: 1px solid rgba(199, 131, 16, 0.26);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(199, 131, 16, 0.08), rgba(5, 179, 152, 0.05)), #ffffff;
}

.preauth-terms {
  display: grid;
  gap: 7px;
  padding: 13px;
  border: 1px solid rgba(199, 131, 16, 0.24);
  border-radius: 14px;
  background: rgba(255, 250, 241, 0.9);
}

.preauth-terms small {
  color: var(--amber);
  font-size: 0.72rem;
  font-weight: 900;
}

.demo-terms-check {
  padding: 12px;
  border: 1px solid rgba(5, 179, 152, 0.18);
  border-radius: 12px;
  background: rgba(5, 179, 152, 0.05);
}

.terms-gate.accepted {
  border-color: rgba(5, 179, 152, 0.24);
  background: linear-gradient(135deg, rgba(5, 179, 152, 0.08), rgba(35, 100, 210, 0.04)), #ffffff;
}

.terms-gate.attention {
  border-color: rgba(201, 79, 79, 0.42);
  box-shadow: 0 0 0 4px rgba(201, 79, 79, 0.08);
}

.terms-check {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  align-items: flex-start;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.55;
}

.terms-check input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--cyan);
}

.terms-gate small {
  color: var(--amber);
  font-size: 0.73rem;
  font-weight: 900;
}

.terms-gate.accepted small {
  color: var(--green);
}

.portal-app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  background:
    linear-gradient(90deg, #ffffff 0 260px, transparent 260px),
    var(--page);
}

.sidebar {
  min-height: 100vh;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  position: sticky;
  top: 0;
}

.side-nav {
  display: grid;
  gap: 8px;
  margin-top: 42px;
}

.side-link,
.sidebar-footer button,
.result-actions button,
.package-card {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 12px;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.side-link {
  padding: 13px 14px;
  text-align: left;
  font-weight: 900;
}

.side-link:hover,
.side-link.active {
  color: var(--cyan-dark);
  border-color: rgba(5, 179, 152, 0.22);
  background: rgba(5, 179, 152, 0.08);
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 12px;
}

.sidebar-footer span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-footer button {
  padding: 11px 12px;
  border-color: var(--line);
  text-align: left;
}

.workspace {
  padding: 28px;
}

.topbar {
  min-height: 96px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 24px;
}

.topbar h1 {
  font-size: clamp(1.7rem, 3vw, 2.7rem);
}

.topbar-subtitle {
  max-width: 680px;
  margin-top: 5px;
  font-size: 0.92rem;
}

.credit-wallet {
  min-width: 170px;
  padding: 15px 16px;
  border-color: rgba(5, 179, 152, 0.22);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(5, 179, 152, 0.08), rgba(35, 100, 210, 0.05)), #ffffff;
}

.credit-wallet > span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.credit-wallet strong {
  display: flex;
  align-items: baseline;
  gap: 5px;
  color: var(--cyan-dark);
  font-family: var(--font-display);
  font-size: 1.95rem;
  line-height: 1;
  margin-top: 6px;
}

.credit-wallet strong span {
  display: inline;
  color: inherit;
  font: inherit;
}

.credit-wallet strong span:last-child {
  color: var(--muted);
  font-size: 0.92rem;
}

.view-panel {
  display: none;
}

.view-panel.active {
  display: block;
}

.portal-grid {
  display: grid;
  grid-template-columns: minmax(420px, 0.92fr) minmax(380px, 1.08fr);
  gap: 20px;
  align-items: start;
}

.tool-panel,
.result-panel,
.single-panel {
  border-radius: 24px;
}

.tool-panel,
.single-panel {
  padding: 24px;
}

.result-panel {
  min-height: 710px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.section-title {
  margin-bottom: 20px;
}

.section-title h2,
.result-header h2 {
  font-size: 1.6rem;
}

.section-title p {
  margin-top: 6px;
  font-size: 0.88rem;
}

.doc-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 20px;
}

.doc-tab {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  color: var(--muted);
  font-weight: 900;
}

.doc-tab.active {
  color: #ffffff;
  border-color: transparent;
  background: var(--gradient);
  box-shadow: 0 12px 26px rgba(5, 179, 152, 0.18);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 0.7fr;
  gap: 12px;
}

.generate-btn {
  margin-top: 4px;
}

.result-header {
  padding: 22px 24px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(5, 179, 152, 0.04), rgba(35, 100, 210, 0.04)), #ffffff;
}

.ai-status {
  margin: 0;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(15, 159, 105, 0.1);
  color: var(--green) !important;
  font-size: 0.72rem !important;
}

.ai-status.loading {
  background: rgba(199, 131, 16, 0.12);
  color: var(--amber) !important;
}

.document-output {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px;
  color: var(--text);
  line-height: 1.72;
  background: #ffffff;
}

.document-output h3 {
  margin-bottom: 16px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.45rem;
}

.document-output h4 {
  margin: 18px 0 8px;
  color: var(--cyan-dark);
  font-family: var(--font-display);
}

.document-output p {
  margin-bottom: 10px;
}

.document-output ul {
  margin-left: 18px;
}

.empty-state {
  height: 100%;
  min-height: 320px;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--muted);
}

.empty-state strong {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.4rem;
}

.result-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 16px 24px 22px;
  border-top: 1px solid var(--line);
  background: #ffffff;
}

.result-actions button {
  min-height: 46px;
  padding: 12px;
  border-color: var(--line);
  background: #ffffff;
  font-weight: 900;
}

.result-actions button:disabled {
  cursor: wait;
  opacity: 0.72;
}

#pdfDownloadBtn {
  color: #ffffff;
  border-color: transparent;
  background: linear-gradient(135deg, #047d70 0%, #05b398 58%, #2364d2 100%);
  box-shadow: 0 12px 24px rgba(5, 179, 152, 0.18);
}

.result-actions button:hover,
.package-card:hover {
  transform: translateY(-2px);
  color: var(--cyan-dark);
  border-color: var(--line-strong);
  background: rgba(5, 179, 152, 0.06);
  box-shadow: var(--shadow-card);
}

#pdfDownloadBtn:hover {
  color: #ffffff;
  border-color: transparent;
  background: linear-gradient(135deg, #046f64 0%, #04a589 58%, #1f59bf 100%);
}

.history-list {
  display: grid;
  gap: 12px;
}

.history-item {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.history-info {
  min-width: 0;
}

.history-info strong,
.history-item > strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
}

.history-info span,
.history-item > span {
  color: var(--muted);
  font-size: 0.82rem;
}

.history-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.history-actions button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  background: #ffffff;
  color: var(--muted);
  font-weight: 900;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.history-actions button:hover {
  transform: translateY(-1px);
  color: var(--cyan-dark);
  border-color: var(--line-strong);
  background: rgba(5, 179, 152, 0.06);
}

.history-actions button:disabled {
  cursor: wait;
  opacity: 0.7;
  transform: none;
}

.history-actions .danger-action {
  color: var(--danger);
}

.history-actions .danger-action:hover {
  border-color: rgba(201, 79, 79, 0.36);
  background: rgba(201, 79, 79, 0.07);
  color: #9d3030;
}

.credit-summary-grid,
.package-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.credit-summary-card,
.package-card {
  min-height: 180px;
  padding: 18px;
  text-align: left;
  border-color: var(--line);
  background: #ffffff;
}

.credit-summary-card {
  border: 1px solid rgba(5, 179, 152, 0.22);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(5, 179, 152, 0.08), rgba(35, 100, 210, 0.04)), #ffffff;
}

.package-card.active {
  border-color: rgba(5, 179, 152, 0.32);
  background: linear-gradient(135deg, rgba(5, 179, 152, 0.08), rgba(35, 100, 210, 0.04)), #ffffff;
}

.credit-summary-card span,
.credit-summary-card small,
.package-card span,
.package-card small {
  display: block;
  color: var(--muted);
  font-weight: 900;
}

.credit-summary-card strong,
.package-card strong {
  display: block;
  margin: 18px 0 8px;
  color: var(--cyan-dark);
  font-family: var(--font-display);
  font-size: 3rem;
}

.package-note {
  margin-top: 18px;
  color: var(--muted);
  line-height: 1.7;
}

@media (max-width: 1120px) {
  .portal-auth,
  .portal-app,
  .portal-grid {
    grid-template-columns: 1fr;
  }

  .auth-hero,
  .auth-panel {
    min-height: auto;
  }

  .sidebar {
    min-height: auto;
    position: static;
  }

  .side-nav {
    grid-template-columns: repeat(3, 1fr);
    margin-top: 24px;
  }

  .sidebar-footer {
    margin-top: 22px;
  }
}

@media (max-width: 700px) {
  .auth-hero,
  .auth-panel,
  .workspace,
  .sidebar {
    padding: 20px;
  }

  .auth-preview,
  .solution-strip,
  .field-row,
  .doc-tabs,
  .result-actions,
  .history-item,
  .credit-summary-grid,
  .package-grid {
    grid-template-columns: 1fr;
  }

  .history-actions {
    justify-content: stretch;
  }

  .history-actions button {
    flex: 1;
  }

  .preview-line {
    display: none;
  }

  .topbar,
  .result-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .result-panel {
    min-height: 620px;
  }
}
