body { font-size: 15px; }
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--brand); color: #fff; padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .logo { background: #fff; border-radius: 10px; padding: 8px 10px; margin-bottom: 14px; }
.side .logo img { height: 24px; display: block; }
.side nav a { display: block; color: #dbe5f5; text-decoration: none; padding: 9px 12px; border-radius: 8px; font-weight: 600; margin-bottom: 2px; }
.side nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.side nav a.on { background: rgba(255,255,255,.16); color: #fff; }
.side .me { font-size: .82rem; color: #b8c6dd; margin-top: 18px; padding: 10px 12px; border-top: 1px solid rgba(255,255,255,.15); }
.side .me button { background: none; border: 0; color: #fff; text-decoration: underline; cursor: pointer; padding: 0; font: inherit; margin-right: 10px; }
.main { padding: 20px 24px 60px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { margin: 0; }
.menu-btn { display: none; }

.grid { display: grid; gap: 12px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.stat .n { font-size: 1.7rem; font-weight: 800; color: var(--brand); font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: .82rem; }
.stat.alert-stat .n { color: var(--bad); }

.tbl-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f6f8fb; font-weight: 700; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .3px; white-space: nowrap; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfd; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.b-ok { background: var(--ok-bg); color: var(--ok); }
.b-bad { background: var(--bad-bg); color: var(--bad); }
.b-warn { background: var(--warn-bg); color: var(--warn); }
.b-info { background: #e8effa; color: var(--brand); }
.b-muted { background: #eef1f5; color: var(--muted); }
.flag { color: var(--warn); font-size: .8rem; }

.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; align-items: end; margin-bottom: 12px; }
.filters label { margin: 0 0 4px; font-size: .78rem; color: var(--muted); }
.filters input, .filters select, .form input, .form select, .form textarea { font-size: 15px; padding: 9px 11px; }
.form label { margin-top: 10px; font-size: .9rem; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.qr-box { text-align: center; }
.qr-box img, .qr-box svg { width: 100%; max-width: 260px; height: auto; }
.code-big { font-size: 2rem; font-weight: 800; letter-spacing: 6px; color: var(--brand); }
.qr-full { position: fixed; inset: 0; background: #fff; z-index: 200; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px; text-align: center; }
.qr-full .qr { width: min(70vh, 90vw); }
.qr-full .qr svg { width: 100%; height: auto; }
.qr-full .code-big { font-size: 3.4rem; }

.bar-cell { display: flex; align-items: center; gap: 8px; min-width: 160px; }
.bar-cell .bar { flex: 1; height: 10px; background: #eef1f5; border-radius: 99px; overflow: hidden; }
.bar-cell .bar > div { height: 100%; background: var(--brand-2); }
.bar-cell .bar.low > div { background: var(--bad); }

.items-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.item { border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: #fff; font-size: .88rem; }
.item.ok { border-color: #9fd3ae; background: #f7fcf8; }
.item.bad { border-color: #f0b4b4; background: #fffafa; }
.item img { max-width: 100%; display: block; margin: 4px 0; border: 1px solid var(--line); border-radius: 6px; }
.item .ref-img { width: 45%; }

.toast { position: fixed; right: 16px; bottom: 16px; z-index: 300; padding: 12px 16px; border-radius: 10px; font-weight: 600; box-shadow: var(--shadow); background: var(--brand); color: #fff; max-width: 380px; }
.toast.err { background: var(--bad); }
.login { max-width: 380px; margin: 8vh auto; padding: 16px; }
.login .logo { text-align: center; margin-bottom: 16px; }
.login .logo img { height: 34px; }
.section-title { margin: 22px 0 10px; }
textarea { min-height: 140px; resize: vertical; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 150; width: 240px; left: -260px; transition: left .2s; }
  .side.open { left: 0; }
  .menu-btn { display: inline-flex; }
  .main { padding: 14px 16px 60px; }
  .grid.c3, .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.c2 { grid-template-columns: 1fr; }
}
@media print {
  .side, .menu-btn, .no-print { display: none !important; }
  .layout { display: block; }
}
