/*
  =========================================
  MitraBooks ERP - Theme Enhancement CSS
  =========================================
  Enhances app-shell.css with theme tokens for dark/light mode support.
  PWA-safe: zero external dependencies, works with existing HTML structure.
*/

/* ============================================
   THEME AWARE OVERRIDES FOR EXISTING CLASSES
   ============================================ */

/* Dark theme (default) - override app-shell.css hardcoded colors */
html[data-theme="dark"] {
  --bg: var(--bg-primary, #090c14);
  --panel: var(--bg-secondary, #0f1424);
  --panel-2: var(--bg-card, rgba(18, 25, 47, 0.65));
  --text: var(--text-primary, #f8fafc);
  --muted: var(--text-secondary, #94a3b8);
  --border: var(--border-color, rgba(255, 255, 255, 0.08));
  --accent: var(--accent-color, #3b82f6);
  --success: var(--success-color, #10b981);
  --warning: var(--warning-color, #f59e0b);
  --danger: var(--danger-color, #ef4444);
}

/* Light theme - override for light mode */
html[data-theme="light"] {
  --bg: var(--bg-primary, #f8fafc);
  --panel: var(--bg-secondary, #ffffff);
  --panel-2: var(--bg-card, rgba(255, 255, 255, 0.85));
  --text: var(--text-primary, #0f172a);
  --muted: var(--text-secondary, #475569);
  --border: var(--border-color, rgba(0, 0, 0, 0.08));
  --accent: var(--accent-color, #2563eb);
  --success: var(--success-color, #059669);
  --warning: var(--warning-color, #d97706);
  --danger: var(--danger-color, #dc2626);
}

body {
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ============================================
   ENHANCE EXISTING SIDEBAR
   ============================================ */

.sidebar {
  transition: background-color 0.3s ease, color 0.3s ease;
}

html[data-theme="dark"] .sidebar {
  background: var(--bg-sidebar, #0a0d18) !important;
  border-color: var(--border-color, rgba(255, 255, 255, 0.08)) !important;
}

html[data-theme="light"] .sidebar {
  background: var(--bg-secondary, #ffffff) !important;
  border-color: var(--border-color, rgba(0, 0, 0, 0.08)) !important;
}

/* ============================================
   ENHANCE BRAND SECTION
   ============================================ */

.brand {
  position: relative;
}

html[data-theme="dark"] .brand {
  color: #e2e8f0;
}

html[data-theme="dark"] .brand h1 {
  color: #e2e8f0;
}

html[data-theme="dark"] .brand p {
  color: #94a3b8;
}

/* ============================================
   ENHANCE NAVIGATION
   ============================================ */

.nav a,
.nav button {
  transition: var(--transition-smooth, all 0.25s ease);
}

html[data-theme="dark"] .nav a,
html[data-theme="dark"] .nav button {
  color: #94a3b8;
}

html[data-theme="dark"] .nav a:hover,
html[data-theme="dark"] .nav button:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
}

html[data-theme="dark"] .nav a.active,
html[data-theme="dark"] .nav button.active {
  background: rgba(var(--accent-rgb, 59, 130, 246), 0.1);
  color: var(--accent-color, #3b82f6);
}

html[data-theme="light"] .nav a:hover,
html[data-theme="light"] .nav button:hover {
  background: rgba(0, 0, 0, 0.05);
}

html[data-theme="light"] .nav a.active,
html[data-theme="light"] .nav button.active {
  color: var(--accent-color, #2563eb);
}

/* ============================================
   ENHANCE TOPBAR/HEADER
   ============================================ */

.topbar {
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

html[data-theme="dark"] .topbar {
  background: var(--bg-secondary, #0f1424) !important;
  border-color: var(--border-color, rgba(255, 255, 255, 0.08)) !important;
}

html[data-theme="light"] .topbar {
  background: var(--bg-secondary, #ffffff) !important;
  border-color: var(--border-color, rgba(0, 0, 0, 0.08)) !important;
}

/* ============================================
   ENHANCE BUTTONS
   ============================================ */

.secondary {
  transition: var(--transition-smooth, all 0.25s ease);
}

html[data-theme="dark"] .secondary {
  background: rgba(255, 255, 255, 0.05) !important;
  color: #94a3b8 !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
}

html[data-theme="dark"] .secondary:hover {
  background: rgba(255, 255, 255, 0.09) !important;
  border-color: rgba(255, 255, 255, 0.15) !important;
}

/* ============================================
   HEALTH/PILL WIDGET
   ============================================ */

.pill {
  transition: var(--transition-smooth, all 0.25s ease);
}

html[data-theme="dark"] .pill {
  background: rgba(var(--accent-rgb, 59, 130, 246), 0.1);
  border-color: rgba(var(--accent-rgb, 59, 130, 246), 0.2);
  color: var(--accent-color, #3b82f6);
}

html[data-theme="light"] .pill {
  background: rgba(var(--accent-rgb, 37, 99, 235), 0.08);
  border-color: rgba(var(--accent-rgb, 37, 99, 235), 0.15);
  color: var(--accent-color, #2563eb);
}

/* ============================================
   CONTENT AREA
   ============================================ */

.content {
  transition: background-color 0.3s ease, color 0.3s ease;
}

html[data-theme="dark"] .content {
  background: var(--bg-primary, #090c14) !important;
}

html[data-theme="light"] .content {
  background: var(--bg-primary, #f8fafc) !important;
}

/* ============================================
   CARD STYLING
   ============================================ */

.card {
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

html[data-theme="dark"] .card {
  background: var(--bg-card, rgba(18, 25, 47, 0.65)) !important;
  border-color: var(--border-color, rgba(255, 255, 255, 0.08)) !important;
  color: var(--text-primary, #f8fafc);
}

html[data-theme="light"] .card {
  background: var(--bg-card, rgba(255, 255, 255, 0.85)) !important;
  border-color: var(--border-color, rgba(0, 0, 0, 0.08)) !important;
  color: var(--text-primary, #0f172a);
}

/* ============================================
   FORM ELEMENTS
   ============================================ */

input,
textarea,
select {
  transition: var(--transition-smooth, all 0.25s ease);
}

html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
  background: var(--bg-input, #12182e) !important;
  color: var(--text-primary, #f8fafc) !important;
  border-color: var(--border-color, rgba(255, 255, 255, 0.08)) !important;
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: var(--text-muted, #475569) !important;
}

html[data-theme="dark"] input:focus,
html[data-theme="dark"] textarea:focus,
html[data-theme="dark"] select:focus {
  border-color: var(--border-color-focus, rgba(59, 130, 246, 0.5)) !important;
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb, 59, 130, 246), 0.1) !important;
}

html[data-theme="light"] input,
html[data-theme="light"] textarea,
html[data-theme="light"] select {
  background: var(--bg-input, #f1f5f9) !important;
  color: var(--text-primary, #0f172a) !important;
  border-color: var(--border-color, rgba(0, 0, 0, 0.08)) !important;
}

html[data-theme="light"] input:focus,
html[data-theme="light"] textarea:focus,
html[data-theme="light"] select:focus {
  border-color: var(--border-color-focus, rgba(37, 99, 235, 0.5)) !important;
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb, 37, 99, 235), 0.08) !important;
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.animate-slide-down {
  animation: slideDown 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.animate-fade-in {
  animation: fadeIn 0.3s ease;
}

/* ============================================
   MITRABOOKS ERP REDESIGNED SHELL
   ============================================ */

.erp-sidebar {
  background: var(--bg-sidebar, #0a0d18);
  border-right: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 100vh;
  padding: 18px 16px;
  position: sticky;
  top: 0;
}

.erp-brand {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: 44px 1fr;
  isolation: isolate;
  min-height: 60px;
}

.brand-mark {
  background: var(--accent-color, #3b82f6);
  border-radius: 8px;
  filter: blur(12px);
  height: 42px;
  opacity: 0.25;
  position: absolute;
  width: 42px;
  z-index: -1;
}

.erp-brand .brand-logo {
  border-radius: 8px;
  height: 44px;
  object-fit: contain;
  width: 44px;
}

.brand-text h1 {
  color: var(--text-primary, #f8fafc);
  font-size: 18px;
  line-height: 1.15;
  margin: 0;
}

.brand-text p {
  color: var(--text-secondary, #94a3b8);
  font-size: 12px;
  line-height: 1.35;
  margin: 2px 0 0;
}

.org-selector,
.fy-selector {
  position: relative;
}

.selected-org,
.fy-badge,
.theme-btn,
.user-profile-tile,
.pwa-status-widget {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: var(--text-primary, #f8fafc);
}

.selected-org {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 12px;
  padding: 10px 12px;
  text-align: left;
  width: 100%;
}

.context-dot {
  background: var(--accent-color, #3b82f6);
  border-radius: 999px;
  box-shadow: 0 0 8px var(--accent-color, #3b82f6);
  flex: 0 0 10px;
  height: 10px;
  width: 10px;
}

.muted-dot {
  background: rgba(255, 255, 255, 0.35);
  box-shadow: none;
}

.context-copy,
.user-details,
.pwa-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.context-copy span,
.context-copy small,
.user-details strong,
.user-details span,
.pwa-details span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.context-copy span,
.org-option strong,
.user-details strong,
.pwa-details strong {
  font-size: 12px;
  font-weight: 700;
}

.context-copy small,
.org-option small,
.fy-selector,
.user-details span,
.pwa-details span {
  color: var(--text-secondary, #94a3b8);
  font-size: 11px;
}

.chevron-icon {
  color: var(--text-secondary, #94a3b8);
  flex: 0 0 14px;
  height: 14px;
  transition: transform 0.2s ease;
  width: 14px;
}

.org-selector.open .chevron-icon {
  transform: rotate(180deg);
}

.org-dropdown,
.fy-dropdown {
  background: var(--bg-secondary, #0f1424);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
  border-radius: 8px;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.35);
  left: 0;
  overflow: hidden;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 20;
}

.org-dropdown[hidden],
.fy-dropdown[hidden] {
  display: none;
}

.org-option,
.fy-option {
  cursor: pointer;
  display: flex;
  gap: 12px;
  padding: 11px 12px;
}

.org-option:not(:last-child),
.fy-option:not(:last-child) {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.org-option:hover,
.fy-option:hover,
.org-option.active,
.fy-option.active {
  background: rgba(var(--accent-rgb, 59, 130, 246), 0.1);
}

.fy-selector {
  align-items: center;
  display: flex;
  gap: 8px;
  padding: 2px 0;
}

.fy-badge {
  align-items: center;
  cursor: pointer;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  gap: 6px;
  padding: 6px 10px;
}

.fy-badge svg {
  height: 10px;
  width: 10px;
}

.fy-dropdown {
  left: 0;
  min-width: 148px;
  right: auto;
}

.fy-option {
  color: var(--text-primary, #f8fafc);
  display: block;
  font-size: 12px;
}

.fy-option small {
  color: var(--text-secondary, #94a3b8);
}

.erp-sidebar .nav {
  align-content: start;
  display: grid;
  gap: 6px;
}

.nav-group-toggle {
  align-items: center;
  background: transparent;
  border: 0;
  color: var(--text-secondary, #94a3b8);
  cursor: pointer;
  display: flex;
  font-size: 11px;
  font-weight: 800;
  justify-content: space-between;
  min-height: 28px;
  padding: 8px 4px 4px;
  text-transform: none;
}

.nav-group-toggle span:last-child {
  color: var(--text-muted, #64748b);
  font-size: 11px;
  transition: transform 0.16s ease;
}

.nav-group-toggle[aria-expanded="false"] span:last-child {
  transform: rotate(-90deg);
}

.nav-group-items {
  display: grid;
  gap: 4px;
}

.nav-group-items[hidden] {
  display: none;
}

.erp-sidebar .nav a.erp-nav-link {
  border-color: transparent;
  border-radius: 8px;
  display: grid;
  gap: 9px;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  min-height: 38px;
  padding: 7px 10px;
}

.erp-sidebar .nav a.erp-nav-link::before {
  content: none;
}

.nav-icon {
  align-items: center;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(96, 165, 250, 0.22);
  border-radius: 6px;
  color: #93c5fd;
  display: inline-flex;
  font-size: 10px;
  font-weight: 800;
  height: 24px;
  justify-content: center;
  width: 24px;
}

.nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-badge {
  align-self: center;
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.26);
  border-radius: 999px;
  color: #86efac;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
}

.erp-sidebar .nav a.erp-nav-link.locked {
  opacity: 0.62;
}

.erp-sidebar .nav a.erp-nav-link.locked .nav-icon {
  background: rgba(148, 163, 184, 0.08);
  border-color: rgba(148, 163, 184, 0.14);
  color: #94a3b8;
}

.app:not(.mandir-theme):not(.gruha-theme):not(.legal-theme):not(.invest-theme) .erp-sidebar .nav a.erp-nav-link.active {
  background: #ffffff;
  border-color: #ffffff;
  color: #111827;
}

.erp-sidebar .nav a.erp-nav-link.active .nav-icon {
  background: #dbeafe;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.sidebar-footer {
  border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: auto;
  padding-top: 14px;
}

.pwa-status-widget,
.user-profile-tile {
  align-items: center;
  display: flex;
  gap: 10px;
  padding: 10px;
}

.pwa-dot {
  background: var(--success-color, #10b981);
  border-radius: 999px;
  box-shadow: 0 0 6px var(--success-color, #10b981);
  height: 8px;
  width: 8px;
}

.theme-switcher {
  display: flex;
  gap: 8px;
}

.theme-btn {
  align-items: center;
  cursor: pointer;
  display: inline-flex;
  flex: 1;
  justify-content: center;
  min-height: 34px;
}

.theme-btn.active {
  border-color: rgba(var(--accent-rgb, 59, 130, 246), 0.45);
  color: var(--accent-color, #3b82f6);
}

.theme-btn svg {
  height: 15px;
  width: 15px;
}

.avatar {
  align-items: center;
  background: var(--accent-color, #3b82f6);
  border-radius: 999px;
  color: #ffffff;
  display: inline-flex;
  flex: 0 0 32px;
  font-size: 12px;
  font-weight: 800;
  height: 32px;
  justify-content: center;
  width: 32px;
}

.erp-topbar {
  align-items: center;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  min-height: 78px;
  padding: 16px 24px;
}

.page-title-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.breadcrumb {
  align-items: center;
  color: var(--text-secondary, #94a3b8);
  display: flex;
  font-size: 12px;
  gap: 8px;
}

.breadcrumb strong,
.page-title-block h1 {
  color: var(--text-primary, #f8fafc);
}

.page-title-block h1 {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}

.topbar-control-strip {
  align-items: center;
  display: flex;
  gap: 14px;
  margin-left: auto;
}

.health-score-widget {
  align-items: center;
  background: rgba(var(--warning-rgb, 245, 158, 11), 0.08);
  border: 1px solid rgba(var(--warning-rgb, 245, 158, 11), 0.22);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  min-width: 150px;
  padding: 8px 10px;
}

.health-score-widget.ok {
  background: rgba(var(--success-rgb, 16, 185, 129), 0.08);
  border-color: rgba(var(--success-rgb, 16, 185, 129), 0.25);
}

.health-score-widget.pending {
  background: rgba(148, 163, 184, 0.08);
  border-color: rgba(148, 163, 184, 0.18);
}

.circular-chart {
  flex: 0 0 40px;
  height: 40px;
  width: 40px;
}

.circle-bg,
.circle {
  fill: none;
  stroke-width: 2;
}

.circle-bg {
  stroke: rgba(148, 163, 184, 0.25);
}

.circle {
  stroke: var(--warning-color, #f59e0b);
  stroke-linecap: round;
  transition: stroke-dasharray 0.25s ease;
}

.health-score-widget.ok .circle {
  stroke: var(--success-color, #10b981);
}

.health-score-widget.pending .circle {
  stroke: var(--text-secondary, #94a3b8);
}

.percentage {
  fill: currentColor;
  font-size: 10px;
  font-weight: 800;
  text-anchor: middle;
}

.health-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.health-text strong {
  color: var(--text-primary, #f8fafc);
  font-size: 12px;
}

.health-text span {
  color: var(--text-secondary, #94a3b8);
  font-size: 11px;
}

.action-buttons {
  align-items: center;
  display: flex;
  gap: 10px;
}

.btn {
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  min-height: 38px;
  padding: 8px 14px;
}

.btn-primary {
  background: var(--accent-color, #3b82f6);
  border: 1px solid var(--accent-color, #3b82f6);
  color: #ffffff;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary, #f8fafc);
}

.btn:hover,
.theme-btn:hover,
.selected-org:hover,
.fy-badge:hover {
  filter: brightness(1.08);
}

.advanced-connection,
.technical-context[hidden] {
  display: none !important;
}

.app.signed-out {
  display: block;
  min-height: 100vh;
}

.app.signed-out .erp-sidebar,
.app.signed-out .erp-topbar,
.app.signed-out #context-cards,
.app.signed-out #legacy-strip,
.app.signed-out #dashboard-preview,
.app.signed-out .technical-context {
  display: none !important;
}

.app.signed-out .main {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.app.signed-out .content {
  background:
    linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(16, 185, 129, 0.08)),
    var(--bg-primary, #090c14) !important;
  display: grid;
  min-height: 100vh;
  padding: 28px;
  place-items: center;
  width: 100%;
}

.app.signed-out #access-panel {
  max-width: 760px;
  width: min(760px, 100%);
}

.app.signed-in:not(.mandir-domain) #access-panel {
  display: none;
}

.app.signed-in:not(.mandir-domain) #context-cards {
  display: none;
}

.app.signed-in:not(.mandir-domain) .main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 100vh;
  min-width: 0;
}

.app.signed-in:not(.mandir-domain) .content {
  min-width: 0;
  overflow-x: hidden;
}

.app.signed-in:not(.mandir-domain) #legacy-strip {
  display: none;
}

.module-switch[hidden],
.mandir-login-links[hidden] {
  display: none !important;
}

.business-context-cards .card {
  min-height: 148px;
}

.business-context-cards h3 {
  margin-bottom: 10px;
}

.dashboard-command-card,
.ceo-insight-card {
  display: grid;
  gap: 16px;
}

.mini-kpi-row {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mini-kpi-row span {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(96, 165, 250, 0.18);
  border-radius: 8px;
  color: var(--text-secondary, #94a3b8);
  display: grid;
  gap: 4px;
  padding: 10px 12px;
}

.mini-kpi-row strong {
  color: var(--text-primary, #f8fafc);
  font-size: 18px;
}

.business-dashboard {
  display: grid;
  gap: 18px;
}

.business-dashboard .preview-heading {
  align-items: start;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.16), rgba(16, 185, 129, 0.08));
  border: 1px solid rgba(var(--accent-rgb, 59, 130, 246), 0.22);
  border-radius: 8px;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  padding: 18px;
}

.business-dashboard .preview-heading h3 {
  font-size: 24px;
  margin: 0 0 6px;
}

.business-dashboard .preview-heading p {
  max-width: 760px;
}

.erp-workbench-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.erp-workbench-card {
  background: var(--bg-card, rgba(18, 25, 47, 0.65));
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  border-radius: 8px;
  display: grid;
  gap: 8px;
  min-height: 188px;
  padding: 16px;
}

.erp-workbench-card h4 {
  color: var(--text-primary, #f8fafc);
  font-size: 17px;
  margin: 0;
}

.erp-workbench-card strong {
  color: var(--text-primary, #f8fafc);
  font-size: 30px;
  line-height: 1;
}

.erp-workbench-card p {
  color: var(--text-secondary, #94a3b8);
  margin: 0;
}

.erp-workbench-card button {
  align-self: end;
  justify-self: start;
}

.executive-dashboard {
  display: grid;
  gap: 16px;
}

.executive-hero,
.finance-chart-card,
.ceo-panel {
  background: var(--bg-card, rgba(18, 25, 47, 0.65));
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  border-radius: 8px;
}

.executive-hero {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(260px, 0.92fr) minmax(360px, 1.08fr);
  padding: 18px;
}

.executive-hero h3 {
  color: var(--text-primary, #f8fafc);
  font-size: 24px;
  margin: 6px 0 8px;
}

.executive-hero p,
.ceo-panel p,
.finance-chart-card p {
  color: var(--text-secondary, #94a3b8);
  margin: 0;
}

.executive-kpi-strip {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.executive-kpi-strip article {
  background: rgba(15, 23, 42, 0.54);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  min-height: 116px;
  padding: 14px;
}

.executive-kpi-strip span,
.executive-kpi-strip small {
  color: var(--text-secondary, #94a3b8);
}

.executive-kpi-strip strong {
  color: var(--text-primary, #f8fafc);
  font-size: 25px;
  line-height: 1.1;
}

.finance-dashboard-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(420px, 1.35fr) minmax(300px, 0.65fr);
}

.finance-chart-card,
.ceo-panel {
  padding: 16px;
}

.finance-chart {
  align-items: end;
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(6, minmax(44px, 1fr));
  min-height: 190px;
  padding: 18px 4px 6px;
}

.finance-bar-group {
  align-items: center;
  display: grid;
  gap: 8px;
  justify-items: center;
}

.finance-bars {
  align-items: end;
  display: flex;
  gap: 7px;
  height: 140px;
}

.finance-bars span {
  border-radius: 999px 999px 4px 4px;
  display: block;
  width: 16px;
}

.income-bar {
  background: linear-gradient(180deg, #22c55e, #16a34a);
}

.expense-bar {
  background: linear-gradient(180deg, #38bdf8, #2563eb);
}

.finance-bar-group small,
.chart-legend {
  color: var(--text-secondary, #94a3b8);
}

.chart-legend {
  display: flex;
  gap: 16px;
  justify-content: flex-end;
}

.chart-legend span {
  align-items: center;
  display: inline-flex;
  gap: 7px;
}

.chart-legend i {
  border-radius: 999px;
  display: inline-block;
  height: 9px;
  width: 9px;
}

.income-dot {
  background: #22c55e;
}

.expense-dot {
  background: #38bdf8;
}

.ceo-panel {
  background:
    radial-gradient(circle at 14% 10%, rgba(168, 85, 247, 0.16), transparent 28%),
    linear-gradient(135deg, rgba(18, 25, 47, 0.92), rgba(20, 24, 54, 0.82));
  overflow: hidden;
}

.ceo-title-block {
  column-gap: 10px;
  display: grid;
  grid-template-columns: auto auto 1fr;
  row-gap: 2px;
}

.ceo-title-block h4 {
  margin: 0;
}

.ceo-title-block p {
  grid-column: 1 / -1;
}

.ceo-orbit {
  align-self: center;
  border: 2px solid rgba(168, 85, 247, 0.7);
  border-radius: 999px;
  box-shadow: 0 0 18px rgba(168, 85, 247, 0.45);
  height: 16px;
  position: relative;
  width: 16px;
}

.ceo-orbit::after {
  background: #c084fc;
  border-radius: 999px;
  content: "";
  height: 5px;
  left: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 5px;
}

.ai-badge {
  align-self: center;
  background: rgba(126, 34, 206, 0.58);
  border: 1px solid rgba(168, 85, 247, 0.42);
  border-radius: 999px;
  color: #d8b4fe;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  padding: 6px 10px;
  width: max-content;
}

.ceo-insight-list {
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  display: grid;
  gap: 18px;
  margin-top: 18px;
  padding-bottom: 18px;
}

.ceo-insight-row {
  align-items: start;
  color: var(--text-primary, #f8fafc);
  display: grid;
  font-weight: 650;
  gap: 10px 12px;
  grid-template-columns: 14px minmax(120px, 1.1fr) minmax(74px, auto) minmax(110px, 0.9fr);
  line-height: 1.45;
}

.ceo-insight-row strong {
  color: var(--text-primary, #f8fafc);
  font-size: 18px;
  line-height: 1.25;
}

.insight-spark {
  align-self: start;
  height: 14px;
  margin-top: 4px;
  position: relative;
  width: 14px;
}

.insight-spark::before {
  background: #c084fc;
  clip-path: polygon(50% 0, 64% 36%, 100% 50%, 64% 64%, 50% 100%, 36% 64%, 0 50%, 36% 36%);
  content: "";
  display: block;
  height: 14px;
  width: 14px;
}

.ceo-ask-row {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto;
  margin-top: 18px;
}

.ceo-ask-row input {
  background: rgba(15, 23, 42, 0.58);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  color: var(--text-primary, #f8fafc);
  min-height: 44px;
  min-width: 0;
  padding: 0 14px;
}

.ceo-ask-row input::placeholder {
  color: rgba(148, 163, 184, 0.72);
}

.ceo-ask-row button {
  background: #3b82f6;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  font-weight: 800;
  min-height: 44px;
  padding: 0 18px;
}

.ceo-footnote {
  color: var(--text-secondary, #94a3b8);
  font-size: 12px;
  margin-top: 12px;
}

.workbench-kicker {
  color: var(--accent-color, #3b82f6);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-tile,
.dashboard-main-grid > article,
.verification-panel,
.erp-health-panel,
.accounting-drilldown-panel,
.trend-panel,
.table-preview,
.entry-panel {
  border-radius: 8px;
}

html[data-theme="light"] .erp-sidebar .brand-text h1,
html[data-theme="light"] .erp-sidebar .brand-text p,
html[data-theme="light"] .erp-sidebar .context-copy span,
html[data-theme="light"] .erp-sidebar .user-details strong,
html[data-theme="light"] .erp-sidebar .pwa-details strong {
  color: var(--text-primary, #0f172a);
}

html[data-theme="light"] .erp-sidebar .context-copy small,
html[data-theme="light"] .erp-sidebar .user-details span,
html[data-theme="light"] .erp-sidebar .pwa-details span,
html[data-theme="light"] .fy-selector {
  color: var(--text-secondary, #475569);
}

/* ============================================
   LOGIN FORM ENHANCEMENTS
   ============================================ */

.password-field-wrapper {
  display: flex;
  gap: 0;
  position: relative;
  width: 100%;
}

.password-field-wrapper input {
  border-radius: 6px 0 0 6px !important;
  padding-right: 40px !important;
  width: 100%;
}

.toggle-password-btn {
  background: var(--bg-input, #12182e);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  border-left: none;
  border-radius: 0 6px 6px 0;
  color: var(--text-secondary, #94a3b8);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  position: relative;
  transition: all 0.25s ease;
  width: 44px;
  flex-shrink: 0;
}

.toggle-password-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary, #f8fafc);
}

.toggle-password-btn svg {
  height: 18px;
  width: 18px;
}

.toggle-password-btn[aria-pressed="true"] {
  color: var(--accent-color, #3b82f6);
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

#login-form .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

#login-form label {
  color: var(--text-primary, #f8fafc);
  font-size: 13px;
  font-weight: 600;
}

#login-form input[type="email"],
#login-form input[type="password"],
#login-form input[type="text"] {
  border-radius: 6px;
  font-size: 14px;
  padding: 10px 12px;
}

#login-form input:focus {
  outline: none;
}

#login-form button {
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  min-height: 42px;
  padding: 10px 16px;
  transition: all 0.25s ease;
}

#login-form button[type="submit"] {
  background: var(--accent-color, #3b82f6);
  border: 1px solid var(--accent-color, #3b82f6);
  color: #ffffff;
  width: 100%;
}

#login-form button[type="submit"]:hover:not(:disabled) {
  background: #2563eb;
  border-color: #2563eb;
  filter: brightness(1.08);
}

#login-form button[type="submit"]:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#login-form .secondary,
#login-form .danger {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary, #f8fafc);
  flex: 1;
}

#login-form .danger {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

#login-form .secondary:hover,
#login-form .danger:hover {
  filter: brightness(1.08);
}

#login-error-field {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 6px;
  margin: 0 !important;
  padding: 12px;
}

#login-error-field[hidden] {
  display: none;
}

#login-error-message {
  color: #fca5a5 !important;
  font-size: 14px;
  margin: 0 !important;
}

@media (max-width: 980px) {
  .app {
    display: block;
  }

  .erp-sidebar {
    min-height: auto;
    position: static;
  }

  .erp-topbar,
  .topbar-control-strip,
  .action-buttons {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-control-strip {
    width: 100%;
  }

  .health-score-widget,
  .action-buttons .btn {
    width: 100%;
  }

  .erp-workbench-grid {
    grid-template-columns: 1fr;
  }

  .mini-kpi-row,
  .executive-hero,
  .executive-kpi-strip,
  .finance-dashboard-grid {
    grid-template-columns: 1fr;
  }

  .finance-chart {
    gap: 8px;
    grid-template-columns: repeat(3, minmax(52px, 1fr));
  }
}

@media (max-width: 1260px) {
  .ceo-insight-row {
    grid-template-columns: 14px minmax(0, 1fr);
  }

  .ceo-insight-row strong {
    grid-column: 2;
  }

  .ceo-ask-row {
    grid-template-columns: 1fr;
  }
}
