:root {
  --primary: #6d28d9;
  --primary-dark: #4c1d95;
  --primary-soft: #f3e8ff;
  --accent: #f59e0b;
  --success: #16a34a;
  --danger: #dc2626;
  --info: #2563eb;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --text: #0f172a;
  --text-light: #64748b;
  --border: #e2e8f0;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Poppins", sans-serif;
}

html,
body {
  min-height: 100%;
  background:
    radial-gradient(circle at top right, rgba(109, 40, 217, 0.12), transparent 24%),
    linear-gradient(180deg, #fcfbff 0%, #f8fafc 100%);
  color: var(--text);
}

body.modal-open {
  overflow: hidden;
}

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

button {
  cursor: pointer;
  border: none;
  outline: none;
  transition: transform 0.18s ease, opacity 0.18s ease, background-color 0.18s ease;
}

button:hover {
  transform: translateY(-1px);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--surface);
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(109, 40, 217, 0.18);
  border-color: rgba(109, 40, 217, 0.45);
}

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

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s ease;
  z-index: 900;
}

.sidebar-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.sidebar {
  width: 240px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 24%),
    linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  z-index: 1000;
  transition: transform 0.24s ease;
}

.logo {
  font-weight: 700;
  font-size: 28px;
  padding: 28px 24px 22px;
  letter-spacing: 0.04em;
}

.menu {
  list-style: none;
  padding: 14px;
  display: grid;
  gap: 8px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: rgba(255, 255, 255, 0.9);
}

.menu-item.active,
.menu-item:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.main {
  min-height: 100vh;
  margin-left: 240px;
  transition: margin-left 0.24s ease;
}

.topbar {
  min-height: 74px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 28px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar h1 {
  font-size: 24px;
  line-height: 1.1;
}

.topbar-subtitle {
  color: var(--text-light);
  font-size: 13px;
  margin-top: 3px;
}

.trip-info {
  margin-left: auto;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-light);
  font-size: 13px;
  white-space: nowrap;
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
}

.content {
  padding: 28px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.page-head h2 {
  font-size: 24px;
}

.page-head p {
  color: var(--text-light);
}

.cards,
.summary-grid,
.info-grid,
.field-grid {
  display: grid;
  gap: 16px;
}

.cards,
.summary-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

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

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

.card,
.panel,
.family-card,
.empty-state {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.card {
  padding: 20px;
}

.card h3 {
  color: var(--text-light);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
}

.card h2 {
  font-size: 28px;
  line-height: 1.1;
}

.panel {
  padding: 24px;
}

.panel-title {
  font-size: 18px;
  margin-bottom: 4px;
}

.panel-subtitle,
.text-muted {
  color: var(--text-light);
}

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

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

.field label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

input[data-mask="currency"],
input[data-mask="phone"] {
  letter-spacing: 0.01em;
}

.family-list {
  display: grid;
  gap: 18px;
}

.family-card {
  overflow: hidden;
}

.family-header,
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.family-header {
  padding: 22px 24px;
  border-bottom: 1px solid var(--border);
}

.family-header h3 {
  font-size: 21px;
}

.family-content {
  padding: 24px;
}

.family-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.metric strong {
  display: block;
  color: var(--text-light);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.metric span {
  font-size: 18px;
  font-weight: 600;
}

.progress-card {
  display: grid;
  gap: 10px;
  padding: 16px 18px;
  background: linear-gradient(135deg, rgba(243, 232, 255, 0.65), rgba(255, 255, 255, 0.95));
  border: 1px solid rgba(109, 40, 217, 0.14);
  border-radius: var(--radius-md);
  margin-top: 18px;
}

.progress-head,
.progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.progress-head strong {
  font-size: 14px;
}

.progress-head span,
.progress-meta {
  color: var(--text-light);
  font-size: 13px;
}

.progress-track {
  width: 100%;
  height: 14px;
  border-radius: 999px;
  background: rgba(109, 40, 217, 0.12);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary) 0%, #8b5cf6 100%);
}

.report-shell {
  gap: 24px;
}

.simulation-shell {
  gap: 24px;
}

.simulation-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 18px;
  align-items: start;
}

.simulation-hero {
  margin-bottom: 0;
}

.simulation-result {
  position: sticky;
  top: 100px;
}

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

.simulation-report-card {
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.simulation-summary {
  display: grid;
  gap: 8px;
  padding: 18px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.simulation-summary p {
  margin: 0;
}

.simulation-alert {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(220, 38, 38, 0.18);
  background: #fef2f2;
  color: #991b1b;
}

.simulation-alert p {
  margin: 0;
}

.print-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 26px;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.35), transparent 28%),
    linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  box-shadow: var(--shadow);
}

.print-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  opacity: 0.74;
  margin-bottom: 10px;
}

.print-hero h3 {
  font-size: 30px;
  line-height: 1.05;
  margin-bottom: 8px;
}

.print-hero .text-muted {
  color: rgba(255, 255, 255, 0.82);
}

.print-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.print-hero .pill {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.toolbar,
.family-actions,
.modal-footer,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.report-switcher {
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 14px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-success {
  background: var(--success);
}

.btn-danger {
  background: var(--danger);
}

.btn-warning {
  background: var(--accent);
}

.btn-ghost {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

.status.pending {
  color: #92400e;
  background: #fef3c7;
}

.status.partial {
  color: #1d4ed8;
  background: #dbeafe;
}

.status.paid {
  color: #166534;
  background: #dcfce7;
}

.empty-state {
  padding: 36px 28px;
  text-align: center;
}

.empty-state h3 {
  margin-bottom: 8px;
}

.list-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
}

.list-table th,
.list-table td {
  padding: 14px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.list-table th {
  color: var(--text-light);
  font-size: 13px;
  font-weight: 600;
}

.list-table tr:last-child td {
  border-bottom: none;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 600;
}

.danger-text {
  color: var(--danger);
}

.success-text {
  color: var(--success);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.58);
  z-index: 2000;
}

.modal {
  width: min(760px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.28);
}

.modal.compact {
  width: min(560px, 100%);
}

.modal-header {
  position: sticky;
  top: 0;
  padding: 22px 24px 18px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  z-index: 2;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  justify-content: flex-end;
  padding: 18px 24px 24px;
  border-top: 1px solid var(--border);
  background: #fff;
}

.icon-button {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--surface-alt);
  color: var(--text);
}

.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 3000;
  display: grid;
  gap: 10px;
}

.toast {
  min-width: 240px;
  max-width: 320px;
  padding: 14px 16px;
  border-radius: 16px;
  color: #fff;
  box-shadow: var(--shadow);
  animation: toast-in 0.24s ease;
}

.toast.info {
  background: var(--info);
}

.toast.success {
  background: var(--success);
}

.toast.error {
  background: var(--danger);
}

.upload-box {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px dashed rgba(109, 40, 217, 0.45);
  border-radius: var(--radius-md);
  background: rgba(243, 232, 255, 0.4);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 920px) {
  .trip-info {
    display: none;
  }

  .field-grid.three {
    grid-template-columns: 1fr;
  }

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

  .simulation-result {
    position: static;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.show {
    transform: translateX(0);
  }

  .main {
    margin-left: 0;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .content,
  .topbar {
    padding-left: 18px;
    padding-right: 18px;
  }

  .content {
    padding-top: 20px;
    padding-bottom: 24px;
  }

  .page-head,
  .family-header,
  .print-hero,
  .progress-head,
  .progress-meta {
    flex-direction: column;
    align-items: flex-start;
  }

  .field-grid.two,
  .field-grid.three {
    grid-template-columns: 1fr;
  }

  .simulation-cards {
    grid-template-columns: 1fr;
  }

  .list-table,
  .list-table thead,
  .list-table tbody,
  .list-table tr,
  .list-table th,
  .list-table td {
    display: block;
    width: 100%;
  }

  .list-table thead {
    display: none;
  }

  .list-table tr {
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
  }

  .list-table td {
    border-bottom: none;
    padding: 6px 0;
  }
}

@media print {
  @page {
    size: A4;
    margin: 12mm;
  }

  html,
  body {
    background: #fff;
  }

  body {
    color: #000;
  }

  .sidebar,
  .sidebar-backdrop,
  .topbar,
  .menu-toggle,
  .toast-container,
  .modal-overlay,
  .page-head .toolbar,
  .report-switcher,
  .simulation-shell .toolbar {
    display: none !important;
  }

  .main {
    margin: 0;
    min-height: auto;
  }

  .content {
    padding: 0;
  }

  .report-shell {
    gap: 14px;
  }

  .print-hero,
  .card,
  .panel,
  .family-card,
  .empty-state {
    color: #000;
    background: #fff;
    border: 1px solid #d1d5db;
    box-shadow: none;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .print-hero {
    padding: 18px;
  }

  .print-hero .text-muted,
  .panel-subtitle,
  .text-muted,
  .progress-head span,
  .progress-meta {
    color: #475569 !important;
  }

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

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

  .simulation-result {
    position: static;
  }

  .progress-card,
  .metric {
    border: 1px solid #e2e8f0;
    background: #fff;
  }

  .progress-track {
    background: #e9d5ff;
  }

  .progress-fill {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .list-table {
    margin-top: 8px;
  }

  .list-table th,
  .list-table td {
    padding: 10px 8px;
    border-color: #d1d5db;
  }
}
