:root {
  --bg-main: #f3efe8;
  --bg-card: rgba(255, 255, 255, 0.84);
  --bg-card-strong: rgba(255, 255, 255, 0.94);
  --border-soft: rgba(15, 23, 42, 0.08);
  --ink: #152033;
  --ink-soft: #51607a;
  --brand: #d86c5a;
  --brand-dark: #a74b40;
  --navy: #0f172a;
  --navy-soft: #1f2b3e;
  --mint: #dce9df;
  --sand: #f7f2ec;
}

html {
  font-size: 16px;
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(216, 108, 90, 0.22), transparent 28%),
    radial-gradient(circle at top right, rgba(15, 23, 42, 0.12), transparent 26%),
    linear-gradient(180deg, #fcfaf7 0%, var(--bg-main) 100%);
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
}

img {
  max-width: 100%;
  height: auto;
}

.logo {
  height: 44px;
  filter: invert(1);
  margin: 2px 0;
}

a {
  color: inherit;
}

.topbar .navbar-nav .nav-link,
.topbar-link,
.topbar .navbar-nav .nav-link:visited {
  color: rgba(248, 250, 252, 0.94) !important;
  font-weight: 500;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.24);
}

.topbar .navbar-nav .nav-link:hover,
.topbar .navbar-nav .nav-link:focus,
.topbar-link:hover,
.topbar-link:focus {
  color: #ffffff !important;
}

.topbar .navbar-nav .nav-link:hover,
.topbar .navbar-nav .nav-link:focus,
.topbar-link:hover,
.topbar-link:focus {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
}

.topbar .navbar-nav .nav-link.active,
.topbar-link.active {
  color: #ffffff !important;
  background: rgba(216, 108, 90, 0.18);
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(216, 108, 90, 0.32);
}

.topbar {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.96) 0%, rgba(30, 41, 59, 0.96) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.18);
}

.topbar-nav {
  padding: 0.65rem 0;
}

.topbar-inner {
  gap: 1rem;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.topbar-nav-groups {
  display: flex;
  align-items: stretch;
  gap: 1.15rem;
  min-width: 0;
}

.topbar-nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.25rem 1.15rem 0.25rem 0;
  min-width: 0;
  position: relative;
}

.topbar-nav-group:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 0.25rem;
  right: 0;
  width: 1px;
  height: calc(100% - 0.5rem);
  background: rgba(255, 255, 255, 0.08);
}

.topbar-nav-label {
  color: rgba(226, 232, 240, 0.5);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding-left: 0.9rem;
}

.topbar-nav-list {
  display: flex;
  flex-direction: row;
  gap: 0.15rem;
  flex-wrap: wrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

.topbar-dashboard-link {
  padding-inline: 0.95rem;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(248, 250, 252, 0.94);
  font-weight: 600;
}

.navbar-toggler {
  border-color: rgba(255, 255, 255, 0.18);
}

.navbar-toggler-icon {
  filter: invert(1);
}

.page-shell {
  padding-top: 2rem;
  padding-bottom: 3rem;
  max-width: 1380px;
}

.btn-brand {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  border: none;
  color: #fff;
}

.btn-brand:hover,
.btn-brand:focus {
  color: #fff;
  background: linear-gradient(135deg, #cf614f 0%, #944238 100%);
}

.form-control {
  border-radius: 1rem;
  border-color: rgba(15, 23, 42, 0.12);
  padding: 0.9rem 1rem;
}

.form-select {
  border-radius: 1rem;
  border-color: rgba(15, 23, 42, 0.12);
  padding: 0.9rem 2.5rem 0.9rem 1rem;
}

.form-control:focus,
.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus {
  box-shadow: 0 0 0 0.25rem rgba(216, 108, 90, 0.16);
  border-color: rgba(216, 108, 90, 0.46);
}

.auth-shell {
  min-height: calc(100vh - 220px);
  display: grid;
  place-items: center;
}

.auth-page {
  position: relative;
}

.auth-page-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
  padding: 1.25rem 1.5rem 0;
}

.auth-page-logo {
  width: 88px;
  max-width: 88px;
  height: auto;
  display: block;
}

.auth-page-copy {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.auth-page-copy strong {
  font-size: 1rem;
}

.auth-page-copy span {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.auth-panel {
  width: min(100%, 540px);
  padding: 2.5rem;
  border: 1px solid var(--border-soft);
  border-radius: 2rem;
  background: var(--bg-card);
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.12);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.auth-logo {
  width: 64px;
  max-width: 64px;
  max-height: 64px;
  height: auto;
  object-fit: contain;
  display: block;
}

.auth-badge,
.section-kicker {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 0.8rem;
  border-radius: 999px;
  background: rgba(216, 108, 90, 0.12);
  color: var(--brand-dark);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-title,
.dashboard-hero h1,
.page-header h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 0.98;
  margin-bottom: 0.85rem;
}

.auth-subtitle,
.dashboard-hero p,
.page-header p,
.module-copy,
.status-panel li,
.hero-meta {
  color: var(--ink-soft);
}

.dashboard-hero,
.page-header,
.status-panel,
.table-shell {
  border: 1px solid var(--border-soft);
  border-radius: 1.75rem;
  background: var(--bg-card-strong);
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.08);
}

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(360px, 0.9fr);
  gap: 1.25rem;
  padding: 1.75rem;
}

.dashboard-hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.dashboard-hero-side {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.9rem;
}

.hero-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.4rem;
  padding: 1.25rem 1.35rem;
  border-radius: 1.35rem;
  background: linear-gradient(135deg, var(--navy) 0%, #24334a 100%);
  color: #fff;
}

.hero-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
  opacity: 0.75;
}

.hero-value {
  font-size: 1.55rem;
  font-weight: 700;
}

.hero-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0;
}

.hero-summary div {
  padding: 1rem 1.1rem;
  border-radius: 1.15rem;
  background: var(--sand);
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.hero-summary dt {
  margin-bottom: 0.35rem;
  color: var(--ink-soft);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.hero-summary dd {
  margin: 0;
  color: var(--navy);
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1;
}

.dashboard-section {
  margin-top: 1.5rem;
}

.dashboard-section-heading {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 1rem;
}

.dashboard-section-heading h2 {
  margin: 0;
  font-size: 1.45rem;
}

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

.module-grid-primary .module-card {
  grid-column: span 4;
}

.module-grid-secondary .module-card {
  grid-column: span 6;
}

.module-card {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-height: 182px;
  padding: 1.5rem;
  border: 1px solid var(--border-soft);
  border-radius: 1.35rem;
  background: rgba(255, 255, 255, 0.74);
  text-decoration: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.module-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.1);
  border-color: rgba(216, 108, 90, 0.2);
  background: rgba(255, 255, 255, 0.9);
}

.module-card-muted {
  opacity: 0.8;
}

.module-title {
  font-size: 1.2rem;
  font-weight: 700;
}

.module-metric {
  margin-top: auto;
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--navy);
}

.module-meta {
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.module-detail {
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.status-panel,
.page-header,
.table-shell {
  margin-top: 1.5rem;
  padding: 1.5rem;
}

.page-header + .form-shell,
.page-header + .table-shell,
.page-header + .detail-card,
.page-header + .details-grid {
  margin-top: 1.1rem;
}

.status-panel ul {
  margin: 0;
  padding-left: 1.1rem;
}

.page-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.78);
}

.page-header-row {
  display: flex;
  flex-direction: column;
}

.page-header-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.alert-soft {
  margin-top: 1.5rem;
  border-radius: 1rem;
  border-color: rgba(22, 163, 74, 0.18);
  background: rgba(34, 197, 94, 0.08);
  color: #14532d;
}

.table-actions {
  display: inline-flex;
  gap: 0.5rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  align-items: end;
}

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

.list-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.form-shell,
.detail-card {
  border: 1px solid var(--border-soft);
  border-radius: 1.75rem;
  background: var(--bg-card-strong);
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.08);
}

.form-shell {
  margin-top: 1.5rem;
  padding: 1.75rem;
}

.user-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.address-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

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

.form-grid-span {
  grid-column: 1 / -1;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 52px;
  padding: 0 0.25rem;
}

.checkbox-row .form-check-input {
  margin-top: 0;
}

.form-actions,
.detail-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.detail-actions + .detail-actions {
  margin-top: 1rem;
}

.detail-actions-danger {
  padding-top: 1rem;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.details-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.8fr);
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.detail-card {
  padding: 1.75rem;
}

.detail-card h2 {
  margin-bottom: 0.25rem;
}

.detail-card-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}

.detail-card-header p {
  color: var(--ink-soft);
  margin-bottom: 0;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
  margin: 0 0 1.25rem;
}

.summary-strip div {
  padding: 0.95rem 1rem;
  border-radius: 1rem;
  background: rgba(247, 242, 236, 0.82);
  border: 1px solid rgba(15, 23, 42, 0.05);
}

.summary-strip dt {
  margin-bottom: 0.3rem;
  color: var(--ink-soft);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.summary-strip dd {
  margin: 0;
  color: var(--navy);
  font-size: 1.25rem;
  font-weight: 800;
}

.detail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin: 0;
}

.detail-list div {
  padding: 1rem 1.1rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.detail-list-span {
  grid-column: 1 / -1;
}

.detail-list dt {
  margin-bottom: 0.35rem;
  color: var(--ink-soft);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.detail-list dd {
  margin: 0;
  font-weight: 600;
}

.compact-card {
  margin-top: 1.5rem;
  padding: 1.25rem 1.5rem;
}

.calculation-definitions-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-top: 1.5rem;
}

.definition-stack {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.definition-step-card {
  padding: 1.5rem;
}

.definition-step-header {
  display: flex;
  justify-content: space-between;
  gap: 1.25rem;
  align-items: flex-start;
  margin-bottom: 1.25rem;
}

.definition-step-copy {
  min-width: 0;
}

.definition-step-topline {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.65rem;
}

.definition-step-kicker {
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.definition-step-actions,
.definition-field-actions {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.definition-system-name {
  color: var(--ink-soft);
  margin: 0;
  font-size: 0.95rem;
  word-break: break-word;
}

.definition-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.definition-field-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.1rem 1.15rem;
  border-radius: 1.2rem;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.68);
}

.definition-field-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.definition-field-head h3 {
  margin: 0 0 0.2rem;
  font-size: 1.05rem;
}

.definition-field-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0;
}

.definition-field-meta div,
.definition-empty {
  padding: 0.85rem 0.95rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.definition-field-meta dt {
  margin-bottom: 0.35rem;
  color: var(--ink-soft);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.definition-field-meta dd {
  margin: 0;
  font-weight: 600;
}

.pager-shell {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

.pager-current {
  color: var(--ink-soft);
  font-weight: 600;
}

.card-hint {
  margin-bottom: 1rem;
  color: var(--ink-soft);
}

.service-cost-summary-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.service-cost-summary-card {
  padding: 1.5rem;
}

.service-cost-type-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.service-cost-type-card {
  padding: 1rem 1.1rem;
  border-radius: 1.1rem;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.service-cost-type-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 0.85rem;
}

.service-cost-type-head h3 {
  margin: 0;
  font-size: 1.05rem;
}

.service-cost-type-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0;
}

.service-cost-type-metrics div {
  padding: 0.8rem 0.9rem;
  border-radius: 0.95rem;
  background: rgba(247, 242, 236, 0.82);
}

.service-cost-type-metrics dt {
  margin-bottom: 0.3rem;
  color: var(--ink-soft);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.service-cost-type-metrics dd {
  margin: 0;
  font-weight: 700;
}

.table-user {
  display: flex;
  flex-direction: column;
}

.table-user span {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.subscription-id-cell {
  max-width: 180px;
}

.subscription-card {
  margin-top: 1.5rem;
}

.table-shell {
  overflow: hidden;
  background: rgba(255, 255, 255, 0.9);
}

.table {
  margin-bottom: 0;
}

.table > :not(caption) > * > * {
  padding: 1rem 0.85rem;
  vertical-align: middle;
}

.table tbody tr + tr td {
  border-top-color: rgba(15, 23, 42, 0.08);
}

.table thead th {
  color: var(--ink-soft);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(247, 242, 236, 0.82);
  border-bottom-color: rgba(15, 23, 42, 0.08);
}

.table-pill,
.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 0.75rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.table-pill {
  background: rgba(15, 23, 42, 0.08);
}

.status-active {
  background: rgba(34, 197, 94, 0.14);
  color: #166534;
}

.status-inactive {
  background: rgba(148, 163, 184, 0.18);
  color: #475569;
}

.footer {
  padding: 1.5rem 0 2rem;
  color: var(--ink-soft);
}

.footer .container {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.92rem;
}

@media (max-width: 991px) {
  .dashboard-hero,
  .module-grid,
  .details-grid,
  .detail-list,
  .summary-strip,
  .form-grid,
  .filter-grid,
  .definition-field-grid,
  .definition-field-meta,
  .service-cost-type-grid,
  .service-cost-type-metrics {
    grid-template-columns: 1fr;
  }

  .page-header,
  .calculation-definitions-toolbar,
  .definition-step-header,
  .definition-field-head {
    flex-direction: column;
  }

  .page-header-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .list-meta,
  .pager-shell {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-nav-groups,
  .topbar-nav-list,
  .topbar-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-nav-group {
    padding: 0.75rem 0 0;
  }

  .topbar-nav-group:not(:last-child)::after {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 1px;
  }

  .topbar-nav-label {
    padding-left: 0;
  }

  .topbar .navbar-collapse {
    margin-top: 1rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }

  .topbar-dashboard-link,
  .user-chip,
  .topbar-actions form .btn {
    width: 100%;
    justify-content: center;
  }

  .module-grid-primary .module-card,
  .module-grid-secondary .module-card {
    grid-column: span 12;
  }
}

@media (max-width: 640px) {
  .auth-panel,
  .dashboard-hero,
  .page-header,
  .status-panel,
  .table-shell,
  .form-shell,
  .detail-card {
    padding: 1.2rem;
    border-radius: 1.25rem;
  }

  .auth-page-brand {
    padding: 1rem 1rem 0;
  }

  .auth-page-logo {
    width: 72px;
    max-width: 72px;
  }

  .definition-step-card {
    padding: 1.2rem;
  }

  .hero-summary {
    grid-template-columns: 1fr;
  }

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