:root {
  --sidebar-w: 260px;
  --sidebar-mini: 68px;
  --topbar-h: 60px;
  --primary: #1a56db;
  --primary-dark: #1e429f;
  --primary-light: #e8f0fe;
  --success: #0e9f6e;
  --danger: #f05252;
  --warning: #ff5a1f;
  --sidebar-bg: #111827;
  --sidebar-text: #9ca3af;
  --transition: .22s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: #f3f4f6; display: flex; overflow-x: hidden; }

/* ── SIDEBAR ──────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  transition: width var(--transition);
  z-index: 1000;
  overflow: hidden;
  flex-shrink: 0;
}

/* Collapsed state */
.sidebar.collapsed { width: var(--sidebar-mini); }

/* Header: logo + brand name */
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 64px;
  border-bottom: 1px solid #1f2937;
  flex-shrink: 0;
  overflow: hidden;
  white-space: nowrap;
}
.brand-logo {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 17px; color: #fff;
  flex-shrink: 0;
}
.brand-text { overflow: hidden; }
.brand-name  { display: block; color: #fff; font-weight: 700; font-size: 14px; white-space: nowrap; }
.brand-sub   { display: block; color: #6b7280; font-size: 11px; white-space: nowrap; }

/* Nav area */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 0;
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #374151; border-radius: 2px; }

.nav-section { margin-bottom: 4px; }
.nav-section-title {
  padding: 8px 20px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  color: #4b5563;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition);
}
.sidebar.collapsed .nav-section-title { opacity: 0; pointer-events: none; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  transition: background var(--transition), color var(--transition);
  border-left: 3px solid transparent;
}
.nav-link i {
  font-size: 15px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  transition: transform var(--transition);
}
.nav-link span { overflow: hidden; white-space: nowrap; }
.nav-link:hover { background: #1f2937; color: #fff; }
.nav-link.active { background: rgba(26,86,219,.15); color: #fff; border-left-color: var(--primary); }
.nav-link.active i { color: var(--primary); }

/* Hide labels when collapsed */
.sidebar.collapsed .nav-link span { opacity: 0; width: 0; }
.sidebar.collapsed .nav-link { padding: 10px 0; justify-content: center; gap: 0; border-left: none; }
.sidebar.collapsed .nav-link.active { background: rgba(26,86,219,.2); }

/* Tooltip on collapsed */
.sidebar.collapsed .nav-link { position: relative; }
.sidebar.collapsed .nav-link::after {
  content: attr(data-label);
  position: absolute;
  left: calc(var(--sidebar-mini) + 8px);
  background: #1f2937;
  color: #fff;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 1100;
}
.sidebar.collapsed .nav-link:hover::after { opacity: 1; }

/* Footer: user info + logout */
.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid #1f2937;
  overflow: hidden;
  flex-shrink: 0;
}
.user-avatar {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}
.user-details {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  min-width: 0;
}
.user-name  { display: block; color: #fff; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.user-role  { display: block; color: #6b7280; font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.sidebar.collapsed .user-details { display: none; }
.btn-logout {
  color: #6b7280; font-size: 16px;
  text-decoration: none;
  padding: 6px; border-radius: 6px;
  transition: color var(--transition);
  flex-shrink: 0;
}
.btn-logout:hover { color: var(--danger); }

/* ── MAIN WRAPPER ─────────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  width: calc(100% - var(--sidebar-w));
  transition: margin-left var(--transition), width var(--transition);
  display: flex;
  flex-direction: column;
}
.main-wrapper.collapsed {
  margin-left: var(--sidebar-mini);
  width: calc(100% - var(--sidebar-mini));
}

/* ── TOP NAVBAR ───────────────────────────────────────────── */
.top-navbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 500;
  flex-shrink: 0;
}
.sidebar-toggle {
  background: none; border: none;
  cursor: pointer;
  color: #6b7280; font-size: 18px;
  padding: 7px; border-radius: 7px;
  line-height: 1;
  transition: background var(--transition), color var(--transition);
}
.sidebar-toggle:hover { background: #f3f4f6; color: #111827; }
.navbar-breadcrumb { flex: 1; font-size: 14px; color: #6b7280; }
.navbar-breadcrumb a { color: var(--primary); text-decoration: none; }
.navbar-breadcrumb a:hover { text-decoration: underline; }
.navbar-actions { display: flex; gap: 8px; align-items: center; }

/* ── ALERTS ───────────────────────────────────────────────── */
.flash-container { padding: 16px 24px 0; }
.flash-container .alert { border-radius: 10px; font-size: 14px; }

/* ── MAIN CONTENT ─────────────────────────────────────────── */
.main-content { padding: 24px; flex: 1; }

/* ── PAGE HEADER ──────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title   { font-size: 22px; font-weight: 700; color: #111827; }
.page-subtitle { font-size: 14px; color: #6b7280; margin-top: 2px; }

/* ── CARDS ────────────────────────────────────────────────── */
.card {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
}
.card-title { font-size: 14px; font-weight: 600; color: #111827; }
.card-body  { padding: 20px; }

/* ── STAT CARDS ───────────────────────────────────────────── */
.stat-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.1); }
.stat-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 22px; flex-shrink: 0;
}
.stat-icon.blue   { background: #dbeafe; color: var(--primary); }
.stat-icon.green  { background: #d1fae5; color: var(--success); }
.stat-icon.red    { background: #fee2e2; color: var(--danger); }
.stat-icon.orange { background: #ffedd5; color: #ea580c; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-icon.teal   { background: #ccfbf1; color: #0d9488; }
.stat-value  { font-size: 22px; font-weight: 700; color: #111827; }
.stat-label  { font-size: 13px; color: #6b7280; }
.stat-change { font-size: 12px; margin-top: 4px; }
.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ── TABLES ───────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 0; }
.table thead th {
  background: #f9fafb;
  color: #374151;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .05em;
  text-transform: uppercase;
  border-bottom: 1px solid #e5e7eb;
  padding: 11px 16px;
  white-space: nowrap;
}
.table tbody td { padding: 12px 16px; vertical-align: middle; border-bottom: 1px solid #f3f4f6; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #f9fafb; }

/* ── STATUS BADGES ────────────────────────────────────────── */
.badge-status {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.badge-active    { background: #d1fae5; color: #065f46; }
.badge-paid      { background: #dbeafe; color: #1e3a8a; }
.badge-overdue   { background: #fee2e2; color: #991b1b; }
.badge-cancelled { background: #f3f4f6; color: #6b7280; }
.badge-confirmed { background: #d1fae5; color: #065f46; }
.badge-pending   { background: #fef3c7; color: #92400e; }
.badge-issued    { background: #dbeafe; color: #1e3a8a; }

/* ── FORMS ────────────────────────────────────────────────── */
.form-label { font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 5px; display: block; }
.form-control, .form-select {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  padding: 9px 12px;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}
textarea.form-control { resize: vertical; }
.input-group { display: flex; }
.input-group .form-control { border-radius: 0 8px 8px 0; }
.input-group-text {
  background: #f9fafb;
  border: 1px solid #d1d5db;
  border-right: none;
  border-radius: 8px 0 0 8px;
  padding: 9px 12px;
  font-size: 14px;
  color: #6b7280;
  display: flex; align-items: center;
}
.input-group .form-control:last-child { border-radius: 0 8px 8px 0; border-left: none; }
.input-group .input-group-text:last-child { border-radius: 0 8px 8px 0; border-left: none; border-right: 1px solid #d1d5db; }
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check-input { width: 16px; height: 16px; cursor: pointer; }
.form-check-label { font-size: 14px; cursor: pointer; }
.form-range { width: 100%; }
.form-section { background: #f9fafb; border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.form-section-title { font-size: 13px; font-weight: 700; color: #374151; margin-bottom: 12px; }

/* ── BUTTONS ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  border-radius: 8px; font-size: 14px; font-weight: 500;
  padding: 8px 16px; cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background .15s, border-color .15s, transform .1s;
  white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn-primary   { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success   { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #057a55; }
.btn-danger    { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #c81e1e; }
.btn-outline-primary   { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary-light); }
.btn-outline-secondary { background: transparent; color: #6b7280; border-color: #d1d5db; }
.btn-outline-secondary:hover { background: #f3f4f6; }
.btn-outline-danger    { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-outline-danger:hover { background: #fff1f2; }
.btn-outline-success   { background: transparent; color: var(--success); border-color: var(--success); }
.btn-outline-success:hover { background: #f0fdf4; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-icon {
  width: 32px; height: 32px;
  padding: 0; font-size: 13px;
  border-radius: 7px;
}
.w-100 { width: 100%; }

/* ── SEARCH BAR ───────────────────────────────────────────── */
.search-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.search-bar .form-control { min-width: 200px; flex: 1; }

/* ── LOGIN ────────────────────────────────────────────────── */
.login-wrapper {
  min-height: 100vh; width: 100%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(145deg, #000000 0%, #1a1a1a 40%, #2d2d2d 70%, #111111 100%);
  padding: 20px;
  position: relative;
  overflow: hidden;
}
/* Subtle texture overlay */
.login-wrapper::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 30% 20%, rgba(255,255,255,.04) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 80%, rgba(255,255,255,.03) 0%, transparent 50%);
  pointer-events: none;
}
.login-card {
  width: 100%; max-width: 420px;
  background: #fff; border-radius: 20px;
  padding: 40px;
  box-shadow: 0 24px 80px rgba(0,0,0,.6);
  position: relative; z-index: 1;
  border-top: 3px solid #000;
}
.login-logo {
  width: 90px; height: 90px;
  background: #f9f9f9;
  border-radius: 16px;
  border: 2px solid #e5e7eb;
  display: grid; place-items: center;
  margin: 0 auto 20px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
}
.login-title { text-align: center; font-size: 18px; font-weight: 700; color: #111827; line-height: 1.3; }
.login-sub { text-align: center; font-size: 13px; color: #6b7280; margin-bottom: 28px; margin-top: 6px; }
.btn-login {
  background: #111827; color: #fff; border: none;
  border-radius: 8px; font-size: 15px; font-weight: 600;
  padding: 12px; cursor: pointer; width: 100%;
  transition: background .2s, transform .1s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-login:hover { background: #000; }
.btn-login:active { transform: scale(.98); }

/* ── DETAIL VIEW ──────────────────────────────────────────── */
.detail-label { font-size: 11px; color: #6b7280; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.detail-value { font-size: 14px; color: #111827; font-weight: 500; margin-top: 3px; }
.detail-section { padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid #f3f4f6; }
.detail-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

/* ── SIMULATOR ────────────────────────────────────────────── */
.schedule-table thead th { font-size: 11px; }

/* ── MISC ─────────────────────────────────────────────────── */
.amount-large { font-size: 20px; font-weight: 700; color: var(--primary); }
.progress { height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 4px; }
.overdue-row td { background: #fff7f7 !important; }
.list-group { list-style: none; }
.list-group-item { padding: 12px 16px; border-bottom: 1px solid #f3f4f6; display: block; }
.list-group-item:last-child { border-bottom: none; }
.list-group-item-action { text-decoration: none; color: inherit; transition: background .12s; }
.list-group-item-action:hover { background: #f9fafb; }
.border-bottom { border-bottom: 1px solid #e5e7eb; }
.border-end { border-right: 1px solid #e5e7eb; }
.text-muted   { color: #9ca3af; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.fw-semibold  { font-weight: 600; }
.fw-bold      { font-weight: 700; }
.opacity-25   { opacity: .25; }
.d-block      { display: block; }
.d-flex       { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-center  { justify-content: center; }
.flex-wrap    { flex-wrap: wrap; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.me-1 { margin-right: 4px; } .me-2 { margin-right: 8px; } .me-3 { margin-right: 12px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.p-0 { padding: 0; } .p-3 { padding: 12px; } .p-4 { padding: 16px; }
.pt-0 { padding-top: 0; } .pb-0 { padding-bottom: 0; }
.px-4 { padding-left: 16px; padding-right: 16px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; }
.py-3 { padding-top: 12px; padding-bottom: 12px; }
.py-4 { padding-top: 16px; padding-bottom: 16px; }
.py-5 { padding-top: 32px; padding-bottom: 32px; }
.text-center { text-align: center; }
.text-end    { text-align: right; }
.h-100       { height: 100%; }
.small, small { font-size: 12px; }
.col-6  { width: 50%; float: left; padding: 0 6px; }
.col-12 { width: 100%; }
.row { display: flex; flex-wrap: wrap; margin: 0 -6px; }
.row.g-3 { margin: -6px; gap: 0; }
.row.g-3 > * { padding: 6px; }
.col-sm-6  { width: 50%; }
.col-md-6  { width: 50%; }
.col-lg-4  { width: 33.333%; }
.col-lg-6  { width: 50%; }
.col-lg-7  { width: 58.333%; }
.col-lg-8  { width: 66.666%; }
.col-xl-4  { width: 33.333%; }
.col-md-3  { width: 25%; }
.col-6.col-md-3 { width: 25%; }
.col-1 { width: 100%; }
.alert { padding: 12px 16px; border-radius: 8px; border: 1px solid transparent; font-size: 14px; display: flex; align-items: flex-start; gap: 8px; position: relative; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #065f46; }
.alert-danger  { background: #fff1f2; border-color: #fecdd3; color: #9f1239; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-info    { background: #eff6ff; border-color: #bfdbfe; color: #1e3a8a; }
.alert-dismissible { padding-right: 40px; }
.btn-close {
  position: absolute; right: 12px; top: 12px;
  background: none; border: none; cursor: pointer;
  font-size: 14px; color: inherit; opacity: .6; padding: 2px;
}
.btn-close::before { content: '✕'; }
.btn-close:hover { opacity: 1; }
.fade.show { opacity: 1; }
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.bg-primary { background: var(--primary) !important; color: #fff; }
.bg-success { background: var(--success) !important; color: #fff; }
.bg-danger  { background: var(--danger) !important; color: #fff; }
.bg-secondary { background: #6b7280 !important; color: #fff; }
.bg-light   { background: #f9fafb !important; }
.bg-opacity-10 { opacity: .9; }
.text-dark  { color: #111827 !important; }
.text-white { color: #fff !important; }
.border     { border: 1px solid #e5e7eb; }
.border-danger { border-color: var(--danger) !important; }
hr { border: none; border-top: 1px solid #e5e7eb; margin: 12px 0; }
a { color: var(--primary); }

/* ── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 1024px) {
  .col-lg-4, .col-lg-6, .col-lg-7, .col-lg-8 { width: 100%; }
  .col-xl-4 { width: 50%; }
}
@media (max-width: 768px) {
  /* On mobile: sidebar slides off-screen by default */
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w) !important;
  }
  .sidebar.mobile-open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,.4); }
  .main-wrapper { margin-left: 0 !important; width: 100% !important; }
  .main-content { padding: 16px; }
  .col-sm-6, .col-md-6, .col-xl-4 { width: 100%; }
  .col-6.col-md-3 { width: 50%; }
}
@media (max-width: 480px) {
  .col-6 { width: 100%; }
  .search-bar .form-control { min-width: 120px; }
}
