:root {
  --background: #f3f6fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-dark: #0f172a;
  --surface-dark-2: #172033;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #dbeafe;
  --success: #15803d;
  --success-soft: #dcfce7;
  --warning: #b45309;
  --warning-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --text: #172033;
  --text-muted: #64748b;
  --border: #dbe3ef;
  --shadow: 0 12px 35px rgba(15, 23, 42, 0.08);
  --shadow-small: 0 4px 14px rgba(15, 23, 42, 0.07);
  --radius-large: 22px;
  --radius-medium: 16px;
  --radius-small: 11px;
  --sidebar-width: 270px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--text);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
}

h2 {
  margin-bottom: 5px;
  font-size: 1.35rem;
  line-height: 1.25;
}

h3 {
  margin-bottom: 4px;
  font-size: 1.02rem;
}

small {
  color: var(--text-muted);
}

.noscript-message {
  padding: 12px 16px;
  background: var(--danger);
  color: white;
  text-align: center;
  font-weight: 700;
}

.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;
}

.app-shell {
  min-height: 100vh;
}

/* Sidebar */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  overflow-y: auto;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.24), transparent 36%),
    var(--surface-dark);
  color: white;
  box-shadow: 10px 0 35px rgba(15, 23, 42, 0.18);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 20px 18px;
}

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

.brand strong,
.mobile-brand {
  font-size: 1.05rem;
}

.brand small {
  display: block;
  margin-top: 1px;
  color: #a9b7cf;
}

.brand-mark {
  display: inline-flex;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 13px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: white;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35);
}

.sidebar-nav {
  display: grid;
  gap: 6px;
  padding: 10px 14px 24px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 14px;
  border-radius: 12px;
  color: #cbd5e1;
  text-decoration: none;
  font-weight: 650;
  transition:
    background 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: white;
  transform: translateX(2px);
}

.nav-link.active {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.9), rgba(37, 99, 235, 0.72));
  color: white;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.22);
}

.nav-link span:first-child {
  width: 25px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding: 18px 20px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.sidebar-footer p {
  margin-bottom: 2px;
  color: #dbe7f7;
  font-size: 0.9rem;
}

.sidebar-footer small {
  color: #8292aa;
}

.sidebar-close-button {
  display: none;
  color: white;
}

/* Main area */

.main-content {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
  padding: 34px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 28px;
}

.page-subtitle,
.panel-header p {
  margin-bottom: 0;
  color: var(--text-muted);
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--primary);
  font-size: 0.77rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

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

/* Buttons */

.button,
.icon-button,
.text-button,
.quick-action-card {
  border: 0;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 17px;
  border-radius: 11px;
  font-weight: 750;
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease;
}

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

.button-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 7px 18px rgba(37, 99, 235, 0.22);
}

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

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

.button-small {
  min-height: 38px;
  padding: 8px 13px;
  font-size: 0.88rem;
}

.icon-button {
  display: inline-flex;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: white;
  color: var(--text);
  font-size: 1.4rem;
}

.text-button {
  padding: 5px 0;
  background: transparent;
  color: var(--primary);
  font-weight: 750;
}

/* Mobile header */

.mobile-header {
  display: none;
}

/* App sections */

.app-section {
  display: none;
}

.app-section.active {
  display: block;
}

/* Summary cards */

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

.summary-card {
  min-width: 0;
  padding: 20px;
  border: 1px solid rgba(219, 227, 239, 0.85);
  border-radius: var(--radius-medium);
  background: var(--surface);
  box-shadow: var(--shadow-small);
}

.summary-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.summary-label {
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.summary-icon {
  display: inline-flex;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  background: var(--primary-soft);
  font-size: 1.15rem;
}

.summary-value {
  display: block;
  margin: 12px 0 4px;
  font-size: clamp(1.45rem, 2.6vw, 2rem);
  line-height: 1;
  letter-spacing: -0.03em;
}

/* Panels */

.panel {
  margin-bottom: 22px;
  padding: 22px;
  border: 1px solid rgba(219, 227, 239, 0.9);
  border-radius: var(--radius-large);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

/* Quick actions */

.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px;
}

.quick-action-card {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  gap: 13px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
  color: var(--text);
  text-align: left;
  transition:
    border-color 150ms ease,
    background 150ms ease,
    transform 150ms ease,
    box-shadow 150ms ease;
}

.quick-action-card:hover {
  transform: translateY(-2px);
  border-color: #9dbcf8;
  background: white;
  box-shadow: var(--shadow-small);
}

.quick-action-icon {
  display: inline-flex;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 12px;
  background: var(--primary-soft);
  font-size: 1.2rem;
}

.quick-action-card strong {
  display: block;
  margin-bottom: 2px;
}

.quick-action-card small {
  display: block;
  line-height: 1.35;
}

/* Dashboard columns */

.dashboard-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(320px, 0.82fr);
  gap: 22px;
}

/* Debt cards */

.debt-list {
  display: grid;
  gap: 15px;
}

.debt-item {
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface-soft);
}

.debt-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.debt-item-header h3 {
  font-size: 1.08rem;
}

.debt-item-header p {
  margin-bottom: 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-unpaid {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-partial {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-paid {
  background: var(--success-soft);
  color: var(--success);
}

.debt-progress-track {
  height: 9px;
  margin: 15px 0;
  overflow: hidden;
  border-radius: 999px;
  background: #e6edf6;
}

.debt-progress-bar {
  height: 100%;
  max-width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #60a5fa);
}

.debt-item-details {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-bottom: 14px;
}

.debt-item-details span {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.debt-item-details strong {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: 0.96rem;
}

/* Timeline */

.timeline {
  display: grid;
  gap: 12px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}

.timeline-item:last-child {
  border-bottom: 0;
}

.timeline-date {
  display: flex;
  width: 54px;
  min-height: 54px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 13px;
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.timeline-date strong {
  font-size: 1.08rem;
  line-height: 1;
}

.timeline-date span {
  margin-top: 4px;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.timeline-content h3 {
  margin-bottom: 2px;
  font-size: 0.96rem;
}

.timeline-content p {
  margin-bottom: 0;
  color: var(--text-muted);
  font-size: 0.83rem;
}

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

/* Budget snapshot */

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

.budget-item {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-soft);
}

.budget-item span,
.budget-item small {
  display: block;
}

.budget-item span {
  font-weight: 750;
}

.budget-item strong {
  flex: 0 0 auto;
}

/* Empty placeholders */

.empty-section {
  min-height: 380px;
  padding: 54px 28px;
  border: 1px dashed #b9c7d9;
  border-radius: var(--radius-large);
  background: rgba(255, 255, 255, 0.68);
  text-align: center;
}

.empty-section > span {
  display: block;
  margin-bottom: 14px;
  font-size: 2.6rem;
}

.empty-section h2 {
  font-size: 1.8rem;
}

.empty-section p {
  max-width: 580px;
  margin: 8px auto 0;
  color: var(--text-muted);
}

/* Modal */

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(680px, 100%);
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  border-radius: 22px;
  background: white;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.35);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 22px 12px;
}

.modal-body {
  padding: 8px 22px 24px;
}

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

/* Overlay */

.sidebar-overlay {
  display: none;
}

/* Responsive */

@media (max-width: 1180px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

@media (max-width: 900px) {
  body.sidebar-open {
    overflow: hidden;
  }

  .mobile-header {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    height: 66px;
    align-items: center;
    justify-content: space-between;
    padding:
      max(10px, env(safe-area-inset-top))
      14px
      10px;
    background: rgba(15, 23, 42, 0.97);
    color: white;
    backdrop-filter: blur(12px);
  }

  .mobile-header .icon-button {
    border-color: rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.08);
    color: white;
  }

  .mobile-brand .brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }

  .sidebar {
    width: min(86vw, 310px);
    transform: translateX(-105%);
    transition: transform 210ms ease;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-close-button {
    display: inline-flex;
    border-color: rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.06);
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(15, 23, 42, 0.56);
    backdrop-filter: blur(2px);
  }

  body.sidebar-open .sidebar-overlay {
    display: block;
  }

  .main-content {
    margin-left: 0;
    padding: 24px 18px 34px;
  }

  .page-header {
    align-items: stretch;
  }

  .page-header-actions {
    display: none;
  }

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

@media (max-width: 620px) {
  .main-content {
    padding: 20px 13px 30px;
  }

  h1 {
    font-size: 2.1rem;
  }

  .page-header {
    margin-bottom: 21px;
  }

  .summary-grid,
  .quick-actions-grid,
  .budget-grid,
  .modal-actions {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    gap: 12px;
  }

  .summary-card,
  .panel {
    border-radius: 16px;
  }

  .panel {
    padding: 17px;
  }

  .panel-header {
    align-items: flex-start;
  }

  .quick-action-card {
    padding: 14px;
  }

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

  .timeline-item {
    grid-template-columns: 54px minmax(0, 1fr);
    align-items: start;
  }

  .timeline-amount {
    grid-column: 2;
    margin-top: -5px;
  }

  .budget-item {
    padding: 13px;
  }
}

@media (max-width: 390px) {
  .mobile-brand > span:last-child {
    display: none;
  }

  .panel-header {
    flex-direction: column;
    gap: 7px;
  }

  .debt-item-header {
    flex-direction: column;
    gap: 7px;
  }

  .debt-item-details {
    grid-template-columns: 1fr 1fr;
  }
}

/* Credit card payment form */

.payment-modal-card {
  width: min(720px, 100%);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

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

.form-field-full {
  grid-column: 1 / -1;
}

.form-field > span {
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 750;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-soft);
  color: var(--text);
  outline: none;
  padding: 11px 13px;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease;
}

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

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.form-field input::placeholder,
.form-field textarea::placeholder {
  color: #94a3b8;
}

.form-message {
  min-height: 24px;
  margin: 16px 0 0;
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 700;
}

.form-message.success {
  color: var(--success);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px 22px;
  border-top: 1px solid var(--border);
}

body.modal-open {
  overflow: hidden;
}

@media (max-width: 620px) {
  .modal {
    align-items: end;
    padding: 10px;
  }

  .payment-modal-card {
    width: 100%;
    max-height: calc(100vh - 20px);
    border-radius: 20px 20px 14px 14px;
  }

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

  .form-field-full {
    grid-column: auto;
  }

  .modal-footer {
    position: sticky;
    bottom: 0;
    background: white;
  }

  .modal-footer .button {
    flex: 1;
  }
}

