:root {
  --primary: #1a365d;
  --primary-light: #2b4f8e;
  --primary-dark: #0f2340;
  --secondary: #047857;
  --secondary-light: #059669;
  --accent: #f59e0b;
  --accent-light: #fbbf24;
  --danger: #dc2626;
  --danger-light: #ef4444;
  --success: #16a34a;
  --warning: #d97706;
  --info: #2563eb;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-family-mr: 'Noto Sans Devanagari', 'Nirmala UI', sans-serif;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --radius-sm: 0.375rem;
  --radius: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: var(--font-family);
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
}

body.lang-mr {
  font-family: var(--font-family-mr);
}

a { color: var(--primary-light); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--primary); }

/* ─── Top Navigation ─── */
.top-navbar {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary), var(--primary-light));
  color: white;
  padding: 0 1.5rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: var(--shadow-md);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: white;
}

.nav-brand .brand-icon {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--primary-dark);
}

.nav-center {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-search-box {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius);
  padding: 0.35rem 0.75rem;
  min-width: 300px;
  transition: all 0.2s;
}

.nav-search-box:focus-within {
  background: rgba(255, 255, 255, 0.25);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.nav-search-box input {
  background: transparent;
  border: none;
  color: white;
  padding: 0.35rem 0.5rem;
  width: 100%;
  font-size: 0.875rem;
  outline: none;
}

.nav-search-box input::placeholder { color: rgba(255, 255, 255, 0.6); }
.nav-search-box .search-icon { color: rgba(255, 255, 255, 0.6); font-size: 0.875rem; }

.nav-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-user-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
}

.nav-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary-dark);
}

.nav-lang-switch {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 0.25rem;
}

.nav-lang-switch a {
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
  transition: all 0.2s;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.nav-lang-switch a.active, .nav-lang-switch a:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

/* ─── Sidebar ─── */
.page-layout {
  display: flex;
  min-height: calc(100vh - 64px);
}

.sidebar {
  width: 250px;
  background: white;
  border-right: 1px solid var(--gray-200);
  padding: 1rem 0;
  overflow-y: auto;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.sidebar-section {
  padding: 0 1rem;
  margin-bottom: 0.5rem;
}

.sidebar-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-400);
  font-weight: 600;
  padding: 0.5rem 0.75rem;
}

.sidebar-menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius);
  color: var(--gray-600);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s;
  cursor: pointer;
}

.sidebar-menu-item:hover {
  background: var(--gray-100);
  color: var(--primary);
}

.sidebar-menu-item.active {
  background: var(--primary);
  color: white;
}

.sidebar-menu-item .menu-icon {
  width: 20px;
  text-align: center;
  font-size: 1rem;
}

/* ─── Main Content ─── */
.main-content {
  flex: 1;
  padding: 1.5rem 2rem;
  overflow-y: auto;
  max-width: calc(100vw - 250px);
}

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

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.025em;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--gray-500);
  margin-top: 0.15rem;
}

/* ─── Cards ─── */
.card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}

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

.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
}

.card-body { padding: 1.25rem; }
.card-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--gray-200); background: var(--gray-50); }

/* ─── Stats Widgets ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  transition: transform 0.2s, box-shadow 0.2s;
}

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

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-icon.blue { background: #dbeafe; color: #1d4ed8; }
.stat-icon.green { background: #d1fae5; color: #059669; }
.stat-icon.amber { background: #fef3c7; color: #d97706; }
.stat-icon.red { background: #fee2e2; color: #dc2626; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }

.stat-content { flex: 1; }
.stat-label { font-size: 0.8rem; color: var(--gray-500); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--gray-900); line-height: 1.2; margin-top: 0.15rem; }
.stat-change { font-size: 0.8rem; margin-top: 0.25rem; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ─── Forms ─── */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--gray-700); margin-bottom: 0.35rem; }
.form-label .required { color: var(--danger); margin-left: 0.15rem; }
.form-control, .form-select {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--gray-800);
  background: white;
  transition: all 0.2s;
  font-family: inherit;
}
.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(43, 79, 142, 0.1);
}
.form-control::placeholder { color: var(--gray-400); }
.form-control.error { border-color: var(--danger); }
.form-hint { font-size: 0.75rem; color: var(--gray-500); margin-top: 0.25rem; }
.form-error { font-size: 0.75rem; color: var(--danger); margin-top: 0.25rem; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 1.1rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  line-height: 1.4;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-light); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border-color: var(--gray-300); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #b45309; }
.btn-info { background: var(--info); color: white; }
.btn-info:hover { background: #1d4ed8; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn-icon { padding: 0.5rem; min-width: 36px; justify-content: center; }

/* ─── Tables ─── */
.table-container { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.data-table th {
  background: var(--gray-50);
  color: var(--gray-600);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}
.data-table td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}
.data-table tbody tr:hover { background: var(--gray-50); }
.data-table .amount { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.data-table .amount.dr { color: var(--danger); }
.data-table .amount.cr { color: var(--success); }
.data-table .center { text-align: center; }

/* ─── Alerts / Flash Messages ─── */
.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid transparent;
}
.alert-success { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }
.alert-error { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.alert-info { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.alert-dismiss { margin-left: auto; cursor: pointer; opacity: 0.7; }
.alert-dismiss:hover { opacity: 1; }

/* ─── Badges ─── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-gray { background: var(--gray-200); color: var(--gray-600); }

/* ─── Pagination ─── */
.pagination { display: flex; align-items: center; gap: 0.25rem; margin-top: 1rem; }
.pagination a, .pagination span {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--gray-600);
  transition: all 0.15s;
}
.pagination a:hover { background: var(--gray-100); border-color: var(--gray-400); }
.pagination .active { background: var(--primary); color: white; border-color: var(--primary); }

/* ─── Login Page ─── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary), var(--primary-light));
  padding: 1.5rem;
}

.login-card {
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 440px;
  overflow: hidden;
}

.login-header {
  padding: 2rem 2rem 1rem;
  text-align: center;
}

.login-logo {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  font-size: 1.8rem;
  color: white;
}

.login-header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--gray-900);
}

.login-header p {
  color: var(--gray-500);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.login-body { padding: 1.5rem 2rem 2rem; }
.login-footer { padding: 1rem 2rem; text-align: center; border-top: 1px solid var(--gray-200); background: var(--gray-50); font-size: 0.8rem; color: var(--gray-500); }

/* ─── Tabs ─── */
.tabs { display: flex; border-bottom: 2px solid var(--gray-200); margin-bottom: 1.25rem; }
.tab-item { padding: 0.65rem 1.25rem; font-size: 0.875rem; font-weight: 500; color: var(--gray-500); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s; }
.tab-item:hover { color: var(--gray-700); }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ─── Detail View ─── */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; }
.detail-section { margin-bottom: 1.5rem; }
.detail-section h4 { font-size: 0.85rem; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.75rem; padding-bottom: 0.4rem; border-bottom: 1px solid var(--gray-200); }
.detail-row { display: flex; padding: 0.4rem 0; border-bottom: 1px solid var(--gray-50); }
.detail-label { flex: 0 0 160px; font-size: 0.8rem; color: var(--gray-500); font-weight: 500; }
.detail-value { flex: 1; font-size: 0.875rem; color: var(--gray-800); font-weight: 500; }
.detail-value.amount { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ─── Dropdown ─── */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  min-width: 200px;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  padding: 0.5rem 0;
}
.dropdown:hover .dropdown-menu { display: block; }
.dropdown-item { display: block; padding: 0.5rem 1rem; font-size: 0.85rem; color: var(--gray-700); transition: background 0.15s; }
.dropdown-item:hover { background: var(--gray-50); color: var(--primary); }

/* ─── Modal ─── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.modal-overlay.show { display: flex; }
.modal { background: white; border-radius: var(--radius-xl); max-width: 600px; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-xl); }
.modal-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 1.1rem; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 1.5rem; color: var(--gray-400); cursor: pointer; padding: 0.25rem; line-height: 1; }
.modal-close:hover { color: var(--gray-600); }
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 0.5rem; }

/* ─── Toolbar ─── */
.action-toolbar { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.search-bar { display: flex; align-items: center; gap: 0.5rem; }
.search-bar input { min-width: 250px; }

/* ─── Loading ─── */
.spinner { display: inline-block; width: 1.5rem; height: 1.5rem; border: 3px solid var(--gray-200); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.8);
  z-index: 3000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
}
.loading-overlay.show { display: flex; }

/* ─── Utilities ─── */
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--gray-500); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: 0.8rem; }
.text-lg { font-size: 1.1rem; }
.font-bold { font-weight: 700; }
.font-mono { font-variant-numeric: tabular-nums; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mr-1 { margin-right: 0.5rem; }
.ml-1 { margin-left: 0.5rem; }
.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }

.d-flex { display: flex; }
.d-flex-center { display: flex; align-items: center; }
.d-flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.flex-1 { flex: 1; }

.w-100 { width: 100%; }

/* ─── Empty State ─── */
.empty-state { text-align: center; padding: 3rem 1rem; }
.empty-state .empty-icon { font-size: 3rem; color: var(--gray-300); margin-bottom: 1rem; }
.empty-state h3 { font-size: 1.1rem; color: var(--gray-600); margin-bottom: 0.5rem; }
.empty-state p { color: var(--gray-400); font-size: 0.875rem; }

/* ─── Responsive ─── */
@media (max-width: 1024px) {
  .sidebar { width: 200px; }
  .main-content { max-width: calc(100vw - 200px); padding: 1rem 1.25rem; }
  .nav-search-box { min-width: 200px; }
}
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { max-width: 100vw; padding: 1rem; }
  .top-navbar { padding: 0 1rem; height: 56px; }
  .nav-search-box { min-width: 0; flex: 1; max-width: 200px; }
  .nav-user-info .user-detail { display: none; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

/* ─── Balance Sheet Horizontal ─── */
.bs-horizontal {
  display: flex;
  gap: 0;
  min-height: 300px;
}
.bs-side {
  flex: 1;
  min-width: 0;
}
.bs-assets { border-right: 2px solid var(--gray-300); }
.bs-liabilities { }
.bs-side .data-table th:first-child,
.bs-side .data-table td:first-child { width: 80px; }
.bs-side .data-table th:last-child,
.bs-side .data-table td:last-child { width: 140px; text-align: right; }
.bs-total td {
  font-weight: 700;
  background: var(--gray-50);
  border-top: 2px solid var(--gray-300);
}
@media (max-width: 900px) {
  .bs-horizontal { flex-direction: column; }
  .bs-assets { border-right: none; border-bottom: 2px solid var(--gray-300); }
}

/* ─── Print ─── */
@media print {
  .top-navbar, .sidebar, .action-toolbar, .no-print { display: none !important; }
  .main-content { max-width: 100%; padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

/* ─── Notifications ─── */
.notification-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--danger);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-notification { position: relative; cursor: pointer; font-size: 1.2rem; color: rgba(255,255,255,0.8); transition: color 0.2s; }
.nav-notification:hover { color: white; }

/* ─── Account Status Indicator ─── */
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 0.35rem; }
.status-dot.active { background: var(--success); }
.status-dot.inactive { background: var(--gray-400); }
.status-dot.closed { background: var(--danger); }
