/* ── Variables ─────────────────────────────────────────────────── */
:root {
  --primary:       #5f5cf1;
  --primary-dark:  #4a47d6;
  --primary-light: #f0f0ff;
  --bg:            #f8f9fb;
  --sidebar-bg:    #ffffff;
  --card-bg:       #ffffff;
  --text:          #0d0d0d;
  --text-muted:    #8d95a3;
  --success:       #16a34a;
  --warning:       #ca8a04;
  --danger:        #dc2626;
  --border:        #e8eaed;
  --border-strong: #d1d5db;
  --sidebar-w:     224px;
  --radius:        7px;
  --radius-lg:     10px;
  --shadow:        0 1px 2px rgba(0,0,0,.06);
  --shadow-md:     0 2px 8px rgba(0,0,0,.08);
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ────────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* ── Sidebar ───────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 20;
  scrollbar-width: thin;
  scrollbar-color: #d1d5db transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 99px;
}
.sidebar::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
}
.brand-icon { font-size: 17px; color: var(--primary); }
.brand-name { font-size: 16px; font-weight: 700; color: var(--text); }

.sidebar-nav { flex: 1; padding: 10px 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 12px;
  margin: 1px 8px;
  border-radius: 6px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13.5px;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav-item.active { color: var(--primary); background: var(--primary-light); font-weight: 600; }
.nav-icon { font-size: 13px; width: 17px; text-align: center; flex-shrink: 0; }

.nav-divider { height: 1px; background: var(--border); margin: 4px 16px; }
.nav-section-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: #b0b8c4;
  padding: 10px 20px 3px;
}

.sidebar-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.user-info {
  display: flex; align-items: center; gap: 9px;
  flex: 1; min-width: 0;
  border-radius: var(--radius); padding: 5px 6px; margin: -5px -6px;
  transition: background 0.12s;
}
.user-info:hover { background: var(--bg); }
.avatar {
  width: 30px; height: 30px;
  background: var(--primary); color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.user-details { min-width: 0; }
.user-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.user-role { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }
.btn-logout {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; flex-shrink: 0;
  border-radius: var(--radius); border: 1px solid var(--border);
  color: var(--text-muted); font-size: 13px; transition: all 0.12s;
}
.btn-logout:hover { background: #fef2f2; color: var(--danger); border-color: var(--danger); text-decoration: none; }

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

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 48px;
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center;
}
.page-title { font-size: 14px; font-weight: 600; color: var(--text); }

.content-area { padding: 24px; flex: 1; }

/* ── Alerts ────────────────────────────────────────────────────── */
.alert {
  border: none;
  border-left: 3px solid;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 500;
}
.alert-success { background: #f0fdf4; color: #15803d; border-color: #16a34a; }
.alert-danger   { background: #fef2f2; color: #dc2626; border-color: #dc2626; }
.alert-error    { background: #fef2f2; color: #dc2626; border-color: #dc2626; }
.alert-warning  { background: #fffbeb; color: #b45309; border-color: #d97706; }
.alert-info     { background: #f0f0ff; color: var(--primary-dark); border-color: var(--primary); }

/* ── Cards ─────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: none;
  margin-bottom: 16px;
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: transparent;
}
.card-title { font-size: 13px; font-weight: 600; color: var(--text); }

/* ── Stats ─────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: none;
}
.stat-value { font-size: 24px; font-weight: 700; color: var(--text); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-weight: 400; }

/* ── Tables ────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  padding: 10px 14px; text-align: left;
  border-bottom: 1px solid var(--border); font-size: 13px;
}
.table th {
  font-weight: 600; color: var(--text-muted); background: transparent;
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1.5px solid var(--border);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f9fafb; }

.table-th {
  padding: 10px 14px; text-align: left;
  font-weight: 600; color: var(--text-muted); background: transparent;
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1.5px solid var(--border);
}
.table-td {
  padding: 10px 14px; text-align: left;
  font-size: 13px; color: var(--text);
  border-bottom: 1px solid var(--border);
}

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  cursor: pointer; border: none;
  transition: background .12s, box-shadow .12s; text-decoration: none;
  line-height: 1.4; height: 32px;
}
.btn:hover { text-decoration: none; }

.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--primary); color: #fff;
  padding: 6px 14px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  cursor: pointer; border: none; height: 32px;
  box-shadow: 0 1px 2px rgba(95,92,241,.25);
  transition: background .12s, box-shadow .12s; text-decoration: none;
  line-height: 1.4;
}
.btn-primary:hover { background: var(--primary-dark); color: #fff; box-shadow: 0 2px 6px rgba(95,92,241,.3); text-decoration: none; }

.btn-secondary {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; color: var(--text);
  padding: 6px 14px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; height: 32px;
  cursor: pointer; border: 1px solid var(--border-strong);
  transition: background .12s; text-decoration: none;
  line-height: 1.4;
}
.btn-secondary:hover { background: var(--bg); color: var(--text); text-decoration: none; }

.btn-danger {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--danger); color: #fff;
  padding: 6px 14px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; height: 32px;
  cursor: pointer; border: none;
  transition: background .12s; text-decoration: none;
  line-height: 1.4;
}
.btn-danger:hover { background: #b91c1c; color: #fff; text-decoration: none; }

.btn-sm { padding: 4px 10px !important; font-size: 12px !important; border-radius: 6px !important; height: 26px !important; }
.btn-block { width: 100%; justify-content: center; }

/* ── Forms ─────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--text-muted); margin-bottom: 5px;
}
.form-control, .form-input {
  width: 100%; padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 13.5px; font-family: inherit;
  color: var(--text); background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(95,92,241,.15);
}
select.form-control, select.form-input { cursor: pointer; }

/* ── Login ─────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-card {
  background: #fff; border: 1px solid var(--border);
  border-radius: 12px; padding: 40px 36px;
  width: 100%; max-width: 400px;
  box-shadow: 0 2px 12px rgba(0,0,0,.07);
}
.login-brand { text-align: center; margin-bottom: 28px; }
.login-title { font-size: 22px; font-weight: 700; color: var(--text); margin-top: 8px; }
.login-subtitle { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.login-card .form-group { margin-bottom: 14px; }
.login-card .btn-primary { margin-top: 8px; }

/* ── Badges ────────────────────────────────────────────────────── */
.badge-available { display: inline-flex; align-items: center; gap: 4px; background: #f0fdf4; color: var(--success); padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; }
.badge-allocated { display: inline-flex; align-items: center; gap: 4px; background: var(--primary-light); color: var(--primary); padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; }
.badge-repair    { display: inline-flex; align-items: center; gap: 4px; background: #fffbeb; color: var(--warning); padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; }
.badge-disposed  { display: inline-flex; align-items: center; gap: 4px; background: #fef2f2; color: var(--danger); padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; }
.badge-active    { display: inline-flex; align-items: center; gap: 4px; background: #f0fdf4; color: var(--success); padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; }
.badge-inactive  { display: inline-flex; align-items: center; gap: 4px; background: #f3f4f6; color: var(--text-muted); padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; }
.badge-returned  { display: inline-flex; align-items: center; gap: 4px; background: #f3f4f6; color: #4b5563; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; }
.badge-success   { background: #f0fdf4; color: var(--success); padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; display: inline-block; }
.badge-warning   { background: #fffbeb; color: #b45309; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; display: inline-block; }
.badge-danger    { background: #fef2f2; color: var(--danger); padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; display: inline-block; }
.badge-info      { background: var(--primary-light); color: var(--primary); padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; display: inline-block; }

/* ── Pagination ────────────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; gap: 4px;
  padding: 12px 16px; border-top: 1px solid var(--border); flex-wrap: wrap;
}
.page-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 30px; padding: 0 8px;
  border: 1px solid var(--border-strong); border-radius: 6px;
  font-size: 13px; font-weight: 500; color: var(--text-muted);
  background: #fff; cursor: pointer; text-decoration: none;
  transition: background .12s, border-color .12s;
}
.page-btn:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); text-decoration: none; }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn.disabled { opacity: .4; cursor: default; pointer-events: none; }

/* ── Empty State ───────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 48px 24px; text-align: center;
  color: var(--text-muted);
}
.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: .3; }

/* ── Grids ─────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ── Print styles ───────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .print\:hidden { display: none !important; }
  .main-content { margin-left: 0 !important; padding: 0 !important; }
  .layout { display: block !important; }
  .content-area { padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; break-inside: avoid; }
  a { color: inherit !important; text-decoration: none !important; }
  body { background: #fff !important; }
}
