:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1c2530;
  --muted: #6b7785;
  --border: #e1e5ea;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --good: #16a34a;
  --bad: #dc2626;
  --warn: #d97706;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
}
a { color: var(--accent); text-decoration: none; }

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand { font-weight: 700; font-size: 18px; }
.topbar nav { display: flex; gap: 14px; flex-wrap: wrap; }
.topbar nav a { color: var(--text); font-size: 14px; padding: 6px 4px; }
.topbar nav a.active { color: var(--accent); font-weight: 600; }
#logoutBtn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; }

.container { max-width: 1000px; margin: 0 auto; padding: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 17px; margin: 0 0 10px; }
.muted { color: var(--muted); font-size: 14px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.table-wrap { overflow-x: auto; }
tr.bad td { background: #fdecec; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge.stock { background: #e7f5ec; color: var(--good); }
.badge.installed { background: #e8effd; color: var(--accent-dark); }
.badge.refill { background: #fef3e0; color: var(--warn); }
.badge.written_off { background: #f1f2f4; color: var(--muted); }

.btn {
  display: inline-block;
  border: none;
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}
.btn:hover { background: var(--accent-dark); }
.btn.secondary { background: #eef1f5; color: var(--text); }
.btn.danger { background: var(--bad); }
.btn.block { width: 100%; }
.btn.big { padding: 18px; font-size: 18px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  background: #fff;
  color: var(--text);
}
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 10px; }
.stat-tile { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.stat-tile .num { font-size: 26px; font-weight: 700; }
.stat-tile .lbl { font-size: 12px; color: var(--muted); }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #1c2530; color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 14px; z-index: 100; opacity: 0; transition: opacity .2s;
}
.toast.show { opacity: 1; }

#reader { width: 100%; max-width: 420px; margin: 0 auto; }

.scan-list { list-style: none; padding: 0; margin: 12px 0 0; }
.scan-list li {
  display: flex; justify-content: space-between; padding: 10px 12px;
  background: #f8fafc; border-radius: 8px; margin-bottom: 6px; font-size: 14px;
}

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
}
.login-card { width: 320px; }

.print-only { display: none; }
@media print {
  .no-print { display: none !important; }
  .print-only { display: block; }
  body { background: #fff; }
}

.label-sheet { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.label {
  border: 1px dashed #999; border-radius: 6px; padding: 8px; text-align: center;
  break-inside: avoid;
}
.label img { width: 100%; max-width: 140px; }
.label .id { font-weight: 700; font-size: 13px; margin-top: 4px; }
.label .model { font-size: 12px; color: var(--muted); }

.sig-block { margin-top: 30px; }
.sig-line { border-bottom: 1px solid #333; display: inline-block; min-width: 260px; margin-left: 8px; }
