/* Shared app UI — both entry system projects */
:root {
  --app-sidebar-width: 260px;
  --app-topbar-height: 80px;
  --app-mobile-nav-height: 52px;
  --app-bg: #f4f6f9;
  --app-sidebar-bg: #0f172a;
  --app-sidebar-border: rgba(255, 255, 255, 0.08);
  --app-link: rgba(255, 255, 255, 0.88);
  --app-link-hover: #ffffff;
  --page-radius: 14px;
  --page-shadow: 0 10px 30px rgba(2, 6, 23, 0.08);
}

body.org-mother-teresa,
body.org-mother_teresa {
  --app-primary: #dc2626;
  --app-primary-dark: #991b1b;
  --app-gradient: linear-gradient(90deg, #b91c1c 0%, #dc2626 50%, #ea580c 100%);
  --app-nav-active-bg: rgba(220, 38, 38, 0.38);
  --app-nav-hover-bg: rgba(220, 38, 38, 0.22);
  --app-dash-hero: linear-gradient(135deg, #7f1d1d 0%, #dc2626 45%, #ea580c 100%);
  --app-dash-hero-shadow: rgba(220, 38, 38, 0.25);
  --app-tint-bg: #fef2f2;
  --app-tint-text: #991b1b;
  --app-tint-border: #fecaca;
  --app-dash-action-bg: #fef2f2;
  --app-dash-action-hover-border: #fca5a5;
  --app-dash-action-hover-color: #991b1b;
}

body.org-kalabharati,
body:not([class*="org-"]) {
  --app-primary: #2563eb;
  --app-primary-dark: #1e40af;
  --app-gradient: linear-gradient(90deg, #2d5fc3 0%, #3f82f6 100%);
  --app-nav-active-bg: rgba(37, 99, 235, 0.38);
  --app-nav-hover-bg: rgba(37, 99, 235, 0.22);
  --app-dash-hero: linear-gradient(135deg, #1e3a8a 0%, #2563eb 45%, #7c3aed 100%);
  --app-dash-hero-shadow: rgba(37, 99, 235, 0.25);
  --app-tint-bg: #eff6ff;
  --app-tint-text: #1e40af;
  --app-tint-border: #bfdbfe;
  --app-dash-action-bg: #eff6ff;
  --app-dash-action-hover-border: #93c5fd;
  --app-dash-action-hover-color: #1d4ed8;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--app-bg);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: #0f172a;
}

label {
  font-weight: 600;
  color: #0f172a;
}

.card {
  border: 1px solid rgba(2, 6, 23, 0.08);
  border-radius: 14px;
}

.card-header.bg-primary,
.card-header.bg-danger,
.card-header.bg-warning,
.card-header.bg-success,
.card-header.bg-info,
.card-header.bg-dark {
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

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

.table thead th {
  white-space: nowrap;
}

.btn {
  font-weight: 600;
}

.btn-primary {
  --bs-btn-bg: var(--app-primary);
  --bs-btn-border-color: var(--app-primary);
  --bs-btn-hover-bg: var(--app-primary-dark);
  --bs-btn-hover-border-color: var(--app-primary-dark);
  --bs-btn-active-bg: var(--app-primary-dark);
  --bs-btn-active-border-color: var(--app-primary-dark);
}

.form-control,
.form-select {
  border-radius: 12px;
}

.table-responsive {
  border-radius: 12px;
}

/* Top bar */
.app-topbar {
  --bs-navbar-padding-y: 0;
  background: var(--app-gradient) !important;
  min-height: var(--app-topbar-height);
  height: auto;
  z-index: 1035;
  box-shadow: 0 2px 12px rgba(2, 6, 23, 0.15);
}

.app-topbar .container-fluid {
  min-height: var(--app-topbar-height);
  height: auto;
  display: flex;
  align-items: center;
  padding-top: 10px;
  padding-bottom: 10px;
}

.navbar-brand.app-brand-wrap {
  white-space: normal;
  overflow: visible;
  max-width: min(520px, calc(100vw - 12rem));
}

.app-brand-wrap {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: #fff;
  text-decoration: none;
  min-height: 56px;
}

.app-brand-wrap form {
  display: inline-flex;
  align-items: center;
  margin: 0;
}

.app-brand-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.15;
  min-width: 0;
  flex: 1;
}

.app-brand-title {
  color: #fff;
  text-decoration: none;
  font-weight: 800;
  font-size: 1.5rem;
  line-height: 1.15;
  letter-spacing: 0.01em;
  margin: 0;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.app-brand-subtitle {
  color: rgba(255, 255, 255, 0.9);
  font-weight: 600;
  font-size: 0.8125rem;
  margin-top: 4px;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.app-brand-title:hover,
.app-brand-wrap:hover {
  color: #fff;
}

.app-project-logo-btn {
  width: 72px;
  height: 52px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.12);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  cursor: pointer;
  overflow: hidden;
  line-height: 0;
  vertical-align: middle;
  flex-shrink: 0;
}

.app-project-logo-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  border-radius: 8px;
  background: transparent;
}

.app-project-logo-fallback {
  font-weight: 700;
  color: #fff;
  font-size: 14px;
  line-height: 1;
}

.app-user-menu {
  flex-shrink: 0;
}

/* Logo modal */
.logo-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  padding: 20px;
}

.logo-modal-overlay.open {
  display: flex;
}

.logo-modal {
  width: min(620px, 95vw);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(2, 6, 23, 0.25);
  padding: 24px;
}

.logo-modal-title {
  font-size: 32px;
  font-weight: 800;
  margin: 0;
  color: #1e293b;
}

.logo-modal-sub {
  margin: 6px 0 18px;
  color: #64748b;
  font-weight: 500;
}

.logo-current-box,
.logo-drop-box {
  border: 2px dashed var(--app-primary);
  border-radius: 14px;
  background: var(--app-tint-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  color: var(--app-tint-text);
}

.logo-current-box {
  min-height: 170px;
  margin-bottom: 14px;
}

.logo-current-preview {
  width: 150px;
  height: 74px;
  object-fit: contain;
  object-position: center;
  border-radius: 10px;
  border: 0;
  background: transparent;
}

.logo-drop-box {
  min-height: 78px;
  cursor: pointer;
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 18px;
}

.logo-drop-box.drag {
  background: var(--app-tint-border);
  border-color: var(--app-primary-dark);
}

.logo-drop-box:focus-visible {
  outline: 2px solid var(--app-primary);
  outline-offset: 2px;
}

.logo-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Sidebar */
.app-sidebar {
  position: fixed;
  top: var(--app-topbar-height);
  left: 0;
  width: var(--app-sidebar-width);
  height: calc(100vh - var(--app-topbar-height));
  background: var(--app-sidebar-bg);
  border-right: 1px solid var(--app-sidebar-border);
  padding: 14px 10px;
  overflow-y: auto;
  z-index: 1020;
}

.app-nav-title {
  color: rgba(255, 255, 255, 0.92);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 10px 12px;
  margin-bottom: 6px;
}

.app-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin: 4px 6px;
  border-radius: 10px;
  color: var(--app-link);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.app-nav-link:hover {
  color: var(--app-link-hover);
  background: var(--app-nav-hover-bg);
}

.app-nav-link.active {
  color: #fff;
  background: var(--app-nav-active-bg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.app-main {
  margin-left: var(--app-sidebar-width);
  padding: 22px;
  padding-top: calc(var(--app-topbar-height) + 22px);
  min-height: 100vh;
}

@media (max-width: 992px) {
  .app-sidebar {
    width: 220px;
  }

  .app-main {
    margin-left: 220px;
  }
}

@media (max-width: 768px) {
  .navbar-brand.app-brand-wrap {
    max-width: calc(100vw - 7rem);
  }

  .app-brand-title {
    font-size: 1.125rem;
  }

  .app-brand-subtitle {
    font-size: 0.6875rem;
  }

  .app-project-logo-btn {
    width: 62px;
    height: 46px;
  }

  .app-sidebar {
    top: var(--app-topbar-height);
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    max-height: none;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 6px 8px;
    -webkit-overflow-scrolling: touch;
  }

  .app-nav-title {
    display: none;
  }

  .app-nav-link {
    flex: 0 0 auto;
    margin: 2px 4px;
    padding: 8px 12px;
    font-size: 13px;
  }

  .app-main {
    margin-left: 0;
    padding-top: calc(var(--app-topbar-height) + var(--app-mobile-nav-height) + 22px);
  }
}

/* Page cards */
.page-card {
  border: 1px solid rgba(2, 6, 23, 0.08);
  border-radius: var(--page-radius);
  box-shadow: var(--page-shadow);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.page-card .card-header {
  padding: 1rem 1.25rem;
}

.page-card .card-header.bg-primary {
  background-color: var(--app-primary) !important;
}

.page-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.page-card-header h4,
.page-card-header h5 {
  margin: 0;
  font-weight: 700;
}

.page-card-body {
  padding: 1.25rem;
}

.page-toolbar {
  padding: 1.25rem;
  background: #f8fafc;
  border-bottom: 1px solid rgba(2, 6, 23, 0.06);
}

.page-toolbar .form-label {
  font-size: 0.8125rem;
  margin-bottom: 0.35rem;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.toolbar-actions .btn {
  min-width: 5.5rem;
  white-space: nowrap;
}

.toolbar-meta {
  margin-top: 0.65rem;
  font-size: 0.8125rem;
  color: #64748b;
}

.table-panel {
  padding: 0 !important;
  margin: 0;
  border-radius: 0;
}

.table-panel .table {
  margin-bottom: 0;
}

.table-panel .table thead th {
  font-size: 0.8125rem;
  font-weight: 700;
}

.empty-table-row td {
  padding: 2.5rem 1rem !important;
}

.form-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
  margin: 1.25rem 0 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid rgba(2, 6, 23, 0.08);
}

.form-section-title:first-child {
  margin-top: 0;
}

.btn-group-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

@media (max-width: 576px) {
  .toolbar-actions {
    width: 100%;
  }

  .toolbar-actions .btn {
    flex: 1 1 auto;
  }
}

/* Accessibility */
.skip-link {
  position: absolute;
  top: -100px;
  left: 12px;
  z-index: 4000;
  padding: 10px 16px;
  background: #fff;
  color: #0f172a;
  font-weight: 700;
  border-radius: 8px;
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(2, 6, 23, 0.2);
}

.skip-link:focus {
  top: 12px;
}

:focus-visible {
  outline: 2px solid var(--app-primary);
  outline-offset: 2px;
}

.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible {
  box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--app-primary) 25%, transparent);
}

/* Themed table headers */
.thead-themed th {
  background-color: var(--app-primary) !important;
  color: #fff !important;
  border-color: var(--app-primary-dark) !important;
}

/* Compact tables — hide extra columns on smaller screens */
@media (max-width: 992px) {
  .table-compact th.col-extra,
  .table-compact td.col-extra {
    display: none;
  }
}

@media (max-width: 768px) {
  .dash-hero {
    padding: 24px 20px;
  }
}

/* Dashboard */
.dash-hero {
  background: var(--app-dash-hero);
  color: #fff;
  border-radius: 20px;
  padding: 32px 36px;
  margin-bottom: 24px;
  box-shadow: 0 20px 50px var(--app-dash-hero-shadow);
}

.dash-hero h1 {
  font-size: clamp(26px, 3vw, 36px);
  font-weight: 800;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}

.dash-hero p {
  margin: 0;
  opacity: 0.92;
  font-size: 16px;
  font-weight: 500;
}

.dash-stat {
  background: #fff;
  border: 1px solid rgba(2, 6, 23, 0.08);
  border-radius: 16px;
  padding: 22px 24px;
  height: 100%;
  box-shadow: 0 10px 30px rgba(2, 6, 23, 0.06);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

@media (prefers-reduced-motion: no-preference) {
  .dash-stat:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 40px rgba(2, 6, 23, 0.1);
  }

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

.dash-stat-label {
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.dash-stat-value {
  font-size: clamp(26px, 2.5vw, 34px);
  font-weight: 800;
  color: #0f172a;
  line-height: 1.1;
}

.dash-stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 12px;
}

.dash-stat-icon.blue { background: var(--app-tint-bg); }
.dash-stat-icon.green { background: #dcfce7; }
.dash-stat-icon.purple { background: #ede9fe; }
.dash-stat-icon.amber { background: #fef3c7; }

.dash-action {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid rgba(2, 6, 23, 0.08);
  background: #fff;
  text-decoration: none;
  color: #0f172a;
  font-weight: 600;
  height: 100%;
  box-shadow: 0 8px 24px rgba(2, 6, 23, 0.05);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.dash-action:hover {
  background: #f8fafc;
  border-color: var(--app-dash-action-hover-border);
  color: var(--app-dash-action-hover-color);
}

.dash-action-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--app-dash-action-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.dash-section-title {
  font-size: 18px;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 14px;
}

.finance-items-table {
  margin-bottom: 1rem;
}
