/* ============================================================
   AccountingSys — Main Stylesheet
   Modern SaaS Financial Dashboard
   ============================================================ */

/* ── 1. Custom Properties ─────────────────────────────────── */
:root {
  /* Brand */
  --primary:        #4F46E5;
  --primary-light:  #EEF2FF;
  --primary-dark:   #3730A3;

  /* Semantic */
  --success:        #10B981;
  --success-light:  #ECFDF5;
  --danger:         #EF4444;
  --danger-light:   #FEF2F2;
  --warning:        #F59E0B;
  --warning-light:  #FFFBEB;
  --info:           #06B6D4;
  --info-light:     #ECFEFF;

  /* Neutrals */
  --white:          #FFFFFF;
  --bg:             #F8FAFC;
  --border:         #E2E8F0;
  --border-dark:    #CBD5E1;

  /* Text */
  --text-primary:   #1E293B;
  --text-secondary: #64748B;
  --text-muted:     #94A3B8;

  /* Sidebar */
  --sidebar-bg:     #0F172A;
  --sidebar-width:  260px;
  --sidebar-text:   #94A3B8;
  --sidebar-active: #4F46E5;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow:     0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-lg:  0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.04);

  /* Radii */
  --radius-sm:  .375rem;
  --radius:     .625rem;
  --radius-lg:  .875rem;

  /* Transition */
  --transition: 180ms ease;

  /* Topbar */
  --topbar-h:   64px;

  /* Font */
  --font:       'Inter', system-ui, -apple-system, sans-serif;
  --font-ar:    'Noto Sans Arabic', sans-serif;
}

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

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

body.rtl {
  font-family: var(--font-ar);
  direction: rtl;
  text-align: right;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg { display: block; max-width: 100%; }

h1,h2,h3,h4,h5,h6 { line-height: 1.3; font-weight: 600; }

ul { list-style: none; }

/* ── 3. Layout ────────────────────────────────────────────── */

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform var(--transition);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.rtl .sidebar { left: auto; right: 0; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .625rem;
  text-decoration: none;
  color: #fff;
}

.brand-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.brand-name {
  font-size: .9375rem;
  font-weight: 700;
  letter-spacing: -.01em;
  white-space: nowrap;
}

.sidebar-close {
  background: none; border: none; cursor: pointer;
  color: var(--sidebar-text); font-size: 1.1rem; padding: .25rem;
}

/* Sidebar Nav */
.sidebar-nav { flex: 1; padding: 1.25rem 0; overflow-y: auto; }

.nav-section { margin-bottom: 1rem; }

.nav-section-label {
  display: block;
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .08em;
  color: #475569;
  padding: 0 1.25rem .5rem;
  text-transform: uppercase;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .625rem 1.25rem;
  color: var(--sidebar-text);
  font-size: .875rem;
  font-weight: 500;
  border-radius: 0;
  transition: all var(--transition);
  text-decoration: none;
  margin: .125rem 0;
}

.nav-link:hover {
  color: #E2E8F0;
  background: rgba(255,255,255,.06);
  text-decoration: none;
}

.nav-link.active {
  color: #fff;
  background: var(--primary);
}

.nav-link i { font-size: 1.0625rem; flex-shrink: 0; }

/* Sidebar Footer */
.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.06);
}

.user-card {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .8125rem; font-weight: 700;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name  { display: block; font-size: .8125rem; font-weight: 600; color: #E2E8F0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { display: block; font-size: .75rem; color: #64748B; text-transform: capitalize; }

.user-logout {
  color: #64748B; font-size: 1rem; padding: .25rem;
  transition: color var(--transition);
}
.user-logout:hover { color: var(--danger); }

/* Main wrapper */
.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin var(--transition);
}

.rtl .main-wrapper { margin-left: 0; margin-right: var(--sidebar-width); }

/* Topbar */
.topbar {
  position: sticky; top: 0;
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 100;
  box-shadow: var(--shadow-sm);
  gap: 1rem;
}

.topbar-left { display: flex; align-items: center; gap: .75rem; }

.sidebar-toggle {
  background: none; border: none; cursor: pointer;
  font-size: 1.375rem; color: var(--text-secondary);
  padding: .25rem; line-height: 1;
  display: none;
}

.page-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-right { display: flex; align-items: center; gap: .75rem; }

/* Language switcher */
.lang-switcher, .auth-lang-switch { display: flex; gap: .25rem; }

.lang-btn {
  padding: .25rem .5rem;
  border-radius: var(--radius-sm);
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  letter-spacing: .03em;
}
.lang-btn:hover { color: var(--primary); text-decoration: none; }
.lang-btn.active { background: var(--primary-light); color: var(--primary); }

/* User dropdown */
.user-dropdown { position: relative; }

.user-dropdown-toggle {
  display: flex; align-items: center; gap: .5rem;
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .375rem .75rem;
  cursor: pointer;
  font-size: .8125rem;
  color: var(--text-primary);
  transition: border-color var(--transition);
}
.user-dropdown-toggle:hover { border-color: var(--primary); }

.avatar-sm {
  width: 28px; height: 28px;
  background: var(--primary);
  border-radius: 50%;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + .5rem);
  right: 0; left: auto;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  z-index: 200;
  display: none;
}

.rtl .dropdown-menu   { right: auto; left: 0; }
.rtl .quick-links-menu { right: auto; left: 0; }

.dropdown-menu.open { display: block; }

.dropdown-header {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.dropdown-header strong { display: block; font-size: .875rem; }
.dropdown-header small  { font-size: .75rem; color: var(--text-muted); }

.dropdown-item {
  display: flex; align-items: center; gap: .5rem;
  padding: .625rem 1rem;
  font-size: .875rem;
  color: var(--text-primary);
  text-decoration: none;
  transition: background var(--transition);
}

.dropdown-item:hover { background: var(--bg); text-decoration: none; }
.dropdown-item.text-danger { color: var(--danger); }

/* Page Content */
.page-content {
  flex: 1;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Overlay */
.sidebar-overlay {
  display: none; position: fixed;
  inset: 0; background: rgba(0,0,0,.45); z-index: 999;
}

/* ── 4. Flash Messages ────────────────────────────────────── */
.flash-messages { padding: .75rem 1.5rem 0; display: flex; flex-direction: column; gap: .5rem; }

.alert {
  display: flex; align-items: flex-start; gap: .625rem;
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  position: relative;
}

.alert-success  { background: var(--success-light); color: #065f46; border: 1px solid #A7F3D0; }
.alert-error    { background: var(--danger-light);  color: #991b1b; border: 1px solid #FCA5A5; }
.alert-warning  { background: var(--warning-light); color: #92400e; border: 1px solid #FCD34D; }
.alert-info     { background: var(--info-light);    color: #155e75; border: 1px solid #A5F3FC; }

.alert-dismissible { padding-right: 2.5rem; }
.rtl .alert-dismissible { padding-right: 1rem; padding-left: 2.5rem; }

.alert-close {
  position: absolute; right: .75rem; top: .5rem;
  background: none; border: none; cursor: pointer;
  opacity: .6; font-size: .875rem;
}

.rtl .alert-close { right: auto; left: .75rem; }

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

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

.card-title {
  font-size: .9375rem;
  font-weight: 600;
  display: flex; align-items: center; gap: .5rem;
}

.card-body { padding: 1.25rem; }

/* ── 6. KPI Cards ─────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
}

.kpi-grid.kpi-small {
  grid-template-columns: repeat(4, 1fr);
}

.kpi-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
  border-left: 4px solid transparent;
}

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

.rtl .kpi-card   { border-left: none; border-right: 4px solid transparent; }

.kpi-projects { border-left-color: var(--primary)!important; }
.kpi-customers{ border-left-color: var(--info)!important; }
.kpi-income   { border-left-color: var(--success)!important; }
.kpi-expense  { border-left-color: var(--danger)!important; }
.kpi-balance.positive { border-left-color: var(--success)!important; }
.kpi-balance.negative { border-left-color: var(--danger)!important; }
.kpi-ratio    { border-left-color: var(--warning)!important; }

.rtl .kpi-projects { border-right-color: var(--primary)!important; }
.rtl .kpi-customers{ border-right-color: var(--info)!important; }
.rtl .kpi-income   { border-right-color: var(--success)!important; }
.rtl .kpi-expense  { border-right-color: var(--danger)!important; }
.rtl .kpi-balance.positive { border-right-color: var(--success)!important; }
.rtl .kpi-balance.negative { border-right-color: var(--danger)!important; }

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

.kpi-projects .kpi-icon  { background: var(--primary-light); color: var(--primary); }
.kpi-customers .kpi-icon { background: var(--info-light);    color: var(--info); }
.kpi-income .kpi-icon    { background: var(--success-light); color: var(--success); }
.kpi-expense .kpi-icon   { background: var(--danger-light);  color: var(--danger); }
.kpi-balance .kpi-icon   { background: var(--primary-light); color: var(--primary); }
.kpi-ratio .kpi-icon     { background: var(--warning-light); color: var(--warning); }

.kpi-body { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.kpi-label { font-size: .75rem; color: var(--text-muted); font-weight: 500; white-space: nowrap; }
.kpi-value { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); line-height: 1.1; direction: ltr; unicode-bidi: isolate; }
.kpi-sub   { font-size: .75rem; color: var(--text-secondary); display: flex; align-items: center; gap: .25rem; }

/* ── 7. Quick Actions ─────────────────────────────────────── */
.quick-actions {
  display: flex; gap: .75rem; flex-wrap: wrap;
}

.quick-btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .625rem 1.25rem;
  border-radius: var(--radius);
  font-size: .875rem; font-weight: 600;
  color: #fff; text-decoration: none;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}

.quick-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); text-decoration: none; color: #fff; }

.btn-indigo  { background: var(--primary); }
.btn-cyan    { background: var(--info); }
.btn-emerald { background: var(--success); }
.btn-amber   { background: var(--warning); }

/* ── 8. Charts ────────────────────────────────────────────── */
.chart-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
}

.chart-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.chart-card.chart-wide { grid-column: span 1; }

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

.chart-title {
  font-size: .9375rem;
  font-weight: 600;
  display: flex; align-items: center; gap: .5rem;
  color: var(--text-primary);
}

.chart-body { padding: 1.25rem; }

/* ── 9. Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  font-size: .875rem; font-weight: 500;
  cursor: pointer; border: 1px solid transparent;
  transition: all var(--transition); line-height: 1.5;
  text-decoration: none; white-space: nowrap;
}

.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }

.btn-outline {
  background: var(--white); color: var(--text-primary); border-color: var(--border-dark);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

.btn-ghost {
  background: transparent; color: var(--text-secondary); border-color: transparent;
}
.btn-ghost:hover { background: var(--bg); color: var(--text-primary); }

.btn-danger-outline {
  background: var(--white); color: var(--danger); border-color: #FCA5A5;
}
.btn-danger-outline:hover { background: var(--danger-light); }

.btn-danger {
  background: var(--danger); color: #fff; border-color: var(--danger);
}
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }

.btn-sm  { padding: .375rem .75rem; font-size: .8125rem; }
.btn-xs  { padding: .25rem .5rem;  font-size: .75rem; }
.btn-full { width: 100%; justify-content: center; }

/* ── 10. Forms ────────────────────────────────────────────── */
.form-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
  max-width: 860px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.form-group { display: flex; flex-direction: column; gap: .375rem; }
.col-span-2 { grid-column: span 2; }

.form-label {
  font-size: .8125rem; font-weight: 600;
  color: var(--text-secondary); display: flex; align-items: center; gap: .25rem;
}

.required { color: var(--danger); font-size: .875rem; }

.form-control, .form-select {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  font-size: .875rem;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  appearance: none;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}

textarea.form-control { resize: vertical; min-height: 80px; }

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16'%3E%3Cpath fill='%2364748B' d='m1.646 4.646 6 6a.5.5 0 0 0 .708 0l6-6a.5.5 0 0 0-.708-.708L8 9.586 2.354 3.94a.5.5 0 0 0-.708.708z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  padding-right: 2rem;
}

.rtl .form-select { background-position: left .75rem center; padding-right: .75rem; padding-left: 2rem; }

.input-prefix {
  display: flex; align-items: stretch;
}

.input-prefix .prefix-text {
  background: var(--bg);
  border: 1px solid var(--border-dark);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  padding: .5rem .75rem;
  font-size: .875rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.rtl .input-prefix .prefix-text {
  border-right: 1px solid var(--border-dark);
  border-left: none;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.input-prefix .form-control { border-radius: 0 var(--radius) var(--radius) 0; }
.rtl .input-prefix .form-control { border-radius: var(--radius) 0 0 var(--radius); }

.input-password { position: relative; }
.input-password .form-control { padding-right: 2.5rem; }
.toggle-password {
  position: absolute; right: .75rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  font-size: 1rem;
}

.rtl .toggle-password { right: auto; left: .75rem; }

.form-actions {
  display: flex; align-items: center; gap: .75rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* Multi-select checkbox grid */
.multi-select-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .5rem;
  padding: .75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 240px;
  overflow-y: auto;
}

.checkbox-card {
  display: flex; align-items: flex-start; gap: .5rem;
  padding: .625rem .75rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition);
  font-size: .875rem;
  position: relative;
}

.checkbox-card:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
}

.checkbox-card input { margin-top: .15rem; flex-shrink: 0; accent-color: var(--primary); }
.checkbox-label { display: flex; flex-direction: column; gap: .1rem; }
.checkbox-label small { font-size: .75rem; color: var(--text-muted); }

/* ── 11. Tables ───────────────────────────────────────────── */
.table-responsive { overflow-x: auto; }

.table-wrapper { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: .65rem 1rem;
  font-size: .875rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table thead th {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  background: var(--bg);
  white-space: nowrap;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--bg); }

.data-table {
  width: 100%; border-collapse: collapse;
  font-size: .875rem;
}

.data-table th {
  padding: .75rem 1rem;
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .04em;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.rtl .data-table th { text-align: right; }

.data-table td {
  padding: .875rem 1rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #F8FAFC; }

.text-end   { text-align: end; }
.text-center { text-align: center; }
.text-start  { text-align: start; }

.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }

/* ── 12. Badges ───────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .2rem .55rem;
  border-radius: 100px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: capitalize;
  white-space: nowrap;
}

.badge-success   { background: var(--success-light); color: #065f46; }
.badge-danger    { background: var(--danger-light);  color: #991b1b; }
.badge-warning   { background: var(--warning-light); color: #92400e; }
.badge-primary   { background: var(--primary-light); color: var(--primary-dark); }
.badge-secondary { background: #F1F5F9; color: #475569; }
.badge-info      { background: var(--info-light);    color: #164e63; }

/* ── 13. Page header ──────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-header h2 { font-size: 1.375rem; }
.page-header p  { font-size: .875rem; margin-top: .25rem; }

/* ── 14. Filter bar ───────────────────────────────────────── */
.filter-bar {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: .875rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

.filter-form {
  display: flex; align-items: center; gap: .625rem; flex-wrap: wrap;
}

.filter-form-lg .filter-group { min-width: 130px; }

.filter-group { flex: 1; min-width: 140px; max-width: 220px; }
.filter-group .form-control,
.filter-group .form-select { font-size: .8125rem; padding: .4375rem .625rem; }

.btn-export { margin-left: auto; }
.rtl .btn-export { margin-left: 0; margin-right: auto; }

/* ── 15. Project Cards ────────────────────────────────────── */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.project-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: .75rem;
  transition: box-shadow var(--transition), transform var(--transition);
}

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

.project-card-header {
  display: flex; align-items: flex-start; gap: .5rem; justify-content: space-between;
}

.project-status-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: .4rem;
}

.status-active    { background: var(--success); }
.status-completed { background: var(--primary); }
.status-on_hold   { background: var(--warning); }
.status-cancelled { background: var(--danger); }

.project-name { font-size: .9375rem; font-weight: 600; flex: 1; }
.project-name a { color: var(--text-primary); }
.project-name a:hover { color: var(--primary); text-decoration: none; }

.project-desc { font-size: .8125rem; color: var(--text-secondary); line-height: 1.5; flex: 1; }

.project-stats {
  display: flex; gap: .75rem;
  padding: .75rem;
  background: var(--bg);
  border-radius: var(--radius);
}

.stat-item { flex: 1; display: flex; flex-direction: column; gap: .1rem; }
.stat-label { font-size: .6875rem; color: var(--text-muted); font-weight: 500; }
.stat-value { font-size: .875rem; font-weight: 600; direction: ltr; unicode-bidi: isolate; }

.project-dates { font-size: .75rem; color: var(--text-muted); display: flex; align-items: center; gap: .3rem; }

.project-actions { display: flex; gap: .375rem; }

/* ── 16. Totals bar (Transactions) ───────────────────────── */
.totals-bar {
  display: flex; gap: .75rem;
  flex-wrap: wrap;
}

.total-item {
  flex: 1; min-width: 150px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: .875rem 1.25rem;
  display: flex; align-items: center; gap: .75rem;
  box-shadow: var(--shadow-sm);
  font-size: .875rem;
  font-weight: 600;
}

.total-item.income   { border-left: 3px solid var(--success); }
.total-item.expense  { border-left: 3px solid var(--danger); }
.total-item.positive { border-left: 3px solid var(--success); }
.total-item.negative { border-left: 3px solid var(--danger); }
.total-item.balance  { border-left: 3px solid var(--primary); }

.rtl .total-item.income   { border-left: none; border-right: 3px solid var(--success); }
.rtl .total-item.expense  { border-left: none; border-right: 3px solid var(--danger); }
.rtl .total-item.balance  { border-left: none; border-right: 3px solid var(--primary); }

.total-item i     { font-size: 1.375rem; }
.total-item.income  i { color: var(--success); }
.total-item.expense i { color: var(--danger); }
.total-item.balance i { color: var(--primary); }

.total-label { display: block; font-size: .75rem; font-weight: 400; color: var(--text-muted); }
.total-value { display: block; font-size: 1.1rem; font-weight: 700; direction: ltr; unicode-bidi: isolate; }

/* ── 17. Transaction type toggle ─────────────────────────── */
.type-toggle-group {
  display: flex; gap: .5rem; margin-bottom: 1.5rem;
}

.type-toggle {
  flex: 1; max-width: 220px;
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .75rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .9rem; font-weight: 600;
  transition: all var(--transition);
  color: var(--text-secondary);
}

.type-toggle input { display: none; }
.type-toggle:hover { border-color: var(--border-dark); }
.type-toggle.active.income  { border-color: var(--success); background: var(--success-light); color: #065f46; }
.type-toggle.active.expense { border-color: var(--danger);  background: var(--danger-light);  color: #991b1b; }

/* ── 18. Action buttons in table ─────────────────────────── */
.action-btns {
  display: flex; align-items: center; gap: .25rem; justify-content: center;
}

/* ── 19. Empty state ──────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 4rem 2rem; text-align: center;
  background: var(--white);
  border: 1px dashed var(--border-dark);
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
}

.empty-state i    { font-size: 3.5rem; color: var(--text-muted); margin-bottom: 1rem; }
.empty-state h3   { font-size: 1.125rem; color: var(--text-primary); margin-bottom: .5rem; }
.empty-state p    { font-size: .875rem; margin-bottom: 1.25rem; }

/* ── 20. Pagination ───────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; justify-content: center; gap: .25rem;
  flex-wrap: wrap; margin-top: .5rem;
}

.page-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: .8125rem; font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition);
  background: var(--white);
}

.page-btn:hover  { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── 21. Detail view ──────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.detail-list { display: grid; grid-template-columns: 1fr 2fr; gap: .5rem 1rem; font-size: .875rem; }
.detail-list dt { font-weight: 600; color: var(--text-secondary); }
.detail-list dd { color: var(--text-primary); }

.customer-list { display: flex; flex-direction: column; gap: .625rem; }
.customer-item { display: flex; align-items: center; gap: .75rem; }

.customer-avatar-sm {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; flex-shrink: 0;
}

.project-list-simple { display: flex; flex-direction: column; gap: .5rem; }
.project-list-simple li { display: flex; align-items: center; gap: .5rem; font-size: .875rem; }

/* ── 22. Auth Page ────────────────────────────────────────── */
.auth-page {
  background: linear-gradient(135deg, #0F172A 0%, #1E293B 50%, #0F172A 100%);
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
}

.auth-container {
  width: 100%;
  max-width: 420px;
  padding: 1.5rem;
}

.auth-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px rgba(0,0,0,.35);
  padding: 2.5rem;
  display: flex; flex-direction: column; gap: 1.5rem;
}

.auth-brand { text-align: center; display: flex; flex-direction: column; align-items: center; gap: .625rem; }

.brand-icon-lg {
  width: 56px; height: 56px;
  background: var(--primary);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; color: #fff;
}

.brand-title    { font-size: 1.375rem; font-weight: 700; margin: 0; }
.brand-subtitle { font-size: .875rem; color: var(--text-secondary); margin: 0; }

.auth-form { display: flex; flex-direction: column; gap: 1.125rem; }

.auth-lang-switch {
  display: flex; justify-content: center; gap: .5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* ── 23. Typography Utilities ─────────────────────────────── */
.text-success  { color: var(--success)!important; }
.text-danger   { color: var(--danger)!important; }
.text-warning  { color: var(--warning)!important; }
.text-muted    { color: var(--text-muted)!important; }
.text-primary  { color: var(--primary)!important; }
.text-secondary{ color: var(--text-secondary)!important; }

.mt-4 { margin-top: 1rem; }
.mb-0 { margin-bottom: 0; }
.ms-2 { margin-left: .5rem; }
.rtl .ms-2 { margin-left: 0; margin-right: .5rem; }

.d-none      { display: none; }
.d-block     { display: block; }
.flex        { display: flex; }
.align-center{ align-items: center; }
.gap-2       { gap: .5rem; }

/* ── 24. Responsive ───────────────────────────────────────── */
@media (min-width: 1025px) {
  .d-lg-none { display: none!important; }
}

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .rtl .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0!important; margin-right: 0!important; }
  .sidebar-toggle { display: block; }
  .sidebar-overlay.open { display: block; }

  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .kpi-grid.kpi-small { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .page-content { padding: 1rem; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid.kpi-small { grid-template-columns: 1fr 1fr; }
  .project-grid { grid-template-columns: 1fr; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .col-span-2 { grid-column: span 1; }
  .filter-form { flex-direction: column; align-items: stretch; }
  .filter-group { max-width: 100%; min-width: 0; }
  .quick-actions { flex-wrap: wrap; }
  .quick-btn { flex: 1; justify-content: center; min-width: 140px; }
  .type-toggle-group { flex-direction: column; }
  .type-toggle { max-width: 100%; }
  .form-card { padding: 1.25rem; }
  .d-md-inline { display: none!important; }
  .totals-bar { flex-direction: column; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .topbar { padding: 0 1rem; }
  .auth-card { padding: 1.75rem 1.25rem; }
}

/* ── Settings Tabs ───────────────────────────────────────────── */
.settings-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.settings-tab {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .875rem 1.25rem;
  font-size: .9rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}

.settings-tab:hover { color: var(--text); }
.settings-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Auth form extras ────────────────────────────────────────── */
.auth-form-header {
  margin-bottom: 1.5rem;
  text-align: center;
}
.auth-form-header h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 .35rem;
}
.auth-form-footer {
  text-align: center;
  margin-top: 1.25rem;
  font-size: .875rem;
}
.auth-form-footer a { color: var(--primary); text-decoration: none; }
.auth-form-footer a:hover { text-decoration: underline; }

/* ── Log badge colours ───────────────────────────────────────── */
.badge-info     { background: rgba(59,130,246,.12); color: #2563eb; }
.badge-success  { background: rgba(16,185,129,.12); color: #059669; }
.badge-danger   { background: rgba(239,68,68,.12);  color: #dc2626; }
.badge-warning  { background: rgba(245,158,11,.12); color: #d97706; }

/* ── Font mono utility ───────────────────────────────────────── */
.font-mono { font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace; font-size: .82rem; direction: ltr; unicode-bidi: isolate; }
.text-nowrap { white-space: nowrap; }

/* ── Settings form hints ─────────────────────────────────────── */
.form-hint { display: block; font-size: .8rem; color: var(--text-muted); margin-top: .3rem; }

/* ── mt/mb utilities ─────────────────────────────────────────── */
.mt-4 { margin-top: 1.5rem; }
.mb-4 { margin-bottom: 1.5rem; }
.me-1 { margin-inline-end: .25rem; }
.me-2 { margin-inline-end: .5rem; }
.ms-2 { margin-inline-start: .5rem; }

/* ── Invoice status badges ───────────────────────────────────── */
.invoice-status-draft,
.invoice-status-sent,
.invoice-status-paid,
.invoice-status-overdue,
.invoice-status-cancelled {
    display: inline-flex;
    align-items: center;
    padding: .2rem .65rem;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    white-space: nowrap;
}
.invoice-status-draft     { background: #f1f5f9; color: #475569; }
.invoice-status-sent      { background: #dbeafe; color: #1d4ed8; }
.invoice-status-paid      { background: #dcfce7; color: #15803d; }
.invoice-status-overdue   { background: #fee2e2; color: #dc2626; }
.invoice-status-cancelled { background: #f3f4f6; color: #6b7280; text-decoration: line-through; }

/* ── Status colour dots (used in dropdowns) ─────────────────── */
[class^="invoice-dot-"] {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.invoice-dot-draft     { background: #94a3b8; }
.invoice-dot-sent      { background: #3b82f6; }
.invoice-dot-paid      { background: #22c55e; }
.invoice-dot-overdue   { background: #ef4444; }
.invoice-dot-cancelled { background: #9ca3af; }

/* ── Status dropdown items ───────────────────────────────────── */
.status-dropdown-menu { min-width: 178px; padding: .3rem 0; }
.status-dropdown-menu .dropdown-item {
  border-radius: 6px;
  margin: .15rem .4rem;
  padding: .5rem .8rem;
  font-weight: 500;
  font-size: .82rem;
  gap: .55rem;
}
.status-dropdown-menu .dropdown-item:hover { background: var(--primary-light); color: var(--primary-dark); }

/* ── Item count chip (invoice list rows) ────────────────────── */
.item-count-chip {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 700;
  padding: .1rem .5rem;
  margin-top: .25rem;
  white-space: nowrap;
}


/* ── Wallet ──────────────────────────────────────────────────── */
.wallet-balance-display {
  font-size: .9rem;
  color: var(--text-secondary);
}

.wallet-balance-chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border-radius: 20px;
  padding: .15rem .6rem;
  white-space: nowrap;
}
.wallet-chip-positive {
  background: var(--success-light, #dcfce7);
  color: #166534;
}

/* Wallet action tabs */
.wallet-tabs {
  display: flex;
  gap: .5rem;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 1.25rem;
}
.wallet-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: .5rem 1rem;
  font-size: .88rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  transition: color .15s, border-color .15s;
}
.wallet-tab:hover { color: var(--primary); }
.wallet-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Wallet panels */
.wallet-tab-panel { display: none; }
.wallet-tab-panel.active { display: block; }

/* Wallet forms */
.wallet-form { max-width: 680px; margin-top: .75rem; }
.wallet-form .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 600px) {
  .wallet-form .form-row { grid-template-columns: 1fr; }
}

/* Compact table variant */
.data-table-sm th,
.data-table-sm td {
  padding: .45rem .75rem;
  font-size: .82rem;
}

/* ─────────────────────────────────────────────────────────────
   Desktop sidebar collapse
───────────────────────────────────────────────────────────── */
.sidebar-collapse-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--text-secondary);
  padding: .25rem .4rem;
  border-radius: var(--radius);
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.sidebar-collapse-btn:hover { background: var(--bg); color: var(--primary); }

@media (min-width: 769px) {
  .sidebar-collapse-btn { display: flex; align-items: center; }
}

/* Collapsed state */
body.sidebar-collapsed .sidebar {
  width: 60px;
  overflow: hidden;
}
body.sidebar-collapsed .brand-name,
body.sidebar-collapsed .nav-section-label,
body.sidebar-collapsed .nav-link span:not(.badge),
body.sidebar-collapsed .user-name,
body.sidebar-collapsed .user-role,
body.sidebar-collapsed .sidebar-footer .user-info { display: none; }

body.sidebar-collapsed .nav-link {
  justify-content: center;
  padding: .625rem;
}
body.sidebar-collapsed .nav-link i {
  margin: 0;
}
body.sidebar-collapsed .sidebar-footer .user-card {
  justify-content: center;
  padding: .5rem;
}
body.sidebar-collapsed .main-wrapper {
  margin-left: 60px;
}
@media (max-width: 768px) {
  body.sidebar-collapsed .main-wrapper { margin-left: 0; }
  body.sidebar-collapsed .sidebar { width: var(--sidebar-width); }
}

/* ─────────────────────────────────────────────────────────────
   Topbar live clock
───────────────────────────────────────────────────────────── */
.topbar-clock {
  font-size: .8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
}
@media (max-width: 860px) { .topbar-clock { display: none; } }

/* ─────────────────────────────────────────────────────────────
   Quick Links dropdown
───────────────────────────────────────────────────────────── */
.quick-links { position: relative; }

.quick-links-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.15rem;
  color: var(--text-secondary);
  padding: .4rem;
  border-radius: var(--radius);
  transition: background var(--transition), color var(--transition);
}
.quick-links-toggle:hover { background: var(--bg); color: var(--primary); }

.quick-links-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 200px;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 350;
  padding: .25rem 0;
}
.quick-links-menu.open { display: block; }

.quick-links-menu a {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem 1rem;
  color: var(--text-primary);
  font-size: .875rem;
  text-decoration: none;
  transition: background var(--transition);
}
.quick-links-menu a:hover { background: var(--bg); }
.quick-links-menu a i { width: 1rem; text-align: center; }

/* ─────────────────────────────────────────────────────────────
   Topbar icon button (chat, etc.)
───────────────────────────────────────────────────────────── */
.topbar-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--text-secondary);
  padding: .4rem;
  border-radius: var(--radius);
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
  position: relative;
}
.topbar-icon-btn:hover { background: var(--bg); color: var(--primary); }

/* ─────────────────────────────────────────────────────────────
   Chat views
───────────────────────────────────────────────────────────── */
.chat-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.25rem;
  height: calc(100vh - var(--topbar-h) - 3rem);
}
@media (max-width: 768px) {
  .chat-layout { grid-template-columns: 1fr; height: auto; }
}

.chat-sidebar { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); overflow-y: auto; }
.chat-sidebar-header { padding: .875rem 1rem; border-bottom: 1px solid var(--border); font-weight: 600; font-size: .9375rem; }

.chat-contact {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text-primary);
  transition: background var(--transition);
}
.chat-contact:hover,
.chat-contact.active { background: rgba(99,102,241,.07); }
.chat-contact .avatar-sm { flex-shrink: 0; }
.chat-contact-info { flex: 1; min-width: 0; }
.chat-contact-name { font-size: .875rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-contact-preview { font-size: .775rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-unread-badge { background: #6366f1; color: #fff; border-radius: 9999px; font-size: .65rem; font-weight: 700; min-width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; padding: 0 4px; flex-shrink: 0; }

.chat-window { display: flex; flex-direction: column; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.chat-window-header { padding: .875rem 1rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .75rem; font-weight: 600; }
.chat-messages { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .6rem; }
.chat-msg { max-width: 68%; word-break: break-word; }
.chat-msg-out { align-self: flex-end; }
.chat-msg-in  { align-self: flex-start; }
.chat-bubble {
  padding: .55rem .875rem;
  border-radius: 1rem;
  font-size: .875rem;
  line-height: 1.5;
}
.chat-msg-out .chat-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: .3rem; }
.chat-msg-in  .chat-bubble { background: var(--bg); border: 1px solid var(--border); border-bottom-left-radius: .3rem; }
.chat-msg-time { font-size: .7rem; color: var(--text-secondary); margin-top: .2rem; }
.chat-msg-out .chat-msg-time { text-align: right; }

.chat-input-bar { padding: .75rem 1rem; border-top: 1px solid var(--border); display: flex; gap: .5rem; }
.chat-input-bar textarea { flex: 1; border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .75rem; font-size: .875rem; resize: none; font-family: inherit; background: var(--bg); color: var(--text-primary); }
.chat-input-bar textarea:focus { outline: none; border-color: var(--primary); }

