:root {
  --bg: #f4f6f9; --panel: #ffffff; --ink: #1d2433; --muted: #6b7486; --line: #e3e7ee;
  --brand: #1f4e9c; --brand-ink: #ffffff; --brand-soft: #e6eefb; --gold: #e0a526; --red: #c62828; --sky: #4fa3d9;
  --ok: #1d8a4e; --ok-soft: #e4f5ec; --warn: #b26a00; --warn-soft: #fff3df; --bad: #c0392b; --bad-soft: #fdeaea;
  --side: #132a5e; --side-ink: #d3dcef; --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", sans-serif; font-size: 16px; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.25; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
code { background: #eef1f6; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* layout */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 16px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { color: #fff; font-weight: 700; font-size: 15px; padding: 4px 10px 16px; display: flex; gap: 8px; align-items: center; }
.side .brand small { display: block; color: var(--side-ink); font-weight: 400; font-size: 11.5px; }
.side nav a { display: flex; align-items: center; gap: 10px; color: var(--side-ink); padding: 9px 12px; border-radius: 8px; margin-bottom: 2px; text-decoration: none; }
.side nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.side nav a.active { background: var(--brand); color: #fff; }
.side nav .sep { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; opacity: .55; padding: 14px 12px 6px; }
.main { min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top .menu-btn { display: none; }
.top .quick { flex: 1; max-width: 460px; }
.top .who { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.content { padding: 22px 24px 60px; max-width: 1400px; }

/* components */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.card > h3:first-child { display: flex; align-items: center; gap: 8px; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .n { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 12.5px; }
.kpi.bad .n { color: var(--bad); } .kpi.ok .n { color: var(--ok); } .kpi.warn .n { color: var(--warn); }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; margin-right: auto; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type=search], .toolbar input[type=text] { min-width: 220px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none; cursor: pointer; }
.tabs a.active { color: var(--brand); border-color: var(--brand); font-weight: 600; }

input, select, textarea { font: inherit; color: inherit; padding: 10px 12px; border: 1px solid #cfd6e1; border-radius: 8px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.toolbar input, .toolbar select { width: auto; }
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-size: 14px; color: #4a5468; font-weight: 500; }
label > input, label > select, label > textarea { margin-top: 5px; color: var(--ink); font-size: 16px; font-weight: 400; }
label.check { display: flex; gap: 10px; align-items: center; color: var(--ink); font-size: 16px; font-weight: 400; }
label.check input { width: 20px; height: 20px; }
label.check input { width: auto; margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid h3 { margin: 8px 0 0; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px; border-radius: 8px; border: 1px solid #cfd6e1; background: #fff; color: var(--ink); cursor: pointer; font: inherit; font-weight: 500; white-space: nowrap; text-decoration: none; }
.btn:hover { background: #f3f5f9; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); border-color: #f0c4bf; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn.big { padding: 11px 20px; font-size: 15px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btns { display: flex; gap: 6px; flex-wrap: wrap; }

table { width: 100%; border-collapse: collapse; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f8fafc; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbfd; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 10px 2px; color: var(--muted); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: #eef1f6; color: #4a5468; white-space: nowrap; }
.badge.ok, .badge.available, .badge.active, .badge.paid, .badge.received, .badge.sent, .badge.ready, .badge.closed { background: var(--ok-soft); color: var(--ok); }
.badge.warn, .badge.on_hold, .badge.partial, .badge.waiting, .badge.ordered, .badge.pending, .badge.repair, .badge.open, .badge.suspended { background: var(--warn-soft); color: var(--warn); }
.badge.bad, .badge.lost, .badge.damaged, .badge.unpaid, .badge.overdue, .badge.failed, .badge.expired { background: var(--bad-soft); color: var(--bad); }
.badge.issued, .badge.staff { background: var(--brand-soft); color: var(--brand); }

.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 12px; border: 1px solid; }
.alert.ok { background: var(--ok-soft); border-color: #b7e2c8; color: #135e36; }
.alert.bad { background: var(--bad-soft); border-color: #f2c2bc; color: #8e2318; }
.alert.warn { background: var(--warn-soft); border-color: #f3d9a8; color: #7a4a00; }
.alert.info { background: var(--brand-soft); border-color: #c9daf5; color: #1a4b92; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 9px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; justify-content: space-between; align-items: flex-start; }
.list li:last-child { border-bottom: 0; }
.dl { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; margin: 0; }
.dl dt { color: var(--muted); } .dl dd { margin: 0; }

/* circulation desk */
.scan { font-size: 22px; padding: 14px 16px; font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .04em; }
.desk { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.member-card { display: flex; gap: 14px; align-items: center; }
.avatar { width: 46px; height: 46px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: 17px; flex: none; }
.result { border-left: 4px solid var(--ok); }
.result.bad { border-left-color: var(--bad); }

/* charts */
.bars { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 200px) 1fr 60px; gap: 10px; align-items: center; font-size: 12.5px; }
.bar-row .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: #eef1f6; border-radius: 4px; height: 14px; overflow: hidden; }
.bar-fill { background: var(--brand); height: 100%; border-radius: 4px; }
.cols { display: flex; align-items: flex-end; gap: 10px; height: 140px; padding-top: 10px; }
.cols .c { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; font-size: 11.5px; color: var(--muted); }
.cols .c .v { background: var(--brand); width: 100%; max-width: 46px; border-radius: 5px 5px 0 0; min-height: 2px; }
.cols .c b { color: var(--ink); font-weight: 600; }

/* book covers */
.cover { width: 44px; height: 62px; border-radius: 4px; object-fit: cover; background: linear-gradient(135deg, #dfe7f5, #c9d6ee); display: grid; place-items: center; color: #6c7fa3; font-size: 18px; flex: none; }
.cover.lg { width: 120px; height: 170px; font-size: 40px; }
.book-head { display: flex; gap: 18px; align-items: flex-start; }

/* modal & toast */
.modal-back { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border-radius: 12px; width: min(680px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { width: min(980px, 100%); }
.modal header { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal header h2 { margin: 0; flex: 1; }
.modal .body { padding: 18px 20px; }
.modal footer { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; background: #fafbfd; position: sticky; bottom: 0; }
.x { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
#toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 60; }
.toast { background: #1d2433; color: #fff; padding: 14px 18px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 420px; font-size: 16px; animation: pop .18s ease-out; }
.toast.bad { background: var(--bad); } .toast.ok { background: var(--ok); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

/* login & install */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: #fff; }
.login-hero { position: relative; overflow: hidden; color: #fff; background: radial-gradient(circle at 20% 15%, #2c62b8 0%, #163a7a 45%, #0f2756 100%); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 40px; text-align: center; }
.login-hero::before { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(135deg, rgba(255,255,255,.035) 0 2px, transparent 2px 14px); }
.login-hero > * { position: relative; }
.founder { width: 220px; height: 260px; border-radius: 130px 130px 18px 18px; object-fit: cover; object-position: center 20%; border: 5px solid var(--gold); box-shadow: 0 18px 40px rgba(0,0,0,.35); background: #0f2756; }
.founder-name { margin-top: 16px; font-weight: 700; font-size: 18px; letter-spacing: .02em; }
.founder-role { color: #f3d58a; font-size: 14px; margin-top: 2px; }
.quote-box { margin-top: 30px; max-width: 520px; min-height: 150px; }
.quote-mark { font-family: Georgia, serif; font-size: 64px; line-height: .6; color: var(--gold); display: block; height: 30px; }
.quote-text { font-family: Georgia, "Times New Roman", serif; font-size: 25px; line-height: 1.4; transition: opacity .6s; }
.quote-by { margin-top: 12px; color: #c9d6f2; font-size: 15px; transition: opacity .6s; }
.quote-dots { display: flex; gap: 8px; justify-content: center; margin-top: 18px; }
.quote-dots i { width: 9px; height: 9px; border-radius: 50%; background: rgba(255,255,255,.3); cursor: pointer; }
.quote-dots i.on { background: var(--gold); }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 40px 28px; background: linear-gradient(180deg, #fff, #f5f8fd); }
.login-box { width: min(400px, 100%); }
.login-brand { text-align: center; margin-bottom: 26px; }
.login-brand img { width: 110px; height: auto; }
.login-brand h1 { font-size: 34px; margin: 10px 0 0; color: #13285c; letter-spacing: .03em; }
.login-brand .sub { color: var(--red); font-weight: 600; letter-spacing: .14em; text-transform: uppercase; font-size: 13px; margin-top: 4px; }
.login-box label { font-size: 16px; color: var(--ink); margin-bottom: 16px; }
.login-box input { font-size: 18px; padding: 14px 16px; border-radius: 10px; }
.login-box .btn.big { width: 100%; justify-content: center; font-size: 18px; padding: 15px; border-radius: 10px; margin-top: 6px; }
.login-help { text-align: center; color: var(--muted); font-size: 14px; margin-top: 18px; line-height: 1.6; }
.motto { text-align: center; margin-top: 26px; font-size: 13px; letter-spacing: .2em; color: var(--brand); font-weight: 700; }
@media (max-width: 860px) {
  .login-page { grid-template-columns: 1fr; }
  .login-hero { padding: 32px 20px; order: 2; }
  .founder { width: 150px; height: 180px; }
  .quote-text { font-size: 20px; }
}

/* home screen: big, friendly buttons */
.hello { font-size: 28px; margin: 0; }
.hello-sub { color: var(--muted); font-size: 17px; margin: 4px 0 22px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; margin-bottom: 26px; }
.tile-btn { display: flex; gap: 16px; align-items: center; background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 20px; color: var(--ink); text-decoration: none; box-shadow: var(--shadow); transition: border-color .15s, transform .15s; }
.tile-btn:hover { border-color: var(--brand); transform: translateY(-2px); text-decoration: none; }
.tile-btn .ic { font-size: 38px; width: 58px; height: 58px; border-radius: 14px; display: grid; place-items: center; background: var(--brand-soft); flex: none; }
.tile-btn b { display: block; font-size: 19px; }
.tile-btn span.d { color: var(--muted); font-size: 14px; }
.tile-btn.main { border-color: #b9cdee; }
.glance { list-style: none; padding: 0; margin: 0; }
.glance li { display: flex; gap: 12px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--line); font-size: 17px; }
.glance li:last-child { border-bottom: 0; }
.glance .big { font-weight: 700; font-size: 20px; min-width: 52px; text-align: right; }
.step { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 700; margin-right: 8px; font-size: 15px; flex: none; }
.big-ok { background: var(--ok-soft); border: 2px solid #9fd8b6; color: #135e36; border-radius: 12px; padding: 16px 18px; font-size: 18px; margin-bottom: 14px; }
.big-bad { background: var(--bad-soft); border: 2px solid #f0b4ad; color: #8e2318; border-radius: 12px; padding: 16px 18px; font-size: 18px; margin-bottom: 14px; }
.pick-list button { display: block; width: 100%; text-align: left; margin-bottom: 8px; }
.side .brand img { width: 40px; height: auto; background: #fff; border-radius: 8px; padding: 3px; }
.side nav details summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; color: var(--side-ink); padding: 9px 12px; border-radius: 8px; margin-top: 10px; }
.side nav details summary::-webkit-details-marker { display: none; }
.side nav details summary:hover { background: rgba(255,255,255,.07); }
.side nav details[open] summary .arrow { transform: rotate(90deg); }
.side nav details .arrow { margin-left: auto; transition: transform .15s; }

body.plain { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login { width: min(380px, 100%); }
.login h1 { text-align: center; }
.install { width: min(720px, 100%); }
.checks { list-style: none; padding: 0; } .checks .ok { color: var(--ok); } .checks .bad { color: var(--bad); font-weight: 600; }
.ok-box, .err-box { padding: 10px 14px; border-radius: 8px; margin: 10px 0; }
.ok-box { background: var(--ok-soft); color: #135e36; } .err-box { background: var(--bad-soft); color: #8e2318; }

/* printing: labels, cards, receipts */
.print-area { display: none; }
.labels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4mm; }
.label { border: 1px dashed #bbb; padding: 3mm; text-align: center; font-size: 9pt; page-break-inside: avoid; }
.label .t { font-size: 8pt; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.label .call { font-weight: 700; font-size: 11pt; }
.label svg { width: 100%; height: 12mm; }
.idcard { width: 86mm; height: 54mm; border: 1px solid #999; border-radius: 3mm; padding: 4mm; display: inline-flex; flex-direction: column; margin: 2mm; page-break-inside: avoid; font-size: 9pt; vertical-align: top; }
.idcard .sch { font-weight: 700; font-size: 10pt; border-bottom: 2px solid var(--brand); padding-bottom: 1mm; margin-bottom: 2mm; }
.idcard .nm { font-size: 12pt; font-weight: 700; }
.idcard svg { margin-top: auto; width: 100%; height: 12mm; }
@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { display: block !important; position: absolute; left: 0; top: 0; width: 100%; }
  .no-print { display: none !important; }
  .print-page .card { box-shadow: none; border: 0; }
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 40; left: 0; top: 0; width: 250px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .top { padding: 10px 16px; } .top .menu-btn { display: inline-flex; }
  .top .who .name { display: none; }
  .content { padding: 16px; }
  .g2, .g3, .desk, .form-grid { grid-template-columns: 1fr; }
  .book-head { flex-direction: column; }
  .dl { grid-template-columns: 110px 1fr; }
}
