:root {
  --navy: #14204b;
  --navy-light: #1c2c63;
  --accent: #2f5bea;
  --green: #16a34a;
  --green-bg: #dcfce7;
  --green-text: #15803d;
  --blue-bg: #dbeafe;
  --blue-text: #1d4ed8;
  --grey-bg: #e5e7eb;
  --grey-text: #4b5563;
  --orange: #f59e0b;
  --border: #e5e7eb;
  --bg: #f3f4f8;
  --text: #1c2333;
  --muted: #6b7280;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy), var(--navy-light));
}
.login-card {
  background: #fff;
  padding: 40px;
  border-radius: 12px;
  width: 340px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-card h1 { font-size: 21px; margin: 0 0 4px; color: var(--navy); font-weight: 700; }
.login-sub { color: var(--muted); margin: 0 0 20px; font-size: 13px; }
.login-card label { display: block; font-size: 12px; margin: 12px 0 4px; color: var(--muted); }
.login-card input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
}
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,91,234,.15); }
.login-card button {
  margin-top: 20px; width: 100%; padding: 11px; border: none; border-radius: 8px;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 600; cursor: pointer;
}
.login-card button:hover { background: #274bcc; }
.error-text { color: #c0392b; font-size: 12px; margin-top: 10px; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: var(--navy); color: #fff; display: flex; flex-direction: column;
  padding: 18px 0; flex-shrink: 0;
}
.brand { font-weight: 700; font-size: 16px; padding: 0 20px 18px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-mark { color: #6f96ff; }
.brand-rest { color: #fff; font-weight: 600; }
#nav-links { flex: 1; padding-top: 12px; display: flex; flex-direction: column; gap: 2px; }
#nav-links a {
  display: flex; align-items: center; gap: 12px; padding: 10px 20px; color: #b9c2e6;
  text-decoration: none; font-size: 14px; margin: 0 8px; border-radius: 8px;
}
#nav-links a .nav-icon { width: 18px; height: 18px; flex-shrink: 0; }
#nav-links a.active { background: var(--accent); color: #fff; }
#nav-links a:hover:not(.active) { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-footer { padding: 14px 20px 0; border-top: 1px solid rgba(255,255,255,.1); margin-top: 10px; }
#logout-btn {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  background: transparent; border: 1px solid rgba(255,255,255,.25);
  color: #fff; border-radius: 8px; cursor: pointer; font-size: 13px;
}
#logout-btn:hover { background: rgba(255,255,255,.1); }
#logout-btn .nav-icon { width: 16px; height: 16px; }

.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ---------- Top bar ---------- */
.topbar {
  height: 60px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; padding: 0 24px; flex-shrink: 0;
}
.icon-btn {
  background: transparent; border: none; color: var(--text); cursor: pointer;
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--bg); }
.topbar-title { font-weight: 600; font-size: 15px; }
.topbar-spacer { flex: 1; }
.topbar-user { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--navy); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
}

.content { flex: 1; padding: 24px 28px; overflow-x: auto; }

h2.page-title { margin: 0 0 18px; font-size: 20px; font-weight: 700; }

/* ---------- Cards / tables ---------- */
.summary-row { display: flex; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.summary-card {
  background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 16px 20px; min-width: 140px;
}
.summary-card .num { font-size: 24px; font-weight: 700; }
.summary-card .label { font-size: 12px; color: var(--muted); }

.card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 20px; }

table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--muted); font-weight: 600; background: #fafbfd; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: #fafbfd; }

.badge {
  display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.badge-available { background: var(--green-bg); color: var(--green-text); }
.badge-issued { background: var(--blue-bg); color: var(--blue-text); }
.badge-inactive { background: var(--grey-bg); color: var(--grey-text); }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.search-wrap { position: relative; flex: 1; min-width: 220px; max-width: 320px; }
.search-wrap svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted);
}
.search-wrap input {
  width: 100%; padding: 9px 10px 9px 32px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px;
}
.toolbar select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px;
}
.toolbar-spacer { flex: 1; }

button {
  display: inline-flex; align-items: center; gap: 6px;
}
button.primary {
  background: var(--accent); color: #fff; border: none; padding: 9px 16px; border-radius: 8px;
  cursor: pointer; font-size: 13px; font-weight: 600;
}
button.primary:hover { background: #274bcc; }
button.secondary {
  background: #fff; color: var(--text); border: 1px solid var(--border); padding: 9px 16px;
  border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600;
}
button.secondary:hover { background: var(--bg); }
button.danger { background: #dc2626; color: #fff; border: none; padding: 9px 16px; border-radius: 8px; cursor: pointer; font-weight: 600; }
button.danger:hover { background: #b91c1c; }

button.btn-add { background: var(--green); color: #fff; border: none; padding: 9px 16px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600; }
button.btn-add:hover { background: #128a3e; }
button.btn-transfer { background: var(--accent); color: #fff; border: none; padding: 9px 16px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600; }
button.btn-transfer:hover { background: #274bcc; }
button.btn-return { background: var(--orange); color: #fff; border: none; padding: 9px 16px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600; }
button.btn-return:hover { background: #d98a08; }
button.btn-export { background: #fff; color: var(--text); border: 1px solid var(--border); padding: 9px 16px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600; }
button.btn-export:hover { background: var(--bg); }

a.link-btn { color: var(--accent); text-decoration: none; font-size: 13px; }
.icon-link {
  display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px;
  border-radius: 6px; color: var(--muted); text-decoration: none;
}
.icon-link:hover { background: var(--bg); color: var(--accent); }
.icon-link svg { width: 17px; height: 17px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 640px; }
.form-grid.single { grid-template-columns: 1fr; }
.form-grid label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 4px; font-weight: 600; }
.form-grid input, .form-grid select, .form-grid textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px;
}
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,91,234,.12);
}
.form-actions { margin-top: 18px; display: flex; gap: 10px; }

/* ---------- Workflow steps ---------- */
.steps { display: flex; gap: 0; margin-bottom: 22px; }
.step {
  flex: 1; text-align: center; padding: 10px; font-size: 12px; color: var(--muted);
  border-bottom: 3px solid var(--border);
}
.step.active { color: var(--accent); border-color: var(--accent); font-weight: 600; }
.step.done { color: var(--green-text); border-color: var(--green); }

/* ---------- Timeline ---------- */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 10px 0 10px 18px; border-left: 2px solid var(--border); position: relative; margin-left: 6px; }
.timeline li::before {
  content: ""; position: absolute; left: -7px; top: 14px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--accent);
}
.timeline .action { font-weight: 600; font-size: 13px; }
.timeline .meta { font-size: 12px; color: var(--muted); }

.empty-state { color: var(--muted); font-size: 13px; padding: 20px 0; text-align: center; }
.msg-banner { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.msg-banner.success { background: var(--green-bg); color: var(--green-text); }
.msg-banner.error { background: #fdecea; color: #c0392b; }

/* ---------- Pagination ---------- */
.pagination {
  display: flex; align-items: center; justify-content: space-between; margin-top: 14px;
  font-size: 12px; color: var(--muted);
}
.pagination .pages { display: flex; gap: 6px; }
.pagination button {
  width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--border); background: #fff;
  color: var(--text); cursor: pointer; font-size: 12px; justify-content: center;
}
.pagination button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination button:disabled { opacity: .4; cursor: default; }

@media (max-width: 700px) {
  .sidebar { position: fixed; left: -220px; top: 0; bottom: 0; z-index: 20; transition: left .2s; }
  .sidebar.open { left: 0; }
  .app-main { width: 100%; }
}
