:root {
  --app-ink: #172b4d;
  --app-muted: #718096;
  --app-blue: #3157c8;
  --app-blue-dark: #2445a5;
  --app-border: #e5eaf2;
  --app-surface: #fff;
  --app-canvas: #f4f7fb;
}

body {
  min-height: 100vh;
  color: var(--app-ink);
  background:
    radial-gradient(ellipse at 70% -20%, #e8efff 0, transparent 38rem),
    var(--app-canvas);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

.navbar {
  min-height: 68px;
  position: sticky;
  top: 0;
  z-index: 1020;
  background: linear-gradient(110deg, #203a8f, #3157c8) !important;
  box-shadow: 0 5px 20px #1e34751c !important;
}

.navbar-brand {
  letter-spacing: -.03em;
}

.navbar-brand-mark {
  width: 2rem;
  height: 2rem;
  object-fit: contain;
  box-shadow: 0 3px 10px #152e8055;
}

.app-shell {
  min-height: calc(100vh - 68px);
}

.app-sidebar {
  width: 260px;
  flex: 0 0 260px;
  background: #fff;
  border-right: 1px solid var(--app-border);
  box-shadow: 5px 0 24px #1f3b6808;
}

.app-sidebar .nav-link {
  color: #52627a;
  border-radius: .7rem;
  padding: .72rem .85rem;
  font-size: .94rem;
  font-weight: 550;
  transition: background-color .16s ease, color .16s ease, transform .16s ease;
}

.app-sidebar .nav-link:hover {
  color: var(--app-blue);
  background: #f0f4ff;
  transform: translateX(2px);
}

.app-sidebar .nav-link.active {
  color: var(--app-blue);
  background: #eaf0ff;
  box-shadow: inset 3px 0 var(--app-blue);
}

.app-sidebar > .text-uppercase {
  letter-spacing: .1em;
  font-size: .68rem !important;
}

.app-main {
  min-width: 0;
}

main {
  max-width: 1680px;
  margin: 0 auto;
}

.app-main main {
  min-height: calc(100vh - 145px);
}

.card,
.table-responsive.rounded {
  border: 1px solid var(--app-border) !important;
  border-radius: 1rem !important;
  box-shadow: 0 8px 28px #243b640a;
}

.card {
  background: var(--app-surface);
}

a.card {
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

a.card:hover {
  border-color: #cbd7f6 !important;
  box-shadow: 0 12px 30px #243b6414;
  transform: translateY(-2px);
}

.form-label {
  color: #42526b;
  font-size: .88rem;
  font-weight: 650;
  margin-bottom: .45rem;
}

.form-field {
  min-width: 0;
}

.form-control,
.form-select {
  min-height: 44px;
  border-color: #dce3ed;
  border-radius: .65rem;
  color: var(--app-ink);
  background-color: #fff;
}

.form-control::placeholder {
  color: #9aa7b8;
}

.form-control:focus,
.form-select:focus {
  border-color: #7794ed;
  box-shadow: 0 0 0 .22rem #3157c81a;
}

.form-check-input {
  border-color: #c7d1df;
}

.form-check-input:checked {
  background-color: var(--app-blue);
  border-color: var(--app-blue);
}

.btn {
  border-radius: .65rem;
  font-weight: 600;
  transition: transform .15s ease, box-shadow .15s ease;
}

.btn-primary {
  background: var(--app-blue);
  border-color: var(--app-blue);
}

.btn-primary:hover {
  background: var(--app-blue-dark);
  border-color: var(--app-blue-dark);
  transform: translateY(-1px);
  box-shadow: 0 5px 12px #3157c833;
}

.table {
  --bs-table-color: var(--app-ink);
  --bs-table-border-color: #e8edf4;
  margin-bottom: 0;
}

.table thead th {
  background: #f7f9fc;
  color: #66758c;
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .045em;
  text-transform: uppercase;
}

.table:not(.household-register-table) > :not(caption) > * > * {
  padding: .8rem .85rem;
  vertical-align: middle;
}

.table tbody tr:hover > * {
  --bs-table-bg-state: #f7f9ff;
}

.table-responsive.rounded,
main .table-responsive {
  overflow-x: auto;
  overflow-y: clip;
  background: #fff;
}

.alert {
  border: 1px solid transparent;
  border-radius: .8rem;
  box-shadow: 0 5px 18px #243b640a;
}

footer {
  background: transparent !important;
  border-color: var(--app-border) !important;
}

.household-form {
  padding: clamp(1rem, 2vw, 2rem) !important;
  border: 1px solid var(--app-border) !important;
}

.household-form .form-section {
  padding: clamp(1rem, 2vw, 1.5rem);
  border: 1px solid var(--app-border);
  border-radius: .9rem;
  background: #fff;
}

.household-form .form-section + .form-section {
  margin-top: 1.25rem;
}

.household-form .section-heading {
  display: flex;
  align-items: flex-start;
  gap: .9rem;
  margin-bottom: 1.25rem;
}

.household-form .section-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 2.35rem;
  height: 2.35rem;
  border-radius: .75rem;
  background: #eaf0ff;
  color: var(--app-blue);
  font-weight: 750;
}

.family-member-row {
  border: 1px solid var(--app-border);
  background: #f9faff !important;
  border-radius: .9rem !important;
  padding: 1.1rem !important;
}

.family-member-row + .family-member-row {
  margin-top: .25rem;
}

.family-member-row .form-label {
  font-size: .81rem;
}

.family-member-row .row + .row {
  padding-top: .7rem;
}

.address-field {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--app-border);
  border-radius: .8rem;
  background: #fff;
}

.address-field legend {
  float: none;
  width: auto;
  padding: 0 .25rem;
  margin-bottom: .75rem;
  color: var(--app-ink);
  font-size: .95rem;
  font-weight: 700;
}

.member-additional {
  margin-top: 1rem;
  padding-top: .85rem;
  border-top: 1px solid var(--app-border);
}

.member-additional summary {
  color: var(--app-blue);
  cursor: pointer;
  font-size: .88rem;
  font-weight: 700;
}

.member-additional[open] summary {
  margin-bottom: .4rem;
}

.family-member-row .remove-family-member {
  text-decoration: none;
  font-weight: 650;
}

.family-member-row .remove-family-member:hover {
  color: #b02a37 !important;
}

.household-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  margin: 1.25rem calc(clamp(1rem, 2vw, 2rem) * -1) calc(clamp(1rem, 2vw, 2rem) * -1);
  padding: 1rem clamp(1rem, 2vw, 2rem);
  background: #ffffffed;
  border-top: 1px solid var(--app-border);
  backdrop-filter: blur(12px);
  border-radius: 0 0 1rem 1rem;
}

.household-register-table {
  min-width: 2850px;
  table-layout: fixed;
  font-size: .72rem;
}

.household-register-table th,
.household-register-table td {
  min-width: 78px;
  padding: .3rem;
  vertical-align: middle;
  white-space: normal;
  overflow-wrap: anywhere;
}

.household-register-table thead th {
  min-width: 90px;
  background: #f3f5f7;
  color: #263238;
  font-size: .72rem;
  line-height: 1.25;
  letter-spacing: 0;
  text-align: center;
  text-transform: none;
}

.household-register-table thead tr:first-child th {
  background: #e8ebee;
  font-weight: 750;
}

.household-register-table tbody tr:nth-child(even) {
  background: #fafbfc;
}

.household-register-table .register-cell {
  min-width: 95px;
}

.household-register-table .register-cell:nth-child(2) {
  min-width: 150px;
}

.household-register-table .register-cell:nth-child(3),
.household-register-table .register-cell:nth-child(5) {
  min-width: 78px;
}

.household-register-table .register-input {
  min-width: 88px;
  min-height: 34px;
  padding: .2rem .35rem;
  border-radius: .3rem;
  font-size: .73rem;
}

.household-register-table .register-checkbox {
  display: block;
  margin: auto;
}

.household-register-table .register-row-actions {
  width: 260px;
  min-width: 260px;
}

.household-register-table td.register-row-actions {
  white-space: nowrap;
}

.register-serial {
  display: inline-block;
  min-width: 1.5rem;
  text-align: center;
}

.register-entry-form .household-register-table {
  min-width: 3200px;
}

.register-table-wrap {
  max-height: none;
}

.register-record-card {
  overflow: hidden;
  border-radius: .9rem !important;
}

.register-record-heading {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--app-border);
  background: #f8faff;
}

.register-record-heading h2 {
  color: var(--app-ink);
  font-weight: 700;
}

.register-form-section {
  padding: 1.25rem;
}

.register-form-section + .register-form-section {
  border-top: 1px solid var(--app-border);
}

.register-section-title {
  margin: 0 0 1rem;
  color: var(--app-blue);
  font-size: 1rem;
  font-weight: 700;
}

.register-occupation-option {
  display: flex;
  align-items: center;
  gap: .6rem;
  min-height: 44px;
  padding: .55rem .75rem;
  border: 1px solid var(--app-border);
  border-radius: .65rem;
  background: #fff;
  cursor: pointer;
}

.register-occupation-option .form-check-input {
  margin: 0;
}

.navbar-user-link {
  color: #fff;
  text-decoration: none;
}

.navbar-user-link:hover {
  color: #fff;
  opacity: .86;
}

.navbar-user-name {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.navbar-signout {
  color: #fff;
  border-color: #ffffff88;
  white-space: nowrap;
}

.navbar-signout:hover {
  color: var(--app-blue);
  background: #fff;
  border-color: #fff;
}

.auth-page {
  min-height: calc(100vh - 150px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 2rem;
  padding-bottom: 2rem;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  overflow: hidden;
  border: 1px solid var(--app-border) !important;
  border-radius: 1.25rem !important;
  box-shadow: 0 18px 55px #20375d14 !important;
}

.auth-card-wide {
  max-width: 420px;
}

.auth-card-community {
  max-width: 380px;
}

.auth-card-portal {
  max-width: 1280px;
}

.portal-login-title {
  font-size: clamp(.75rem, 4vw, 1.375rem);
  line-height: 1.35;
  text-align: center;
  overflow-wrap: anywhere;
}

.portal-description {
  padding: 1rem 1.25rem;
  border: 1px solid var(--app-border);
  border-radius: .75rem;
  background: #f7f9fc;
  line-height: 1.8;
}

.portal-founder-column,
.portal-entry-column {
  min-width: 0;
}

.portal-entry-column {
  min-width: 0;
}

.portal-entry-panel {
  padding: .85rem;
  border: 1px solid var(--app-border);
  border-color: #bdcbe0;
  border-radius: .65rem;
  background: #f7f9fd;
  box-shadow: 0 3px 12px #20375d0b;
}

.portal-login-layout {
  align-items: start !important;
}

.portal-founder-heading {
  padding-bottom: .65rem;
  border-bottom: 1px solid var(--app-border);
}

.portal-founder-card {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-height: 112px;
  padding: .65rem;
  border: 1px solid var(--app-border);
  border-radius: .75rem;
  background: #fff;
}

.portal-founder-photo {
  width: 82px;
  height: 96px;
  flex: 0 0 82px;
  border-radius: .5rem;
  object-fit: cover;
  background: #eef2f8;
}

.portal-founder-photo-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--app-muted);
  font-size: .75rem;
}

.portal-founder-name {
  font-weight: 650;
  overflow-wrap: anywhere;
}

.portal-founder-phone {
  display: inline-block;
  margin-top: .2rem;
  color: var(--app-blue);
  font-size: .9rem;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.portal-founder-phone:hover {
  text-decoration: underline;
}

.portal-founder-preview {
  width: 100px;
  height: 120px;
  border-radius: .5rem;
  object-fit: cover;
}

@media (min-width: 576px) {
  .auth-card-portal .portal-login-title {
    white-space: nowrap;
  }
}

@media (max-width: 575.98px) {
  .page-login .auth-page-ekata {
    align-items: flex-start;
  }

  .auth-card-portal .auth-content {
    padding: 1rem;
  }

  .portal-description {
    padding: .75rem;
    margin-bottom: 1rem !important;
    font-size: .95rem;
  }

  .portal-founder-card {
    min-height: 96px;
  }

  .portal-founder-photo {
    width: 68px;
    height: 80px;
    flex-basis: 68px;
  }
}

.auth-mark {
  width: 3rem;
  height: 3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: .9rem;
  background: #eaf0ff;
  color: var(--app-blue);
  font-size: 1.2rem;
  font-weight: 800;
}

img.auth-mark {
  object-fit: contain;
  background: #fff;
  padding: .2rem;
}

.auth-content {
  padding: clamp(1.75rem, 5vw, 2.5rem);
}

.auth-kicker {
  color: var(--app-blue);
  font-size: .73rem;
  font-weight: 750;
  letter-spacing: .11em;
  text-transform: uppercase;
}

.auth-form .form-field {
  margin-bottom: .25rem;
}

.auth-submit {
  min-height: 48px;
}

.page-login main {
  padding: 0 !important;
}

.page-login footer {
  display: none;
}

.page-login .auth-page {
  min-height: 100vh;
  padding: 1rem;
}

.page-login .auth-content {
  padding: 1.25rem;
}

.page-login .auth-mark.mb-4 {
  width: 2.5rem;
  height: 2.5rem;
  margin-bottom: .75rem !important;
}

.page-login .auth-form {
  --bs-gutter-y: .5rem;
}

.page-login .form-label {
  margin-bottom: .25rem;
}

.page-login .auth-submit {
  min-height: 42px;
}

.page-login .auth-content > .text-secondary.mb-4 {
  margin-bottom: .75rem !important;
}

.page-login .auth-content > .small.mt-4 {
  margin-top: .75rem !important;
}

.page-login hr.my-4 {
  margin: .75rem 0 !important;
}

.page-heading {
  padding: .25rem 0 1rem;
  margin-bottom: 1.75rem !important;
  border-bottom: 1px solid #dfe6f0;
}

.page-heading h1 {
  color: var(--app-ink);
  font-weight: 750;
  letter-spacing: -.035em;
}

.page-heading p {
  color: var(--app-muted) !important;
}

.dashboard-filters {
  border-top: 3px solid var(--app-blue) !important;
}

.compact-filter-panel {
  padding: .75rem !important;
}

.compact-filters {
  --bs-gutter-x: .75rem;
  --bs-gutter-y: .5rem;
}

.compact-filters .form-label {
  margin-bottom: .25rem;
  font-size: .78rem;
}

.compact-filters .form-control,
.compact-filters .form-select {
  min-height: 36px;
  padding: .35rem .6rem;
  border-radius: .5rem;
  font-size: .85rem;
}

.compact-filters .btn {
  min-height: 36px;
  padding: .35rem .7rem;
  font-size: .85rem;
}

.dashboard-chart {
  display: grid;
  gap: .85rem;
  width: 100%;
}

.dashboard-chart-row {
  display: grid;
  grid-template-columns: minmax(5rem, 7rem) minmax(0, 1fr) 2.5rem;
  align-items: center;
  gap: .75rem;
}

.dashboard-chart-label {
  overflow: hidden;
  color: #52627a;
  font-size: .84rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-chart-track {
  display: block;
  height: .7rem;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f7;
}

.dashboard-chart-bar {
  display: block;
  height: 100%;
  min-width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #3157c8, #6885e3);
  transition: width .25s ease;
}

.dashboard-chart-bar-alt {
  background: linear-gradient(90deg, #159477, #54c3a2);
}

.dashboard-chart-value {
  color: var(--app-ink);
  font-size: .84rem;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

@media (min-width: 992px) {
  .app-sidebar {
    position: sticky;
    top: 68px;
    align-self: flex-start;
    height: calc(100vh - 68px);
    overflow-y: auto;
  }

  .app-main {
    width: calc(100% - 260px);
  }
}

@media (max-width: 991.98px) {
  .app-sidebar {
    width: 100%;
    flex-basis: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--app-border);
    box-shadow: 0 8px 20px #243b640a;
  }

  .app-sidebar.collapse:not(.show) {
    display: none;
  }

  .app-main main,
  main.container-fluid {
    padding-top: 1.5rem !important;
    padding-bottom: 1.5rem !important;
  }
}

@media (max-width: 575.98px) {
  .navbar-brand {
    max-width: 55vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .navbar-brand-mark {
    flex: 0 0 2rem;
  }

  .app-sidebar {
    padding: 1rem !important;
  }

  .page-heading {
    margin-bottom: 1.25rem !important;
  }

  .page-heading h1 {
    font-size: 1.45rem;
  }

  .table > :not(caption) > * > * {
    padding: .65rem;
  }

  .dashboard-chart-row {
    grid-template-columns: minmax(4rem, 5.5rem) minmax(0, 1fr) 2rem;
    gap: .5rem;
  }
}

@media (max-width: 400px) {
  .navbar > .container-fluid {
    flex-wrap: nowrap;
    gap: .35rem;
  }

  .navbar-brand {
    max-width: 29vw;
    flex: 0 1 auto;
  }

  .navbar > .container-fluid > .d-flex {
    flex: 0 0 auto;
    gap: .35rem !important;
  }

  .register-entry-form .row.g-3 > .col-6 {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}

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

  html,
  body {
    width: 100%;
    margin: 0 !important;
    background: #fff !important;
    color: #000 !important;
  }

  .navbar,
  .app-sidebar,
  footer,
  .register-toolbar-actions,
  .register-row-actions,
  .report-filter-controls,
  .report-actions,
  .alert {
    display: none !important;
  }

  .app-shell,
  .app-main,
  .app-main main {
    display: block !important;
    width: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  main {
    max-width: none !important;
  }

  body.page-reports {
    font-size: 10pt;
  }

  body.page-reports .card {
    box-shadow: none !important;
    border-color: #999 !important;
  }

  body.page-reports details {
    display: block !important;
    border-color: #999 !important;
  }

  body.page-reports details > :not(summary) {
    display: block !important;
  }

  body.page-reports details summary {
    display: none !important;
  }

  body.page-reports .table-responsive {
    overflow: visible !important;
  }

  body.page-reports .table thead {
    display: table-header-group;
  }

  .register-table-wrap {
    max-height: none !important;
    overflow: visible !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }

  .household-register-table,
  .register-entry-form .household-register-table {
    width: 100% !important;
    min-width: 0 !important;
    table-layout: auto !important;
    border-collapse: collapse !important;
    font-size: 5pt !important;
  }

  .household-register-table thead {
    display: table-header-group;
  }

  .household-register-table tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .household-register-table th,
  .household-register-table td {
    min-width: 0 !important;
    padding: 1px 2px !important;
    border: 1px solid #555 !important;
    color: #000 !important;
    background: #fff !important;
    font-size: 5pt !important;
    line-height: 1.15 !important;
    overflow-wrap: anywhere !important;
  }

  .household-register-table .register-input {
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    color: #000 !important;
    font-size: 5pt !important;
    box-shadow: none !important;
  }

  .household-register-table .register-checkbox {
    appearance: checkbox !important;
  }

  .household-register-table .register-cell:nth-child(2) {
    min-width: 0 !important;
  }

  .page-heading {
    margin: 0 0 3mm !important;
    padding: 0 !important;
    border: 0 !important;
  }

  .page-heading h1 {
    margin: 0 !important;
    font-size: 12pt !important;
  }

  .page-heading p {
    margin: 0 !important;
    font-size: 7pt !important;
  }
}
