/* ==========================================================================
   TallyBridge - Professional Corporate Financial Theme (Light & Crisp)
   ========================================================================== */

:root {
  --bg-main: #f8fafc;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-table-header: #f8fafc;
  --bg-table-hover: #f1f5f9;
  --bg-table-alt: #fcfdfe;

  --border-color: #e2e8f0;
  --border-highlight: #cbd5e1;
  --border-subtle: #f1f5f9;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-faint: #64748b;
  --text-inverse: #ffffff;

  --accent-primary: #1e40af;
  --accent-primary-hover: #1d4ed8;
  --accent-blue: #2563eb;
  --accent-emerald: #059669;
  --accent-amber: #d97706;
  --accent-purple: #7c3aed;
  --accent-rose: #dc2626;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-popover: 0 12px 30px rgba(15, 23, 42, 0.12), 0 4px 10px rgba(15, 23, 42, 0.06);

  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Executive Dark Mode */
body.dark-mode {
  --bg-main: #0b1120;
  --bg-sidebar: #0f172a;
  --bg-card: #131d33;
  --bg-card-hover: #1e293b;
  --bg-input: #1a243b;
  --bg-subtle: #1e293b;
  --bg-table-header: #152238;
  --bg-table-hover: #1e293b;
  --bg-table-alt: #10192e;

  --border-color: #27354f;
  --border-highlight: #3b4e6d;
  --border-subtle: #1e293b;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --text-inverse: #0b1120;

  --accent-primary: #3b82f6;
  --accent-primary-hover: #60a5fa;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.6);
  --shadow-popover: 0 16px 36px rgba(0, 0, 0, 0.7);
}

body.dark-mode .sidebar {
  background-color: var(--bg-sidebar);
  border-right-color: var(--border-color);
}

body.dark-mode .connection-widget {
  background: #111a2e;
  border-color: var(--border-color);
}

body.dark-mode .nav-item {
  color: var(--text-muted);
}
body.dark-mode .nav-item:hover {
  background-color: #1e293b;
  color: #fff;
}
body.dark-mode .nav-item.active {
  background-color: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.35);
  color: #60a5fa;
}

body.dark-mode .form-input,
body.dark-mode .form-select,
body.dark-mode .form-textarea {
  background-color: var(--bg-input);
  border-color: var(--border-color);
  color: var(--text-main);
}

body.dark-mode .card-header {
  background: var(--bg-card);
  border-bottom-color: var(--border-color);
}

body.dark-mode .filter-card,
body.dark-mode .chart-card {
  background: var(--bg-card);
  border-color: var(--border-color);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 250px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  padding: 1.25rem 1rem;
  box-shadow: var(--shadow-sm);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.5rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

.brand-title {
  display: block;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.brand-subtitle {
  display: block;
  font-size: 0.72rem;
  color: var(--text-faint);
}

/* Connection & Company Widget in Sidebar */
.connection-widget {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  margin: 1.25rem 0;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #94a3b8;
}

.status-dot.online {
  background-color: var(--accent-emerald);
  box-shadow: 0 0 6px var(--accent-emerald);
}

.status-dot.offline {
  background-color: var(--accent-rose);
}

.status-dot.pulse {
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { opacity: 0.6; }
  50% { opacity: 1; transform: scale(1.15); }
  100% { opacity: 0.6; }
}

.company-dropdown {
  background: #fff;
  border: 1px solid var(--border-highlight);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.connection-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-faint);
}

.separator {
  color: var(--border-color);
}

.btn-text-action {
  background: none;
  border: none;
  color: var(--accent-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0 0.25rem;
}
.btn-text-action:hover {
  text-decoration: underline;
}

/* Sidebar Nav */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-fast);
}

.nav-item:hover {
  background-color: #f1f5f9;
  color: var(--text-main);
}

.nav-item.active {
  background-color: #e0f2fe;
  border-color: #bae6fd;
  color: #0369a1;
  font-weight: 600;
}

.nav-item.active svg,
.nav-item:hover svg {
  color: #0284c7;
}

.nav-item svg {
  color: var(--text-faint);
  transition: color var(--transition-fast);
}

.nav-item .badge {
  margin-left: auto;
  background-color: #e2e8f0;
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-family: var(--font-mono);
}

.sidebar-footer {
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.dataset-source {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.75rem;
}

.source-tag {
  color: var(--accent-emerald);
  font-weight: 600;
}

.sync-time {
  color: var(--text-faint);
}

/* Main Content Area */
.main-wrapper {
  margin-left: 250px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Top Persistent Period & Company Bar */
.top-period-bar {
  position: sticky;
  top: 0;
  z-index: 90;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 0.65rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  box-shadow: var(--shadow-xs);
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.header-pill-group {
  display: inline-flex;
  align-items: center;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.28rem 0.65rem;
  gap: 0.5rem;
  transition: all var(--transition-fast);
}

.header-pill-group:hover,
.header-pill-group:focus-within {
  border-color: var(--border-highlight);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.08);
}

.header-pill-icon {
  color: var(--accent-primary);
  display: flex;
  align-items: center;
}

.header-pill-content {
  display: flex;
  flex-direction: column;
}

.header-micro-label {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  line-height: 1;
  margin-bottom: 2px;
}

.header-select {
  border: none;
  background: transparent;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  padding: 0;
  line-height: 1.2;
}

.header-select-company {
  max-width: 175px;
}

.header-select-period {
  min-width: 145px;
}

.header-select option {
  background: var(--bg-card);
  color: var(--text-main);
}

.header-divider {
  width: 1px;
  height: 24px;
  background-color: var(--border-color);
  flex-shrink: 0;
}

.header-dates-wrapper {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.22rem 0.55rem;
}

.header-date-input {
  border: none;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-main);
  outline: none;
  width: 110px;
}

.header-date-sep {
  color: var(--text-faint);
  font-size: 0.75rem;
}

.btn-filter-apply {
  background: var(--accent-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-xs);
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.btn-filter-apply:hover {
  background: var(--accent-primary-hover);
}

.period-badge-info {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.32rem 0.65rem;
  border-radius: var(--radius-md);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* Preferences Popover */
.popover-wrapper {
  position: relative;
}

.btn-header-tool {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.38rem 0.68rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-header-tool:hover {
  background: var(--bg-subtle);
  border-color: var(--border-highlight);
  color: var(--text-main);
}

.pref-badge-summary {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--accent-primary);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-xs);
  font-weight: 600;
}

.preferences-popover-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 290px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-popover);
  padding: 1rem;
  display: none;
  flex-direction: column;
  gap: 0.85rem;
  z-index: 200;
  animation: popoverFadeIn 0.18s ease-out;
}

.preferences-popover-menu.open {
  display: flex;
}

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

.popover-header {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.popover-header strong {
  font-size: 0.82rem;
  color: var(--text-main);
}

.popover-item {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.popover-item label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.popover-item select {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.78rem;
  padding: 0.42rem 0.55rem;
  outline: none;
  transition: border-color var(--transition-fast);
}

.popover-item select:focus {
  border-color: var(--accent-primary);
}

/* Auto-Sync Pill Switch */
.auto-sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.35rem 0.65rem;
  cursor: pointer;
  user-select: none;
  transition: all var(--transition-fast);
}

.auto-sync-pill:hover {
  border-color: var(--border-highlight);
}

.auto-sync-pill input[type="checkbox"] {
  display: none;
}

.sync-switch-slider {
  width: 26px;
  height: 14px;
  background-color: var(--border-highlight);
  border-radius: 999px;
  position: relative;
  transition: background-color var(--transition-fast);
}

.sync-switch-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  background-color: #ffffff;
  border-radius: 50%;
  transition: transform var(--transition-fast);
}

.auto-sync-pill input[type="checkbox"]:checked + .sync-switch-slider {
  background-color: var(--accent-emerald);
}

.auto-sync-pill input[type="checkbox"]:checked + .sync-switch-slider::after {
  transform: translateX(12px);
}

.sync-switch-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Sync Live Button */
.btn-sync-live {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--accent-primary);
  color: #ffffff;
  border: none;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.38rem 0.75rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(30, 64, 175, 0.2);
  transition: all var(--transition-fast);
}

.btn-sync-live:hover {
  background: var(--accent-primary-hover);
  transform: translateY(-1px);
}

.btn-sync-live svg {
  transition: transform 0.5s ease;
}

.btn-sync-live.loading svg {
  animation: spin 1s linear infinite;
}

/* Theme Toggle Button */
.btn-theme-toggle {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-theme-toggle:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
  border-color: var(--border-highlight);
}

.btn-theme-toggle .moon-icon {
  display: none;
}
.btn-theme-toggle .sun-icon {
  display: block;
}

body.dark-mode .btn-theme-toggle .sun-icon {
  display: none;
}
body.dark-mode .btn-theme-toggle .moon-icon {
  display: block;
  color: #fbbf24;
}

/* Content Container */
.content-container {
  padding: 1.75rem;
  max-width: 1600px;
  width: 100%;
}

.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
}

/* Page Header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.page-title {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.page-subtitle {
  font-size: 0.85rem;
  color: var(--text-faint);
  margin-top: 0.15rem;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* KPI Cards Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.15rem;
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  overflow: hidden;
}

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

.kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-card.accent-blue .kpi-icon { background: #eff6ff; color: #2563eb; }
.kpi-card.accent-purple .kpi-icon { background: #f5f3ff; color: #7c3aed; }
.kpi-card.accent-emerald .kpi-icon { background: #ecfdf5; color: #059669; }
.kpi-card.accent-amber .kpi-icon { background: #fffbeb; color: #d97706; }
.kpi-card.accent-rose .kpi-icon { background: #fef2f2; color: #dc2626; }

.kpi-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.kpi-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-value {
  font-size: clamp(0.92rem, 1.15vw, 1.15rem);
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text-main);
  letter-spacing: -0.02em;
  margin: 0.25rem 0;
  white-space: nowrap;
  line-height: 1.25;
}

.kpi-subtext {
  font-size: 0.75rem;
  color: var(--text-faint);
  line-height: 1.3;
}

/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.chart-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.chart-tag {
  font-size: 0.72rem;
  color: var(--text-faint);
  background: #f1f5f9;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
}

.chart-body {
  height: 260px;
  position: relative;
}

/* Dashboard Tables Grid */
.dashboard-tables-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
  gap: 1.25rem;
}

/* Card generic */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.card-body {
  padding: 1.25rem;
}
.card-body.p-0 {
  padding: 0;
}

/* Form Elements */
.form-input, .form-select, .form-textarea {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  font-family: inherit;
  transition: border-color var(--transition-fast);
  outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.1);
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.form-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-faint);
  margin-top: 0.25rem;
}

/* Filter Card */
.filter-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 250px;
}

.search-box svg {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
}

.search-input {
  width: 100%;
  padding-left: 2.25rem;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.select-compact, .input-compact {
  padding: 0.4rem 0.65rem;
  font-size: 0.8rem;
}

.input-number {
  width: 110px;
}

/* Summary Chips */
.summary-chips-bar {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.summary-chip {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  box-shadow: var(--shadow-sm);
}

.chip-label {
  color: var(--text-faint);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.78rem;
}

.btn-primary {
  background: #0284c7;
  color: #fff;
  box-shadow: 0 1px 3px rgba(2, 132, 199, 0.3);
}
.btn-primary:hover {
  background: #0369a1;
}

.btn-secondary {
  background: #ffffff;
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-secondary:hover {
  background: #f8fafc;
  border-color: var(--border-highlight);
}

.btn-excel {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
  font-weight: 600;
}
.btn-excel:hover {
  background: #d1fae5;
  border-color: #6ee7b7;
}

.btn-pdf {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
  font-weight: 600;
}
.btn-pdf:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

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

.btn-text {
  background: none;
  border: none;
  color: var(--accent-primary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-text:hover {
  text-decoration: underline;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.data-table th {
  background: #f8fafc;
  color: var(--text-faint);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 0.35rem 0.65rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
  line-height: 1.35;
  font-size: 0.83rem;
}

.data-table tbody tr:nth-child(even) {
  background-color: #fbfcfd;
}

.data-table tbody tr:hover {
  background-color: #f1f5f9;
}

/* Strictly aligned accounting columns */
.data-table th.text-right,
.data-table td.text-right,
.statement-table th.text-right,
.statement-table td.text-right {
  text-align: right !important;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  white-space: nowrap;
}

.data-table th.text-center,
.data-table td.text-center {
  text-align: center;
}

.total-row td {
  background-color: #f8fafc;
  font-weight: 700;
  border-top: 2px solid var(--border-highlight);
  border-bottom: 3px double #0f172a;
  font-size: 0.9rem;
}

/* Corporate Financial Statement Specific Table (GAAP & IFRS) — KPMG Illustrative Model */
/* ========================================================================= */
/* Corporate Financial Statements (Clean System-Generated Accounting Model) */
/* ========================================================================= */
.corporate-statement-card {
  padding: 1.25rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius-md);
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

/* Institutional Statement Header (Clean, dignified, zero blunt boxes) */
.statement-title-block {
  text-align: center;
  background: var(--bg-main) !important;
  color: var(--text-main) !important;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
  border: 1px solid var(--border-color) !important;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.statement-title-block h3 {
  font-family: var(--font-sans);
  font-size: 1.15rem !important;
  font-weight: 700 !important;
  color: var(--text-main) !important;
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.3;
}

.statement-title-block h4 {
  font-family: var(--font-sans);
  font-size: 0.82rem !important;
  font-weight: 700 !important;
  color: var(--accent-primary) !important;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0.15rem 0;
  line-height: 1.3;
}

.statement-period {
  font-size: 0.74rem !important;
  color: var(--text-muted) !important;
  font-family: var(--font-sans);
  font-weight: 500;
  display: inline-block;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.2rem 0.75rem;
  border-radius: 999px;
  margin-top: 0.25rem;
}

/* Institutional Financial Statement Table */
.statement-table,
#tab-reports .data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.82rem !important;
  line-height: 1.45 !important;
  font-family: var(--font-sans);
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-card);
}

.statement-table th,
#tab-reports .data-table th {
  padding: 0.55rem 0.85rem !important;
  font-size: 0.72rem !important;
  font-weight: 700 !important;
  color: var(--text-muted) !important;
  background: var(--bg-table-header) !important;
  border-bottom: 1px solid var(--border-color) !important;
  border-top: none !important;
  border-left: none !important;
  border-right: none !important;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-family: var(--font-sans);
  white-space: nowrap;
}

.statement-table td,
#tab-reports .data-table td {
  padding: 0.45rem 0.85rem !important;
  border-bottom: 1px solid var(--border-color) !important;
  border-top: none !important;
  border-left: none !important;
  border-right: none !important;
  line-height: 1.45 !important;
  font-family: var(--font-sans);
  color: var(--text-main) !important;
  font-size: 0.82rem !important;
}

.statement-table td.font-mono,
.statement-table td.text-right,
#tab-reports .data-table td.text-right {
  font-family: var(--font-mono) !important;
  font-size: 0.82rem !important;
  font-feature-settings: 'tnum' 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

/* Subtle Alternate & Hover Row */
.statement-table tbody tr:hover td,
#tab-reports .data-table tbody tr:hover td {
  background-color: var(--bg-table-hover) !important;
}

/* Section Header Rows (Major categories: ASSETS, LIABILITIES, REVENUE, etc.) */
.section-header-row td {
  font-weight: 700 !important;
  color: var(--accent-primary) !important;
  background: var(--bg-table-header) !important;
  border-top: 1px solid var(--border-color) !important;
  border-bottom: 1px solid var(--border-color) !important;
  padding: 0.5rem 0.85rem !important;
  font-size: 0.78rem !important;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-family: var(--font-sans);
}

/* Sub-header rows */
.sub-header-row td {
  font-weight: 600 !important;
  color: var(--text-main) !important;
  background: var(--bg-main) !important;
  border-bottom: 1px solid var(--border-color) !important;
  padding: 0.4rem 0.85rem !important;
  font-size: 0.8rem !important;
  font-family: var(--font-sans);
}

/* Subtotals */
.subtotal-row td {
  font-weight: 600 !important;
  border-top: 1px solid var(--border-highlight) !important;
  border-bottom: 1px solid var(--border-color) !important;
  color: var(--text-main) !important;
  padding: 0.45rem 0.85rem !important;
  background: var(--bg-main) !important;
  font-size: 0.82rem !important;
}

/* Grand Totals (Classic Financial Double-Underline) */
.grand-total-row td,
#tab-reports .total-row td {
  font-weight: 700 !important;
  font-size: 0.86rem !important;
  color: var(--text-main) !important;
  padding: 0.55rem 0.85rem !important;
  background: var(--bg-subtle) !important;
  border-top: 1.5px solid var(--text-main) !important;
  border-bottom: none !important;
}

.grand-total-row td.text-right,
#tab-reports .total-row td.text-right {
  border-bottom: 3.5px double var(--text-main) !important;
}

/* Template Selector Pill */
.template-selector-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.3rem 0.65rem;
  box-shadow: var(--shadow-xs);
}

.template-selector-pill select {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  background: var(--bg-main);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
}

/* Badges & Tags */
.vch-type-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  text-transform: uppercase;
  font-family: var(--font-mono);
}

.vch-type-badge.journal { background: #f3e8ff; color: #6b21a8; }
.vch-type-badge.receipt { background: #ecfdf5; color: #065f46; }
.vch-type-badge.payment { background: #fef2f2; color: #991b1b; }
.vch-type-badge.sales { background: #eff6ff; color: #1e40af; }
.vch-type-badge.purchase { background: #fffbeb; color: #92400e; }

.category-pill {
  font-size: 0.72rem;
  background: #f1f5f9;
  color: var(--text-muted);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border-color);
}

.text-emerald { color: #059669; }
.text-blue { color: #2563eb; }
.text-rose { color: #dc2626; }
.text-muted { color: var(--text-muted); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-mono { font-family: var(--font-mono); }

/* Subtabs bar */
.subtabs-bar {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
}

.subtab-btn {
  background: none;
  border: none;
  padding: 0.75rem 1.25rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
}

.subtab-btn:hover {
  color: var(--text-main);
}

.subtab-btn.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
  font-weight: 700;
}

.subtab-pane {
  display: none;
}
.subtab-pane.active {
  display: block;
}

/* Inner Report View Pills (for GAAP & IFRS) */
.inner-report-pills {
  display: flex;
  gap: 0.4rem;
  background: #f1f5f9;
  padding: 3px;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
}

.report-pill-btn {
  background: none;
  border: none;
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.report-pill-btn.active {
  background: #ffffff;
  color: var(--accent-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Trial Balance Header */
.report-header-banner {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.report-period-tag {
  font-size: 0.75rem;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

.tb-balance-badge {
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tb-balance-badge.balanced {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.tb-balance-badge.unbalanced {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

/* Statement Selector */
.statement-selector-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.select-ledger-picker {
  min-width: 320px;
}

.statement-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 780px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-subtitle {
  font-size: 0.75rem;
  color: var(--accent-primary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

.vch-entry-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}

.vch-entry-table th {
  background: #f8fafc;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border-color);
}

.vch-entry-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.85rem;
}

/* Status Banner */
.status-banner {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.status-dot-large {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  display: inline-block;
  box-shadow: 0 0 6px var(--accent-emerald);
}

.alert {
  padding: 1rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  font-size: 0.82rem;
}

.alert-live {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.live-pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
  margin-top: 4px;
  flex-shrink: 0;
  animation: pulse 1.5s infinite;
}

.mb-4 { margin-bottom: 1rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }

/* Segmented Control */
.segmented-control {
  display: inline-flex;
  align-items: center;
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  padding: 3px;
  border-radius: var(--radius-sm);
  gap: 2px;
}

.segment-btn {
  background: transparent;
  border: none;
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.segment-btn:hover {
  color: var(--text-main);
}

.segment-btn.active {
  background: #ffffff;
  color: var(--accent-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Multi-Period PE Statement Toolbar & Checkboxes */
.multi-period-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.85rem;
}

.multi-period-col-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem;
}

.period-check-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #1e293b;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s ease;
}

.period-check-item:hover {
  color: #2563eb;
}

.period-check-item input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: #2563eb;
  cursor: pointer;
  border-radius: 4px;
}

.period-badge-tag {
  font-size: 0.68rem;
  font-weight: 500;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: #e2e8f0;
  color: #475569;
}

/* Print Mode */
@media print {
  .sidebar, .top-period-bar, .page-actions, .filter-card, .btn, .subtabs-bar, .inner-report-pills {
    display: none !important;
  }
  .main-wrapper {
    margin-left: 0 !important;
  }
  body {
    background: #fff !important;
    color: #000 !important;
  }
  .corporate-statement-card, .card {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
  .statement-table th, .statement-table td, .data-table th, .data-table td {
    color: #000 !important;
  }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.spinning {
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
