:root {
  --primary: #1a4f8a;
  --primary-dark: #133a68;
  --primary-light: #e8f0fb;
  --accent: #f5a623;
  --sidebar-width: 250px;
  --sidebar-bg: #0f2d52;
  --sidebar-text: #b8cde0;
  --sidebar-active: rgba(255,255,255,0.12);
  --card-shadow: 0 2px 12px rgba(0,0,0,0.08);
  --border-radius: 10px;
  --success: #28a745;
  --danger: #dc3545;
  --warning: #ffc107;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
  background: #f0f4f8;
  color: #2c3e50;
  margin: 0;
  font-size: 14px;
}

/* ─── Sidebar ─────────────────────────────── */
#sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  overflow-y: auto;
  z-index: 1040;
  transition: transform .25s ease;
  display: flex;
  flex-direction: column;
}
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius:2px; }

/* Sidebar backdrop overlay (mobile) */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1039;
}
#sidebar-overlay.show { display: block; }

.sidebar-brand {
  padding: 14px 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.sidebar-brand .brand-logo {
  width: 38px; height: 38px;
  object-fit: contain; flex-shrink: 0;
  border-radius: 50%;
  background: #fff;
  padding: 2px;
}
.sidebar-brand .brand-text h6 {
  color: #fff; margin: 0; font-size: 12.5px; font-weight: 700; line-height: 1.2;
}
.sidebar-brand .brand-text small {
  color: var(--sidebar-text); font-size: 10px; line-height: 1;
}

.sidebar-section {
  padding: 18px 12px 4px;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,.35);
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

#sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  color: var(--sidebar-text);
  border-radius: 8px;
  margin: 1px 8px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s, color .15s;
}
#sidebar .nav-link i { font-size: 15px; flex-shrink: 0; }
#sidebar .nav-link:hover { background: var(--sidebar-active); color: #fff; }
#sidebar .nav-link.active { background: var(--primary); color: #fff; }
#sidebar .nav-link .badge { margin-left: auto; }

.sidebar-bottom {
  margin-top: auto;
  padding: 14px;
  border-top: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.sidebar-bottom .user-info {
  display: flex; align-items: center; gap: 10px;
}
.sidebar-bottom .user-info .avatar {
  width: 34px; height: 34px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.sidebar-bottom .user-info .name {
  font-size: 12.5px; color: #fff; font-weight: 600; line-height: 1.2;
}
.sidebar-bottom .user-info .role {
  font-size: 10.5px; color: var(--sidebar-text);
}

/* ─── Main Content ────────────────────────── */
#main {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex; flex-direction: column;
}

/* ─── Topbar ──────────────────────────────── */
#topbar {
  background: #fff;
  border-bottom: 1px solid #e8ecf0;
  padding: 0 20px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 900;
  gap: 12px;
}
.topbar-title { font-size: 16px; font-weight: 700; color: #1a2e4a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.notif-btn {
  position: relative;
  background: none;
  border: none;
  font-size: 20px;
  color: #7a8ba0;
  cursor: pointer;
  padding: 4px 6px;
  transition: color .15s;
}
.notif-btn:hover { color: var(--primary); }
.notif-btn .badge-dot {
  position: absolute; top: 2px; right: 2px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid #fff;
}

/* ─── Hamburger ───────────────────────────── */
.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  font-size: 22px;
  color: #1a2e4a;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}

/* ─── Content Area ────────────────────────── */
.content-area { padding: 20px 24px; flex: 1; }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 10px;
}
.page-header h4 { margin: 0; font-size: 19px; font-weight: 700; color: #1a2e4a; }

/* ─── Stat Cards ──────────────────────────── */
.stat-card {
  background: #fff;
  border-radius: var(--border-radius);
  padding: 18px 20px;
  box-shadow: var(--card-shadow);
  display: flex; align-items: center; gap: 14px;
  border-left: 4px solid transparent;
  transition: transform .15s, box-shadow .15s;
  text-decoration: none; color: inherit;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.12); }
.stat-card .stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.stat-card .stat-value { font-size: 26px; font-weight: 800; line-height: 1; }
.stat-card .stat-label { font-size: 12px; color: #6c7a8d; font-weight: 500; margin-top: 2px; }

.stat-card.blue  { border-left-color: var(--primary); }
.stat-card.blue  .stat-icon { background: var(--primary-light); color: var(--primary); }
.stat-card.green { border-left-color: var(--success); }
.stat-card.green .stat-icon { background: #e8f8ed; color: var(--success); }
.stat-card.orange{ border-left-color: var(--accent); }
.stat-card.orange .stat-icon { background: #fff5e5; color: var(--accent); }
.stat-card.red   { border-left-color: var(--danger); }
.stat-card.red   .stat-icon { background: #fde8ea; color: var(--danger); }
.stat-card.gray  { border-left-color: #aaa; }
.stat-card.gray  .stat-icon { background: #f0f2f4; color: #6c7a8d; }

/* ─── Cards ───────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--border-radius);
  box-shadow: var(--card-shadow);
  border: none;
}
.card-header {
  background: transparent;
  border-bottom: 1px solid #eef0f3;
  padding: 14px 18px;
  font-weight: 700;
  font-size: 14px;
  color: #1a2e4a;
  display: flex; align-items: center; justify-content: space-between;
}

/* ─── Tables ──────────────────────────────── */
.table-card { background: #fff; border-radius: var(--border-radius); box-shadow: var(--card-shadow); overflow: hidden; }
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table thead th {
  background: #f8fafc;
  border-bottom: 2px solid #e8ecf0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: #6c7a8d;
  padding: 11px 14px;
  white-space: nowrap;
}
.table td { padding: 11px 14px; vertical-align: middle; font-size: 13px; border-color: #f0f2f5; }
.table tbody tr:hover { background: #fafbfc; }

/* ─── Badges ──────────────────────────────── */
.badge { font-size: 11px; font-weight: 600; padding: 4px 9px; border-radius: 20px; }
.badge.bg-success { background: #d4edda !important; color: #155724 !important; }
.badge.bg-warning { background: #fff3cd !important; color: #856404 !important; }
.badge.bg-danger  { background: #f8d7da !important; color: #721c24 !important; }
.badge.bg-secondary { background: #e2e8ee !important; color: #4a5568 !important; }
.badge.bg-primary { background: #cfe2ff !important; color: #084298 !important; }
.badge.bg-dark    { background: #343a40 !important; color: #fff !important; }

/* ─── Forms ───────────────────────────────── */
.form-control, .form-select {
  border: 1.5px solid #e0e6ed;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,79,138,.12);
}
.form-label { font-weight: 600; font-size: 13px; color: #374151; margin-bottom: 6px; }

/* ─── Buttons ─────────────────────────────── */
.btn { font-size: 13.5px; font-weight: 600; border-radius: 8px; padding: 9px 18px; transition: all .15s; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-sm { padding: 5px 12px; font-size: 12.5px; border-radius: 6px; }

/* ─── Login Page ──────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f2d52 0%, #1a4f8a 60%, #2d6bb5 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo {
  text-align: center; margin-bottom: 28px;
}
.login-logo img {
  width: 90px; height: 90px; object-fit: contain; margin-bottom: 12px;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,.15));
}

/* ─── Asset Image ─────────────────────────── */
.asset-img {
  width: 44px; height: 44px; object-fit: cover;
  border-radius: 8px; background: #f0f4f8;
}
.asset-img-placeholder {
  width: 44px; height: 44px;
  background: var(--primary-light);
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--primary); font-size: 20px;
}

/* ─── Alert bar ───────────────────────────── */
.alert { border-radius: 10px; font-size: 13.5px; }

/* ─── Progress / Overdue bar ──────────────── */
.overdue-bar { height: 6px; border-radius: 3px; background: #f0f2f5; overflow: hidden; }
.overdue-bar .fill { height: 100%; border-radius: 3px; background: var(--danger); }

/* ─── Notification Dropdown ───────────────── */
.notif-dropdown {
  min-width: 320px;
  max-height: 420px;
  overflow-y: auto;
  padding: 0;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,.15);
  border: 1px solid #e8ecf0;
}
.notif-item {
  padding: 12px 14px;
  border-bottom: 1px solid #f0f2f5;
  display: flex; gap: 10px; align-items: flex-start;
  transition: background .1s;
}
.notif-item:hover { background: #f8fafc; }
.notif-item.unread { background: #f0f7ff; }
.notif-item .notif-icon {
  width: 34px; height: 34px; flex-shrink: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.notif-item .notif-title { font-size: 13px; font-weight: 600; color: #1a2e4a; }
.notif-item .notif-msg { font-size: 12px; color: #6c7a8d; margin-top: 2px; }
.notif-item .notif-time { font-size: 11px; color: #aab4c0; margin-top: 4px; }

/* ─── Search bar ──────────────────────────── */
.search-box { position: relative; }
.search-box .form-control { padding-left: 38px; background: #f0f4f8; border-color: transparent; }
.search-box .form-control:focus { background: #fff; border-color: var(--primary); }
.search-box i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #9aabb8; }

/* ─── Tabs ────────────────────────────────── */
.nav-tabs .nav-link { color: #6c7a8d; font-weight: 600; font-size: 13px; border: none; border-bottom: 3px solid transparent; padding: 9px 14px; white-space: nowrap; }
.nav-tabs .nav-link.active { color: var(--primary); border-bottom-color: var(--primary); background: none; }
.nav-tabs { border-bottom: 2px solid #e8ecf0; overflow-x: auto; flex-wrap: nowrap; }

/* ─── Checkout timer ──────────────────────── */
.countdown-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600;
}
.countdown-chip.ok     { background: #e8f8ed; color: #155724; }
.countdown-chip.warn   { background: #fff3cd; color: #856404; }
.countdown-chip.danger { background: #f8d7da; color: #721c24; }

/* ─── Tom Select ──────────────────────────── */
.ts-wrapper .ts-control { border: 1.5px solid #e0e6ed; border-radius: 8px; padding: 8px 14px; font-size: 14px; }
.ts-wrapper.focus .ts-control { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,79,138,.12); }

/* ════════════════════════════════════════════
   RESPONSIVE — Tablet (≤992px)
   ════════════════════════════════════════════ */
@media (max-width: 992px) {
  :root { --sidebar-width: 240px; }
  .content-area { padding: 16px 18px; }
  .stat-card .stat-value { font-size: 22px; }
}

/* ════════════════════════════════════════════
   RESPONSIVE — Mobile (≤768px)
   ════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Sidebar slides off-screen; toggled open */
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); }

  #main { margin-left: 0; }

  /* Show hamburger */
  .sidebar-toggle { display: flex; }

  .content-area { padding: 12px 14px; }

  /* Topbar compact */
  #topbar { padding: 0 14px; height: 54px; }
  .topbar-title { font-size: 14px; }

  /* Page header stacks */
  .page-header { flex-direction: column; align-items: flex-start; gap: 8px; margin-bottom: 16px; }
  .page-header h4 { font-size: 16px; }

  /* Stat cards: 2 per row */
  .stat-card { padding: 14px 16px; gap: 12px; }
  .stat-card .stat-icon { width: 40px; height: 40px; font-size: 18px; border-radius: 10px; }
  .stat-card .stat-value { font-size: 20px; }
  .stat-card .stat-label { font-size: 11px; }

  /* Notification dropdown full-width */
  .notif-dropdown { min-width: calc(100vw - 28px); right: -60px !important; left: auto !important; }

  /* Tables scroll horizontally */
  .table-responsive { border-radius: var(--border-radius); }
  .table thead th { font-size: 10px; padding: 9px 10px; }
  .table td { font-size: 12px; padding: 9px 10px; }

  /* Login card full-width */
  .login-card { padding: 28px 20px; border-radius: 12px; }
  .login-logo img { width: 75px; height: 75px; }

  /* Tabs scrollable */
  .nav-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .nav-tabs .nav-link { padding: 8px 12px; font-size: 12.5px; }

  /* Buttons full-width on mobile forms */
  .btn-mobile-full { width: 100%; }

  /* Card body padding reduced */
  .card-body { padding: 14px !important; }
  .card-header { padding: 12px 14px; font-size: 13px; }

  /* Hide search in topbar on mobile (use asset page search instead) */
  .search-box { display: none !important; }
}

/* ════════════════════════════════════════════
   RESPONSIVE — Small Mobile (≤480px)
   ════════════════════════════════════════════ */
@media (max-width: 480px) {
  .stat-card .stat-value { font-size: 18px; }
  .badge { font-size: 10px; padding: 3px 7px; }
  .btn { font-size: 13px; }
  .table td { white-space: nowrap; }
}
