/* ── Variables ─────────────────────────────────────────────────── */
:root {
  --primary:       #0A66C2;
  --primary-dark:  #004182;
  --primary-light: #E8F0FE;
  --bg:            #F3F2EF;
  --sidebar-bg:    #FFFFFF;
  --card-bg:       #FFFFFF;
  --text:          #1D2226;
  --text-muted:    #5F6163;
  --success:       #057642;
  --warning:       #915907;
  --danger:        #B11422;
  --border:        #E0DFDC;
  --sidebar-w:     220px;
  --radius:        8px;
  --shadow:        0 1px 4px rgba(0,0,0,.1);
}

/* ── 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;
}

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

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 14px;
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--primary-light); color: var(--primary); text-decoration: none; }
.nav-item.active { color: var(--primary); background: var(--primary-light); border-left-color: var(--primary); }
.nav-icon { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }

.nav-divider { height: 1px; background: var(--border); margin: 8px 0; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.avatar {
  width: 34px; height: 34px;
  background: var(--primary); color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; flex-shrink: 0;
}
.user-name { font-weight: 600; font-size: 13px; }
.user-role { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }
.btn-logout {
  display: block; text-align: center; padding: 7px;
  border-radius: var(--radius); border: 1px solid var(--border);
  color: var(--text-muted); font-size: 13px; font-weight: 500;
}
.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: 14px 24px;
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center;
}
.page-title { font-size: 17px; font-weight: 700; color: var(--text); }

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

/* ── Alerts ────────────────────────────────────────────────────── */
.alert {
  padding: 10px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 500;
}
.alert-success { background: #d1fae5; color: #065f46; }
.alert-danger   { background: #fee2e2; color: #991b1b; }
.alert-error    { background: #fee2e2; color: #991b1b; }
.alert-warning  { background: #fef9c3; color: #92400e; }
.alert-info     { background: #dbeafe; color: #1e40af; }

/* ── Cards ─────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
}
.card-title { font-size: 15px; font-weight: 600; }

/* ── 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);
  padding: 20px;
  box-shadow: var(--shadow);
}
.stat-value { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-weight: 500; }

/* ── 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: #fafafa;
  font-size: 12px; text-transform: uppercase; letter-spacing: .5px;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafafe; }

.table-th {
  padding: 10px 14px; text-align: left;
  font-weight: 600; color: var(--text-muted); background: #fafafa;
  font-size: 12px; text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px 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: 7px 18px; border-radius: 20px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; border: none;
  transition: background .15s, color .15s; text-decoration: none;
  line-height: 1.4;
}
.btn:hover { text-decoration: none; }

.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--primary); color: #fff;
  padding: 7px 18px; border-radius: 20px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; border: none;
  transition: background .15s; text-decoration: none;
  line-height: 1.4;
}
.btn-primary:hover { background: var(--primary-dark); color: #fff; text-decoration: none; }

.btn-secondary {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; color: var(--text);
  padding: 7px 18px; border-radius: 20px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; border: 1.5px solid var(--border);
  transition: background .15s; text-decoration: none;
  line-height: 1.4;
}
.btn-secondary:hover { background: #f5f5f5; color: var(--text); text-decoration: none; }

.btn-danger {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--danger); color: #fff;
  padding: 7px 18px; border-radius: 20px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; border: none;
  transition: background .15s; text-decoration: none;
  line-height: 1.4;
}
.btn-danger:hover { background: #8b0f1a; color: #fff; text-decoration: none; }

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

/* ── Forms ─────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-muted); margin-bottom: 4px;
  text-transform: uppercase; letter-spacing: .4px;
}
.form-control, .form-input {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px; font-family: inherit;
  color: var(--text); background: #fff;
  transition: border-color .15s;
}
.form-control:focus, .form-input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(10,102,194,.12);
}
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: var(--radius); padding: 40px 36px;
  width: 100%; max-width: 400px;
  box-shadow: 0 4px 20px rgba(0,0,0,.08);
}
.login-brand { text-align: center; margin-bottom: 28px; }
.login-title { font-size: 24px; font-weight: 700; color: var(--primary); 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: #d1fae5; color: var(--success); padding: 2px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-allocated { display: inline-flex; align-items: center; gap: 4px; background: #dbeafe; color: var(--primary); padding: 2px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-repair    { display: inline-flex; align-items: center; gap: 4px; background: #fef9c3; color: var(--warning); padding: 2px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-disposed  { display: inline-flex; align-items: center; gap: 4px; background: #fee2e2; color: var(--danger); padding: 2px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-active    { display: inline-flex; align-items: center; gap: 4px; background: #d1fae5; color: var(--success); padding: 2px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-inactive  { display: inline-flex; align-items: center; gap: 4px; background: #f3f4f6; color: var(--text-muted); padding: 2px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-returned  { display: inline-flex; align-items: center; gap: 4px; background: #f3f4f6; color: #4b5563; padding: 2px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-success   { background: #d1fae5; color: var(--success); padding: 2px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; display: inline-block; }
.badge-warning   { background: #fef9c3; color: #92400e; padding: 2px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; display: inline-block; }
.badge-danger    { background: #fee2e2; color: var(--danger); padding: 2px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; display: inline-block; }
.badge-info      { background: var(--primary-light); color: var(--primary); padding: 2px 10px; border-radius: 12px; 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: 32px; height: 32px; padding: 0 8px;
  border: 1.5px solid var(--border); 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; }
}
