:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1f2430;
  --muted: #7a8190;
  --line: #e4e7ec;
  --primary: #3b6ef0;
  --primary-dark: #2f59c4;
  --lent: #2e9e6b;
  --borrowed: #d9822b;
  --danger: #d64545;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(20, 30, 60, 0.08), 0 6px 16px rgba(20, 30, 60, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}

.hidden { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, transform 0.05s;
  font-family: inherit;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { background: rgba(0, 0, 0, 0.06); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 6px; }

/* ---------- Auth ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
}
.auth-logo { margin: 0; font-size: 26px; text-align: center; }
.auth-sub {
  margin: 4px 0 22px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.auth-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg);
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 20px;
}
.auth-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
}
.auth-tab.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 12px 0 0; text-align: center; }

label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); }
input, textarea, select {
  width: 100%;
  margin-top: 5px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 110, 240, 0.15);
}
textarea { resize: vertical; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--card);
  padding: 0 20px;
  height: 58px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand { font-weight: 700; font-size: 18px; white-space: nowrap; }
.tabs { display: flex; gap: 6px; margin-left: 10px; }
.tab {
  border: none;
  background: transparent;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
  font-family: inherit;
  font-size: 15px;
}
.tab.active { background: var(--bg); color: var(--ink); }
.user-area { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-name { color: var(--muted); font-size: 14px; font-weight: 600; white-space: nowrap; }

/* ---------- Layout ---------- */
.container { max-width: 1100px; margin: 0 auto; padding: 22px 18px 60px; }
.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.column-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.column-head h2 { font-size: 17px; margin: 0; }
.hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.card-list { display: flex; flex-direction: column; gap: 12px; min-height: 40px; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  gap: 12px;
  border-left: 4px solid var(--line);
  transition: opacity 0.3s;
}
.card.dir-lent_out { border-left-color: var(--lent); }
.card.dir-borrowed { border-left-color: var(--borrowed); }
.card.done { opacity: 0.4; }
.card-thumb {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: cover;
  cursor: pointer;
  flex-shrink: 0;
  background: var(--bg);
}
.card-body { flex: 1; min-width: 0; }
.card-title {
  font-weight: 700;
  font-size: 15px;
  margin: 0 0 2px;
  word-break: break-word;
}
.card-amount { font-size: 18px; font-weight: 700; margin: 0 0 2px; }
.card-meta { font-size: 13px; color: var(--ink); }
.card-desc { font-size: 13px; color: var(--muted); margin: 4px 0 0; word-break: break-word; }
.card-owner { font-size: 11px; color: var(--muted); margin-top: 6px; }
.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  gap: 8px;
}
.card-check { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.card-check input { width: auto; margin: 0; }
.card-actions { display: flex; gap: 4px; }
.icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 15px;
  padding: 4px 7px;
  border-radius: 6px;
  line-height: 1;
}
.icon-btn:hover { background: rgba(0, 0, 0, 0.07); }

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 26px 10px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

/* ---------- Summary ---------- */
.summary { display: flex; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.summary-box {
  flex: 1;
  min-width: 160px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  border-top: 3px solid var(--line);
}
.summary-box.lent { border-top-color: var(--lent); }
.summary-box.borrowed { border-top-color: var(--borrowed); }
.summary-label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
.summary-value { display: block; font-size: 26px; font-weight: 800; margin-top: 4px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 25, 40, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}
.modal {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 440px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal h3 { margin: 0 0 18px; }
.modal form { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: flex; gap: 12px; }
.form-row > label { flex: 1; }
.check-inline { display: flex; align-items: center; gap: 8px; }
.check-inline input { width: auto; margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.form-error { color: var(--danger); font-size: 13px; min-height: 16px; margin: 0; }

.photo-preview { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.photo-preview img {
  max-width: 140px;
  max-height: 140px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

/* ---------- Admin ---------- */
.admin-h { margin: 18px 0 10px; font-size: 14px; }
.admin-block { display: flex; flex-direction: column; gap: 10px; }
.admin-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.admin-user-row .uname { font-weight: 600; }
.admin-user-row .badge {
  font-size: 11px;
  background: var(--primary);
  color: #fff;
  padding: 2px 7px;
  border-radius: 20px;
  margin-left: 6px;
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  cursor: zoom-out;
  padding: 20px;
}
.lightbox img { max-width: 95%; max-height: 95%; border-radius: 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .columns { grid-template-columns: 1fr; gap: 26px; }
  .topbar { gap: 8px; padding: 0 12px; }
  .brand { font-size: 16px; }
  .tab { padding: 8px 10px; font-size: 14px; }
  .user-name { display: none; }
  .container { padding: 16px 12px 50px; }
}
