/* ============================================================
   VODAFONE CASH MANAGEMENT SYSTEM — Premium Dark Theme
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --red: #E60012;
  --red-dark: #a8000d;
  --red-light: #ff3347;
  --red-glow: rgba(230, 0, 18, 0.25);
  --primary: #3fb950;
  --accent: #388bfd;
  --green: #3fb950;
  --orange: #d29922;
  --card: #161b22;
  --card-bg: #161b22;
  --bg:      #0d1117;
  --bg2:     #161b22;
  --bg3:     #1c2330;
  --surface:  #21262d;
  --surface2: #2d333b;
  --border:  rgba(255,255,255,0.08);
  --text:    #e6edf3;
  --text2:   #8b949e;
  --text3:   #6e7681;
  --success: #3fb950;
  --warning: #d29922;
  --info:    #388bfd;
  --purple:  #8b5cf6;
  --sidebar-w: 260px;
  --topbar-h:  62px;
  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 4px 24px rgba(0,0,0,0.45);
  --shadow-lg: 0 12px 48px rgba(0,0,0,0.65);
  --tr: all 0.22s ease;
}

html.light {
  --bg:      #f0f2f5;
  --bg2:     #ffffff;
  --bg3:     #f8f9fa;
  --surface:  #e9ecef;
  --surface2: #dee2e6;
  --border:  rgba(0,0,0,0.08);
  --text:    #212529;
  --text2:   #495057;
  --text3:   #6c757d;
  --shadow:    0 4px 20px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.1);
  --red-glow: rgba(230, 0, 18, 0.15);
  --card: #ffffff;
  --card-bg: #ffffff;
  --primary: #1a7f37;
  --green: #1a7f37;
  --orange: #9a6700;
  --accent: #1558c0;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Cairo', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */

#pg-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: radial-gradient(ellipse at 70% 20%, rgba(180,0,12,0.18) 0%, transparent 60%),
              radial-gradient(ellipse at 20% 80%, rgba(180,0,12,0.12) 0%, transparent 50%),
              var(--bg);
  overflow: hidden;
}

.login-bg-shapes .shape {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.shape.s1 {
  width: 550px; height: 550px;
  background: radial-gradient(circle, rgba(230,0,18,0.12), transparent 70%);
  top: -180px; right: -180px;
  animation: pulseBg 6s ease-in-out infinite;
}
.shape.s2 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(230,0,18,0.08), transparent 70%);
  bottom: -130px; left: -100px;
  animation: pulseBg 8s ease-in-out infinite 2s;
}
.shape.s3 {
  width: 180px; height: 180px;
  background: radial-gradient(circle, rgba(255,100,100,0.1), transparent 70%);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  animation: pulseBg 4s ease-in-out infinite 1s;
}

@keyframes pulseBg {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; }
}

.login-card {
  background: rgba(22, 27, 34, 0.85);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 24px;
  padding: 44px 40px;
  width: 540px;
  max-width: 95vw;
  position: relative;
  z-index: 10;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6), 0 0 0 1px rgba(230,0,18,0.08);
  animation: slideUpIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#form-login {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
#form-login .field-group:nth-child(1) {
  grid-column: span 2;
}
#form-login .field-group:nth-child(2) {
  grid-column: span 1;
}
#form-login .field-group:nth-child(3) {
  grid-column: span 1;
}
#form-login .login-err,
#form-login .btn-login-submit {
  grid-column: span 2;
}

@media (max-width: 600px) {
  #form-login {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  #form-login .field-group:nth-child(1),
  #form-login .field-group:nth-child(2),
  #form-login .field-group:nth-child(3) {
    grid-column: span 1;
  }
}

@keyframes slideUpIn {
  from { opacity: 0; transform: translateY(40px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-logo { text-align: center; margin-bottom: 34px; }

.logo-icon {
  width: 72px; height: 72px;
  background: linear-gradient(135deg, var(--red) 0%, var(--red-dark) 100%);
  border-radius: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  color: white;
  margin-bottom: 16px;
  box-shadow: 0 8px 28px var(--red-glow);
  animation: glowPulse 3s ease-in-out infinite;
}

@keyframes glowPulse {
  0%, 100% { box-shadow: 0 8px 28px rgba(230,0,18,0.3); }
  50%       { box-shadow: 0 8px 44px rgba(230,0,18,0.55); }
}

.login-logo h1 { font-size: 26px; font-weight: 900; color: var(--text); margin-bottom: 5px; }
.login-logo p  { color: var(--text2); font-size: 14px; font-weight: 500; }

.field-group { margin-bottom: 20px; }

.field-group label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text2);
  margin-bottom: 8px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.field-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.field-icon {
  position: absolute;
  right: 14px;
  color: var(--text3);
  font-size: 14px;
  z-index: 1;
  pointer-events: none;
}

.field-wrap input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 42px;
  color: var(--text);
  font-family: 'Cairo', sans-serif;
  font-size: 14px;
  outline: none;
  transition: var(--tr);
  text-align: right;
}

.field-wrap input:focus {
  border-color: var(--red);
  background: rgba(230,0,18,0.04);
  box-shadow: 0 0 0 3px var(--red-glow);
}

.field-wrap input::placeholder { color: var(--text3); }

.btn-eye {
  position: absolute;
  left: 12px;
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: var(--tr);
  font-size: 14px;
}
.btn-eye:hover { color: var(--red); }

.login-err {
  background: rgba(230,0,18,0.08);
  border: 1px solid rgba(230,0,18,0.25);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: #ff7b7b;
  font-size: 13px;
  margin-bottom: 16px;
  text-align: center;
  animation: shake 0.35s ease;
}

@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.btn-login-submit {
  width: 100%;
  background: linear-gradient(135deg, #ff1a2e 0%, #d60010 100%);
  color: white;
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.25);
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: 'Cairo', sans-serif;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: var(--tr);
  box-shadow: 0 4px 18px var(--red-glow), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  letter-spacing: 0.3px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
}
.btn-login-submit::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.12), transparent);
  pointer-events: none;
}
.btn-login-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(230,0,18,0.5), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  background: linear-gradient(135deg, #ff3347 0%, #e60012 100%);
}
.btn-login-submit:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(230,0,18,0.3), inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.login-restore-section {
  margin-top: 24px;
  text-align: center;
  border-top: 1px dashed var(--border);
  padding-top: 18px;
}

.btn-restore-folder {
  background: none;
  border: none;
  color: var(--info);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  transition: var(--tr);
  font-weight: 600;
  outline: none;
}

.btn-restore-folder:hover {
  color: #fff;
  background: rgba(56, 139, 253, 0.15);
  box-shadow: 0 4px 12px rgba(56, 139, 253, 0.1);
  transform: translateY(-1px);
}

.btn-restore-folder:active {
  transform: translateY(1px);
}

/* Light mode specific login screen overrides */
html.light #pg-login {
  background: radial-gradient(ellipse at 70% 20%, rgba(230,0,18,0.06) 0%, transparent 60%),
              radial-gradient(ellipse at 20% 80%, rgba(230,0,18,0.04) 0%, transparent 50%),
              #f0f2f5;
}
html.light .login-card {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 24px 64px rgba(0,0,0,0.08), 0 0 0 1px rgba(230,0,18,0.03);
}
html.light .field-wrap input {
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.12);
  color: #212529;
}
html.light .field-wrap input:focus {
  background: #ffffff;
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-glow);
}
html.light .login-footer small {
  background: rgba(0,0,0,0.03);
  border: 1px solid rgba(0,0,0,0.05);
}

.login-footer { text-align: center; margin-top: 22px; }
.login-footer small {
  color: var(--text3);
  font-size: 12px;
  background: rgba(255,255,255,0.04);
  padding: 7px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
}
.login-footer strong { color: var(--text2); }

/* ============================================================
   APP LAYOUT
   ============================================================ */

#pg-app { display: flex; min-height: 100vh; }

/* SIDEBAR */
#sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-left: 1px solid var(--border);
  position: fixed;
  top: 0; right: 0; bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  overflow: hidden;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 99;
  backdrop-filter: blur(4px);
}

.sb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
}

.sb-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 900;
  color: var(--red);
  text-decoration: none;
}

.sb-logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 15px;
  box-shadow: 0 4px 12px var(--red-glow);
}

.sb-close-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 16px;
  padding: 7px;
  border-radius: 6px;
  transition: var(--tr);
}
.sb-close-btn:hover { background: var(--surface); color: var(--text); }

.sb-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
}

.sb-avatar {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: white;
  flex-shrink: 0;
}

.sb-username { font-weight: 700; font-size: 14px; color: var(--text); line-height: 1.3; }
.sb-role { font-size: 11px; color: var(--text2); margin-top: 2px; }

.sb-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--surface2) transparent;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: var(--tr);
  cursor: pointer;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.nav-item::before {
  content: '';
  position: absolute;
  right: 0; top: 50%;
  transform: translateY(-50%);
  width: 0; height: 0;
  background: var(--red);
  border-radius: 2px;
  transition: var(--tr);
}

.nav-item:hover {
  background: var(--surface);
  color: var(--text);
}

.nav-item.active {
  background: rgba(230,0,18,0.13);
  color: var(--red);
  font-weight: 700;
}

.nav-item.active::before { height: 24px; width: 3px; }
.nav-item.active i { color: var(--red); }

.nav-item i {
  width: 18px;
  font-size: 14px;
  text-align: center;
  flex-shrink: 0;
  transition: var(--tr);
}

.nav-divider {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text3);
  padding: 14px 14px 6px;
  margin-top: 4px;
}

.sb-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}

.sb-branch-info {
  font-size: 12px;
  color: var(--text2);
  text-align: center;
  padding: 7px 10px;
  margin-bottom: 8px;
  background: var(--bg3);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.btn-logout {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  background: rgba(230,0,18,0.08);
  border: 1px solid rgba(230,0,18,0.18);
  border-radius: var(--radius-sm);
  color: var(--red);
  font-family: 'Cairo', sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--tr);
}
.btn-logout:hover { background: rgba(230,0,18,0.18); border-color: rgba(230,0,18,0.4); }

/* MAIN CONTENT */
.app-main {
  margin-right: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* TOP BAR */
.topbar {
  height: var(--topbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 12px;
}

.topbar-right, .topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-menu {
  display: none;
  background: none;
  border: none;
  color: var(--text2);
  font-size: 18px;
  cursor: pointer;
  padding: 7px;
  border-radius: 7px;
  transition: var(--tr);
}
.btn-menu:hover { background: var(--surface); color: var(--text); }

.page-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
}

.branch-select-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  color: var(--text2);
  font-size: 13px;
  transition: var(--tr);
}
.branch-select-wrap:focus-within { border-color: rgba(230,0,18,0.3); }
.branch-select-wrap i { color: var(--red); }

.branch-select-wrap select {
  background: none;
  border: none;
  color: var(--text);
  font-family: 'Cairo', sans-serif;
  font-size: 13px;
  cursor: pointer;
  outline: none;
  padding: 0;
  direction: rtl;
  font-weight: 600;
}
.branch-select-wrap select option { background: var(--bg2); color: var(--text); }

.clock {
  font-size: 12px;
  color: var(--text2);
  white-space: nowrap;
  background: var(--surface);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-weight: 500;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text2);
  font-weight: 600;
}
.topbar-user i { color: var(--red); font-size: 22px; }

/* PAGE CONTENT */
.page-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* ============================================================
   COMPONENTS
   ============================================================ */

/* PAGE ANIMATION */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* CARDS */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 8px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title i { color: var(--red); }

/* KPI GRID */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: var(--tr);
  cursor: default;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--kpi-color, var(--red));
  border-radius: 3px 3px 0 0;
}

.kpi-card::after {
  content: '';
  position: absolute;
  top: -30px; left: -30px;
  width: 100px; height: 100px;
  background: radial-gradient(circle, rgba(var(--kpi-rgb, 230,0,18),0.1), transparent 70%);
  pointer-events: none;
}

.kpi-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: rgba(var(--kpi-rgb, 230,0,18),0.25);
}

.kpi-icon {
  width: 46px; height: 46px;
  background: rgba(var(--kpi-rgb, 230,0,18), 0.12);
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--kpi-color, var(--red));
  margin-bottom: 14px;
}

.kpi-label { font-size: 12px; color: var(--text2); margin-bottom: 5px; font-weight: 500; }
.kpi-value { font-size: 22px; font-weight: 900; color: var(--text); line-height: 1.2; }
.kpi-sub { font-size: 11px; color: var(--text3); margin-top: 5px; }

/* TABLES */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }

thead th {
  background: var(--bg3);
  color: var(--text2);
  font-weight: 700;
  padding: 12px 14px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

tbody tr {
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: var(--tr);
}
tbody tr:hover { background: rgba(255,255,255,0.025); }
tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: 11px 14px;
  color: var(--text);
  vertical-align: middle;
}

/* BADGES */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-red    { background: rgba(230,0,18,0.12);   color: #ff7b7b; border: 1px solid rgba(230,0,18,0.2); }
.badge-blue   { background: rgba(56,139,253,0.12); color: #6aacff; border: 1px solid rgba(56,139,253,0.2); }
.badge-green  { background: rgba(63,185,80,0.12);  color: #5dde73; border: 1px solid rgba(63,185,80,0.2); }
.badge-orange { background: rgba(210,153,34,0.12); color: #e8b84b; border: 1px solid rgba(210,153,34,0.2); }
.badge-purple { background: rgba(139,92,246,0.12); color: #a78bfa; border: 1px solid rgba(139,92,246,0.2); }
.badge-yellow { background: rgba(245,158,11,0.12); color: #f59e0b; border: 1px solid rgba(245,158,11,0.2); }

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: 'Cairo', sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: var(--tr);
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, #ff1a2e 0%, #d60010 100%);
  color: white;
  border-top: 1px solid rgba(255, 255, 255, 0.25);
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
  box-shadow: 0 4px 12px var(--red-glow), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  font-weight: 700;
  letter-spacing: 0.2px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
}
.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.12), transparent);
  pointer-events: none;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(230, 0, 18, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  background: linear-gradient(135deg, #ff3347 0%, #e60012 100%);
}
.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(230, 0, 18, 0.3), inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface2); border-color: rgba(255, 255, 255, 0.15); }

.btn-calc {
  padding: 0 12px !important;
  height: 38px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 5px !important;
}

.btn-danger {
  background: rgba(230, 0, 18, 0.07);
  color: #ff5252;
  border: 1px solid rgba(230, 0, 18, 0.22);
  transition: var(--tr);
}
.btn-danger:hover {
  background: #e60012;
  color: white;
  border-color: #e60012;
  box-shadow: 0 4px 12px rgba(230, 0, 18, 0.25);
}
.btn-danger:active {
  transform: translateY(1px);
}

.btn-theme {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text2);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: var(--tr);
}
.btn-theme:hover {
  background: var(--surface2);
  color: var(--red);
  border-color: rgba(230,0,18,0.25);
  box-shadow: 0 0 10px rgba(230,0,18,0.1);
}

.btn-success {
  background: rgba(63,185,80,0.1);
  color: var(--success);
  border: 1px solid rgba(63,185,80,0.2);
}
.btn-success:hover { background: rgba(63,185,80,0.2); }

.btn-warning {
  background: rgba(210,153,34,0.1);
  color: var(--warning);
  border: 1px solid rgba(210,153,34,0.2);
}
.btn-warning:hover { background: rgba(210,153,34,0.2); }

.btn-sm  { padding: 5px 10px; font-size: 12px; }
.btn-lg  { padding: 13px 24px; font-size: 15px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* FORMS */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text2);
  letter-spacing: 0.2px;
}

.form-field input,
.form-field select,
.form-field textarea,
.fee-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-family: 'Cairo', sans-serif;
  font-size: 13px;
  outline: none;
  transition: var(--tr);
  text-align: right;
  direction: rtl;
  width: 100%;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus,
.fee-input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-glow);
  background: rgba(230,0,18,0.03);
}

.form-field input::placeholder { color: var(--text3); }
.form-field select option { background: var(--bg2); color: var(--text); }
.form-field textarea { resize: vertical; min-height: 80px; }

.fee-input {
  text-align: center;
  direction: ltr;
  padding: 7px 8px;
  min-width: 0;
}

/* TOGGLE SWITCH */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--surface2);
  border-radius: 24px;
  transition: 0.3s;
  border: 1px solid var(--border);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  right: 2px; bottom: 2px;
  background: var(--text3);
  border-radius: 50%;
  transition: 0.3s;
}

.toggle input:checked + .toggle-slider { background: var(--red); border-color: var(--red); }
.toggle input:checked + .toggle-slider::before { transform: translateX(-20px); background: white; }

/* FILTER BAR */
.filter-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  padding: 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
}
.filter-bar .form-field { flex: 1; min-width: 130px; }

/* EMPTY STATE */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text2);
}
.empty-state i { font-size: 48px; color: var(--text3); margin-bottom: 16px; display: block; }
.empty-state h3 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.empty-state p { font-size: 14px; color: var(--text3); }

/* CHARTS */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.chart-card canvas { max-height: 260px; }

/* MODAL */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-box {
  background: var(--bg2);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 18px;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.28s cubic-bezier(0.34,1.56,0.64,1);
  box-shadow: var(--shadow-lg);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.88) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 16px; font-weight: 800; color: var(--text); }

.modal-close {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 16px;
  padding: 5px 7px;
  border-radius: 7px;
  transition: var(--tr);
}
.modal-close:hover { background: var(--surface); color: var(--text); }

.modal-body    { padding: 24px; }
.modal-footer  { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 24px; border-top: 1px solid var(--border); }

/* TOAST */
#toast-wrap {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease;
  min-width: 220px;
  max-width: 320px;
  pointer-events: auto;
}

.toast.success { border-right: 3px solid var(--success); }
.toast.error   { border-right: 3px solid var(--red); }
.toast.info    { border-right: 3px solid var(--info); }
.toast.warning { border-right: 3px solid var(--warning); }

.toast i { font-size: 16px; flex-shrink: 0; }
.toast.success i { color: var(--success); }
.toast.error   i { color: var(--red); }
.toast.info    i { color: var(--info); }
.toast.warning i { color: var(--warning); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* SUMMARY BOXES */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.summary-box {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  transition: var(--tr);
}
.summary-box:hover { border-color: rgba(230,0,18,0.2); }
.summary-box .val { font-size: 18px; font-weight: 900; color: var(--text); margin-bottom: 4px; }
.summary-box .lbl { font-size: 11px; color: var(--text2); font-weight: 600; }

/* PAGE HEADER */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h2 {
  font-size: 20px;
  font-weight: 900;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}
.page-header h2 i { color: var(--red); }

/* FEE PREVIEW */
.fee-calc-preview {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 14px;
  animation: slideUp 0.25s ease;
}

.fee-calc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 13px;
}
.fee-calc-row:last-child { border-bottom: none; font-weight: 800; font-size: 14px; }
.fee-calc-row span:first-child { color: var(--text2); }

/* TYPE GRID */
.type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: var(--tr);
  font-family: 'Cairo', sans-serif;
}
.type-btn i { font-size: 22px; transition: var(--tr); }
.type-btn span { font-size: 12px; font-weight: 700; color: var(--text); }
.type-btn:hover { border-color: rgba(255,255,255,0.2); background: var(--surface2); transform: translateY(-2px); }

.type-btn.active[data-type="withdrawal"] { border-color: #ff6b6b; background: rgba(255,107,107,0.08); }
.type-btn.active[data-type="withdrawal"] i, .type-btn.active[data-type="withdrawal"] span { color: #ff6b6b; }

.type-btn.active[data-type="transfer"] { border-color: var(--info); background: rgba(56,139,253,0.08); }
.type-btn.active[data-type="transfer"] i, .type-btn.active[data-type="transfer"] span { color: var(--info); }

.type-btn.active[data-type="recharge"] { border-color: var(--success); background: rgba(63,185,80,0.08); }
.type-btn.active[data-type="recharge"] i, .type-btn.active[data-type="recharge"] span { color: var(--success); }

.type-btn.active[data-type="balance-transfer"] { border-color: var(--purple); background: rgba(139,92,246,0.08); }
.type-btn.active[data-type="balance-transfer"] i, .type-btn.active[data-type="balance-transfer"] span { color: var(--purple); }

.type-btn.active[data-type="deposit"] { border-color: var(--warning); background: rgba(210,153,34,0.08); }
.type-btn.active[data-type="deposit"] i, .type-btn.active[data-type="deposit"] span { color: var(--warning); }

.type-btn.active[data-type="instapay-send"] { border-color: #9c27b0; background: rgba(156,39,176,0.08); }
.type-btn.active[data-type="instapay-send"] i, .type-btn.active[data-type="instapay-send"] span { color: #9c27b0; }

.type-btn.active[data-type="instapay-receive"] { border-color: #009688; background: rgba(0,150,136,0.08); }
.type-btn.active[data-type="instapay-receive"] i, .type-btn.active[data-type="instapay-receive"] span { color: #009688; }

.type-btn.active[data-type="atm-withdrawal"] { border-color: #ef5350; background: rgba(239,83,80,0.08); }
.type-btn.active[data-type="atm-withdrawal"] i, .type-btn.active[data-type="atm-withdrawal"] span { color: #ef5350; }

.type-btn.active[data-type="atm-deposit"] { border-color: #4caf50; background: rgba(76,175,80,0.08); }
.type-btn.active[data-type="atm-deposit"] i, .type-btn.active[data-type="atm-deposit"] span { color: #4caf50; }

.type-btn.active[data-type="electricity"] { border-color: #f59e0b; background: rgba(245,158,11,0.08); }
.type-btn.active[data-type="electricity"] i, .type-btn.active[data-type="electricity"] span { color: #f59e0b; }

/* COMPANY GRID */
.company-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 6px;
}

.company-btn {
  padding: 10px 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: 'Cairo', sans-serif;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: var(--tr);
}
.company-btn:hover { border-color: rgba(230,0,18,0.3); }
.company-btn.active { border-color: var(--red); background: rgba(230,0,18,0.1); color: var(--red); }

/* INFO BOX */
.info-box {
  background: rgba(56,139,253,0.08);
  border: 1px solid rgba(56,139,253,0.2);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-size: 13px;
  color: #6aacff;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.6;
}
.info-box i { margin-top: 2px; flex-shrink: 0; }

.info-box.settle-match {
  background: rgba(63,185,80,0.08);
  border-color: rgba(63,185,80,0.2);
  color: #5dde73;
}
.info-box.settle-deficit {
  background: rgba(230,0,18,0.08);
  border-color: rgba(230,0,18,0.2);
  color: #ff7b7b;
}
.info-box.settle-surplus {
  background: rgba(210,153,34,0.08);
  border-color: rgba(210,153,34,0.2);
  color: #e8b84b;
}

html.light .info-box.settle-match {
  background: rgba(63,185,80,0.06);
  border-color: rgba(63,185,80,0.18);
  color: #1a7f37;
}
html.light .info-box.settle-deficit {
  background: rgba(230,0,18,0.05);
  border-color: rgba(230,0,18,0.15);
  color: #d60010;
}
html.light .info-box.settle-surplus {
  background: rgba(210,153,34,0.06);
  border-color: rgba(210,153,34,0.15);
  color: #9a6700;
}

/* PERMISSIONS */
.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.perm-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: var(--tr);
}
.perm-item:hover { border-color: rgba(230,0,18,0.2); background: rgba(230,0,18,0.02); }

.perm-label {
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.perm-label i { color: var(--text2); width: 16px; text-align: center; }

/* DIVIDER */
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1200px) {
  .page-content { padding: 18px; }
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
  #sidebar { transform: translateX(100%); }
  #sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .sb-close-btn { display: flex; }
  .app-main { margin-right: 0; }
  .btn-menu { display: flex; }
  .page-content { padding: 14px; }
  .type-grid { grid-template-columns: repeat(2, 1fr); }
  .company-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar { padding: 0 12px; gap: 6px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .card { padding: 14px; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { font-size: 12px; min-width: 500px; }
  .modal-box { width: 95vw !important; max-width: 95vw !important; }
}

@media (max-width: 768px) {
  .page-content { padding: 10px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .page-header .btn-group { flex-wrap: wrap; gap: 6px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-value { font-size: 20px; }
  .kpi-label { font-size: 11px; }
  .card-title { font-size: 14px; }
  .topbar-title { font-size: 13px; }
  .btn { font-size: 12px; padding: 7px 10px; }
  .btn-lg { font-size: 13px; padding: 10px 16px; }
  .filter-bar { flex-wrap: wrap; gap: 6px; }
  .filter-bar input, .filter-bar select { min-width: 0; width: 100%; }
  .summary-box { padding: 10px; }
}

@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .clock { display: none; }
  .topbar-user span { display: none; }
  .branch-select-wrap { padding: 5px 8px; }
  .kpi-value { font-size: 18px; }
  .card { padding: 12px; }
  table { font-size: 11px; }
  .btn-sm { font-size: 11px; padding: 4px 7px; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .topbar { padding: 0 8px; gap: 4px; }
  .page-content { padding: 8px; }
  .type-grid { grid-template-columns: 1fr 1fr; }
  .company-grid { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 16px; }
  .kpi-label { font-size: 10px; }
  .page-title { font-size: 15px; }
  .card-title { font-size: 13px; }
  .modal-box { padding: 0 !important; }
  .modal-header, .modal-body, .modal-footer { padding: 12px !important; }
}

/* PRINT */
@media print {
  @page {
    size: A4 portrait;
    margin: 10mm;
  }
  #sidebar, .topbar, .btn, .btn-group, .filter-bar,
  .page-header .btn-group, #branch-select-wrap, .clock { display: none !important; }
  #sidebar-overlay { display: none !important; }
  .app-main { margin-right: 0 !important; margin: 0 !important; padding: 0 !important; }
  .page-content { padding: 0 !important; }
  body {
    background: white !important;
    color: #000 !important;
    font-family: 'Cairo', sans-serif !important;
    font-weight: 700 !important;
  }
  .card, .kpi-card, .chart-card, .summary-box {
    border: 1px solid #000 !important;
    background: white !important;
    color: #000 !important;
  }
  .kpi-value, .kpi-label, .page-title, .card-title, tbody td, thead th {
    color: #000 !important;
    font-weight: 700 !important;
  }
  .text2 { color: #000 !important; font-weight: 700 !important; }
  table {
    width: 100% !important;
    max-width: 100% !important;
    font-size: 11px !important;
    border-collapse: collapse !important;
    font-family: 'Cairo', sans-serif !important;
  }
  thead { display: table-header-group; }
  tr { page-break-inside: avoid; break-inside: avoid; }
}

.btn-backup-alert {
  color: var(--warning) !important;
  border-color: rgba(210, 153, 34, 0.4) !important;
  background: rgba(210, 153, 34, 0.08) !important;
  animation: pulseAlert 2s infinite;
}
@keyframes pulseAlert {
  0% { box-shadow: 0 0 0 0 rgba(210, 153, 34, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(210, 153, 34, 0); }
  100% { box-shadow: 0 0 0 0 rgba(210, 153, 34, 0); }
}

/* ============================================================
   UPDATE NOTIFICATION BANNER
   ============================================================ */

#update-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 99999;
  display: none;
  flex-direction: column;
  align-items: stretch;
  animation: bannerSlideDown 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#update-banner.show {
  display: flex;
}

@keyframes bannerSlideDown {
  from { opacity: 0; transform: translateY(-100%); }
  to   { opacity: 1; transform: translateY(0); }
}

.update-banner-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, #1a2744 0%, #0f1b38 100%);
  border-bottom: 1px solid rgba(56, 139, 253, 0.3);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

#update-banner.critical .update-banner-inner {
  background: linear-gradient(135deg, #3a0a0a 0%, #280505 100%);
  border-bottom: 1px solid rgba(230, 0, 18, 0.4);
}

.update-banner-glow {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(56, 139, 253, 0.06) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmer 3s infinite linear;
  pointer-events: none;
}

#update-banner.critical .update-banner-glow {
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(230, 0, 18, 0.06) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.update-banner-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

.update-banner-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(56, 139, 253, 0.15);
  border: 1px solid rgba(56, 139, 253, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #6aacff;
  flex-shrink: 0;
  animation: iconPulse 2.5s ease-in-out infinite;
}

#update-banner.critical .update-banner-icon {
  background: rgba(230, 0, 18, 0.15);
  border-color: rgba(230, 0, 18, 0.3);
  color: #ff7b7b;
}

@keyframes iconPulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.1); }
}

.update-banner-text {
  min-width: 0;
}

.update-banner-title {
  font-size: 14px;
  font-weight: 800;
  color: #e6edf3;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.update-version-badge {
  background: rgba(56, 139, 253, 0.2);
  border: 1px solid rgba(56, 139, 253, 0.4);
  color: #6aacff;
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}

#update-banner.critical .update-version-badge {
  background: rgba(230, 0, 18, 0.15);
  border-color: rgba(230, 0, 18, 0.35);
  color: #ff9b9b;
}

.update-banner-notes {
  font-size: 12px;
  color: #8b949e;
  line-height: 1.5;
  white-space: pre-line;
  max-height: 36px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.update-banner-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.btn-update-now {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  border-radius: 8px;
  background: linear-gradient(135deg, #388bfd 0%, #1f6feb 100%);
  color: white;
  border: none;
  font-family: 'Cairo', sans-serif;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.22s ease;
  box-shadow: 0 4px 14px rgba(56, 139, 253, 0.35);
  white-space: nowrap;
  animation: updatePulse 2s ease-in-out infinite;
}

#update-banner.critical .btn-update-now {
  background: linear-gradient(135deg, #ff1a2e 0%, #d60010 100%);
  box-shadow: 0 4px 14px rgba(230, 0, 18, 0.4);
}

@keyframes updatePulse {
  0%, 100% { box-shadow: 0 4px 14px rgba(56, 139, 253, 0.35); }
  50%       { box-shadow: 0 4px 24px rgba(56, 139, 253, 0.6); }
}

#update-banner.critical .btn-update-now {
  animation: updatePulseCritical 2s ease-in-out infinite;
}

@keyframes updatePulseCritical {
  0%, 100% { box-shadow: 0 4px 14px rgba(230, 0, 18, 0.4); }
  50%       { box-shadow: 0 4px 24px rgba(230, 0, 18, 0.65); }
}

.btn-update-now:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(56, 139, 253, 0.5);
}
.btn-update-now:active { transform: translateY(0); }

.btn-update-later {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #8b949e;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-family: 'Cairo', sans-serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.22s ease;
  white-space: nowrap;
}
.btn-update-later:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #c9d1d9;
}

/* Light mode overrides */
html.light .update-banner-inner {
  background: linear-gradient(135deg, #dbeafe 0%, #eff6ff 100%);
  border-bottom: 1px solid rgba(56, 139, 253, 0.3);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}
html.light #update-banner.critical .update-banner-inner {
  background: linear-gradient(135deg, #fee2e2 0%, #fff5f5 100%);
  border-bottom: 1px solid rgba(230, 0, 18, 0.25);
}
html.light .update-banner-title { color: #1e293b; }
html.light .update-banner-notes { color: #64748b; }
html.light .btn-update-later {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.1);
  color: #64748b;
}
html.light .btn-update-later:hover {
  background: rgba(0, 0, 0, 0.08);
  color: #334155;
}

/* Adjust app layout when banner is visible */
body.has-update-banner #pg-app .app-main {
  padding-top: 0;
}

/* ── PRINT STYLES (hide app UI when printing main window) ──── */
@media print {
  #sidebar, #sidebar-overlay, .topbar, #update-banner,
  #toast-wrap, #modal-overlay, #submodal-overlay,
  .btn-logout, .sb-footer, .nav-divider,
  .page-header .btn-group, .filter-bar {
    display: none !important;
  }
  body {
    background: #fff !important;
    color: #000 !important;
    font-family: 'Cairo', sans-serif !important;
    font-weight: 700 !important;
  }
  .app-main { margin: 0 !important; padding: 0 !important; }
  .page-content { padding: 0 !important; }
}
/* ============================================================
   LIGHT MODE — UNIFIED DESIGN OVERRIDES
   Ensures all components look premium in both themes
   ============================================================ */

/* ── Cards & Surfaces ── */
html.light .card { background: #ffffff; border-color: rgba(0,0,0,0.08); box-shadow: 0 1px 4px rgba(0,0,0,0.05); }
html.light .kpi-card { background: #ffffff; border-color: rgba(0,0,0,0.08); }
html.light .chart-card { background: #ffffff; border-color: rgba(0,0,0,0.08); }
html.light .summary-box { background: #f8f9fa; border-color: rgba(0,0,0,0.08); }
html.light .filter-bar { background: #ffffff; border-color: rgba(0,0,0,0.08); }

/* ── Sidebar ── */
html.light #sidebar { background: #ffffff; border-left-color: rgba(0,0,0,0.08); }
html.light .sb-header { border-bottom-color: rgba(0,0,0,0.08); }
html.light .sb-user { background: #f8f9fa; border-bottom-color: rgba(0,0,0,0.08); }
html.light .nav-item { color: #495057; }
html.light .nav-item:hover { background: rgba(0,0,0,0.04); color: #212529; }
html.light .nav-item.active { background: rgba(230,0,18,0.08); color: var(--red); }
html.light .nav-divider { color: #adb5bd; }
html.light .sb-footer { border-top-color: rgba(0,0,0,0.08); }
html.light .sb-branch-info { background: #f0f2f5; border-color: rgba(0,0,0,0.08); }
html.light .btn-logout { background: rgba(230,0,18,0.05); border-color: rgba(230,0,18,0.15); }
html.light .btn-logout:hover { background: rgba(230,0,18,0.12); }

/* ── Top Bar ── */
html.light .topbar { background: #ffffff; border-bottom-color: rgba(0,0,0,0.08); }
html.light .branch-select-wrap { background: #f0f2f5; border-color: rgba(0,0,0,0.08); }
html.light .branch-select-wrap select { color: #212529; background: transparent !important; border: none !important; box-shadow: none !important; }
html.light .clock { background: #f0f2f5; border-color: rgba(0,0,0,0.08); color: #495057; }
html.light .topbar-user { color: #495057; }
html.light .btn-theme { background: #f0f2f5; border-color: rgba(0,0,0,0.08); color: #495057; }
html.light .btn-theme:hover { background: #e9ecef; color: var(--red); }

/* ── Page Content ── */
html.light .page-content { background: #f0f2f5; }
html.light .app-main { background: #f0f2f5; }

/* ── Tables ── */
html.light thead th { background: #f8f9fa; color: #495057; border-bottom-color: rgba(0,0,0,0.08); }
html.light tbody tr { border-bottom-color: rgba(0,0,0,0.05); }
html.light tbody tr:hover { background: rgba(0,0,0,0.02); }
html.light tbody td { color: #212529; }

/* ── Forms & Inputs ── */
html.light .form-field input,
html.light .form-field select,
html.light .form-field textarea,
html.light .fee-input,
html.light input[type="text"],
html.light input[type="password"],
html.light input[type="number"],
html.light input[type="datetime-local"],
html.light select,
html.light textarea {
  background: #ffffff !important;
  border-color: rgba(0,0,0,0.12) !important;
  color: #212529 !important;
}
html.light .form-field input:focus,
html.light .form-field select:focus,
html.light .form-field textarea:focus {
  border-color: var(--red) !important;
  box-shadow: 0 0 0 3px var(--red-glow) !important;
}
html.light .form-field label { color: #495057; }
html.light select option { background: #ffffff; color: #212529; }

/* ── Buttons ── */
html.light .btn-secondary { background: #f0f2f5; color: #212529; border-color: rgba(0,0,0,0.12); }
html.light .btn-secondary:hover { background: #e9ecef; }
html.light .btn-danger { background: rgba(230,0,18,0.06); color: #d60010; border-color: rgba(230,0,18,0.2); }
html.light .btn-danger:hover { background: var(--red); color: white; }
html.light .btn-success { background: rgba(63,185,80,0.08); color: #1a7f37; border-color: rgba(63,185,80,0.2); }
html.light .btn-warning { background: rgba(210,153,34,0.08); color: #9a6700; border-color: rgba(210,153,34,0.2); }

/* ── Badges ── */
html.light .badge-red    { background: rgba(230,0,18,0.08);   color: #d60010; border-color: rgba(230,0,18,0.15); }
html.light .badge-blue   { background: rgba(56,139,253,0.08); color: #1558c0; border-color: rgba(56,139,253,0.15); }
html.light .badge-green  { background: rgba(63,185,80,0.08);  color: #1a7f37; border-color: rgba(63,185,80,0.15); }
html.light .badge-orange { background: rgba(210,153,34,0.08); color: #9a6700; border-color: rgba(210,153,34,0.15); }
html.light .badge-purple { background: rgba(139,92,246,0.08); color: #6938ef; border-color: rgba(139,92,246,0.15); }

/* ── Modal ── */
html.light .modal-overlay { background: rgba(0,0,0,0.45); }
html.light .modal-box { background: #ffffff; border-color: rgba(0,0,0,0.1); box-shadow: 0 20px 60px rgba(0,0,0,0.15); }
html.light .modal-header { border-bottom-color: rgba(0,0,0,0.08); }
html.light .modal-footer { border-top-color: rgba(0,0,0,0.08); }
html.light .modal-title { color: #212529; }
html.light .modal-close { color: #6c757d; }
html.light .modal-close:hover { background: #f0f2f5; color: #212529; }

/* ── Toast ── */
html.light .toast { background: #ffffff; border-color: rgba(0,0,0,0.1); color: #212529; box-shadow: 0 4px 16px rgba(0,0,0,0.1); }

/* ── Type Buttons (Transaction types) ── */
html.light .type-btn { background: #ffffff; border-color: rgba(0,0,0,0.1); }
html.light .type-btn span { color: #212529; }
html.light .type-btn:hover { border-color: rgba(0,0,0,0.2); background: #f8f9fa; }
html.light .company-btn { background: #ffffff; border-color: rgba(0,0,0,0.1); color: #212529; }

/* ── Permissions ── */
html.light .perm-item { background: #f8f9fa; border-color: rgba(0,0,0,0.08); }
html.light .perm-label { color: #212529; }
html.light .perm-label i { color: #6c757d; }

/* ── Toggle ── */
html.light .toggle-slider { background: #dee2e6; border-color: rgba(0,0,0,0.1); }
html.light .toggle-slider::before { background: #adb5bd; }

/* ── KPI values in light mode ── */
html.light .kpi-value { color: #212529; }
html.light .kpi-label { color: #6c757d; }
html.light .kpi-sub { color: #adb5bd; }
html.light .page-header h2 { color: #212529; }
html.light .card-title { color: #212529; }

/* ── Fee preview ── */
html.light .fee-calc-preview { background: #f8f9fa; border-color: rgba(0,0,0,0.08); }
html.light .fee-calc-row { border-bottom-color: rgba(0,0,0,0.05); }
html.light .fee-calc-row span:first-child { color: #6c757d; }

/* ── Info Box ── */
html.light .info-box { background: rgba(56,139,253,0.06); color: #1558c0; border-color: rgba(56,139,253,0.2); }

/* ── Empty State ── */
html.light .empty-state i { color: #adb5bd; }
html.light .empty-state h3 { color: #495057; }

/* ── Scrollbar ── */
html.light ::-webkit-scrollbar-thumb { background: #dee2e6; }
html.light ::-webkit-scrollbar-thumb:hover { background: #adb5bd; }


/* ============================================================
   CONSISTENT SYS-TAB BUTTONS
   ============================================================ */
.sys-tab-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px 8px 0 0;
  background: var(--surface);
  color: var(--text2);
  font-family: 'Cairo', sans-serif;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  white-space: nowrap;
}
.sys-tab-btn.active {
  background: var(--red) !important;
  color: #fff !important;
}
.sys-tab-btn:hover:not(.active) {
  background: var(--surface2);
  color: var(--text);
}

/* ============================================================
   SYSTEM ADMIN TAB PANE BASE STYLES
   Ensures all tab panes properly hide/show without leaking
   ============================================================ */
.sys-tab-pane {
  display: none;
  width: 100%;
  overflow: visible;
}
/* The dashboard tab is shown by default on first render */
#sys-tab-dashboard {
  display: block;
}

/* ── Announcements tab layout fix ── */
#sys-tab-announcements {
  overflow: visible;
}
#sys-tab-announcements .card { height: auto; }
#sys-tab-announcements textarea {
  font-family: 'Cairo', sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
#sys-tab-announcements textarea:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-glow);
}

/* ── Unified input styles inside system admin panels ── */
#sys-tab-announcements input,
#sys-tab-announcements select,
#sys-tab-audit input,
#sys-tab-stores input,
#sys-tab-stores select,
#sys-tab-licenses input,
#sys-tab-licenses select,
#sys-tab-myaccount input,
#sys-tab-myaccount select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 12px;
  font-family: 'Cairo', sans-serif;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  direction: rtl;
}

/* ── Notifications badge overflow fix ── */
#notifications-badge {
  min-width: 18px;
  box-sizing: content-box;
}

/* ============================================================
   PAGE LOAD TRANSITION — Smooth fade-in for page content
   ============================================================ */
#page-content > * {
  animation: pageContentFadeIn 0.25s ease forwards;
}
@keyframes pageContentFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   RESPONSIVE FIXES — Light mode mobile
   ============================================================ */
@media (max-width: 900px) {
  html.light #sidebar { background: #ffffff; box-shadow: 4px 0 20px rgba(0,0,0,0.15); }
  html.light .sidebar-overlay { background: rgba(0,0,0,0.3); }
}

/* ============================================================
   DESIGN CONSISTENCY FIXES
   Fills gaps to ensure unified look across all pages
   ============================================================ */

/* ── btn-xs: Extra small button variant ── */
.btn-xs {
  padding: 4px 10px !important;
  font-size: 11px !important;
  border-radius: 6px !important;
  gap: 4px !important;
}

/* ── btn-info: Info/blue action buttons ── */
.btn-info {
  background: rgba(56,139,253,0.1);
  color: var(--info);
  border: 1px solid rgba(56,139,253,0.2);
  transition: var(--tr);
}
.btn-info:hover {
  background: #388bfd;
  color: white;
  border-color: #388bfd;
  box-shadow: 0 4px 12px rgba(56,139,253,0.25);
}
html.light .btn-info { background: rgba(56,139,253,0.08); color: #1558c0; border-color: rgba(56,139,253,0.2); }
html.light .btn-info:hover { background: #1558c0; color: white; }

/* ── btn-orange / btn-warning solid hover ── */
.btn-warning:hover {
  background: #d29922;
  color: white;
  border-color: #d29922;
  box-shadow: 0 4px 12px rgba(210,153,34,0.25);
}
.btn-success:hover {
  background: #3fb950;
  color: white;
  border-color: #3fb950;
  box-shadow: 0 4px 12px rgba(63,185,80,0.25);
}
html.light .btn-warning:hover { background: #9a6700; color: white; }
html.light .btn-success:hover { background: #1a7f37; color: white; }

/* ── Page header unified style ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.page-header h2 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}
.page-header h2 i { color: var(--red); }

/* ── Card hover enhancement ── */
.card {
  transition: box-shadow 0.22s ease, border-color 0.22s ease;
}
html.light .card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  border-color: rgba(0,0,0,0.12);
}

/* ── Table row hover improvement for light mode ── */
html.light tbody tr:hover {
  background: rgba(230,0,18,0.025) !important;
}

/* ── Scrollbar global ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── System Admin Tab Nav enhancement ── */
#sys-tab-nav {
  background: var(--bg2);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 12px 16px 0;
  margin-bottom: 0;
  border-bottom: none;
  gap: 4px;
}
html.light #sys-tab-nav {
  background: #ffffff;
  border-bottom: none;
  box-shadow: 0 1px 0 rgba(0,0,0,0.06);
}
.sys-tab-btn {
  border-bottom: 3px solid transparent;
  border-radius: 8px 8px 0 0 !important;
  padding: 10px 18px;
  position: relative;
}
.sys-tab-btn.active {
  background: var(--bg) !important;
  color: var(--red) !important;
  border-bottom: 3px solid var(--red) !important;
}
html.light .sys-tab-btn.active {
  background: #f0f2f5 !important;
  color: var(--red) !important;
  border-bottom: 3px solid var(--red) !important;
}

/* ── System Admin Tab Pane container ── */
.sys-tab-content-area {
  background: var(--bg);
  border-radius: 0 0 var(--radius) var(--radius);
  padding-top: 8px;
}
html.light .sys-tab-content-area {
  background: #f0f2f5;
}

/* ── Improve filter-bar in light mode ── */
html.light .filter-bar {
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

/* ── Summary box (totals) ── */
.summary-box {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}
html.light .summary-box {
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

/* ── Badge success and danger (missing variants) ── */
.badge-success { background: rgba(63,185,80,0.12); color: #5dde73; border: 1px solid rgba(63,185,80,0.2); }
.badge-danger  { background: rgba(230,0,18,0.12);  color: #ff5252; border: 1px solid rgba(230,0,18,0.2); }
.badge-info    { background: rgba(56,139,253,0.12); color: #6aacff; border: 1px solid rgba(56,139,253,0.2); }
.badge-warning { background: rgba(210,153,34,0.12); color: #e8b84b; border: 1px solid rgba(210,153,34,0.2); }

html.light .badge-success { background: rgba(63,185,80,0.08);  color: #1a7f37; border-color: rgba(63,185,80,0.15); }
html.light .badge-danger  { background: rgba(230,0,18,0.08);   color: #d60010; border-color: rgba(230,0,18,0.15); }
html.light .badge-info    { background: rgba(56,139,253,0.08);  color: #1558c0; border-color: rgba(56,139,253,0.15); }
html.light .badge-warning { background: rgba(210,153,34,0.08);  color: #9a6700; border-color: rgba(210,153,34,0.15); }


