/* ============================================================
   Sumadhura BG Management System — Premium UI
   Bootstrap 5.3 + Custom Design System
   ============================================================ */

:root {
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 72px;
  --header-height: 60px;

  --primary:     #1a237e;
  --primary-light: #3949ab;
  --primary-dark:  #0d1757;
  --success:     #1b5e20;
  --warning:     #f57f17;
  --danger:      #b71c1c;
  --info:        #006064;
  --orange:      #e65100;

  --sidebar-bg:  #0f1729;
  --sidebar-text:#c5cfe8;
  --sidebar-hover: #1a2540;
  --sidebar-active: linear-gradient(90deg, #1a3a8f, #1565c0);

  --bg-page:     #f0f2f8;
  --bg-card:     #ffffff;
  --border-color:#e2e7f0;

  --text-primary:  #1a237e;
  --text-dark:     #1e2a45;
  --text-muted:    #64748b;

  --shadow-sm:   0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:   0 4px 15px rgba(0,0,0,.08);
  --shadow-lg:   0 10px 30px rgba(0,0,0,.12);

  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   14px;
  --radius-xl:   20px;
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-page);
  color: var(--text-dark);
  font-size: 14px;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1050;
  transition: width .3s ease, transform .3s ease;
  overflow: hidden;
  box-shadow: 2px 0 20px rgba(0,0,0,.2);
}

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  min-height: var(--header-height);
  flex-shrink: 0;
}

.brand-logo {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #1565c0, #0d47a1);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(21,101,192,.4);
}

.brand-text { overflow: hidden; }
.brand-name {
  display: block;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .3px;
  white-space: nowrap;
}
.brand-subtitle {
  display: block;
  color: rgba(255,255,255,.5);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  white-space: nowrap;
}

/* Menu */
.sidebar-menu { flex: 1; overflow-y: auto; padding: 12px 0; }
.sidebar-menu::-webkit-scrollbar { width: 4px; }
.sidebar-menu::-webkit-scrollbar-track { background: transparent; }
.sidebar-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

.sidebar-menu .nav-item { padding: 2px 12px; }

.sidebar-menu .nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--sidebar-text);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  transition: all .2s;
  position: relative;
  white-space: nowrap;
}

.sidebar-menu .nav-link i {
  font-size: 17px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.sidebar-menu .nav-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.sidebar-menu .nav-link.active {
  background: var(--sidebar-active);
  color: #fff;
  box-shadow: 0 3px 10px rgba(21,101,192,.35);
}

.sidebar-badge {
  margin-left: auto;
  font-size: 10px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  line-height: 18px;
  border-radius: 9px;
}

.nav-divider {
  padding: 14px 26px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255,255,255,.25);
  font-weight: 600;
  list-style: none;
}

/* Footer */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}

.btn-logout {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.55);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background .2s, color .2s;
}
.btn-logout:hover {
  background: rgba(239,83,80,.15);
  color: #ef5350;
}
.btn-logout-label { flex: 1; }

/* ── Header user pill ─────────────────────────────────────── */
.header-user-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  background: #f5f7ff;
  border: 1px solid var(--border-color);
  border-radius: 40px;
  padding: 5px 12px 5px 5px;
  cursor: pointer;
  transition: background .2s, box-shadow .2s;
  text-align: left;
}
.header-user-btn:hover,
.header-user-btn[aria-expanded="true"] {
  background: #eef0fb;
  box-shadow: 0 2px 8px rgba(57,73,171,.12);
}

.header-user-avatar {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, #1565c0, #42a5f5);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}

.header-user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.header-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
  white-space: nowrap;
}
.header-user-role {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: capitalize;
}

.header-user-caret {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 2px;
  transition: transform .2s;
}
.header-user-btn[aria-expanded="true"] .header-user-caret {
  transform: rotate(180deg);
}

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

/* ── Top Header ───────────────────────────────────────────── */
.top-header {
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: var(--shadow-sm);
}

.header-left { display: flex; align-items: center; gap: 16px; }
.header-right { display: flex; align-items: center; gap: 10px; }

.sidebar-toggle {
  background: none; border: none;
  font-size: 22px; color: var(--text-muted);
  cursor: pointer; padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: all .2s;
}
.sidebar-toggle:hover { background: var(--bg-page); color: var(--primary); }

.breadcrumb { font-size: 12.5px; }
.breadcrumb-item.active { color: var(--text-muted); }
.breadcrumb-item a { color: var(--primary); text-decoration: none; }

.header-time { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }

.btn-icon {
  background: none; border: 1px solid var(--border-color);
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; cursor: pointer;
  color: var(--text-muted);
  transition: all .2s; position: relative;
}
.btn-icon:hover { background: var(--bg-page); color: var(--primary); border-color: var(--primary); }

.btn-icon-warning { color: #f57f17; border-color: #ffe0b2; }
.btn-icon-warning:hover { background: #fff8e1; }

.notif-dot {
  position: absolute; top: -4px; right: -4px;
  background: #d32f2f; color: #fff;
  width: 18px; height: 18px;
  border-radius: 50%; font-size: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; border: 2px solid #fff;
}

.notif-dropdown { min-width: 260px; box-shadow: var(--shadow-md); border-radius: var(--radius-md); }
.notif-header { padding: 10px 16px; font-size: 12px; font-weight: 600; color: var(--text-muted); border-bottom: 1px solid var(--border-color); }

/* ── Page Content ─────────────────────────────────────────── */
.page-content { flex: 1; }

.page-content-inner { padding: 24px; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-dark);
  margin: 0;
}

.page-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin: 2px 0 0;
}

.page-header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.card-header-custom {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  background: #fafbff;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.section-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  display: flex;
  align-items: center;
}

.card-title-sm {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
  margin: 0;
}

.card-chart { height: 100%; }

/* ── KPI Cards ────────────────────────────────────────────── */
.kpi-card {
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  border: none;
  box-shadow: var(--shadow-md);
  transition: transform .2s, box-shadow .2s;
  overflow: hidden;
  position: relative;
}

.kpi-card::after {
  content: '';
  position: absolute;
  right: -20px; top: -20px;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
}

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

.kpi-primary { background: linear-gradient(135deg, #1a237e, #283593); }
.kpi-success { background: linear-gradient(135deg, #1b5e20, #2e7d32); }
.kpi-warning { background: linear-gradient(135deg, #e65100, #f57f17); }
.kpi-danger  { background: linear-gradient(135deg, #b71c1c, #c62828); }

.kpi-icon {
  width: 52px; height: 52px;
  background: rgba(255,255,255,.15);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: rgba(255,255,255,.9);
  flex-shrink: 0;
}

.kpi-body { flex: 1; overflow: hidden; }
.kpi-label { display: block; font-size: 11.5px; color: rgba(255,255,255,.75); font-weight: 500; letter-spacing: .3px; }
.kpi-value { display: block; font-size: 26px; font-weight: 800; color: #fff; letter-spacing: -.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Mini KPI */
.kpi-mini {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  box-shadow: var(--shadow-sm);
}
.kpi-mini-label { display: block; font-size: 11.5px; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
.kpi-mini-value { display: block; font-size: 22px; font-weight: 800; color: var(--text-dark); }
.kpi-mini-action { border-left: 3px solid #ffc107; transition: box-shadow .15s; }
.kpi-mini-action:hover { box-shadow: 0 2px 8px rgba(0,0,0,.12); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  font-weight: 500;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  transition: all .2s;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  border: none;
  box-shadow: 0 2px 8px rgba(26,35,126,.3);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); box-shadow: 0 4px 12px rgba(26,35,126,.4); }

.btn-success { background: linear-gradient(135deg, #43a047, #2e7d32); border: none; }
.btn-danger  { background: linear-gradient(135deg, #e53935, #b71c1c); border: none; }
.btn-warning { background: linear-gradient(135deg, #fb8c00, #e65100); border: none; color: #fff; }
.btn-info    { background: linear-gradient(135deg, #00acc1, #006064); border: none; }

.btn-xs { padding: 3px 7px; font-size: 12px; }

/* ── Tables ───────────────────────────────────────────────── */
.table-header th {
  background: #f5f7ff;
  color: var(--primary);
  font-weight: 600;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: .4px;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
  padding: 12px 14px;
}

.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: #f8f9ff; }

.table td { padding: 11px 14px; vertical-align: middle; font-size: 13.5px; border-bottom: 1px solid #f0f2f8; }

.text-truncate-custom { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* DataTables overrides */
.dataTables_wrapper .dataTables_length select {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 5px 30px 5px 10px;
  font-size: 13px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16'%3E%3Cpath fill='%236c757d' d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  min-width: 70px;
}
.dataTables_wrapper .dataTables_filter input {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 13px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
  border-radius: var(--radius-sm);
}

.dataTables_wrapper .dataTables_info { font-size: 12.5px; color: var(--text-muted); }

/* ── Filters ──────────────────────────────────────────────── */
.filter-card {
  border-left: 3px solid var(--primary-light);
}

/* ── Custom Nav Tabs ──────────────────────────────────────── */
.nav-tabs-custom {
  border-bottom: 2px solid var(--border-color);
  gap: 4px;
}

.nav-tabs-custom .nav-link {
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  padding: 10px 18px;
  margin-bottom: -2px;
  transition: all .2s;
}

.nav-tabs-custom .nav-link:hover {
  color: var(--primary);
  border-bottom-color: var(--primary-light);
  background: transparent;
}

.nav-tabs-custom .nav-link.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
  background: transparent;
}

/* ── User avatar (table inline) ──────────────────────────── */
.user-avatar-sm {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, #1565c0, #42a5f5);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}

/* ── Masters Tab Nav ──────────────────────────────────────── */
.nav-tabs-master {
  display: flex;
  list-style: none;
  padding: 0;
  margin: 0;
  border-bottom: 2px solid var(--border-color);
  background: #f8f9ff;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  overflow-x: auto;
}

.nav-tabs-master .nav-item { flex-shrink: 0; }

.nav-tab-master {
  display: flex;
  align-items: center;
  padding: 13px 22px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color .2s, border-color .2s;
  margin-bottom: -2px;
}
.nav-tab-master:hover { color: var(--primary); }
.nav-tab-master.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
  background: #fff;
}

/* ── Role Cards ───────────────────────────────────────────── */
.role-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s;
}
.role-card:hover { box-shadow: var(--shadow-md); }

.role-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border-color);
  background: #f8f9ff;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.role-actions { display: flex; gap: 6px; }

.role-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}
.role-stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.1;
}
.role-stat-label {
  font-size: 10.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-top: 1px;
}

.role-desc {
  min-height: 36px;
  line-height: 1.5;
}

/* Permission chips preview on card */
.permission-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.chip {
  display: inline-block;
  background: #eef0fb;
  color: var(--primary);
  border: 1px solid #d0d5f5;
  border-radius: 20px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.chip-more {
  background: #f5f5f5;
  color: var(--text-muted);
  border-color: var(--border-color);
}

/* ── Assign Permissions (modal) ───────────────────────────── */
.perm-group-block {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.perm-group-title {
  background: #f5f7ff;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
}

.perm-checkboxes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0;
  padding: 4px 0;
}

.perm-check-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 14px;
  cursor: pointer;
  border-radius: 0;
  transition: background .15s;
  border-bottom: 1px solid #f3f4f8;
}
.perm-check-item:hover { background: #f0f3ff; }
.perm-check-item input[type="checkbox"] {
  margin-top: 2px;
  accent-color: var(--primary);
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  cursor: pointer;
}

.perm-check-label {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  min-width: 0;
}
.perm-check-name {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-dark);
}
.perm-check-key {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* Permission counter badge in modal footer */
#selectedPermCount {
  font-weight: 700;
  color: var(--primary);
}

/* ── Permission Matrix ────────────────────────────────────── */
.permission-matrix thead th {
  background: #f5f7ff;
  color: var(--text-dark);
  font-weight: 600;
  font-size: 12.5px;
  padding: 14px 12px;
  border-color: var(--border-color);
  vertical-align: middle;
}

.permission-matrix td {
  padding: 10px 12px;
  border-color: var(--border-color);
  font-size: 13.5px;
  vertical-align: middle;
}

.permission-group-header td {
  background: #eef0fb;
  color: var(--primary);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .6px;
  padding: 8px 14px;
}

.permission-label { color: var(--text-dark); }

.perm-allowed { background: #f0fff4; }
.perm-denied  { background: #fff5f5; }

/* ── Forms ────────────────────────────────────────────────── */
.form-label.required::after {
  content: ' *';
  color: #e53935;
}

.form-control, .form-select {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  transition: border-color .2s, box-shadow .2s;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(57,73,171,.12);
}

/* ── Badges ───────────────────────────────────────────────── */
.badge { font-size: 11.5px; font-weight: 600; letter-spacing: .2px; padding: 4px 8px; border-radius: 5px; }
.badge-xs { font-size: 9px; padding: 2px 5px; }
.bg-orange  { background-color: var(--orange) !important; }
.bg-purple  { background-color: #7b2ff7 !important; }
.text-orange { color: var(--orange) !important; }

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}
.blink { animation: blink 1.2s ease-in-out infinite; }

/* ── Detail View ──────────────────────────────────────────── */
.detail-row {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
}
.detail-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.detail-value { font-size: 13.5px; font-weight: 500; color: var(--text-dark); }

/* ── Auth ─────────────────────────────────────────────────── */
.auth-body {
  background: linear-gradient(135deg, #0d1757 0%, #1565c0 50%, #0d47a1 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

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

.auth-card {
  background: #fff;
  border-radius: var(--radius-xl);
  padding: 40px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.auth-logo { text-align: center; margin-bottom: 28px; }

.auth-logo-icon {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, #1565c0, #0d47a1);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; color: #fff;
  margin: 0 auto 12px;
  box-shadow: 0 8px 20px rgba(21,101,192,.35);
}

.auth-title { font-size: 22px; font-weight: 800; color: var(--text-dark); margin: 0; }
.auth-subtitle { font-size: 12.5px; color: var(--text-muted); margin: 4px 0 0; }

.otp-box {
  height: 54px;
  width: 44px !important;
  flex: 1;
  padding: 0;
  font-size: 22px !important;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  text-align: center;
}

.otp-box:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(57,73,171,.15);
}

/* ── Toast ────────────────────────────────────────────────── */
.toast-custom {
  min-width: 300px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

/* ── Sidebar Collapsed ────────────────────────────────────── */
body.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed-width); }
body.sidebar-collapsed .main-wrapper { margin-left: var(--sidebar-collapsed-width); }
body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .nav-link span,
body.sidebar-collapsed .nav-divider,
body.sidebar-collapsed .sidebar-badge { display: none; }
body.sidebar-collapsed .sidebar-menu .nav-link { justify-content: center; padding: 12px; }
body.sidebar-collapsed .btn-logout { justify-content: center; }
body.sidebar-collapsed .btn-logout-label { display: none; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  body.sidebar-collapsed .sidebar { width: var(--sidebar-width); transform: translateX(0); }
  body.sidebar-collapsed .main-wrapper { margin-left: 0; }

  .overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1040;
  }
  .overlay.show { display: block; }

  .page-content-inner { padding: 16px; }
  .kpi-card .kpi-value { font-size: 20px; }
}

@media (max-width: 575.98px) {
  .page-header { flex-direction: column; }
  .auth-card { padding: 28px 22px; }
  .otp-box { height: 48px; font-size: 18px !important; }
}

/* ── Workflow Timeline ───────────────────────────────────────── */
.workflow-timeline {
  padding: 20px 24px;
}
.wf-item {
  display: flex;
  gap: 16px;
  padding-bottom: 24px;
  position: relative;
}
.wf-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 32px;
  bottom: 0;
  width: 2px;
  background: #dee2e6;
}
.wf-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  z-index: 1;
}
.wf-body {
  flex: 1;
  padding-top: 4px;
}
.wf-title {
  font-weight: 600;
  font-size: 14px;
  color: #212529;
}
.wf-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: #6c757d;
  margin-top: 2px;
}
.wf-actor { font-weight: 500; }
.wf-comment {
  margin-top: 6px;
  padding: 8px 12px;
  background: #f8f9fa;
  border-left: 3px solid #dee2e6;
  border-radius: 0 4px 4px 0;
  font-size: 13px;
  color: #495057;
}

/* ── Workflow action card borders ───────────────────────────── */
.border-purple { border-color: #7b2ff7 !important; }
.btn-purple { background: #7b2ff7; border-color: #7b2ff7; }
.btn-purple:hover { background: #6825d6; border-color: #6825d6; }
.alert-purple {
  background-color: #ede7fd;
  border-color: #c4a8f9;
  color: #4a1a8c;
}
.btn-outline-purple {
  color: #7b2ff7;
  border-color: #7b2ff7;
}
.btn-outline-purple:hover {
  background: #7b2ff7;
  color: #fff;
}

/* ── Workflow Step Progress ─────────────────────────────────── */
.wf-steps {
  display: flex;
  align-items: center;
  padding: 20px 28px 16px;
  gap: 0;
}
.wf-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.wf-step-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  background: #e9ecef;
  color: #adb5bd;
  border: 2px solid #dee2e6;
  transition: all .2s;
}
.wf-step.done .wf-step-dot   { background: #198754; color: #fff; border-color: #198754; }
.wf-step.active .wf-step-dot { background: #fff; color: #ffc107; border-color: #ffc107; box-shadow: 0 0 0 3px rgba(255,193,7,.25); }
.wf-step.rejected .wf-step-dot { background: #dc3545; color: #fff; border-color: #dc3545; }
.wf-step-label {
  font-size: 11px;
  font-weight: 600;
  color: #adb5bd;
  white-space: nowrap;
}
.wf-step.done .wf-step-label   { color: #198754; }
.wf-step.active .wf-step-label { color: #856404; }
.wf-step.rejected .wf-step-label { color: #dc3545; }
.wf-step-line {
  flex: 1;
  height: 2px;
  background: #dee2e6;
  margin-bottom: 18px;
}
.wf-step-line.done { background: #198754; }

/* ── Workflow Action Box ─────────────────────────────────────── */
.wf-action-box {
  border: 1px solid;
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 16px;
}
.wf-action-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 8px;
}

/* ── Workflow History Label ──────────────────────────────────── */
.wf-history-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #6c757d;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

/* ── Workflow Action Row (modal trigger buttons) ─────────────── */
.wf-action-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 20px;
  background: #f8f9fa;
  border-top: 1px solid var(--border-color);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* ── Workflow Step: pending state ────────────────────────────── */
.wf-step.pending .wf-step-dot  { background: #fff; color: #7b2ff7; border-color: #7b2ff7; box-shadow: 0 0 0 3px rgba(123,47,247,.18); }
.wf-step.pending .wf-step-label { color: #7b2ff7; }
.wf-step-line.pending { background: linear-gradient(90deg, #198754 50%, #dee2e6 50%); }

/* ── Modal BG mini-card ──────────────────────────────────────── */
.wf-modal-bg-card {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.wf-modal-bg-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  padding: 3px 0;
}
.wf-modal-bg-row span:first-child {
  color: #6c757d;
  flex-shrink: 0;
}
.wf-modal-bg-row span:last-child {
  font-weight: 600;
  text-align: right;
}

/* ── Radio Cards (Approve / Reject decision) ─────────────────── */
.wf-radio-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 12px;
  border: 2px solid #dee2e6;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  text-align: center;
  user-select: none;
}
.wf-radio-card:hover {
  border-color: #adb5bd;
  background: #f8f9fa;
}
.wf-radio-card.selected {
  border-color: currentColor;
  background: #fff;
}
.wf-radio-card.approve-card.selected  { border-color: #198754; background: #f0fdf4; }
.wf-radio-card.reject-card.selected   { border-color: #dc3545; background: #fff5f5; }

/* ── Claim detail box (inside Claim Decision modal) ──────────── */
.wf-claim-detail-box {
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 13px;
}
.wf-claim-detail-title {
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #856404;
  margin-bottom: 6px;
}

/* ── Inline timeline tags ────────────────────────────────────── */
.wf-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 20px;
  letter-spacing: .03em;
  vertical-align: middle;
  margin-left: 4px;
}
.wf-tag-active  { background: #d1fae5; color: #065f46; }
.wf-tag-expired { background: #fee2e2; color: #991b1b; }
.wf-tag-success { background: #d1fae5; color: #065f46; }
.wf-tag-danger  { background: #fee2e2; color: #991b1b; }
.wf-tag-warning { background: #fef9c3; color: #854d0e; }
.wf-tag-purple  { background: #ede9fe; color: #5b21b6; }

/* ── Email Template Cards ────────────────────────────────────── */
.email-tpl-card {
  border: 1px solid var(--border-color);
  transition: box-shadow .15s, border-color .15s;
}
.email-tpl-card:hover {
  border-color: #0d6efd;
  box-shadow: 0 4px 16px rgba(13,110,253,.1);
}

/* ── Structured template editor ─────────────────────────────── */
.tpl-section-label {
  display: block;
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 4px;
}
.tpl-section-hint {
  font-size: 12px;
  color: #6c757d;
  margin-bottom: 10px;
}

/* Dashed border for the auto-generated table note */
.border-dashed {
  border-style: dashed !important;
  border-color: var(--border-color) !important;
  background: #fafafa;
}

/* ── Color picker row ────────────────────────────────────────── */
.tpl-color-row { }
.tpl-swatches {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.tpl-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform .1s, border-color .1s;
  flex-shrink: 0;
}
.tpl-swatch:hover  { transform: scale(1.15); }
.tpl-swatch.active { border-color: #fff; outline: 2px solid #333; }

.tpl-native-picker {
  width: 36px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  background: none;
  flex-shrink: 0;
}

/* ── Live header preview bar ─────────────────────────────────── */
.tpl-header-preview {
  border-radius: 6px;
  padding: 16px 20px;
  transition: background .2s;
}
.tpl-header-preview-title {
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 2px;
}
.tpl-header-preview-sub {
  color: rgba(255,255,255,.85);
  font-size: 12px;
}

/* ── Variable chips ──────────────────────────────────────────── */
.var-chip {
  font-size: 11px;
  padding: 3px 8px;
  cursor: pointer;
  transition: all .15s;
}
.var-chip code {
  font-size: 11px;
  color: inherit;
}

/* ── Email Log KPI cards (light variant) ─────────────────────── */
.email-kpi-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  box-shadow: var(--shadow-sm);
  background: #fff;
}
.email-kpi-icon {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.email-kpi-body  { flex: 1; min-width: 0; }
.email-kpi-value { display: block; font-size: 26px; font-weight: 800; line-height: 1.1; }
.email-kpi-label { display: block; font-size: 11.5px; font-weight: 500; margin-top: 2px; color: #6c757d; }

.email-kpi-success { border-color: #d1e7dd; }
.email-kpi-success .email-kpi-icon  { background: #d1e7dd; color: #0f5132; }
.email-kpi-success .email-kpi-value { color: #0f5132; }

.email-kpi-danger  { border-color: #f8d7da; }
.email-kpi-danger  .email-kpi-icon  { background: #f8d7da; color: #842029; }
.email-kpi-danger  .email-kpi-value { color: #842029; }

.email-kpi-primary { border-color: #cfe2ff; }
.email-kpi-primary .email-kpi-icon  { background: #cfe2ff; color: #084298; }
.email-kpi-primary .email-kpi-value { color: #084298; }

.email-kpi-neutral { border-color: #e9ecef; }
.email-kpi-neutral .email-kpi-icon  { background: #e9ecef; color: #495057; }
.email-kpi-neutral .email-kpi-value { color: #343a40; }

/* ── Dashboard Analytics Widgets ─────────────────────────── */

/* Heatmap */
.heatmap-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 60px;
}
.hm-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  height: 46px;
  border-radius: 7px;
  cursor: pointer;
  padding: 4px 8px;
  transition: transform .12s, box-shadow .12s;
  flex-shrink: 0;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.3);
  overflow: hidden;
}
.hm-tile:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
  z-index: 10;
  position: relative;
}
.hm-tile-num {
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.hm-tile-days {
  font-size: 10px;
  font-weight: 500;
  opacity: .88;
  line-height: 1;
  margin-top: 3px;
  white-space: nowrap;
}
.hm-legend {
  font-size: 11px;
  color: #6c757d;
}
.hm-legend-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}
.hm-legend-label { color: #6c757d; font-size: 11px; white-space: nowrap; }

/* Calendar */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-head {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: #6c757d;
  text-transform: uppercase;
  padding: 4px 2px 6px;
  border-bottom: 2px solid #e9ecef;
}
.cal-cell {
  min-height: 60px;
  border-radius: 6px;
  padding: 5px 6px;
  background: #fff;
  border: 1px solid #e9ecef;
  position: relative;
  transition: background .1s, border-color .1s;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cal-cell.cal-empty {
  background: transparent;
  border-color: transparent;
}
.cal-cell.cal-has-bg {
  background: #eff6ff;
  border-color: #bfdbfe;
  cursor: pointer;
}
.cal-cell.cal-has-bg:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}
.cal-cell.cal-today {
  border-color: #1565c0;
  border-width: 2px;
}
.cal-day-num {
  font-size: 12px;
  font-weight: 600;
  color: #6c757d;
  line-height: 1;
}
.cal-cell.cal-today .cal-day-num {
  color: #1565c0;
}
.cal-bg-badge {
  display: inline-block;
  background: #1565c0;
  color: #fff;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  line-height: 1.4;
  width: fit-content;
}
.cal-bg-amt {
  font-size: 9.5px;
  color: #1565c0;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* My Tasks */
.task-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border-color);
  transition: background .1s;
}
.task-row:last-of-type { border-bottom: none; }
.task-row:hover { background: #f8f9fa; }
.task-urgency-bar {
  width: 4px;
  min-height: 36px;
  border-radius: 3px;
  flex-shrink: 0;
}
.task-info { flex: 1; min-width: 0; }
.task-bg-num { font-size: 13px; font-weight: 700; color: #1565c0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-meta { font-size: 11.5px; color: #6c757d; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-expiry { font-size: 11px; font-weight: 600; color: #495057; white-space: nowrap; flex-shrink: 0; }
.task-footer {
  padding: 8px 14px;
  border-top: 1px solid var(--border-color);
  background: #fafbfc;
}

/* Vendor Scoreboard */
.vs-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  transition: background .1s;
}
.vs-row:last-child { border-bottom: none; }
.vs-row:hover { background: #f8f9fa; }
.vs-rank-col { flex-shrink: 0; padding-top: 2px; }
.vs-medal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 800;
}
.vs-medal-gold   { background: #ffd700; color: #5a4000; }
.vs-medal-silver { background: #c0c0c0; color: #333; }
.vs-medal-bronze { background: #cd7f32; color: #fff; }
.vs-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  background: #e9ecef;
  color: #495057;
}
.vs-info { flex: 1; min-width: 0; }
.vs-name {
  font-size: 13px;
  font-weight: 600;
  color: #212529;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.vs-bar-wrap {
  height: 4px;
  background: #e9ecef;
  border-radius: 2px;
  margin-bottom: 4px;
}
.vs-bar {
  height: 4px;
  background: linear-gradient(90deg, #1565c0, #42a5f5);
  border-radius: 2px;
  transition: width .5s ease;
}
.vs-meta { font-size: 12px; display: flex; align-items: center; flex-wrap: wrap; gap: 2px; }

/* ── Document Management ─────────────────────────────────── */

.doc-upload-panel {
  padding: 16px 20px;
  background: #f8f9fa;
  border-bottom: 1px solid var(--border-color);
}
.doc-upload-panel .form-label {
  margin-bottom: 5px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.doc-upload-panel .btn {
  white-space: nowrap;
}

/* Preview modal — tall body */
.doc-preview-body {
  height: 78vh;
  overflow: hidden;
  background: #1e1e1e;
}
.doc-preview-body iframe,
.doc-preview-body img {
  display: block;
}

/* ── Vendor Contacts Modal ───────────────────────────────── */

.vc-form-panel {
  background: #f8f9fa;
}
.vc-form-panel .form-label {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 3px;
}
#vcTable td { font-size: 13px; }

/* ── Vendor autofill highlight ───────────────────────────── */
@keyframes autofill-flash {
  0%   { background-color: #e8f4ff; }
  100% { background-color: transparent; }
}
.autofill-flash {
  animation: autofill-flash 1.2s ease-out;
}

/* ── Read-only select (vendor auto-fill) ─────────────────── */
.select-readonly {
  background-color: var(--bs-secondary-bg, #e9ecef);
  pointer-events: none;
  opacity: 1;
}

/* ── Settings page ───────────────────────────────────────── */
.settings-logo-preview {
  width: 88px;
  height: 88px;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8f9fa;
  flex-shrink: 0;
  overflow: hidden;
}
.settings-logo-preview img,
#logoImg {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.sidebar-logo-img {
  max-width: 36px;
  max-height: 36px;
  object-fit: contain;
}

/* ── Activity Log Timeline ───────────────────────────────── */
.act-item {
  display: flex;
  gap: .75rem;
  padding: .75rem 0;
  border-bottom: 1px solid var(--bs-border-color-translucent);
}
.act-item:last-child { border-bottom: none; }
.act-icon-wrap {
  flex-shrink: 0;
  width: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.act-icon-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bs-tertiary-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  flex-shrink: 0;
}
.act-body {
  flex: 1;
  min-width: 0;
}
.act-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .25rem .5rem;
}
.act-time {
  margin-left: auto;
  white-space: nowrap;
}
.act-detail {
  background: var(--bs-tertiary-bg);
  border-radius: .375rem;
  padding: .5rem .75rem;
  font-size: .8rem;
}
.act-filter-chip.active {
  font-weight: 600;
}

/* ── Section Headings (Email Templates page) ──────────────── */
.section-heading {
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border-color);
}
.section-heading-title {
  margin: 0 0 4px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}
.section-heading-desc {
  margin: 0;
  font-size: .825rem;
  color: var(--text-muted);
}
