:root {
  --primary:     #1a56db;
  --primary-dk:  #1240a0;
  --accent:      #0ea5e9;
  --success:     #16a34a;
  --warning:     #d97706;
  --danger:      #dc2626;
  --bg:          #f1f5f9;
  --surface:     #ffffff;
  --border:      #e2e8f0;
  --text:        #1e293b;
  --text-muted:  #64748b;
  --sidebar-w:   240px;
  --topbar-h:    56px;
  --radius:      8px;
  --shadow:      0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:   0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

/* ── Layout ──────────────────────────────────────────────────── */
#app { display: flex; min-height: 100vh; }

#sidebar {
  width: var(--sidebar-w);
  background: #0f172a;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
}

#sidebar .logo {
  padding: 18px 20px;
  border-bottom: 1px solid #1e293b;
}
#sidebar .logo h1 { font-size: 16px; font-weight: 700; color: #fff; }
.sidebar-logo { width: 140px; height: auto; }
#sidebar .logo p  { font-size: 11px; color: #64748b; margin-top: 2px; }

#sidebar nav { flex: 1; padding: 12px 0; }

.nav-section {
  padding: 8px 20px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #475569;
}
.nav-section-toggle {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}
.nav-section-toggle:hover { color: #94a3b8; }
.nav-chevron {
  font-size: 12px;
  transition: transform .2s;
  transform: rotate(-90deg);
}
.nav-group.collapsed .nav-chevron { transform: rotate(0deg); }
.nav-group.collapsed .nav-group-items { display: none; }
.nav-group + .nav-group { margin-top: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: #94a3b8;
  text-decoration: none;
  cursor: pointer;
  border-radius: 0;
  transition: background .15s, color .15s;
  font-size: 13.5px;
}
.nav-item:hover  { background: #1e293b; color: #e2e8f0; }
.nav-item.active { background: #1d4ed8; color: #fff; font-weight: 600; }
.nav-item .icon  { width: 18px; text-align: center; flex-shrink: 0; }
.fav-context-menu {
  position: fixed;
  background: #1e293b;
  color: #e2e8f0;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
  white-space: nowrap;
}
.fav-context-menu:hover { background: #334155; }
.fav-context-menu span { margin-right: 6px; color: #eab308; }

#main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}

#topbar .page-title { font-size: 16px; font-weight: 600; flex: 1; }
#topbar .company-badge {
  background: #eff6ff;
  color: var(--primary);
  border: 1px solid #bfdbfe;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
#topbar .user-menu {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; padding: 6px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
#topbar .user-menu:hover { background: var(--bg); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}

#content { flex: 1; padding: 24px; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h2 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

/* ── KPI tiles ───────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.kpi-tile .label { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing:.05em; }
.kpi-tile .value { font-size: 22px; font-weight: 700; margin: 5px 0 3px; }
.kpi-tile .sub   { font-size: 11px; color: var(--text-muted); }
.kpi-tile.blue   .value { color: var(--primary); }
.kpi-tile.green  .value { color: var(--success); }
.kpi-tile.amber  .value { color: var(--warning); }
.kpi-tile.red    .value { color: var(--danger); }

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  background: #f8fafc;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
}
.badge-draft    { background: #f1f5f9; color: #64748b; }
.badge-approved { background: #eff6ff; color: #1d4ed8; }
.badge-posted   { background: #f0fdf4; color: #16a34a; }
.badge-cancelled{ background: #fff7ed; color: #c2410c; }
.badge-received { background: #f0fdf4; color: #16a34a; }
.badge-lodged   { background: #eff6ff; color: #1d4ed8; }
.badge-cleared  { background: #f0fdf4; color: #15803d; }
.badge-bounced  { background: #fef2f2; color: #dc2626; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 600;
  cursor: pointer; border: none;
  transition: opacity .15s, transform .1s;
  text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dk); }
.btn-secondary{ background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-success  { background: var(--success); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px; color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29,78,216,.15); }

/* ── Smart Picker ────────────────────────────────────────────── */
.sp-wrap { position: relative; }
.sp-input { padding-right: 28px !important; }
.sp-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  cursor: pointer; color: var(--text-muted); font-size: 16px; line-height: 1;
  z-index: 2;
}
.sp-clear:hover { color: var(--danger); }
.sp-dropdown {
  display: none; position: absolute; top: 100%; left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow-md); max-height: 220px; overflow-y: auto;
  z-index: 1000;
}
.sp-dropdown.open { display: block; }
.sp-option {
  padding: 7px 12px; cursor: pointer; font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.sp-option:last-child { border-bottom: none; }
.sp-option:hover, .sp-option.active { background: #eff6ff; color: var(--primary); }
.sp-option mark { background: #fef08a; color: inherit; border-radius: 2px; padding: 0 1px; }
.sp-empty { padding: 10px 12px; color: var(--text-muted); font-size: 13px; text-align: center; }

.form-row { display: grid; gap: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.modal {
  background: var(--surface);
  border-radius: 12px;
  width: 560px; max-width: 95vw;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close {
  width: 28px; height: 28px; border-radius: 50%;
  border: none; background: var(--bg);
  cursor: pointer; font-size: 16px; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
}
.modal-body   { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ── Login ───────────────────────────────────────────────────── */
#login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: row;
  background: #fff;
}

/* Left panel — form */
.login-left {
  flex: 0 0 648px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 64px;
  background: #fff;
}
.login-form-wrap { width: 100%; max-width: 400px; }

.login-brand {
  display: flex; flex-direction: column; align-items: center;
  margin-bottom: 12px;
}
.login-brand-logo {
  width: 240px; height: auto;
}
.login-brand-name {
  font-size: 32px; font-weight: 800; color: #0a1e3d;
  letter-spacing: -0.5px;
}

.login-tagline {
  font-size: 11px; font-weight: 700; letter-spacing: 1.5px;
  color: #94a3b8; text-transform: uppercase;
  margin-bottom: 10px;
}

.login-title {
  font-size: 28px; font-weight: 800; color: #0f172a;
  margin-bottom: 6px; letter-spacing: -0.5px;
}
.login-form-sub {
  color: #64748b; font-size: 14px; margin-bottom: 32px;
}

/* Input with icon */
.login-input-wrap {
  position: relative; display: flex; align-items: center;
}
.login-input-icon {
  position: absolute; left: 12px; width: 18px; height: 18px;
  color: #94a3b8; pointer-events: none;
}
.login-input-wrap .form-control {
  padding-left: 38px; padding-right: 40px;
  height: 44px; font-size: 14px;
  border-radius: 10px;
  background: #eef2fb;
  border: 1.5px solid transparent;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.login-input-wrap .form-control:focus {
  background: #fff;
  border-color: #14919b;
  box-shadow: 0 0 0 3px rgba(20,145,155,.12);
}

/* Password toggle */
.login-pw-toggle {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: #94a3b8; padding: 4px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; transition: color .15s;
}
.login-pw-toggle:hover { color: #475569; }

/* Submit */
.login-submit {
  width: 100%; height: 46px; margin-top: 8px;
  background: linear-gradient(135deg, #0d5c63 0%, #14919b 100%);
  color: #fff; border: none; border-radius: 10px;
  font-size: 15px; font-weight: 700; cursor: pointer;
  transition: opacity .15s, transform .1s;
  box-shadow: 0 2px 8px rgba(13,92,99,.25);
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.login-submit:hover { opacity: .92; }
.login-submit:active { transform: scale(.985); }
.login-submit-arrow { width: 16px; height: 16px; }

/* Demo credentials */
.login-demo {
  margin-top: 28px;
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  border-radius: 10px;
  padding: 14px 16px;
}
.login-demo-header {
  font-size: 10px; font-weight: 700; letter-spacing: .8px;
  color: #0d9488; margin-bottom: 10px;
  display: flex; align-items: center; gap: 6px;
}
.login-demo-creds {
  display: flex; flex-direction: column; gap: 4px;
  margin-bottom: 12px;
}
.login-demo-row {
  font-size: 13px; color: #0f172a;
  display: flex; align-items: center; gap: 8px;
}
.login-demo-row span {
  font-size: 11px; font-weight: 600; color: #64748b;
  min-width: 60px; text-transform: uppercase; letter-spacing: .3px;
}
.login-demo-fill {
  width: 100%; padding: 8px 14px;
  background: #0d9488; color: #fff;
  border: none; border-radius: 8px;
  font-size: 12px; cursor: pointer; font-weight: 600;
  transition: background .15s;
}
.login-demo-fill:hover { background: #0f766e; }

/* Right panel — brand showcase */
.login-right {
  flex: 1;
  background: linear-gradient(160deg, #072e33 0%, #0a3d44 40%, #0d4f58 100%);
  display: flex;
  padding: 48px 56px;
  position: relative;
  overflow: hidden;
}
.login-right-inner {
  position: relative; z-index: 1;
  width: 100%; max-width: 560px; margin: 0 auto;
  display: flex; flex-direction: column; justify-content: space-between;
}

.login-topbar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 32px;
}
.login-topbar-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: rgba(255,255,255,.12);
  color: #5eead4;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.login-topbar-name { font-size: 16px; font-weight: 800; color: #fff; }
.login-topbar-sub { font-size: 11px; color: rgba(255,255,255,.5); }

.login-footer-contact {
  margin-top: 32px; padding-top: 20px;
  border-top: 1px solid rgba(255,255,255,.1);
}
.lfc-name { font-size: 12px; font-weight: 700; color: #fff; margin-bottom: 6px; }
.lfc-row { font-size: 11px; color: rgba(255,255,255,.5); margin-bottom: 4px; }
.lfc-addr { font-size: 11px; color: rgba(255,255,255,.35); }
.login-right::before {
  content: '';
  position: absolute;
  top: -200px; right: -200px;
  width: 500px; height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(20,145,155,.12) 0%, transparent 70%);
  pointer-events: none;
}
.login-right::after {
  content: '';
  position: absolute;
  bottom: -150px; left: -100px;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(13,92,99,.1) 0%, transparent 70%);
  pointer-events: none;
}

.login-showcase {
  position: relative; z-index: 1;
  width: 100%; max-width: 520px;
}

.login-showcase-badge {
  display: inline-block;
  background: rgba(20,145,155,.2);
  border: 1px solid rgba(20,145,155,.3);
  color: #5eead4;
  font-size: 11px; font-weight: 600; letter-spacing: .5px;
  padding: 5px 14px; border-radius: 20px;
  margin-bottom: 16px; text-transform: uppercase;
}

/* Feature slideshow */
.login-slides {
  position: relative;
  min-height: 340px;
  margin-bottom: 24px;
}
.login-slide {
  position: absolute; inset: 0;
  opacity: 0;
  transform: translateX(30px);
  transition: opacity .5s ease, transform .5s ease;
  pointer-events: none;
}
.login-slide.active {
  opacity: 1;
  transform: translateX(0);
  pointer-events: all;
  position: relative;
}

.login-slide h2 {
  font-size: 30px; font-weight: 800; line-height: 1.2;
  color: #fff; margin-bottom: 12px; letter-spacing: -0.5px;
}
.login-slide h2 em {
  font-style: normal;
  background: linear-gradient(135deg, #5eead4, #14b8a6);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-slide > p {
  color: rgba(255,255,255,.5); font-size: 13px; line-height: 1.7;
  max-width: 420px; margin-bottom: 20px;
}

.ls-features {
  display: flex; flex-direction: column; gap: 10px;
}
.ls-feat {
  display: flex; gap: 12px; align-items: flex-start;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px; padding: 12px 14px;
  transition: border-color .2s;
}
.ls-feat:hover { border-color: rgba(20,184,166,.3); }
.ls-icon { font-size: 20px; min-width: 24px; line-height: 1; }
.ls-feat strong {
  display: block; font-size: 12px; font-weight: 700;
  color: #fff; margin-bottom: 2px;
}
.ls-feat span {
  font-size: 11px; color: rgba(255,255,255,.4); line-height: 1.4;
}

.ls-dots {
  display: flex; gap: 6px; margin-bottom: 20px;
}
.ls-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(255,255,255,.2); cursor: pointer;
  transition: all .3s; border: none; padding: 0;
}
.ls-dot.active {
  background: #14b8a6; width: 24px; border-radius: 4px;
}
.ls-dot:hover { background: rgba(255,255,255,.35); }
.ls-dot.active:hover { background: #14b8a6; }

/* Stats bar */
.login-stats {
  display: flex; gap: 12px;
}
.login-stat {
  flex: 1;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  padding: 14px 12px;
  display: flex; flex-direction: column; gap: 4px;
  text-align: center;
}
.login-stat strong {
  color: #fff; font-size: 18px; font-weight: 800;
}
.login-stat span {
  color: rgba(255,255,255,.4); font-size: 10px;
  text-transform: uppercase; letter-spacing: .5px;
}

/* ── Login responsive ─────────────────────────────────────────── */
@media (max-width: 960px) {
  #login-page { flex-direction: column; }
  .login-left { flex: none; padding: 32px 24px; }
  .login-right { min-height: 50vh; padding: 32px 24px; }
  .login-slide h2 { font-size: 24px; }
  .login-slides { min-height: 300px; }
}

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 13px; margin-bottom: 16px;
}
.alert-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #14532d; border: 1px solid #bbf7d0; }

/* ── Pagination ──────────────────────────────────────────────── */
.pagination { display: flex; gap: 6px; align-items: center; padding: 16px 20px; }
.page-btn { padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); cursor: pointer; font-size: 13px; }
.page-btn.active  { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:hover:not(.active) { background: var(--bg); }

/* ── Utilities ───────────────────────────────────────────────── */
.text-right  { text-align: right; }
.text-muted  { color: var(--text-muted); }
.fw-600      { font-weight: 600; }
.mt-16       { margin-top: 16px; }
.mb-16       { margin-bottom: 16px; }
.flex        { display: flex; }
.items-center{ align-items: center; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.hidden      { display: none !important; }
.amount      { font-family: 'Courier New', monospace; font-weight: 600; }
.risk-high   { color: var(--danger); font-weight: 700; }
.risk-medium { color: var(--warning); font-weight: 600; }
.risk-low    { color: var(--success); }

/* ── Loading ─────────────────────────────────────────────────── */
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  animation: spin .7s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center { text-align: center; padding: 40px; color: var(--text-muted); }

/* ── Additional badge variants ───────────────────────────────── */
.badge-success   { background: #f0fdf4; color: #16a34a; }
.badge-danger    { background: #fef2f2; color: #dc2626; }
.badge-warning   { background: #fffbeb; color: #d97706; }
.badge-info      { background: #eff6ff; color: #1d4ed8; }
.badge-secondary { background: #f1f5f9; color: #64748b; }

/* ── Card header h3 ──────────────────────────────────────────── */
.card-header h3 { font-size: 14px; font-weight: 600; }

/* ── Page header ─────────────────────────────────────────────── */
.page-header { margin-bottom: 1.25rem; display: flex; justify-content: space-between; align-items: flex-start; }
.page-header h1, .page-title { font-size: 20px; font-weight: 700; margin-bottom: 2px; }
.page-subtitle { font-size: 12px; color: var(--text-muted); margin: 0; }

/* ── Detail row (view modals) ────────────────────────────────── */
.detail-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.detail-row span:first-child { color: var(--text-muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }

/* ── Form cols-4 ─────────────────────────────────────────────── */
.form-row.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* ── Tab bar ─────────────────────────────────────────────────── */
.tab-bar {
  display: flex; gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 0;
}
.tab-btn {
  padding: 9px 18px;
  border: none; background: transparent;
  font-size: 13px; font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.tab-btn:hover  { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Toggle switch ───────────────────────────────────────────── */
.toggle {
  position: relative; display: inline-block;
  width: 36px; height: 20px; cursor: pointer;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0;
  background: #cbd5e1;
  border-radius: 20px;
  transition: .2s;
}
.slider::before {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: .2s;
}
.toggle input:checked + .slider { background: var(--success); }
.toggle input:checked + .slider::before { transform: translateX(16px); }

/* ── data-table (alias for global table) ─────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }

/* ── Field tooltip (UI.tip) ──────────────────────────────────── */
.field-tip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px;
  background: #e0e7ff; color: #4f46e5;
  border-radius: 50%; font-size: 10px; font-weight: 700;
  cursor: help; margin-left: 4px; vertical-align: middle;
  position: relative; flex-shrink: 0;
  font-style: normal; line-height: 1;
}
.field-tip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%; transform: translateX(-50%);
  background: #1e293b; color: #f1f5f9;
  font-size: 11.5px; font-weight: 400;
  line-height: 1.5; text-align: left;
  padding: 7px 10px; border-radius: 6px;
  width: max-content; max-width: 240px;
  white-space: normal;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
  pointer-events: none; opacity: 0;
  transition: opacity .15s;
  z-index: 9999;
}
.field-tip::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 1px); left: 50%; transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1e293b;
  opacity: 0; transition: opacity .15s;
  z-index: 9999;
}
.field-tip:hover::after,
.field-tip:hover::before { opacity: 1; }

/* ── RTL / Arabic Support ───────────────────────────────────── */
body.rtl { direction: rtl; font-family: 'Segoe UI', Tahoma, 'Arial', sans-serif; }

/* Sidebar flips to right */
body.rtl #sidebar { left: auto; right: 0; }
body.rtl #main    { margin-left: 0; margin-right: var(--sidebar-w); }

/* Topbar alignment */
body.rtl #topbar { flex-direction: row-reverse; }
body.rtl #topbar .page-title { text-align: right; }

/* Nav items */
body.rtl .nav-item { flex-direction: row-reverse; text-align: right; }
body.rtl .nav-section { text-align: right; }
body.rtl .nav-section-toggle { flex-direction: row-reverse; }

/* Forms */
body.rtl .form-group label { text-align: right; }
body.rtl .form-control { text-align: right; }
body.rtl input[type="number"] { text-align: left; }

/* Tables */
body.rtl thead th { text-align: right; }
body.rtl thead th.text-right { text-align: left; }
body.rtl tbody td.text-right { text-align: left; }
body.rtl .amount { text-align: left; }

/* Buttons & Badges */
body.rtl .btn { flex-direction: row-reverse; }

/* Modal */
body.rtl .modal-header { flex-direction: row-reverse; }
body.rtl .modal-footer { flex-direction: row-reverse; }

/* Cards */
body.rtl .card-header { flex-direction: row-reverse; }

/* KPI tiles */
body.rtl .kpi-tile { text-align: right; }

/* Detail rows */
body.rtl .detail-row { flex-direction: row-reverse; }

/* Page header */
body.rtl .page-header { flex-direction: row-reverse; }

/* Login page */
body.rtl #login-page { flex-direction: row; }
body.rtl .login-form-wrap { text-align: right; }
body.rtl .login-input-icon { left: auto; right: 12px; }
body.rtl .login-input-wrap .form-control { padding-left: 40px; padding-right: 38px; }
body.rtl .login-pw-toggle { right: auto; left: 10px; }
body.rtl .login-showcase-content { text-align: right; }

/* Tab bar */
body.rtl .tab-bar { flex-direction: row-reverse; }

/* Pagination */
body.rtl .pagination { flex-direction: row-reverse; }

/* Sidebar nav padding */
body.rtl .nav-item .icon { margin-right: 0; margin-left: 8px; }
body.rtl #sidebar .logo { text-align: right; }

/* Filter bars */
body.rtl .filter-bar,
body.rtl .toolbar,
body.rtl .flex-row { flex-direction: row-reverse; }
body.rtl .filter-bar > *,
body.rtl .toolbar > * { margin-left: 0; margin-right: 8px; }
body.rtl .filter-bar > *:first-child { margin-right: 0; }

/* Alerts */
body.rtl .alert { text-align: right; direction: rtl; }

/* Badges */
body.rtl .badge { margin-left: 0; margin-right: 4px; }

/* Select dropdowns */
body.rtl select.form-control { text-align: right; padding-right: 8px; padding-left: 28px; background-position: left 8px center; }

/* List/Grid gaps */
body.rtl .grid-2, body.rtl .grid-3, body.rtl .grid-4 { direction: rtl; }

/* Accordion */
body.rtl .accordion-header { flex-direction: row-reverse; }

/* Toast notifications */
body.rtl #toast-container { left: 20px; right: auto; }

/* AI Insight panels */
body.rtl .ai-insight-panel { text-align: right; }
body.rtl .ai-insight-panel .ai-narration-btn { float: left; }

/* Report output */
body.rtl .report-output { direction: rtl; }
body.rtl .report-output th,
body.rtl .report-output td { text-align: right; }
body.rtl .report-output th.text-right,
body.rtl .report-output td.text-right { text-align: left; }

/* Company badge in topbar */
body.rtl .company-badge { margin-left: 0; margin-right: auto; }

/* Close button in modals */
body.rtl .modal-close { left: 12px; right: auto; }

/* Form inline row */
body.rtl .form-row { flex-direction: row-reverse; }

/* Tooltip position */
body.rtl .field-tip::before { left: auto; right: 0; }

/* ── Language Switcher ──────────────────────────────────────── */
#lang-switcher {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin: 0 8px;
}
#lang-switcher .lang-opt {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: background .15s, color .15s;
  line-height: 1.4;
}
#lang-switcher .lang-opt:first-child { border-right: 1px solid var(--border); }
body.rtl #lang-switcher .lang-opt:first-child { border-right: none; border-left: 1px solid var(--border); }
#lang-switcher .lang-opt.active {
  background: var(--primary);
  color: #fff;
}
#lang-switcher .lang-opt:hover:not(.active) { background: var(--bg); }

/* ── Date input with calendar picker ─────────────────────────────────────── */
input.date-upgraded {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='%23888'%3E%3Cpath d='M4.5 1a.5.5 0 0 1 .5.5V2h6v-.5a.5.5 0 0 1 1 0V2h1.5A1.5 1.5 0 0 1 15 3.5v10a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 1 13.5v-10A1.5 1.5 0 0 1 2.5 2H4v-.5a.5.5 0 0 1 .5-.5zM2 6v7.5a.5.5 0 0 0 .5.5h11a.5.5 0 0 0 .5-.5V6H2zm0-1h12V3.5a.5.5 0 0 0-.5-.5H2.5a.5.5 0 0 0-.5.5V5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 14px;
  padding-right: 26px !important;
  cursor: text;
}
.date-invalid {
  border-color: var(--danger, #dc2626) !important;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.15);
}
/* Calendar dropdown */
.dcal {
  position: absolute;
  z-index: 100000;
  width: 252px;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
  padding: 10px;
  font-family: inherit;
  font-size: 13px;
  user-select: none;
}
.dcal-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.dcal-title { font-weight: 600; font-size: 13px; }
.dcal-nav {
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  color: #64748b;
}
.dcal-nav:hover { background: #f1f5f9; color: #1e293b; }
.dcal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}
.dcal-dow {
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  padding: 4px 0;
}
.dcal-day {
  padding: 5px 0;
  border-radius: 4px;
  cursor: pointer;
  line-height: 1;
}
.dcal-day:hover { background: #e2e8f0; }
.dcal-today { font-weight: 700; color: var(--primary, #2563eb); }
.dcal-sel { background: var(--primary, #2563eb) !important; color: #fff !important; font-weight: 600; }

/* RBAC: hide elements based on permissions */
body.no-ai .ai-feature { display: none !important; }
.rbac-hidden { display: none !important; }
