:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1a1f2b;
  --muted: #6b7280;
  --primary: #1e3a8a;
  --primary-hover: #1b357d;
  --primary-ink: #ffffff;
  --success: #16a34a;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --border: #e5e7eb;
  --radius: 10px;
  --gap: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0 0 8px; font-weight: 650; }
.muted { color: var(--muted); font-size: 13px; }
.hidden { display: none !important; }

.btn { min-height: 44px; padding: 0 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font-size: 15px; font-family: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: background .12s, border-color .12s; }
.btn:hover { border-color: #cbd2dc; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; }

input.field { min-height: 44px; width: 100%; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 15px; font-family: inherit; background: var(--surface); color: var(--text); }
input.field:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
label.lbl { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--gap); box-shadow: var(--shadow); }
.stat .muted { margin-bottom: 4px; }
.stat-num { font-size: 24px; font-weight: 680; font-variant-numeric: tabular-nums; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
td .btn.sm { padding: 0 10px; min-height: 30px; font-size: 13px; }

.app-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.app-header .brand { font-weight: 680; font-size: 17px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); margin-right: 5px; }
.dot.on { background: var(--success); }

.grid-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--gap); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.tabs { display: inline-flex; background: #eef1f5; border-radius: var(--radius); padding: 3px; }
.tabs .btn { min-height: 38px; border: 0; background: transparent; }
.tabs .btn.primary { box-shadow: var(--shadow); }
.field-group { display: flex; flex-direction: column; }
.grow { flex: 1 1 180px; }

.tbl-wrap { overflow: auto; max-height: 62vh; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; }
thead th { position: sticky; top: 0; background: #f8fafc; z-index: 1; font-weight: 600; color: #374151; }
tbody tr:hover { background: #f9fafb; }

.inv-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 8px; background: var(--surface); }
.inv-card-top { display: flex; justify-content: space-between; }
.inv-card-total { font-size: 17px; font-weight: 650; margin-top: 4px; }

.banner { padding: 10px 14px; border-radius: var(--radius); }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.err { background: var(--danger-bg); color: var(--danger); }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -3px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

.captcha-box { display: flex; align-items: center; gap: 10px; background: #f8fafc; border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 10px; min-height: 52px; }
.captcha-box svg { height: 40px; }

@media (max-width: 860px) {
  .grid-stats { grid-template-columns: repeat(2, 1fr); }
  table.desktop-only { display: none; }
  .toolbar .btn, .toolbar .field-group { flex: 1 1 100%; }
}
@media (min-width: 861px) {
  .cards-mobile { display: none; }
}
