/* Hobitec Manager — shared styles */
:root {
  --bg: #f4f6f9; --card: #fff; --ink: #172033; --ink-2: #4a5568; --ink-3: #8a94a6;
  --line: #e2e6ee; --line-2: #eef1f6; --field: #fff;
  --accent: #1557d6; --accent-ink: #fff; --accent-soft: #e8f0fe;
  --orange: #f07a12;
  --ok: #138a4b; --ok-soft: #e6f6ed; --warn: #a86400; --warn-soft: #fff4dc;
  --bad: #c53030; --bad-soft: #fdeaea; --info-soft: #eef2ff;
  --series-1: #2a78d6; --series-2: #eb6834; --ghost: #c9ced8; --grid: #eceff4;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141c; --card: #171e29; --ink: #e8edf5; --ink-2: #b4bfd0; --ink-3: #7d899c;
    --line: #2a3443; --line-2: #212a37; --field: #111821;
    --accent: #5b8fff; --accent-ink: #0b1220; --accent-soft: #1b2a47;
    --ok: #4fd18b; --ok-soft: #12301f; --warn: #f2b84b; --warn-soft: #33270f;
    --bad: #ff7b7b; --bad-soft: #3a1717; --info-soft: #1c2440;
    --series-1: #3987e5; --series-2: #d95926; --ghost: #3a4454; --grid: #222b38;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Georgian", sans-serif; }
a { color: var(--accent); }
.wrap { max-width: 1320px; margin: 0 auto; padding: 16px; }
.muted { color: var(--ink-3); }
.small { font-size: .8rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82rem; }
.hidden { display: none !important; }

/* Header */
.app-header { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; margin-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 1.25rem; font-weight: 600; }
.brand b { color: var(--accent); }
.brand-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), var(--orange)); color: #fff; font-weight: 800; }
.app-header .spacer { flex: 1; }
.pill { font-size: .72rem; padding: 2px 8px; border-radius: 99px; background: var(--line-2); color: var(--ink-2); }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -2px; padding: 9px 14px; font: inherit; font-weight: 500; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card h2 { font-size: 1rem; margin: 0 0 4px; }
.card > p.muted { margin: 0 0 12px; font-size: .85rem; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

/* Controls */
.controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-bottom: 12px; }
label { display: flex; flex-direction: column; gap: 3px; font-size: .78rem; color: var(--ink-2); font-weight: 500; }
label.inline { flex-direction: row; align-items: center; gap: 6px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--field); border: 1px solid var(--line); border-radius: 7px; padding: 6px 9px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
textarea { width: 100%; resize: vertical; }
.btn { font: inherit; font-weight: 500; border-radius: 7px; padding: 7px 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--ink-3); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { color: var(--bad); }
.btn-sm { padding: 3px 9px; font-size: .78rem; }
.btn:disabled { opacity: .5; cursor: default; }
.paste-zone { border: 2px dashed var(--line); border-radius: 8px; padding: 8px 12px; color: var(--ink-3); background: var(--line-2); resize: none; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th { text-align: left; font-weight: 600; font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-3); background: var(--line-2); padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; }
th.sortable { cursor: pointer; } th.sortable:hover { color: var(--ink); }
td { padding: 6px 8px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td input { width: 100%; padding: 4px 7px; }
td input.num { text-align: right; }
.thumb { width: 38px; height: 38px; object-fit: contain; border-radius: 5px; background: #fff; border: 1px solid var(--line-2); display: block; }
.scroll-y { max-height: 62vh; overflow-y: auto; }
tr.row-ok td { background: var(--ok-soft); }
tr.row-err td { background: var(--bad-soft); }
tr.row-warn td { background: var(--warn-soft); }

/* Badges & margins */
.badge { display: inline-block; font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-info { background: var(--accent-soft); color: var(--accent); }
.m-good { color: var(--ok); font-weight: 600; } .m-ok { color: var(--warn); font-weight: 600; } .m-bad { color: var(--bad); font-weight: 600; }
.sale-tag { font-size: .65rem; font-weight: 700; color: var(--orange); margin-left: 4px; }

/* Progress / toast */
.progress { height: 6px; background: var(--line-2); border-radius: 9px; overflow: hidden; margin: 10px 0 4px; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.toast { position: fixed; right: 16px; bottom: 16px; max-width: 420px; padding: 10px 14px; border-radius: 8px; background: var(--ink); color: var(--bg); box-shadow: 0 6px 24px rgba(0,0,0,.2); z-index: 100; font-size: .86rem; }
.toast.err { background: var(--bad); color: #fff; }

/* Form layouts (New Product) */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 12px; }
.form-grid .span-2 { grid-column: span 2; } .form-grid .span-all { grid-column: 1 / -1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 180px; overflow-y: auto; padding: 6px; border: 1px solid var(--line); border-radius: 7px; background: var(--field); }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: .8rem; padding: 3px 9px; border-radius: 99px; border: 1px solid var(--line); cursor: pointer; color: var(--ink-2); user-select: none; }
.chip input { width: 13px; height: 13px; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.img-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.img-list figure { margin: 0; position: relative; }
.img-list img { width: 84px; height: 84px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 7px; }
.img-list button { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: var(--bad); color: #fff; cursor: pointer; font-size: 12px; line-height: 1; }

/* KPIs (Dashboard) */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi .k-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 600; }
.kpi .k-value { font-size: 1.45rem; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: .76rem; color: var(--ink-3); }
.up { color: var(--ok); } .down { color: var(--bad); }
.chart { width: 100%; overflow-x: auto; }
.chart svg { display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: .78rem; color: var(--ink-2); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.bar-row { display: grid; grid-template-columns: minmax(110px, 200px) 1fr 92px; gap: 8px; align-items: center; font-size: .82rem; margin: 5px 0; }
.bar-row .bar { height: 14px; background: var(--line-2); border-radius: 3px; overflow: hidden; }
.bar-row .bar > div { height: 100%; background: var(--accent); border-radius: 3px; }
.bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Scanner (Stock Count) */
.scan-input { font-size: 1.25rem; padding: 10px 14px; width: 100%; max-width: 440px; letter-spacing: .04em; }
.scan-flash { animation: flash .5s; }
@keyframes flash { from { background: var(--ok-soft); } to { background: transparent; } }
#cam-video { width: 100%; max-width: 440px; border-radius: 8px; background: #000; margin-top: 8px; }

/* Login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-box { width: 100%; max-width: 340px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 26px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.login-box .brand { justify-content: center; }
.login-box p { text-align: center; margin: -4px 0 6px; font-size: .85rem; }
.login-box input { padding: 9px 11px; }
.login-box .btn { justify-content: center; padding: 9px; }
.login-err { color: var(--bad); font-size: .84rem; text-align: center; }

@media (max-width: 640px) {
  .wrap { padding: 10px; }
  .card { padding: 12px; }
  .form-grid .span-2 { grid-column: 1 / -1; }
  .bar-row { grid-template-columns: 100px 1fr 80px; }
  /* Stock count on phones: keep product, stock, counted and difference visible */
  #sc-table th:nth-child(2), #sc-table td:nth-child(2), #sc-table th:nth-child(4), #sc-table td:nth-child(4),
  #sc-table th:nth-child(5), #sc-table td:nth-child(5), #sc-table th:nth-child(9), #sc-table td:nth-child(9) { display: none; }
}

/* Charts */
.tip { position: fixed; pointer-events: none; z-index: 90; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 7px; padding: 6px 9px; font-size: .78rem; box-shadow: 0 6px 20px rgba(0,0,0,.15); white-space: nowrap; }
.tip b { font-variant-numeric: tabular-nums; }
svg .hit { fill: transparent; cursor: default; }
svg .hit:hover + .mark, svg .mark:hover { opacity: .85; }
svg text { fill: var(--ink-3); font-size: 11px; }
.bar-row .bar > div { background: var(--series-1); }
.bar-row .ly { font-size: .72rem; color: var(--ink-3); }
