:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --text: #172026;
  --muted: #66747f;
  --line: #dbe2e6;
  --primary: #256f68;
  --primary-dark: #174d49;
  --danger: #a83f3f;
  --income: #1f7a4d;
  --expense: #b4532a;
  --shadow: 0 16px 40px rgba(23, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

[hidden] {
  display: none !important;
}

.auth-screen {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  display: grid;
  align-items: start;
  justify-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 48%, rgba(186, 238, 242, 0.72) 0 18%, rgba(109, 164, 184, 0.55) 38%, rgba(21, 55, 78, 0.94) 78%),
    linear-gradient(90deg, rgba(8, 31, 48, 0.9), rgba(103, 159, 179, 0.42) 30%, rgba(151, 220, 224, 0.38) 50%, rgba(103, 159, 179, 0.42) 70%, rgba(8, 31, 48, 0.9)),
    #244f68;
}

.auth-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent 0 16%, rgba(255, 255, 255, 0.28) 16.2% 16.5%, transparent 16.7% 83%, rgba(255, 255, 255, 0.25) 83.2% 83.5%, transparent 83.7%),
    linear-gradient(0deg, transparent 0 57%, rgba(255, 255, 255, 0.14) 57.2% 57.6%, transparent 58%),
    repeating-linear-gradient(90deg, rgba(8, 31, 48, 0.2) 0 1px, transparent 1px 360px),
    repeating-linear-gradient(0deg, rgba(8, 31, 48, 0.22) 0 2px, transparent 2px 128px);
  opacity: 0.75;
}

.auth-screen::after {
  content: "";
  position: absolute;
  top: 26px;
  left: 50%;
  width: min(32vw, 460px);
  height: 54px;
  transform: translateX(-50%);
  border-radius: 3px;
  background: repeating-linear-gradient(0deg, rgba(245, 253, 255, 0.95) 0 6px, rgba(161, 218, 230, 0.95) 6px 10px);
  box-shadow: 0 0 26px rgba(218, 255, 255, 0.75);
}

.auth-backdrop-brand {
  position: absolute;
  top: 52%;
  left: 50%;
  display: grid;
  justify-items: center;
  transform: translate(-50%, -24%);
  color: rgba(13, 91, 137, 0.8);
  text-align: center;
  text-shadow: 0 0 18px rgba(214, 255, 255, 0.9);
  pointer-events: none;
}

.auth-backdrop-brand strong {
  font-size: clamp(92px, 20vw, 250px);
  line-height: 0.82;
  letter-spacing: 0;
  background: linear-gradient(90deg, #0b64a6, #2fcf96);
  -webkit-background-clip: text;
  color: transparent;
}

.auth-backdrop-brand span {
  margin-top: 20px;
  color: rgba(8, 60, 104, 0.85);
  font-size: clamp(18px, 3vw, 42px);
  font-weight: 700;
}

.auth-logo {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 18px;
  width: min(100%, 270px);
  min-height: 66px;
  margin: 6px auto 28px;
  padding: 11px 18px;
  background: rgba(255, 255, 255, 0.92);
  color: #1e6fb8;
  font-weight: 700;
}

.auth-logo strong {
  font-size: 24px;
  letter-spacing: 0;
  background: linear-gradient(90deg, #0d63aa, #2dbf91);
  -webkit-background-clip: text;
  color: transparent;
}

.auth-card {
  position: relative;
  z-index: 1;
  width: min(100%, 420px);
  margin-top: min(14vh, 128px);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  padding: 32px 34px 24px;
  background: rgba(222, 238, 244, 0.78);
  box-shadow: 0 24px 70px rgba(2, 18, 28, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(8px);
}

.auth-card h1 {
  margin-bottom: 10px;
  color: #d10000;
  font-size: 15px;
  text-align: center;
}

.auth-copy {
  margin: 0 0 20px;
  color: rgba(2, 30, 46, 0.78);
  text-align: center;
  font-size: 13px;
}

.auth-card form {
  width: min(100%, 260px);
  margin: 0 auto;
}

.auth-card label {
  color: rgba(2, 30, 46, 0.74);
}

.auth-card input {
  min-height: 30px;
  padding: 6px 8px;
  border-color: rgba(53, 88, 110, 0.45);
  background: rgba(247, 252, 255, 0.86);
}

.auth-card input:focus {
  outline: 2px solid #ffb100;
  outline-offset: 0;
  border-color: #ffb100;
}

.auth-card .primary-button {
  width: fit-content;
  min-height: 32px;
  margin: 0 auto;
  padding: 0 14px;
  border: 1px solid rgba(38, 64, 80, 0.65);
  background: rgba(236, 244, 247, 0.76);
  color: #4b585f;
  font-weight: 700;
}

.auth-card .primary-button:hover {
  background: rgba(211, 230, 236, 0.96);
}

.auth-credit {
  position: absolute;
  z-index: 1;
  margin: 0;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
  font-size: 14px;
}

.auth-card-copyright {
  position: static !important;
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 14px auto 0;
  border-radius: 999px;
  padding: 7px 14px;
  background: rgba(40, 53, 55, 0.52);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.26);
  color: #ffffff;
  font-size: 12px;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

.auth-footer {
  display: none !important;
}

.auth-credit {
  right: 12px;
  bottom: 10px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 5px;
  padding: 8px 12px;
  background: rgba(18, 31, 38, 0.36);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 4vw, 44px);
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 12px;
  color: var(--muted);
  background: #fbfcfc;
  font-size: 13px;
  font-weight: 700;
}

.module-nav {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  padding: 14px clamp(18px, 4vw, 44px) 0;
}

.nav-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-group > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.management-group {
  margin-left: auto;
}

.tab-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 14px;
  color: var(--muted);
  background: #ffffff;
  cursor: pointer;
  font-weight: 700;
}

.tab-button.active {
  border-color: var(--primary);
  color: #ffffff;
  background: var(--primary);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 42px);
}

.brand-line {
  display: flex;
  align-items: center;
  gap: 12px;
}

.active-company-logo {
  width: 54px;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: contain;
  background: #ffffff;
  padding: 5px;
}

h2 {
  font-size: 20px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 24px;
  padding: 24px clamp(18px, 4vw, 44px) 44px;
}

.entry-panel,
.records-panel,
.settings-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.entry-panel,
.settings-panel {
  padding: 22px;
}

.settings-layout {
  display: grid;
  gap: 24px;
  padding: 24px clamp(18px, 4vw, 44px) 44px;
}

.portal-layout {
  display: grid;
  gap: 20px;
  padding: 24px clamp(18px, 4vw, 44px) 44px;
}

.portal-hero {
  display: flex;
  align-items: center;
  min-height: 130px;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.portal-hero h2 {
  margin: 4px 0 8px;
  font-size: clamp(28px, 4vw, 44px);
}

.portal-hero p:last-child {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
}

.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.module-card {
  min-height: 150px;
  padding: 20px;
  color: var(--text);
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.module-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.module-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.module-card strong {
  display: block;
  margin: 10px 0;
  font-size: 24px;
}

.module-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.profile-panel {
  max-width: 780px;
}

.settings-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-actions {
  display: flex;
  gap: 8px;
}

.settings-panel h3 {
  margin: 10px 0 0;
  color: var(--text);
  font-size: 16px;
}

.settings-status {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.settings-status article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfc;
}

.settings-status span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.settings-status strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 15px;
}

.compact-form {
  margin-bottom: 18px;
}

.permissions-panel {
  display: grid;
  gap: 14px;
  margin-top: 22px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.permissions-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.permission-item {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfc;
  color: var(--text);
}

.permission-item input {
  width: auto;
}

.medical-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.evolution-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfcfc;
}

.history-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.history-item {
  border-left: 4px solid var(--primary);
  padding: 12px;
  background: #ffffff;
}

.history-item strong,
.history-item span {
  display: block;
}

.history-item span {
  color: var(--muted);
  font-size: 13px;
}

.history-item p {
  margin: 8px 0 0;
  line-height: 1.45;
}

.report-results {
  display: grid;
  gap: 18px;
  margin-top: 22px;
}

.report-results h3 {
  margin: 0;
  font-size: 16px;
}

.report-summary {
  margin-bottom: 0;
}

form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  color: var(--text);
  background: #ffffff;
}

textarea {
  resize: vertical;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segmented label {
  display: block;
  color: var(--text);
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  display: block;
  padding: 11px 12px;
  text-align: center;
  cursor: pointer;
}

.segmented input:checked + span {
  background: var(--primary);
  color: #ffffff;
}

.primary-button,
.secondary-button,
.icon-button,
.delete-button {
  border: 0;
  cursor: pointer;
}

.primary-button {
  min-height: 44px;
  border-radius: 6px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
}

.primary-button:hover,
.icon-button:hover {
  background: var(--primary-dark);
}

.secondary-button {
  min-height: 38px;
  border-radius: 6px;
  padding: 0 14px;
  background: #eaf2f1;
  color: var(--primary-dark);
  font-weight: 700;
}

.secondary-button:hover {
  background: #d8e8e6;
}

.link-button {
  align-self: center;
  border: 0;
  background: transparent;
  color: var(--primary-dark);
  cursor: pointer;
  font-weight: 700;
  padding: 6px 10px;
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  font-size: 20px;
}

.message {
  min-height: 20px;
  margin: 0;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

.message.error {
  color: var(--danger);
}

.records-panel {
  min-width: 0;
  padding: 22px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.summary-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfcfc;
}

.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.summary-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.alerts-panel {
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfcfc;
}

.alerts-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.alerts-list {
  display: grid;
  gap: 10px;
}

.alert-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-left: 4px solid var(--expense);
  padding: 10px 12px;
  background: #ffffff;
}

.alert-item strong,
.alert-item span {
  display: block;
}

.alert-item span,
.empty-inline {
  color: var(--muted);
  font-size: 13px;
}

.alert-link {
  color: var(--primary);
  font-weight: 700;
  white-space: nowrap;
  text-decoration: none;
}

.alert-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.secondary-link {
  font-size: 13px;
}

.records-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.filters {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 150px 150px;
  gap: 10px;
  width: min(100%, 620px);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 1020px;
  border-collapse: collapse;
  background: #ffffff;
}

.small-table table {
  min-width: 680px;
}

.company-logo-thumb {
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  object-fit: contain;
  background: #ffffff;
  padding: 4px;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: capitalize;
}

.pill.receita,
.amount.receita {
  color: var(--income);
}

.pill.despesa,
.amount.despesa {
  color: var(--expense);
}

.pill.status {
  background: #eef3f3;
  color: var(--muted);
}

.amount {
  white-space: nowrap;
  font-weight: 700;
}

.attachment-link {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
}

.delete-button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--danger);
  background: #fff1f1;
  font-size: 18px;
}

.empty-state {
  display: none;
  margin: 18px 0 0;
  color: var(--muted);
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .records-header {
    align-items: stretch;
    flex-direction: column;
  }

  .filters,
  .settings-status {
    grid-template-columns: 1fr;
  }

  .module-nav {
    flex-direction: column;
    overflow-x: auto;
    padding-bottom: 8px;
  }

  .nav-group {
    align-items: stretch;
    flex-wrap: wrap;
    width: 100%;
  }

  .management-group {
    margin-left: 0;
  }

  .tab-button {
    flex: 0 0 auto;
  }

  .permissions-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .auth-screen {
    padding: 18px;
  }

  .auth-screen::after {
    width: 70vw;
  }

  .auth-card {
    margin-top: 92px;
    padding: 26px 20px 22px;
  }

  .auth-backdrop-brand {
    top: 58%;
  }

  .auth-backdrop-brand span {
    margin-top: 12px;
  }

  .auth-credit {
    left: 18px;
    right: 18px;
    text-align: center;
  }

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

  .form-grid,
  .summary-grid,
  .permissions-grid {
    grid-template-columns: 1fr;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }

  .alert-actions {
    justify-content: stretch;
    width: 100%;
  }

  .topbar-actions {
    align-items: stretch;
    flex-wrap: wrap;
    width: 100%;
  }

  .user-badge {
    width: 100%;
  }
}
