* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

main {
  overflow-x: clip;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

.app-bg {
  background-color: var(--bg);
  background-image:
    linear-gradient(135deg, rgba(31, 111, 235, 0.06), transparent 26%),
    linear-gradient(225deg, rgba(14, 169, 114, 0.05), transparent 32%),
    linear-gradient(145deg, var(--bg), var(--bg-2));
}

a {
  color: inherit;
}

a,
button,
input,
select,
textarea {
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

input,
select,
textarea,
button {
  max-width: 100%;
  min-width: 0;
}

[class*="grid"] > *,
[class*="flex"] > * {
  min-width: 0;
}

[data-theme] .bg-white,
[data-theme] .bg-white\/80,
[data-theme] .dark\:bg-slate-900\/70 {
  background-color: var(--card-bg) !important;
}

[data-theme] [class*="border-slate-"] {
  border-color: var(--card-border) !important;
}

[data-theme] .text-slate-900,
[data-theme] .text-slate-800,
[data-theme] .dark\:text-slate-100 {
  color: var(--text) !important;
}

[data-theme] .text-slate-700,
[data-theme] .text-slate-600,
[data-theme] .text-slate-500,
[data-theme] .text-slate-400,
[data-theme] .dark\:text-slate-300,
[data-theme] .dark\:text-slate-200,
[data-theme] .dark\:text-slate-400 {
  color: var(--text-muted) !important;
}

[data-theme] .shadow,
[data-theme] .shadow-sm,
[data-theme] .shadow-2xl {
  box-shadow: var(--shadow) !important;
}

[data-theme] .bg-slate-100,
[data-theme] .bg-slate-100\/70,
[data-theme] .dark\:bg-slate-800 {
  background-color: var(--table-header-bg) !important;
}

[data-theme] .bg-slate-200,
[data-theme] .dark\:bg-slate-800 {
  background-color: var(--surface-2) !important;
}

[data-sidebar] {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-right: 1px solid var(--card-border);
  box-shadow: 6px 0 18px rgba(15, 27, 46, 0.06);
}

.app-sidebar-caption {
  color: var(--sidebar-muted);
}

.app-sidebar-section-title {
  color: var(--sidebar-muted);
}

.app-sidebar-brand {
  display: grid;
  gap: 0.5rem;
  justify-items: center;
  text-align: center;
}

.app-sidebar-system-logo-wrap {
  width: 100%;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-sidebar-system-logo {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 62px;
  object-fit: contain;
}

.app-sidebar-church-name {
  margin: 0;
  color: var(--sidebar-text);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  word-break: break-word;
}

.app-nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.95rem;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  opacity: 0.96;
  transition: background-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}

.app-nav-item:hover {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  box-shadow: inset 0 0 0 1px var(--card-border);
}

.app-nav-item.is-active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  box-shadow: inset 0 0 0 1px var(--card-border);
}

.app-nav-item.is-disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.app-topbar {
  background: var(--surface);
  border-bottom-color: var(--border) !important;
  min-height: 72px;
  box-shadow: 0 6px 18px rgba(15, 27, 46, 0.08);
  overflow: visible;
  isolation: isolate;
}

.notification-root {
  position: relative;
}

.notification-bell {
  position: relative;
}

.notification-count-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  padding: 0 5px;
  background: color-mix(in srgb, var(--danger), transparent 12%);
  color: #fff;
  border: 1px solid color-mix(in srgb, var(--danger), #fff 35%);
}

.notification-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(420px, 92vw);
  max-width: calc(100vw - 1rem);
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card-bg);
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 80;
}

[data-notification-dropdown] {
  border-radius: 14px;
  border: 1px solid var(--card-border);
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.14);
}

:root[data-theme="dark"] [data-notification-dropdown] {
  box-shadow: 0 20px 42px rgba(2, 8, 23, 0.64);
}

.notification-dropdown-head,
.notification-dropdown-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
}

.notification-dropdown-foot {
  border-bottom: 0;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  justify-content: flex-start;
}

.notification-list {
  max-height: 360px;
  overflow-y: auto;
}

.notification-item {
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--border);
}

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

.notification-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.notification-item-top strong {
  font-size: 0.86rem;
  color: var(--text);
}

.notification-item-top time {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.notification-item p {
  margin-top: 0.26rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.34;
}

.notification-item.is-unread {
  background: color-mix(in srgb, var(--primary), transparent 92%);
}

.notification-mark-read,
.notification-link {
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

.notification-empty {
  padding: 0.8rem 0.85rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.app-topbar-inner {
  min-width: 0;
}

.app-topbar-actions {
  min-width: 0;
  flex-wrap: nowrap;
  justify-content: flex-end;
  flex-shrink: 0;
}

.app-topbar-user {
  max-width: 220px;
}

.app-topbar-user p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-dropdown {
  z-index: 95;
  border: 1px solid var(--card-border);
  background: var(--surface-2) !important;
  box-shadow: 0 24px 54px rgba(15, 23, 42, 0.2);
  opacity: 1;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

:root[data-theme="dark"] .user-dropdown {
  background: #141d2c !important;
  box-shadow: 0 24px 54px rgba(2, 8, 23, 0.65);
}

:root[data-theme="light"] .user-dropdown {
  background: #ffffff !important;
  box-shadow: 0 20px 42px rgba(15, 23, 42, 0.14);
}

[data-theme] .rounded-2xl {
  border-radius: 16px !important;
}

[data-theme] .rounded-lg {
  border-radius: 12px !important;
}

[data-theme] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
[data-theme] select,
[data-theme] textarea {
  background: var(--input-bg) !important;
  color: var(--input-text) !important;
  border: 1px solid var(--input-border) !important;
}

[data-theme] input[type="date"],
[data-theme] input[type="month"],
[data-theme] input[type="time"] {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: block;
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-theme] input[type="date"]::-webkit-datetime-edit,
[data-theme] input[type="month"]::-webkit-datetime-edit,
[data-theme] input[type="time"]::-webkit-datetime-edit,
[data-theme] input[type="date"]::-webkit-datetime-edit-fields-wrapper,
[data-theme] input[type="month"]::-webkit-datetime-edit-fields-wrapper,
[data-theme] input[type="time"]::-webkit-datetime-edit-fields-wrapper,
[data-theme] input[type="date"]::-webkit-date-and-time-value,
[data-theme] input[type="month"]::-webkit-date-and-time-value,
[data-theme] input[type="time"]::-webkit-date-and-time-value {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

[data-theme] input::placeholder,
[data-theme] textarea::placeholder {
  color: var(--placeholder) !important;
}

[data-theme] select option,
[data-theme] datalist option {
  background: var(--input-bg);
  color: var(--input-text);
}

[data-theme] input[type="date"]::-webkit-calendar-picker-indicator,
[data-theme] input[type="time"]::-webkit-calendar-picker-indicator,
[data-theme] input[type="month"]::-webkit-calendar-picker-indicator {
  filter: var(--calendar-filter);
  opacity: 0.96;
  cursor: pointer;
  transform: scale(1.15);
  transform-origin: center;
}

[data-theme] input[type="month"] {
  cursor: pointer;
}

[data-theme] input:focus,
[data-theme] select:focus,
[data-theme] textarea:focus,
[data-theme] button:focus,
[data-theme] a:focus {
  outline: none;
  box-shadow: var(--ring) !important;
  border-color: var(--primary) !important;
}

[data-theme] input[type="checkbox"],
[data-theme] input[type="radio"] {
  accent-color: var(--primary);
}

[data-theme] .bg-slate-900,
[data-theme] .dark\:bg-indigo-500 {
  background: linear-gradient(135deg, var(--primary), var(--primary-2)) !important;
  color: #fff !important;
  border-color: transparent !important;
}

[data-theme] .bg-slate-900:hover,
[data-theme] .dark\:bg-indigo-500:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

[data-theme] .bg-slate-200,
[data-theme] .text-slate-700 {
  color: var(--text) !important;
}

[data-theme] .table-zebra {
  border-collapse: separate;
  border-spacing: 0;
}

[data-theme] .table-zebra thead {
  background: var(--table-header-bg) !important;
}

[data-theme] .table-zebra tbody tr {
  background: var(--table-row-bg);
}

[data-theme] .table-zebra tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--table-row-bg), var(--surface-2) 22%);
}

[data-theme] .table-zebra tbody tr:hover {
  background: var(--table-row-hover) !important;
}

[data-theme] .table-zebra th,
[data-theme] .table-zebra td {
  border-bottom: 1px solid var(--border);
}

[data-theme] .table-zebra tbody tr:last-child td {
  border-bottom: none;
}

[data-theme] [data-alert] {
  border-width: 1px;
}

[data-theme="dark"] .bg-emerald-100 { background: rgba(16, 185, 129, 0.22) !important; }
[data-theme="dark"] .text-emerald-700 { color: #6ee7b7 !important; }
[data-theme="dark"] .bg-rose-100 { background: rgba(244, 63, 94, 0.2) !important; }
[data-theme="dark"] .text-rose-700 { color: #fda4af !important; }
[data-theme="dark"] .bg-amber-100 { background: rgba(245, 158, 11, 0.2) !important; }
[data-theme="dark"] .text-amber-700 { color: #fcd34d !important; }

[data-theme] .scrollbar-thin::-webkit-scrollbar {
  width: 8px;
}

[data-theme] .scrollbar-thin::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text-muted), transparent 45%);
  border-radius: 999px;
}

@media (max-width: 1024px) {
  [data-sidebar] {
    box-shadow: var(--shadow);
  }
}

@media (max-width: 768px) {
  [data-theme] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
  [data-theme] select,
  [data-theme] textarea,
  [data-theme] button,
  [data-theme] .btn {
    font-size: 16px !important;
    line-height: 1.2;
  }

  [data-theme] input[type="date"],
  [data-theme] input[type="month"],
  [data-theme] input[type="time"] {
    font-size: 16px !important;
    line-height: 1.2;
    -webkit-appearance: none;
    appearance: none;
  }

  .notification-root {
    position: static;
  }

  .notification-dropdown,
  [data-notification-dropdown] {
    position: fixed;
    left: 0.6rem;
    right: 0.6rem;
    top: max(72px, calc(env(safe-area-inset-top) + 58px));
    width: auto;
    max-width: none;
    border-radius: 12px;
    z-index: 120;
  }

  .notification-list,
  [data-notification-list] {
    max-height: calc(100dvh - 210px);
  }

  [data-dropdown-menu].user-dropdown {
    position: fixed;
    right: 0.6rem;
    left: auto;
    top: max(72px, calc(env(safe-area-inset-top) + 58px));
    width: min(92vw, 320px);
    max-width: calc(100vw - 1.2rem);
    z-index: 121;
  }

  .app-topbar-actions {
    gap: 0.35rem;
  }

  .app-topbar-actions > a,
  .app-topbar-actions > button,
  .app-topbar-actions .notification-bell {
    min-height: 38px;
    min-width: 38px;
  }

  .app-sidebar-system-logo {
    max-height: 48px;
  }

  .app-sidebar-church-name {
    font-size: 1.08rem;
  }
}

@media (max-width: 420px) {
  .notification-dropdown,
  [data-notification-dropdown] {
    left: 0.45rem;
    right: 0.45rem;
    border-radius: 10px;
  }

  [data-dropdown-menu].user-dropdown {
    right: 0.45rem;
    max-width: calc(100vw - 0.9rem);
  }

  .app-topbar-appname {
    display: none;
  }

  .app-topbar-title {
    font-size: 1.05rem;
    line-height: 1.15;
  }
}

.dashboard-shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 16px;
}

.dashboard-title {
  font-size: clamp(1.42rem, 0.75vw + 1.02rem, 1.72rem);
  line-height: 1.1;
  font-weight: 700;
  color: var(--text);
}

.dashboard-subtitle {
  margin-top: 0.35rem;
  color: var(--text-muted);
  font-size: clamp(0.92rem, 0.15vw + 0.86rem, 1rem);
}

.dashboard-account-card,
.dashboard-kpi-card,
.dashboard-panel,
.dashboard-indicator-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.dashboard-kpi-card:hover,
.dashboard-panel:hover,
.dashboard-indicator-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 34px rgba(15, 23, 42, 0.16);
}

.dashboard-account-card {
  padding: 1.35rem 1.45rem;
}

.dashboard-account-card.is-highlight {
  border-left: 4px solid #5d7ff8;
}

.dashboard-account-title {
  font-size: clamp(0.95rem, 0.15vw + 0.9rem, 1.02rem);
  font-weight: 600;
  color: var(--text);
}

.dashboard-account-icon {
  color: color-mix(in srgb, var(--primary), var(--text-muted) 45%);
}

.dashboard-account-value {
  margin-top: 0.8rem;
  font-size: clamp(1.28rem, 0.52vw + 0.94rem, 1.56rem);
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}

.dashboard-account-desc {
  margin-top: 0.4rem;
  color: var(--text-muted);
}

.dashboard-kpi-card {
  padding: 1.4rem 1.55rem;
}

.dashboard-kpi-label {
  color: var(--text-muted);
  font-weight: 600;
  font-size: clamp(0.88rem, 0.1vw + 0.83rem, 0.95rem);
}

.dashboard-kpi-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.2rem;
  height: 3.2rem;
  border-radius: 14px;
}

.dashboard-kpi-icon-indigo {
  background: color-mix(in srgb, #5d7ff8, transparent 84%);
  color: #5d7ff8;
}

.dashboard-kpi-icon-emerald {
  background: color-mix(in srgb, #32b279, transparent 82%);
  color: #2b9a69;
}

.dashboard-kpi-icon-green {
  background: color-mix(in srgb, #55b985, transparent 82%);
  color: #3a8f65;
}

.dashboard-kpi-icon-red {
  background: color-mix(in srgb, #e35f57, transparent 84%);
  color: #c94e47;
}

.dashboard-kpi-value,
.dashboard-kpi-money {
  margin-top: 0.75rem;
  font-size: clamp(1.28rem, 0.62vw + 0.94rem, 1.62rem);
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}

.dashboard-kpi-note {
  margin-top: 0.55rem;
  color: var(--text-muted);
}

.dashboard-due-card {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid color-mix(in srgb, #ceab3a, transparent 60%);
  background: color-mix(in srgb, #f6f0db, var(--card-bg) 38%);
  box-shadow: var(--shadow);
}

[data-theme="dark"] .dashboard-due-card {
  border-color: color-mix(in srgb, #d0a84b, transparent 65%);
  background: color-mix(in srgb, #2b2516, var(--card-bg) 68%);
}

.dashboard-due-border {
  position: absolute;
  left: 0;
  top: 0;
  width: 4px;
  height: 100%;
  background: #d2a133;
}

.dashboard-due-content {
  padding: 1.55rem 1.6rem 1.25rem 1.6rem;
}

.dashboard-due-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 14px;
  color: #bb7a1a;
  background: color-mix(in srgb, #e5ca8d, transparent 68%);
}

.dashboard-due-title {
  font-size: 1.38rem;
  font-weight: 700;
  color: color-mix(in srgb, var(--text), #7f4a00 35%);
}

.dashboard-due-subtitle {
  margin-top: 0.35rem;
  color: color-mix(in srgb, var(--text-muted), #885300 35%);
}

.dashboard-due-total {
  font-size: 1.52rem;
  font-weight: 700;
  color: color-mix(in srgb, var(--text), #7b4a00 30%);
}

.dashboard-due-list {
  border-top: 1px solid color-mix(in srgb, #cca14c, transparent 65%);
  padding-top: 0.95rem;
  display: grid;
  gap: 0.6rem;
}

.dashboard-due-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: var(--text);
}

.dashboard-panel {
  padding: 1.35rem 1.35rem 1.15rem 1.35rem;
  border-radius: var(--radius);
}

.dashboard-panel canvas {
  touch-action: pan-y;
  display: block;
  width: 100% !important;
  height: auto !important;
  max-height: 340px;
}

.dashboard-shell .grid > * {
  min-width: 0;
}

.dashboard-panel-title {
  margin-bottom: 0.95rem;
  font-size: clamp(1rem, 0.22vw + 0.94rem, 1.12rem);
  line-height: 1.2;
  font-weight: 700;
  color: var(--text);
}

.dashboard-indicator-card {
  overflow: hidden;
}

.dashboard-indicator-header {
  padding: 1.5rem 1.45rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  color: #fff;
}

.dashboard-indicator-header-success {
  background: linear-gradient(135deg, #62b874, #4e9f5f);
}

.dashboard-indicator-header-success-soft {
  background: linear-gradient(135deg, #5cbf9d, #4ea98b);
}

.dashboard-indicator-header-warning {
  background: linear-gradient(135deg, #d29b4b, #b97d2d);
}

.dashboard-indicator-header-danger {
  background: linear-gradient(135deg, #d35f5f, #a64242);
}

.dashboard-indicator-caption {
  font-size: 0.95rem;
  font-weight: 600;
  opacity: 0.92;
}

.dashboard-indicator-title {
  margin-top: 0.35rem;
  font-size: clamp(1rem, 0.24vw + 0.92rem, 1.14rem);
  line-height: 1.1;
  font-weight: 700;
}

.dashboard-indicator-icon {
  width: 3.7rem;
  height: 3.7rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
}

.dashboard-indicator-body {
  padding: 1.35rem 1.45rem;
}

.dashboard-indicator-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  color: var(--text-muted);
}

.dashboard-indicator-row strong {
  color: var(--text);
}

.dashboard-indicator-track {
  margin-top: 0.85rem;
  width: 100%;
  height: 0.6rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-muted), transparent 82%);
  overflow: hidden;
}

.dashboard-indicator-fill {
  height: 100%;
  background: linear-gradient(90deg, #49b77b, #67c594);
}


.dashboard-kpi-note,
.dashboard-account-desc,
.dashboard-due-subtitle {
  overflow-wrap: anywhere;
}


@media (max-width: 1024px) {
  .dashboard-title {
    font-size: 1.52rem;
  }

  .dashboard-panel-title {
    font-size: 1.15rem;
  }

  .dashboard-indicator-title {
    font-size: 1.08rem;
  }

  .dashboard-account-value,
  .dashboard-kpi-value,
  .dashboard-kpi-money {
    font-size: 1.32rem;
  }
}

@media (max-width: 768px) {
  .dashboard-shell {
    padding: 0 4px;
  }

  .dashboard-account-card,
  .dashboard-kpi-card,
  .dashboard-panel,
  .dashboard-indicator-body,
  .dashboard-due-content {
    padding: 1rem;
  }

  .dashboard-due-title {
    font-size: 1.08rem;
  }

  .dashboard-due-total {
    font-size: 1.3rem;
  }

  .dashboard-kpi-note {
    font-size: 0.86rem;
  }
}

@media (min-width: 1280px) {
  .dashboard-title {
    font-size: 1.48rem;
  }

  .dashboard-subtitle {
    font-size: 0.88rem;
  }

  .dashboard-panel-title {
    font-size: 0.96rem;
  }

  .dashboard-account-value {
    font-size: 1.28rem;
  }

  .dashboard-kpi-value,
  .dashboard-kpi-money {
    font-size: 1.3rem;
  }

  .dashboard-kpi-label {
    font-size: 0.82rem;
  }
}

/* SaaS premium layout refresh */
.app-shell {
  background:
    radial-gradient(circle at top left, rgba(108, 125, 224, 0.18), transparent 26%),
    radial-gradient(circle at bottom right, rgba(210, 177, 101, 0.1), transparent 20%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  min-width: 0;
  overflow-x: clip;
}

.app-main-column {
  min-width: 0;
  width: 100%;
}

@media (min-width: 1024px) {
  .app-main-column {
    margin-left: var(--sidebar-width);
  }
}

.app-main {
  min-width: 0;
  background: transparent;
  width: 100%;
  overflow-x: clip;
}

.app-content-shell {
  display: grid;
  width: 100%;
  min-width: 0;
  margin-inline: auto;
  gap: 1.15rem;
}

.app-content-shell > :where(section, article, .finance-wrap, .dashboard-shell) {
  min-width: 0;
}

[data-sidebar].app-sidebar {
  width: var(--sidebar-width);
  max-width: min(var(--sidebar-width), 88vw);
  border-right: 1px solid var(--card-border);
  background: color-mix(in srgb, var(--sidebar-bg), transparent 0%);
  box-shadow: 16px 0 42px rgba(15, 23, 42, 0.12);
}

:root[data-theme="dark"] [data-sidebar].app-sidebar {
  background: color-mix(in srgb, var(--sidebar-bg), transparent 0%);
  box-shadow: 18px 0 44px rgba(2, 8, 23, 0.34);
}

.app-sidebar-brand {
  display: grid;
  justify-items: start;
  gap: 0.9rem;
  text-align: left;
}

.app-sidebar-system-logo-wrap {
  width: 100%;
  min-height: 52px;
  justify-content: flex-start;
}

.app-sidebar-system-logo {
  max-height: 56px;
}

.app-sidebar-caption {
  color: var(--sidebar-muted);
}

.app-sidebar-church-name {
  color: var(--sidebar-text);
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.25;
}

.app-sidebar-section-title {
  color: var(--sidebar-muted);
  font-weight: 700;
}

.app-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.66rem;
  min-height: 41px;
  border-radius: 12px;
  padding: 0.58rem 0.76rem;
  color: var(--sidebar-text);
  font-size: 0.89rem;
  font-weight: 600;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.app-nav-item::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 9px;
  width: 3px;
  height: calc(100% - 18px);
  border-radius: 999px;
  background: transparent;
  transition: background-color 0.2s ease;
}

.app-nav-item:hover {
  background: color-mix(in srgb, var(--sidebar-active-bg), transparent 8%);
  color: var(--sidebar-active-text);
  transform: translateX(1px);
}

.app-nav-item.is-active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary), transparent 72%);
}

.app-nav-item.is-active::before {
  background: linear-gradient(180deg, var(--primary), var(--primary-2));
}

.app-nav-item.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.app-topbar {
  background: color-mix(in srgb, var(--surface), transparent 2%);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
}

.topbar-icon-btn {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: color-mix(in srgb, var(--surface), transparent 3%);
}

.topbar-icon-btn:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--surface-2), transparent 2%);
}

.topbar-icon-btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-color: var(--primary);
}

.app-topbar-actions > a,
.app-topbar-actions > button,
.app-topbar-actions .notification-bell {
  flex-shrink: 0;
}

.app-topbar-title {
  color: var(--text);
}

.app-topbar-caption {
  color: var(--text-muted);
}

.app-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 600;
  line-height: 1;
  transition: transform 0.2s ease, filter 0.2s ease, box-shadow 0.2s ease;
}

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

.app-btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-color: var(--primary);
}

.app-btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}

.app-btn-secondary {
  color: var(--text);
  border-color: var(--input-border);
  background: color-mix(in srgb, var(--surface), transparent 3%);
}

.app-btn-ghost {
  color: var(--text-muted);
  border-color: transparent;
  background: transparent;
}

.notification-dropdown {
  border-radius: 14px;
  border: 1px solid var(--card-border);
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.14);
}

:root[data-theme="dark"] .notification-dropdown {
  box-shadow: 0 20px 42px rgba(2, 8, 23, 0.64);
}

[data-theme] .bg-white,
[data-theme] .bg-white\/80,
[data-theme] .dark\:bg-slate-900\/70,
.finance-card,
.finance-filters,
.finance-stat-card,
.dashboard-account-card,
.dashboard-kpi-card,
.dashboard-panel,
.dashboard-indicator-card,
.record-card,
.assembly-shell,
.assembly-section,
.assembly-kpi,
.assembly-shell__header,
.assembly-approval__kpis > div {
  border-radius: 14px !important;
  border-color: var(--card-border) !important;
  box-shadow: var(--shadow) !important;
}

.module-shell {
  display: grid;
  gap: 1rem;
}

.module-header-card,
.module-panel {
  background: color-mix(in srgb, var(--surface), transparent 4%);
  border: 1px solid var(--card-border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 1.25rem 1.35rem;
}

.module-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.module-eyebrow {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.22em;
}

.module-title {
  margin-top: 0.6rem;
  color: var(--text);
  font-size: clamp(1.6rem, 0.75vw + 1.2rem, 2rem);
  line-height: 1.08;
  font-weight: 700;
}

.module-subtitle {
  margin-top: 0.45rem;
  color: var(--text-muted);
  max-width: 56rem;
  line-height: 1.65;
}

.dashboard-hero-actions,
.dashboard-primary-metrics,
.dashboard-secondary-metrics,
.dashboard-analytics-grid,
.dashboard-finance-grid,
.dashboard-ebd-grid {
  min-width: 0;
}

.dashboard-hero-actions > * {
  min-width: 0;
}

.dashboard-events-panel > div:last-child {
  min-width: 0;
}

:root[data-theme="light"] .dashboard-root {
  background: linear-gradient(180deg, rgba(255,255,255,0.68) 0%, rgba(255,255,255,0.58) 100%) !important;
  border: 1px solid var(--card-border);
}

:root[data-theme="light"] .dashboard-root,
:root[data-theme="light"] .module-header-card,
:root[data-theme="light"] .module-panel {
  box-shadow: 0 18px 38px rgba(15, 27, 46, 0.08) !important;
}

:root[data-theme="light"] .dashboard-shell [class*="bg-white/"] {
  background: rgba(244, 247, 252, 0.86) !important;
}

:root[data-theme="light"] .dashboard-shell [class*="bg-white/[0.03"],
:root[data-theme="light"] .dashboard-shell [class*="bg-white/[0.04"] {
  background: rgba(255, 255, 255, 0.76) !important;
}

:root[data-theme="light"] .dashboard-shell [class*="border-white/"] {
  border-color: var(--card-border) !important;
}

:root[data-theme="light"] .dashboard-shell [class*="text-[#f5f1e8]"] {
  color: var(--text) !important;
}

:root[data-theme="light"] .dashboard-shell .text-slate-300,
:root[data-theme="light"] .dashboard-shell .text-slate-400,
:root[data-theme="light"] .dashboard-shell .text-slate-500 {
  color: var(--text-muted) !important;
}

:root[data-theme="light"] .dashboard-shell [class*="text-emerald-200"],
:root[data-theme="light"] .dashboard-shell [class*="text-emerald-300"] {
  color: #226f4b !important;
}

main label {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.82rem;
}

main table {
  width: 100%;
}

main table thead th {
  background: var(--table-header-bg);
  color: var(--text-muted);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

main table tbody tr {
  transition: background-color 0.18s ease;
}

main table tbody tr:hover {
  background: var(--table-row-hover);
}

main .btn,
main button[type="submit"],
main a.btn {
  font-weight: 600;
}

@media (max-width: 1023px) {
  [data-sidebar].app-sidebar {
    width: min(82vw, 300px);
    max-width: min(82vw, 300px);
    box-shadow: 0 24px 48px rgba(2, 8, 23, 0.42);
  }

  .app-sidebar-brand {
    padding-top: calc(1.1rem + env(safe-area-inset-top));
  }

  .app-sidebar-system-logo {
    max-height: 48px;
  }

  .app-sidebar-church-name {
    font-size: 0.98rem;
  }

  .app-main-column {
    margin-left: 0;
  }

  .app-main {
    padding: 0.95rem;
  }

  .app-topbar-inner {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.75rem;
    min-height: 70px;
    padding-inline: 0.95rem;
    padding-block: 0.85rem;
  }

  .app-topbar-actions {
    width: auto;
    justify-self: end;
    gap: 0.45rem;
  }

  .app-topbar-user {
    max-width: none;
    padding: 0.28rem;
    border-radius: 14px;
  }

  .app-topbar-profile-copy {
    display: none !important;
  }

  .app-topbar-user img,
  .app-topbar-user > span {
    width: 2.3rem;
    height: 2.3rem;
  }

  .topbar-icon-btn {
    width: 38px;
    height: 38px;
  }

  .module-header-row {
    flex-direction: column;
    align-items: stretch;
  }

  .module-header-row > :last-child {
    width: 100%;
  }

  .module-header-row > :last-child .app-btn,
  .module-header-row > :last-child .btn {
    width: 100%;
  }

  .dashboard-root {
    padding: 1.15rem !important;
    border-radius: 24px !important;
  }

  .dashboard-hero-head {
    gap: 1rem !important;
  }

  .dashboard-hero-actions {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem !important;
    width: 100%;
  }

  .dashboard-hero-actions > * {
    width: 100%;
    min-height: 46px;
    justify-content: center;
    text-align: center;
  }

  .dashboard-hero-panels,
  .dashboard-analytics-grid,
  .dashboard-finance-grid,
  .dashboard-ebd-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .dashboard-primary-metrics,
  .dashboard-secondary-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .dashboard-events-panel > div:last-child {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 640px) {
  .app-content-shell {
    gap: 0.75rem;
  }

  .app-main {
    padding-top: 0.62rem;
  }

  .app-topbar-inner {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0.65rem;
    min-height: 64px;
    padding-inline: 0.78rem;
    padding-block: 0.62rem;
  }

  .app-topbar-actions {
    gap: 0.35rem;
  }

  .app-topbar-user {
    min-width: 44px;
    justify-content: center;
  }

  .app-topbar-title {
    font-size: 1.28rem;
    line-height: 1.05;
  }

  .app-topbar-caption {
    font-size: 0.64rem;
    letter-spacing: 0.18em;
  }

  .module-header-card,
  .module-panel {
    padding: 0.95rem;
    border-radius: 22px;
  }

  .module-title {
    margin-top: 0.45rem;
    font-size: 1.52rem;
  }

  .module-subtitle {
    margin-top: 0.35rem;
    font-size: 0.92rem;
    line-height: 1.55;
  }

  .module-header-row > :last-child {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.65rem;
  }

  .app-topbar-actions > a,
  .app-topbar-actions > button,
  .app-topbar-actions .notification-bell {
    min-width: 38px;
    min-height: 38px;
  }

  .dashboard-root {
    padding: 0.82rem !important;
    border-radius: 20px !important;
    gap: 0.82rem !important;
  }

  .dashboard-hero-head {
    gap: 0.72rem !important;
    padding-bottom: 0.82rem !important;
  }

  .dashboard-root h2 {
    font-size: 1.86rem !important;
    line-height: 1.04 !important;
  }

  .dashboard-root section:first-child p.inline-flex {
    margin-top: 0.7rem !important;
    width: fit-content;
    max-width: 100%;
  }

  .dashboard-root section:first-child p.text-sm,
  .dashboard-root .text-sm.leading-6 {
    line-height: 1.55;
  }

  .dashboard-primary-metrics,
  .dashboard-secondary-metrics,
  .dashboard-events-panel > div:last-child {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .dashboard-hero-actions {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.55rem !important;
    align-items: stretch;
  }

  .dashboard-hero-actions > * {
    min-height: 42px;
    padding: 0.78rem 0.95rem !important;
    border-radius: 16px !important;
    font-size: 0.95rem !important;
  }

  .dashboard-root article.rounded-\[26px\],
  .dashboard-root article.rounded-\[24px\],
  .dashboard-root article.rounded-\[22px\] {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
  }

  .dashboard-root [data-sensitive-chart] canvas {
    max-height: 240px !important;
  }

  .dashboard-root svg[viewBox="0 0 240 96"] {
    height: 92px;
  }

  .dashboard-events-panel article {
    min-height: 0;
  }
}

@media (max-width: 480px) {
  [data-sidebar].app-sidebar {
    width: min(86vw, 290px);
    max-width: min(86vw, 290px);
  }

  .app-main {
    padding: 0.52rem 0.72rem 1rem;
  }

  .topbar-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 11px;
  }

  .app-topbar-user img,
  .app-topbar-user > span {
    width: 2.15rem;
    height: 2.15rem;
  }

  .app-topbar-title {
    font-size: 1.16rem;
  }

  .module-header-card,
  .module-panel {
    padding: 0.88rem;
    border-radius: 18px;
  }

  .module-title {
    font-size: 1.38rem;
  }

  .dashboard-root h2 {
    font-size: 1.74rem !important;
  }

  .dashboard-hero-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.5rem !important;
  }

  .dashboard-hero-actions > * {
    min-height: 40px;
    padding: 0.72rem 0.8rem !important;
    font-size: 0.9rem !important;
  }

  .dashboard-root p[data-sensitive-value],
  .dashboard-root h3[data-sensitive-value] {
    word-break: break-word;
  }
}

@media (max-width: 390px) {
  .dashboard-hero-actions {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

/* Light-mode contrast tuning (buttons/cards with low visibility) */
:root[data-theme="light"] .text-indigo-700 {
  color: #312e81 !important;
}

:root[data-theme="light"] .bg-indigo-50 {
  background-color: #e5ecff !important;
}

:root[data-theme="light"] .bg-indigo-100 {
  background-color: #d9e4ff !important;
}

:root[data-theme="light"] .border-indigo-200 {
  border-color: #a8b8ff !important;
}

:root[data-theme="light"] .text-rose-700 {
  color: #b91c1c !important;
}

:root[data-theme="light"] .bg-rose-100 {
  background-color: #ffe4e6 !important;
}

:root[data-theme="light"] .text-emerald-700 {
  color: #047857 !important;
}

:root[data-theme="light"] .bg-emerald-100 {
  background-color: #dcfce7 !important;
}

/* EBD action buttons readable in both themes */
.ebd-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  min-height: 40px;
  padding: 0.6rem 0.95rem;
  border: 1px solid transparent;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

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

.ebd-btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.ebd-btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  border-color: color-mix(in srgb, var(--primary-2), transparent 30%);
}

.ebd-btn-primary:hover {
  filter: brightness(1.04);
}

.ebd-btn-secondary {
  color: var(--text);
  background: color-mix(in srgb, var(--surface), transparent 3%);
  border-color: var(--input-border);
}

.ebd-btn-secondary:hover {
  background: color-mix(in srgb, var(--surface-2), transparent 6%);
}

.ebd-btn-danger {
  color: #fff;
  background: #e11d48;
  border-color: #be123c;
}

.ebd-btn-danger:hover {
  background: #be123c;
}

.ebd-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--input-border);
  background: color-mix(in srgb, var(--surface-2), transparent 10%);
  color: var(--text);
}

.ebd-reflect-card {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  --mx: 50%;
  --my: 50%;
  --tilt-x: 0deg;
  --tilt-y: 0deg;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.ebd-reflect-card > * {
  position: relative;
  z-index: 1;
}

.ebd-reflect-card::before {
  content: "";
  position: absolute;
  inset: -28%;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  background: radial-gradient(circle at var(--mx) var(--my), rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.06) 22%, transparent 56%);
  transition: opacity 0.22s ease;
}

.ebd-reflect-card::after {
  content: "";
  position: absolute;
  top: -12%;
  left: -160%;
  width: 60%;
  height: 124%;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transform: skewX(-22deg);
  background: linear-gradient(115deg, transparent 6%, rgba(255, 255, 255, 0.03) 38%, rgba(255, 255, 255, 0.32) 50%, rgba(255, 255, 255, 0.05) 62%, transparent 95%);
}

.ebd-reflect-card.is-hovering {
  transform: perspective(980px) rotateX(var(--tilt-y)) rotateY(var(--tilt-x)) translateY(-3px);
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.24), 0 0 0 1px color-mix(in srgb, var(--primary), transparent 64%);
}

.ebd-reflect-card.is-hovering::before {
  opacity: 1;
}

.ebd-reflect-card.is-hovering::after {
  left: 158%;
  opacity: 1;
  transition: left 0.82s ease, opacity 0.22s ease;
}

:root[data-theme="light"] .ebd-reflect-card::before {
  background: radial-gradient(circle at var(--mx) var(--my), rgba(79, 70, 229, 0.28) 0%, rgba(56, 189, 248, 0.18) 24%, rgba(147, 197, 253, 0.08) 42%, transparent 62%);
  mix-blend-mode: multiply;
}

:root[data-theme="light"] .ebd-reflect-card::after {
  background: linear-gradient(115deg, transparent 6%, rgba(79, 70, 229, 0.04) 34%, rgba(79, 70, 229, 0.28) 50%, rgba(56, 189, 248, 0.18) 62%, transparent 95%);
  mix-blend-mode: multiply;
}

:root[data-theme="light"] .ebd-reflect-card.is-hovering {
  border-color: color-mix(in srgb, var(--primary), #c7d2fe 45%);
  box-shadow: 0 14px 28px rgba(30, 41, 59, 0.16), 0 0 0 1px rgba(79, 70, 229, 0.25);
}

@media (prefers-reduced-motion: reduce) {
  .ebd-reflect-card,
  .ebd-reflect-card::before,
  .ebd-reflect-card::after {
    transition: none !important;
    transform: none !important;
  }
}

/* EBD results readability and responsiveness */
.ebd-results-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.ebd-result-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 1rem;
  box-shadow: var(--shadow);
  padding: 1rem;
  min-width: 0;
}

.ebd-result-metric {
  background: color-mix(in srgb, var(--surface-2), var(--card-bg) 30%) !important;
  border: 1px solid var(--input-border) !important;
  border-radius: 0.85rem;
  padding: 0.62rem 0.68rem;
  min-width: 0;
}

.ebd-result-metric-label {
  color: var(--text-muted) !important;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.25;
}

.ebd-result-metric-value {
  color: var(--text) !important;
  font-weight: 700;
  margin-top: 0.18rem;
  line-height: 1.2;
  font-size: 1rem;
}

.ebd-result-cta {
  width: 100%;
}

:root[data-theme="light"] .ebd-result-metric {
  background: #eef3fb !important;
  border-color: #c8d3e6 !important;
}

:root[data-theme="light"] .ebd-result-metric-label {
  color: #5d6a82 !important;
}

:root[data-theme="light"] .ebd-result-metric-value {
  color: #1e2b45 !important;
}

:root[data-theme="dark"] .ebd-result-metric {
  background: #15253f !important;
  border-color: #314768 !important;
}

:root[data-theme="dark"] .ebd-result-metric-label {
  color: #9eb1cf !important;
}

:root[data-theme="dark"] .ebd-result-metric-value {
  color: #e9f1ff !important;
}

@media (min-width: 768px) {
  .ebd-results-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1280px) {
  .ebd-results-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .ebd-result-card {
    padding: 0.85rem;
  }

  .ebd-result-metric {
    padding: 0.58rem 0.62rem;
  }
}

