:root {
  --bg-page: #f8fafc;
  --bg-panel: #ffffff;
  --bg-sidebar: #0f172a;
  --bg-sidebar-accent: #111827;
  --text-primary: #0f172a;
  --text-muted: #64748b;
  --text-inverse: #e2e8f0;
  --border-soft: #e2e8f0;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --shadow-soft: 0 8px 30px rgba(15, 23, 42, 0.08);
}

html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 15px;
  }
}

body {
  font-family: "Manrope", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at top left, #ffffff, #f8fafc 38%, #f1f5f9 100%);
  color: var(--text-primary);
}

/* Auth form required-field styling */
.auth-card .required-asterisk {
  color: #ef4444;
  font-size: 1.05em;
  font-weight: 700;
  margin-left: 2px;
}

.auth-card .required-input {
  border-color: #fecaca;
  background: linear-gradient(180deg, #fff7f7 0%, #ffffff 70%);
}

.auth-card .required-input:focus {
  border-color: #ef4444;
  box-shadow: 0 0 0 0.15rem rgba(239, 68, 68, 0.2), 0 0 0 0.32rem #fff;
}

.auth-card .required-input.field-error,
.auth-card .required-input.input-validation-error {
  border-color: #dc2626 !important;
  background: linear-gradient(180deg, #fff1f2 0%, #ffffff 72%);
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.14);
}

.auth-card .validation-summary-clean {
  background: #fff5f5;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  margin-bottom: 1rem;
  font-size: 0.93rem;
}

.auth-card .validation-summary-clean ul {
  margin: 0;
  padding-left: 1rem;
}
input[readonly],
textarea[readonly],
.form-control[readonly],
.form-select[readonly] {
  background: #f5f5f5;
  border-color: #d1d5db;
  color: #1f2937;
  box-shadow: none;
  opacity: 1;
}

input[readonly]:focus,
textarea[readonly]:focus,
.form-control[readonly]:focus,
.form-select[readonly]:focus {
  background: #f5f5f5;
  border-color: #cbd5e1;
  box-shadow: none;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem #fff, 0 0 0 0.2rem rgba(15, 118, 110, 0.35);
}

.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 286px;
  background: linear-gradient(160deg, var(--bg-sidebar), var(--bg-sidebar-accent));
  color: var(--text-inverse);
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: 10px 0 35px rgba(15, 23, 42, 0.18);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.4px;
  margin-bottom: 26px;
  padding: 0 8px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(148, 163, 184, 0.18);
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 12px;
  font-size: 0.95rem;
}

.brand-text {
  color: var(--text-inverse);
}

.sidebar-section {
  text-transform: uppercase;
  font-size: 0.64rem;
  letter-spacing: 1.6px;
  color: rgba(226, 232, 240, 0.55);
  margin: 18px 0 8px;
  padding: 0 10px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--text-inverse);
  text-decoration: none;
  transition: background 0.16s ease, transform 0.16s ease, border-color 0.16s ease;
  margin-bottom: 4px;
  border: 1px solid transparent;
}

.sidebar-link i {
  font-size: 0.95rem;
  opacity: 0.9;
}

.sidebar-link:hover {
  background: rgba(148, 163, 184, 0.14);
  transform: translateX(2px);
}

.sidebar-link.active {
  background: rgba(37, 99, 235, 0.24);
  border: 1px solid rgba(96, 165, 250, 0.45);
}

.sidebar-link.muted {
  opacity: 0.75;
}

.sidebar-divider {
  height: 1px;
  background: rgba(148, 163, 184, 0.22);
  margin: 20px 0;
}

.app-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  position: sticky;
  top: 0;
  z-index: 1015;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
  box-shadow: var(--shadow-soft);
  transition: background-color 0.24s ease, box-shadow 0.24s ease, padding 0.24s ease, backdrop-filter 0.24s ease;
}

body.topbar-scrolled .topbar {
  padding-top: 12px;
  padding-bottom: 12px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sidebar-toggle {
  display: none;
}

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

.topbar-breadcrumb {
  margin-top: 2px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.topbar-breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
}

.breadcrumb-sep {
  margin: 0 6px;
  color: #b0b7b7;
}

.content-body {
  padding: 24px 28px 34px;
}

.app-footer {
  padding: 12px 28px 20px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.branch-filter-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1rem;
}

.branch-filter-toolbar__main {
  flex: 1 1 320px;
  min-width: 0;
}

.branch-filter-toolbar__controls {
  margin-inline-start: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 0.75rem;
}

.branch-filter-field {
  min-width: 220px;
  max-width: 320px;
}

.branch-filter-field .form-label,
.branch-filter-field .small {
  text-align: start;
}

.branch-filter-panel-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}

.branch-filter-panel-form .branch-filter-anchor {
  margin-inline-start: auto;
}

html[dir="rtl"] .branch-filter-toolbar__controls {
  justify-content: flex-start;
}

@media (max-width: 767.98px) {
  .branch-filter-toolbar__controls,
  .branch-filter-panel-form .branch-filter-anchor {
    margin-inline-start: 0;
  }

  .branch-filter-toolbar__controls,
  .branch-filter-panel-form {
    width: 100%;
  }

  .branch-filter-field {
    min-width: 100%;
    max-width: 100%;
  }
}

.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.topbar-actions .dropdown .btn {
  border-color: #e2e8f0;
  background: #fff;
}

.topbar-actions .dropdown .btn:hover {
  background: #f8fafc;
}

.sidebar-overlay {
  display: none;
}

.card {
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  box-shadow: var(--shadow-soft);
}

.table {
  color: var(--text-primary);
}

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: #0f172a url('/images/login-bg.svg') center / cover no-repeat fixed;
  position: relative;
  isolation: isolate;
}

.auth-shell::before {
  content: '';
  position: fixed;
  inset: 0;
  background: linear-gradient(125deg, transparent 30%, rgba(99,102,241,0.06) 40%, rgba(167,139,250,0.1) 50%, rgba(99,102,241,0.06) 60%, transparent 70%);
  background-size: 300% 300%;
  animation: authShimmer 12s ease-in-out infinite;
  pointer-events: none;
  z-index: -1;
}

@keyframes authShimmer {
  0%,100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.auth-card {
  width: min(100%, 460px);
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: 18px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35), 0 0 80px rgba(99, 102, 241, 0.08);
  padding: 2rem;
  backdrop-filter: blur(12px);
  position: relative;
  z-index: 1;
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
  transform: none !important;
}

.auth-card.auth-card-wide {
  width: min(100%, 620px);
}

.auth-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-title {
  font-size: 1.55rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.25rem;
}

.auth-subtitle {
  color: #64748b;
  font-size: 0.92rem;
  margin-bottom: 0;
}

.auth-actions {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.auth-language {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 2100;
}

.auth-language .btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #e2e8f0;
  backdrop-filter: blur(8px);
}

.auth-language .btn:hover,
.auth-language .btn:focus {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

html[dir="rtl"] .auth-language {
  right: auto;
  left: 1rem;
}

@media (max-width: 992px) {
  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    height: 100vh;
    width: 286px;
    z-index: 1030;
    transition: left 0.25s ease;
  }

  .sidebar-toggle {
    display: inline-flex;
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1020;
  }

  body.sidebar-open .sidebar {
    left: 0;
  }

  body.sidebar-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .topbar {
    padding: 14px 16px;
  }

  .content-body {
    padding: 16px;
  }
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  border-radius: 9999px;
  padding: 0.28rem 0.72rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
}

.badge.bg-primary {
  background-color: #2563eb !important;
  border-color: #1d4ed8 !important;
  color: #ffffff !important;
}

.badge.bg-success {
  background-color: #059669 !important;
  border-color: #047857 !important;
  color: #ffffff !important;
}

.badge.bg-danger {
  background-color: #e11d48 !important;
  border-color: #be123c !important;
  color: #ffffff !important;
}

.badge.bg-secondary {
  background-color: #475569 !important;
  border-color: #334155 !important;
  color: #ffffff !important;
}

.badge.bg-info {
  background-color: #0891b2 !important;
  border-color: #0e7490 !important;
  color: #ffffff !important;
}

.badge.bg-warning {
  background-color: #f59e0b !important;
  border-color: #d97706 !important;
  color: #111827 !important;
}

.quick-links-grid {
  row-gap: 0.5rem;
}

.quick-link-button {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  min-height: 3.1rem;
  border: 1px solid #dbe3ef;
  border-radius: 0.85rem;
  background: #ffffff;
  color: #0f172a;
  text-decoration: none;
  padding: 0.75rem 0.95rem;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}

.quick-link-button:hover {
  border-color: #c7d2fe;
  background: #f8faff;
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.12);
  transform: translateY(-1px);
  color: #0f172a;
}

.quick-link-button:focus,
.quick-link-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.24);
}

.quick-link-button .twi {
  font-size: 1.15rem;
}

.quick-link-button span {
  font-weight: 600;
}

html[dir="rtl"] {
  direction: ltr; /* keeps window scrollbar on the right even in RTL mode */
}

html[dir="rtl"] body {
  direction: rtl;
  text-align: right;
}

html[dir="rtl"] .app-shell {
  flex-direction: row-reverse;
}

html[dir="rtl"] .sidebar {
  order: 2;
  left: auto;
  right: 0;
  box-shadow: -12px 0 30px rgba(0, 0, 0, 0.15);
  /* direction: rtl inherited from body — scrollbar sits on inner (left) edge of sidebar */
}

html[dir="rtl"] .app-content {
  order: 1;
}

html[dir="rtl"] .sidebar-link:hover {
  transform: translateX(-2px);
}

html[dir="rtl"] .topbar-left {
  flex-direction: row-reverse;
}

html[dir="rtl"] .topbar-actions {
  margin-left: 0;
  margin-right: auto;
}

html[dir="rtl"] .form-check {
  padding-left: 0;
  padding-right: 1.5em;
}

html[dir="rtl"] .form-check .form-check-input {
  float: right;
  margin-left: 0;
  margin-right: -1.5em;
}

html[dir="rtl"] .form-check-inline {
  margin-right: 0;
  margin-left: 1rem;
}

html[dir="rtl"] .form-switch {
  padding-left: 0;
  padding-right: 2.5em;
}

html[dir="rtl"] .form-switch .form-check-input {
  margin-left: 0;
  margin-right: -2.5em;
}

@media (max-width: 992px) {
  html[dir="rtl"] .sidebar {
    left: auto;
    right: -100%;
    transition: right 0.25s ease;
  }

  html[dir="rtl"] body.sidebar-open .sidebar {
    left: auto;
    right: 0;
  }
}

/* ===== Column Help Icon Tooltip System ===== */
.column-help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  cursor: help;
  color: #94a3b8;
  font-size: 16px;
  position: relative;
  transition: color 0.2s ease;
  vertical-align: middle;
  --tooltip-top: 0px;
  --tooltip-left: 0px;
  --arrow-top: 0px;
  --arrow-left: 0px;
}

.column-help-icon:hover {
  color: #2563eb;
}

.column-help-icon::before {
  content: attr(data-tooltip);
  position: fixed;
  top: var(--tooltip-top);
  left: var(--tooltip-left);
  transform: translate(-50%, 4px);
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: #ffffff;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  white-space: normal;
  max-width: 280px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.15);
  z-index: 99999;
  line-height: 1.5;
  text-align: center;
}

.column-help-icon::after {
  content: '';
  position: fixed;
  top: var(--arrow-top);
  left: var(--arrow-left);
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: #0f172a;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 99999;
}

.column-help-icon:hover::before {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.column-help-icon:hover::after {
  opacity: 1;
  visibility: visible;
}

/* Keep horizontal table scroll inside table container and allow vertical tooltip overflow */
.table-responsive {
  overflow-x: auto !important;
  overflow-y: visible !important;
}

.card {
  overflow: visible !important;
}

.card-body {
  overflow: visible !important;
}

thead th {
  position: relative;
  overflow: visible !important;
}