/* Bluecrane Finance — Equation-inspired horizontal layout + Material elements */
:root {
  --bc-navy: #0f2347;
  --bc-navy-light: #1a3566;
  --bc-gold: #f4b41a;
  --bc-gold-dark: #d99a08;
  --bc-charcoal: #3d4654;
  --bc-muted: #6b7280;
  --bc-bg: #f0f2f5;
  --bc-surface: #ffffff;
  --bc-surface-muted: #fafbfc;
  --bc-surface-alt: #f8f9fb;
  --bc-border: #e5e7eb;
  --bc-input-border: #cfd4dc;
  --bc-shadow: 0 1px 3px rgba(15, 35, 71, 0.08), 0 4px 12px rgba(15, 35, 71, 0.06);
  --bc-shadow-lg: 0 8px 24px rgba(15, 35, 71, 0.12);
  --bc-radius: 10px;
  --bc-header-h: 64px;
  --bc-text-on-navy: #ffffff;
  --bc-link: var(--bc-navy);
  --bs-primary: var(--bc-navy);
  --bs-primary-rgb: 15, 35, 71;
  --bc-nav-hover: rgba(15, 35, 71, 0.06);
  --bc-nav-active: rgba(244, 180, 26, 0.18);
  --bc-table-hover: rgba(244, 180, 26, 0.06);
  color-scheme: light;
}

[data-theme="dark"] {
  --bc-navy: #dbeafe;
  --bc-navy-light: #93c5fd;
  --bc-gold: #f4b41a;
  --bc-gold-dark: #d99a08;
  --bc-charcoal: #e5e7eb;
  --bc-muted: #9ca3af;
  --bc-bg: #0b1220;
  --bc-surface: #141b2d;
  --bc-surface-muted: #1a2338;
  --bc-surface-alt: #1e2840;
  --bc-border: #2a3548;
  --bc-input-border: #3d4a63;
  --bc-shadow: 0 1px 3px rgba(0, 0, 0, 0.35), 0 4px 12px rgba(0, 0, 0, 0.25);
  --bc-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.45);
  --bc-text-on-navy: #f8fafc;
  --bc-link: #93c5fd;
  --bs-primary: #93c5fd;
  --bs-primary-rgb: 147, 197, 253;
  --bc-nav-hover: rgba(255, 255, 255, 0.08);
  --bc-nav-active: rgba(244, 180, 26, 0.22);
  --bc-table-hover: rgba(244, 180, 26, 0.1);
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  font-family: "Roboto", system-ui, -apple-system, sans-serif;
  background: var(--bc-bg);
  color: var(--bc-charcoal);
  min-height: 100vh;
}

/* ── Typography & Material icons ── */
.material-symbols-outlined {
  font-family: "Material Symbols Outlined";
  font-weight: normal;
  font-style: normal;
  font-size: 1.15rem;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
  user-select: none;
}

.header-nav .material-symbols-outlined {
  font-size: 1.05rem;
  min-width: 1.25rem;
  text-align: center;
}

/* ── Authenticated app shell ── */
.app-body { display: flex; flex-direction: column; min-height: 100vh; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 1030;
  height: var(--bc-header-h);
  background: var(--bc-surface);
  border-bottom: 1px solid var(--bc-border);
  box-shadow: var(--bc-shadow);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1rem;
  overflow: visible;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--bc-navy);
  flex-shrink: 0;
  min-width: 200px;
}

.header-brand img { height: 40px; width: auto; }

.header-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.header-brand-text .title {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.header-brand-text .subtitle {
  font-size: 0.68rem;
  color: var(--bc-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.header-nav {
  flex: 1;
  min-width: 0;
  overflow: visible;
  position: relative;
}

.header-nav-scroll {
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.header-nav .nav-item.dropdown {
  position: static;
}

.header-nav .nav {
  flex-wrap: nowrap;
  gap: 0.15rem;
}

.header-nav .nav-link {
  color: var(--bc-charcoal);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.header-nav .nav-link:hover,
.header-nav .nav-link:focus {
  background: var(--bc-nav-hover);
  color: var(--bc-navy);
}

.header-nav .nav-link.active {
  background: var(--bc-nav-active);
  color: var(--bc-navy);
}

.header-nav .dropdown-menu {
  border: 1px solid var(--bc-border);
  box-shadow: var(--bc-shadow-lg);
  border-radius: var(--bc-radius);
  padding: 0.35rem;
  z-index: 1055;
  margin-top: 0.35rem;
}

.header-nav .dropdown-menu.show {
  display: block;
}

.header-nav .dropdown-item {
  border-radius: 6px;
  font-size: 0.875rem;
  padding: 0.45rem 0.75rem;
}

.header-nav .dropdown-item:hover {
  background: var(--bc-nav-hover);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem 0.25rem 0.25rem;
  border-radius: 999px;
  border: 1px solid var(--bc-border);
  background: var(--bc-surface-muted);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--bc-navy), var(--bc-navy-light));
  color: var(--bc-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.user-meta { line-height: 1.2; }
.user-meta .name { font-size: 0.8rem; font-weight: 600; }
.user-meta .role { font-size: 0.68rem; color: var(--bc-muted); text-transform: capitalize; }

.app-content {
  flex: 1;
  padding: 1.5rem 1.25rem 2rem;
}

.app-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--bc-border);
  background: var(--bc-surface);
  font-size: 0.78rem;
  color: var(--bc-muted);
  text-align: center;
}

/* ── Page layout (Equation-style) ── */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.page-header h1 {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0;
  color: var(--bc-navy);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.breadcrumb-bar {
  background: var(--bc-surface);
  border: 1px solid var(--bc-border);
  border-radius: var(--bc-radius);
  padding: 0.65rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.82rem;
}

.breadcrumb-bar .breadcrumb { margin: 0; }

/* ── Material cards ── */
.card {
  border: 1px solid var(--bc-border);
  border-radius: var(--bc-radius);
  box-shadow: var(--bc-shadow);
  background: var(--bc-surface);
}

.card-header {
  background: var(--bc-surface-muted);
  border-bottom: 1px solid var(--bc-border);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--bc-navy);
  padding: 0.85rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.card-body { padding: 1.1rem; }

.kpi-card {
  border-left: 4px solid var(--bc-gold);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--bc-shadow-lg);
}

.kpi-card .kpi-label {
  font-size: 0.78rem;
  color: var(--bc-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-card .kpi-value {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--bc-navy);
}

/* ── Material form fields ── */
.form-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--bc-charcoal);
  margin-bottom: 0.35rem;
}

.form-control,
.form-select {
  border: 1px solid var(--bc-input-border);
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  font-size: 0.9rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: var(--bc-surface);
  color: var(--bc-charcoal);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--bc-navy-light);
  box-shadow: 0 0 0 3px rgba(15, 35, 71, 0.12);
}

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

.material-field {
  position: relative;
  margin-bottom: 1.1rem;
}

.material-field .form-control {
  padding-top: 1.1rem;
  padding-bottom: 0.45rem;
}

.material-field label {
  position: absolute;
  top: 0.55rem;
  left: 0.85rem;
  font-size: 0.9rem;
  color: var(--bc-muted);
  pointer-events: none;
  transition: all 0.15s ease;
}

.material-field .form-control:focus + label,
.material-field .form-control:not(:placeholder-shown) + label {
  top: 0.2rem;
  font-size: 0.68rem;
  color: var(--bc-navy);
  font-weight: 600;
}

.form-panel {
  background: var(--bc-surface);
  border: 1px solid var(--bc-border);
  border-radius: var(--bc-radius);
  box-shadow: var(--bc-shadow);
  padding: 1.5rem;
}

/* ── Buttons ── */
.btn {
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-primary {
  background: var(--bc-navy);
  border-color: var(--bc-navy);
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--bc-navy-light);
  border-color: var(--bc-navy-light);
}

.btn-accent {
  background: var(--bc-gold);
  border-color: var(--bc-gold);
  color: var(--bc-navy);
}

.btn-accent:hover {
  background: var(--bc-gold-dark);
  border-color: var(--bc-gold-dark);
  color: var(--bc-navy);
}

.btn-outline-primary {
  color: var(--bc-navy);
  border-color: var(--bc-navy);
}

.btn-outline-primary:hover {
  background: var(--bc-navy);
  border-color: var(--bc-navy);
}

/* ── Tables ── */
.table {
  margin-bottom: 0;
  font-size: 0.875rem;
}

.table thead th {
  background: var(--bc-surface-alt);
  color: var(--bc-navy);
  font-weight: 600;
  border-bottom-width: 1px;
  white-space: nowrap;
}

.table-hover tbody tr:hover { background: var(--bc-table-hover); }

.table-panel {
  background: var(--bc-surface);
  border: 1px solid var(--bc-border);
  border-radius: var(--bc-radius);
  box-shadow: var(--bc-shadow);
  overflow: hidden;
}

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

/* ── Alerts ── */
.alert {
  border: none;
  border-radius: var(--bc-radius);
  border-left: 4px solid;
  font-size: 0.875rem;
}

.alert-success { border-left-color: #22c55e; background: #f0fdf4; }
.alert-danger { border-left-color: #ef4444; background: #fef2f2; }
.alert-warning { border-left-color: var(--bc-gold); background: #fffbeb; }
.alert-info { border-left-color: #3b82f6; background: #eff6ff; }
.alert-secondary { border-left-color: #9ca3af; background: #f9fafb; }

.badge { font-weight: 500; border-radius: 6px; }

/* ── Auth pages (Equation cover / registration style) ── */
.auth-body {
  min-height: 100vh;
  display: flex;
  background: var(--bc-bg);
}

.auth-brand-panel {
  flex: 1;
  display: none;
  background: linear-gradient(145deg, var(--bc-navy) 0%, var(--bc-navy-light) 55%, #243f73 100%);
  color: #fff;
  padding: 3rem;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.auth-brand-panel::before {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: rgba(244, 180, 26, 0.08);
  top: -120px;
  right: -80px;
}

.auth-brand-panel .brand-logo { max-width: 320px; margin-bottom: 2rem; }

.auth-brand-panel h2 {
  font-weight: 700;
  font-size: 1.75rem;
  margin-bottom: 0.75rem;
}

.auth-brand-panel p {
  opacity: 0.85;
  max-width: 380px;
  line-height: 1.6;
}

.auth-form-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bc-surface);
  border: 1px solid var(--bc-border);
  border-radius: 14px;
  box-shadow: var(--bc-shadow-lg);
  padding: 2rem;
}

.auth-card-logo {
  display: block;
  max-width: 240px;
  margin: 0 auto 1.25rem;
}

.auth-card h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--bc-navy);
  text-align: center;
  margin-bottom: 0.25rem;
}

.auth-card .auth-subtitle {
  text-align: center;
  color: var(--bc-muted);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

.auth-card .btn-primary { width: 100%; padding: 0.65rem; }

@media (min-width: 992px) {
  .auth-brand-panel { display: flex; }
}

.header-actions .dropdown-menu {
  z-index: 1055;
}

.bc-mobile-nav .bc-mobile-section {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--bc-muted);
  background: var(--bc-surface-alt);
  padding-top: 0.75rem;
  padding-bottom: 0.35rem;
}

.bc-mobile-nav {
  background: var(--bc-surface);
  color: var(--bc-charcoal);
}

.bc-mobile-nav .list-group-item {
  background: var(--bc-surface);
  color: var(--bc-charcoal);
  border-color: var(--bc-border);
  min-height: 44px;
  display: flex;
  align-items: center;
}

.bc-mobile-nav .list-group-item-action:hover,
.bc-mobile-nav .list-group-item-action:focus {
  background: var(--bc-nav-hover);
  color: var(--bc-navy);
}

@media (max-width: 767px) {
  .app-content { padding: 1rem; padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
  .app-header {
    padding: 0 0.75rem;
    padding-left: calc(0.75rem + env(safe-area-inset-left));
    padding-right: calc(0.75rem + env(safe-area-inset-right));
    gap: 0.5rem;
  }
  .header-brand { min-width: auto; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-header .btn-group,
  .page-header .d-flex { width: 100%; flex-wrap: wrap; }
  .form-panel { padding: 1rem; }
  .btn { min-height: 44px; }
  .btn-sm { min-height: 38px; }
  .table-panel { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table { font-size: 0.8125rem; }
  .kpi-card .kpi-value { font-size: 1.2rem; }
}

@media (max-width: 991px) {
  .header-nav { display: none; }
  .header-brand-text { display: none; }
  .user-meta { display: none; }
  .header-actions .user-chip { border: none; padding: 0.15rem; background: transparent; }
}

@media (min-width: 992px) {
  .nav-mobile-toggle { display: none !important; }
  .bc-mobile-theme { display: none; }
}

/* ── Theme switcher ── */
.theme-switcher {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.theme-switcher-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--bc-muted);
}

.theme-switcher-options {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.2rem;
  border-radius: 999px;
  border: 1px solid var(--bc-border);
  background: var(--bc-surface-muted);
}

.theme-switcher-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: none;
  background: transparent;
  color: var(--bc-muted);
  border-radius: 999px;
  padding: 0.35rem 0.55rem;
  min-width: 36px;
  min-height: 36px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.theme-switcher-btn .material-symbols-outlined {
  font-size: 1.05rem;
}

.theme-switcher-btn:hover,
.theme-switcher-btn:focus-visible {
  background: var(--bc-nav-hover);
  color: var(--bc-navy);
  outline: none;
}

.theme-switcher-btn.active {
  background: var(--bc-surface);
  color: var(--bc-navy);
  box-shadow: var(--bc-shadow);
}

.theme-switcher--full {
  flex-direction: column;
  align-items: stretch;
  gap: 0.45rem;
}

.theme-switcher--full .theme-switcher-options {
  width: 100%;
  justify-content: stretch;
}

.theme-switcher--full .theme-switcher-btn {
  flex: 1;
  min-height: 44px;
}

.auth-theme-bar {
  position: fixed;
  top: calc(0.75rem + env(safe-area-inset-top));
  right: calc(0.75rem + env(safe-area-inset-right));
  z-index: 1040;
}

.bc-mobile-theme {
  padding: 0.75rem;
  border: 1px solid var(--bc-border);
  border-radius: var(--bc-radius);
  background: var(--bc-surface-muted);
}

/* ── Dark mode component tweaks ── */
[data-theme="dark"] .btn-primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

[data-theme="dark"] .btn-primary:hover,
[data-theme="dark"] .btn-primary:focus {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

[data-theme="dark"] .btn-outline-primary {
  color: var(--bc-link);
  border-color: var(--bc-link);
}

[data-theme="dark"] .btn-outline-secondary {
  color: var(--bc-charcoal);
  border-color: var(--bc-border);
}

[data-theme="dark"] .alert-success { background: #052e16; color: #bbf7d0; }
[data-theme="dark"] .alert-danger { background: #450a0a; color: #fecaca; }
[data-theme="dark"] .alert-warning { background: #422006; color: #fde68a; }
[data-theme="dark"] .alert-info { background: #172554; color: #bfdbfe; }
[data-theme="dark"] .alert-secondary { background: #1f2937; color: #e5e7eb; }

[data-theme="dark"] .dropdown-menu {
  background: var(--bc-surface);
  border-color: var(--bc-border);
}

[data-theme="dark"] .dropdown-item {
  color: var(--bc-charcoal);
}

[data-theme="dark"] .dropdown-item:hover {
  background: var(--bc-nav-hover);
  color: var(--bc-navy);
}

[data-theme="dark"] .user-avatar {
  background: linear-gradient(135deg, #1e3a5f, #2563eb);
}

[data-theme="dark"] .auth-card,
[data-theme="dark"] .offcanvas {
  background: var(--bc-surface);
  color: var(--bc-charcoal);
}

[data-theme="dark"] .offcanvas-header {
  border-bottom: 1px solid var(--bc-border);
}

[data-theme="dark"] .btn-close {
  filter: invert(1) grayscale(1);
}

/* ── Responsive utilities ── */
.mobile-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

@media (max-width: 575px) {
  .mobile-stack > * { flex: 1 1 100%; }
  .mobile-hide { display: none !important; }
}

.touch-scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

@media (max-width: 767px) {
  .theme-switcher--compact .theme-switcher-btn {
    min-width: 34px;
    padding: 0.3rem 0.4rem;
  }
  .theme-switcher--compact .theme-switcher-text { display: none; }
}
