:root {
  --blue-950: #10243d;
  --blue-900: #16324f;
  --blue-700: #2563eb;
  --teal-700: #2f9e8f;
  --teal-100: #e8f8f4;
  --yellow-500: #f6c453;
  --yellow-100: #fff5d8;
  --red-600: #dc3545;
  --red-100: #ffe8ec;
  --green-600: #258a5f;
  --green-100: #e8f7ee;
  --gray-950: #182333;
  --gray-700: #516070;
  --gray-500: #7b8794;
  --gray-200: #dfe7ee;
  --gray-100: #eef4f7;
  --white: #ffffff;
  --radius: 8px;
  --shadow: 0 16px 40px rgba(16, 36, 61, 0.10);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--gray-950);
  background: var(--gray-100);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 16px;
}

img,
svg {
  max-width: 100%;
}

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

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

button {
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.public-shell {
  min-height: calc(100vh - 56px);
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 26px 0 42px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 178px 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 12px max(18px, calc((100vw - 1180px) / 2));
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--gray-200);
  backdrop-filter: blur(12px);
}

.brand img {
  display: block;
  width: 174px;
  height: auto;
}

.main-nav {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
}

.main-nav a,
.user-chip,
.button,
.ghost-button,
.danger-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-weight: 700;
  line-height: 1.1;
}

.main-nav a {
  color: var(--gray-700);
}

.main-nav a:hover,
.main-nav a.active {
  color: var(--blue-900);
  background: var(--teal-100);
}

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

.family-switch select,
.field input,
.field select,
.field textarea,
.filters select,
.filters input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--gray-950);
  background: var(--white);
  outline: none;
}

.family-switch select {
  min-width: 160px;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.filters select:focus,
.filters input:focus {
  border-color: var(--teal-700);
  box-shadow: 0 0 0 3px rgba(47, 158, 143, 0.14);
}

.user-chip {
  color: var(--blue-900);
  background: var(--gray-100);
}

.user-chip span {
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  color: var(--white);
  background: var(--teal-700);
  text-transform: uppercase;
}

.menu-button {
  display: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--white);
}

.menu-button span {
  display: block;
  width: 18px;
  height: 2px;
  margin: 4px auto;
  background: var(--blue-900);
}

.app-footer {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 26px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--gray-500);
  font-size: 14px;
}

.hero {
  min-height: calc(100vh - 56px);
  display: grid;
  align-items: center;
  background:
    linear-gradient(100deg, rgba(16, 36, 61, 0.92), rgba(47, 158, 143, 0.78)),
    url("../img/logo-icon-casa-em-conta.svg");
  background-repeat: no-repeat;
  background-position: center right 10%;
  background-size: auto, min(42vw, 420px);
  color: var(--white);
}

.hero-inner {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 58px 0;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.8fr);
  gap: 40px;
  align-items: center;
}

.hero-logo {
  width: 260px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: var(--radius);
  padding: 12px;
}

.hero h1,
.page-title h1 {
  margin: 0;
  font-size: clamp(34px, 6vw, 64px);
  line-height: 1.02;
  letter-spacing: 0;
}

.hero p {
  max-width: 560px;
  margin: 18px 0 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 20px;
  line-height: 1.45;
}

.hero-actions,
.page-actions,
.form-actions,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.hero-actions {
  margin-top: 28px;
}

.button {
  color: var(--white);
  background: var(--blue-700);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.22);
}

.button:hover {
  background: #1f56d2;
}

.button.secondary {
  color: var(--blue-900);
  background: var(--yellow-500);
  box-shadow: none;
}

.ghost-button {
  color: var(--blue-900);
  background: var(--white);
  border: 1px solid var(--gray-200);
}

.danger-button {
  color: var(--white);
  background: var(--red-600);
}

.hero-panel,
.auth-card,
.panel,
.stat-card,
.expense-card,
.member-card {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
}

.hero-panel {
  padding: 24px;
  color: var(--gray-950);
}

.quick-list {
  display: grid;
  gap: 12px;
  padding: 0;
  margin: 18px 0 0;
  list-style: none;
}

.quick-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--gray-100);
}

.auth-page {
  background:
    linear-gradient(120deg, rgba(244, 251, 249, 0.95), rgba(238, 244, 247, 0.98)),
    url("../img/logo-icon-casa-em-conta.svg");
  background-repeat: no-repeat;
  background-position: left 7vw bottom 8vh;
  background-size: min(44vw, 360px);
}

.auth-wrap {
  min-height: calc(100vh - 56px);
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: 0.8fr minmax(310px, 440px);
  gap: 34px;
  align-items: center;
  padding: 36px 0;
}

.auth-copy img {
  width: 246px;
  margin-bottom: 24px;
}

.auth-copy h1 {
  margin: 0;
  color: var(--blue-900);
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.04;
}

.auth-copy p {
  max-width: 430px;
  margin: 16px 0 0;
  color: var(--gray-700);
  line-height: 1.55;
}

.auth-card,
.panel {
  padding: clamp(18px, 3vw, 28px);
}

.auth-card h2,
.panel h2,
.panel h3 {
  margin: 0 0 16px;
  color: var(--blue-900);
}

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

.form-grid.two,
.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid.three,
.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: var(--blue-900);
  font-size: 14px;
  font-weight: 800;
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 48px;
}

.password-toggle {
  position: absolute;
  right: 6px;
  bottom: 5px;
  width: 38px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius);
  color: var(--gray-700);
  background: transparent;
}

.alert {
  margin: 0 0 18px;
  border-radius: var(--radius);
  padding: 14px 16px;
  font-weight: 700;
}

.alert.success {
  color: #155f3f;
  background: var(--green-100);
}

.alert.error {
  color: #9f1f2d;
  background: var(--red-100);
}

.alert.info {
  color: #6d4b00;
  background: var(--yellow-100);
}

.page-title {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-end;
  margin-bottom: 22px;
}

.page-title h1 {
  color: var(--blue-900);
  font-size: clamp(28px, 4vw, 42px);
}

.page-title p,
.muted {
  margin: 7px 0 0;
  color: var(--gray-700);
  line-height: 1.45;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  min-height: 132px;
  padding: 18px;
  display: grid;
  align-content: space-between;
  box-shadow: none;
}

.stat-card span {
  color: var(--gray-700);
  font-size: 14px;
  font-weight: 800;
}

.stat-card strong {
  color: var(--blue-900);
  font-size: 26px;
  line-height: 1;
}

.stat-card.paid strong,
.status-paid {
  color: var(--green-600);
}

.stat-card.pending strong,
.status-pending {
  color: #936600;
}

.stat-card.overdue strong,
.status-overdue {
  color: var(--red-600);
}

.grid {
  display: grid;
  gap: 18px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 18px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 12px;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
  vertical-align: middle;
}

th {
  color: var(--gray-700);
  font-size: 13px;
  text-transform: uppercase;
}

.badge {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.paid {
  color: #155f3f;
  background: var(--green-100);
}

.badge.pending {
  color: #7a5707;
  background: var(--yellow-100);
}

.badge.overdue {
  color: #9f1f2d;
  background: var(--red-100);
}

.badge.neutral {
  color: var(--blue-900);
  background: var(--gray-100);
}

.filters {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}

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

.expense-card,
.member-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  box-shadow: none;
}

.expense-card-header,
.member-card {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.expense-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--gray-700);
  font-size: 14px;
}

.split-box {
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

.split-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px 120px;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--gray-100);
}

.copy-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.invite-code {
  min-height: 44px;
  display: flex;
  align-items: center;
  border: 1px dashed var(--teal-700);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--blue-900);
  background: var(--teal-100);
  font-weight: 900;
  letter-spacing: 0;
}

.chart-box {
  min-height: 280px;
}

.empty-state {
  border: 1px dashed var(--gray-200);
  border-radius: var(--radius);
  padding: 22px;
  color: var(--gray-700);
  background: rgba(255, 255, 255, 0.65);
}

@media (max-width: 1080px) {
  .app-header {
    grid-template-columns: 170px auto auto;
  }

  .menu-button {
    display: block;
    justify-self: end;
  }

  .main-nav {
    display: none;
    grid-column: 1 / -1;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .main-nav.open {
    display: flex;
  }

  .header-actions {
    justify-self: end;
  }

  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .hero-inner,
  .auth-wrap,
  .dashboard-grid,
  .form-grid.two,
  .form-grid.three,
  .grid.two,
  .grid.three {
    grid-template-columns: 1fr;
  }

  .hero {
    background-size: auto, 260px;
    background-position: center right -86px;
  }

  .hero-panel {
    display: none;
  }

  .auth-copy {
    display: none;
  }

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

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app-header {
    grid-template-columns: 152px 44px;
    padding: 10px 14px;
  }

  .brand img {
    width: 150px;
  }

  .header-actions {
    grid-column: 1 / -1;
    width: 100%;
    justify-content: space-between;
  }

  .family-switch {
    flex: 1;
  }

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

  .split-row {
    grid-template-columns: 1fr;
  }

  .expense-card-header,
  .member-card {
    grid-template-columns: 1fr;
  }

  .button,
  .ghost-button,
  .danger-button {
    width: 100%;
  }

  .app-footer {
    flex-direction: column;
  }
}
