/* TECHHELP noliktava, dark theme
   Solid surfaces for data (tables, forms), glass only for floating elements (sidebar, toasts, login, menus). */

:root {
  --bg: #0a0d13;
  --surface: #111620;
  --surface-2: #161c28;
  --surface-3: #1c2433;
  --stroke: rgba(255, 255, 255, 0.07);
  --stroke-strong: rgba(255, 255, 255, 0.13);
  --text: #ffffff;
  --text-2: #ffffff;
  --muted: #9aa3b6;           /* only for descriptions and explanations */
  /* Tailwind CSS default palette: blue 500/600/400, emerald 500, amber 500, red 500 */
  --accent: #3b82f6;
  --accent-strong: #60a5fa;
  --accent-btn: #2563eb;
  --accent-btn-hover: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.15);
  --ok: #10b981;
  --warn: #f59e0b;
  --bad: #ef4444;
  --bad-soft: rgba(239, 68, 68, 0.12);
  --ok-soft: rgba(16, 185, 129, 0.12);
  --radius: 10px;
  --radius-sm: 7px;
  --gap: 24px;
  --edge: 24px;                 /* minimum distance from screen edges */
  --sidebar: 236px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --glass-bg: linear-gradient(25deg, rgba(20, 26, 40, 0.62) 0%, rgba(34, 46, 82, 0.48) 100%);
  --glass-stroke: rgba(255, 255, 255, 0.11);
  --glass-hi: rgba(255, 255, 255, 0.06);
  color-scheme: dark;
}

@media (max-width: 760px) { :root { --edge: 16px; --gap: 16px; } }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  min-height: 100vh;
}
/* quiet backdrop so the glass has something to refract */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(1100px 700px at 0% 0%, rgba(80, 110, 255, 0.06), transparent 60%),
    radial-gradient(900px 600px at 100% 100%, rgba(40, 170, 220, 0.04), transparent 60%),
    linear-gradient(25deg, #090c12 0%, #0b0f18 55%, #0a0e16 100%);
}

a { color: var(--text); text-decoration: none; transition: color .15s var(--ease); }
a:hover { color: var(--accent-strong); }
td a, .page-head a:not(.btn), p a { text-decoration: underline; text-decoration-color: rgba(255,255,255,0.18); text-underline-offset: 3px; }
td a:hover, p a:hover { text-decoration-color: var(--accent-strong); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

h1 { font-size: 22px; font-weight: 650; letter-spacing: -0.01em; margin: 0; }
h2 { font-size: 15px; font-weight: 700; color: var(--text); margin: 28px 0 10px; text-transform: none; }
p { margin: 8px 0; }
small { color: var(--text); opacity: .85; }
.muted, .sub, .hint, .legend { color: var(--muted); }
.bad, .ok { color: var(--text); }
td.bad::before, td.ok::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; vertical-align: middle; }
td.bad::before { background: var(--bad); }
td.ok::before { background: var(--ok); }
p.bad, p.ok, h2 .bad { display: flex; align-items: center; gap: 8px; }
p.bad::before, p.ok::before { content: ""; width: 8px; height: 8px; border-radius: 50%; flex: none; }
p.bad::before { background: var(--bad); }
p.ok::before { background: var(--ok); }

/* ---------- glass ---------- */
.glass {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid var(--glass-stroke);
  box-shadow: inset 0 1px 0 var(--glass-hi), 0 10px 30px rgba(0, 0, 0, 0.35);
}
/* Chromium only: light refraction on the edges (added by app.js) */
.refract .glass { backdrop-filter: url(#edge-refract) blur(18px) saturate(150%); }

/* ---------- layout ---------- */
.shell { display: flex; gap: var(--gap); padding: var(--edge); min-height: 100vh; }
.sidebar {
  position: sticky; top: var(--edge); align-self: flex-start;
  width: var(--sidebar); flex: none; max-height: calc(100vh - 2 * var(--edge)); overflow-y: auto;
  border-radius: 14px; padding: 18px 12px;
}
.brand { display: block; padding: 2px 8px 18px; }
.brand img { width: 150px; height: auto; display: block; }
.nav-group { margin: 6px 0 14px; }
.nav-title { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text); opacity: .55; padding: 0 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); border: 1px solid transparent;
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.nav a:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav a.on { background: var(--accent-soft); color: var(--text); border-color: rgba(59,130,246,0.3); }
.nav svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.who { border-top: 1px solid var(--stroke); margin-top: 8px; padding: 12px 10px 0; font-size: 13px; color: var(--text); }
.who b { display: block; color: var(--text); font-weight: 600; }

.content { flex: 1; min-width: 0; animation: rise .28s var(--ease) both; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 4px 0 20px; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* mobile: sidebar turns into a top bar with a menu */
.topbar { display: none; }
@media (max-width: 960px) {
  .shell { flex-direction: column; }
  .sidebar { display: none; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: var(--edge); z-index: 20; border-radius: 14px; padding: 10px 14px;
  }
  .topbar img { height: 30px; width: auto; display: block; }
  .topbar details { position: relative; }
  .topbar summary { list-style: none; cursor: pointer; }
  .topbar summary::-webkit-details-marker { display: none; }
  .menu-panel {
    position: absolute; right: -14px; top: calc(100% + 14px); width: min(300px, calc(100vw - 2 * var(--edge)));
    max-height: 75vh; overflow-y: auto; border-radius: 14px; padding: 12px; animation: drop .2s var(--ease) both;
  }
}

/* ---------- cards / surfaces ---------- */
.card { background: linear-gradient(25deg, var(--surface) 0%, var(--surface) 45%, #172036 100%); border: 1px solid var(--stroke); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: var(--gap); }
.grid > .card + .card, .grid > * { margin-top: 0; }
.grid { display: grid; gap: var(--gap); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
@media (max-width: 760px) { .grid.two { grid-template-columns: 1fr; } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat {
  display: block; background: linear-gradient(25deg, var(--surface) 0%, #18223a 100%); border: 1px solid var(--stroke); border-radius: var(--radius);
  padding: 14px 16px; color: var(--text); transition: border-color .15s var(--ease), transform .15s var(--ease);
}
a.stat:hover { border-color: var(--stroke-strong); transform: translateY(-1px); color: var(--text); }
.stat .k { font-size: 13px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.stat .v { font-size: 26px; font-weight: 650; margin-top: 4px; letter-spacing: -0.02em; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.s-IN_STOCK { background: var(--accent); }
.s-WITH_TECH { background: var(--warn); }
.s-INSTALLED { background: var(--ok); }
.s-DEFECTIVE { background: var(--bad); }
.s-RETURNED { background: var(--muted); }

.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px;
  font-size: 12.5px; border: 1px solid var(--stroke-strong); color: var(--text); white-space: nowrap;
  background: linear-gradient(25deg, rgba(255,255,255,0.02), rgba(255,255,255,0.06));
}

/* ---------- tables ---------- */
.table-wrap { background: linear-gradient(25deg, var(--surface) 0%, var(--surface) 60%, #141c2e 100%); border: 1px solid var(--stroke); border-radius: var(--radius); overflow: auto; max-height: 72vh; }
table { border-collapse: separate; border-spacing: 0; width: 100%; }
th, td { padding: 10px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--stroke); white-space: nowrap; }
td.wrap, th.wrap { white-space: normal; min-width: 180px; }
th {
  position: sticky; top: 0; z-index: 1; background: var(--surface-2);
  font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text);
}
tbody tr { transition: background .12s var(--ease); }
tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
tr:last-child td { border-bottom: 0; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
td.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13.5px; letter-spacing: .02em; }
tfoot td { background: var(--surface-2); font-weight: 600; }
.empty { color: var(--text); text-align: center; padding: 28px; }
@media (max-width: 760px) { .hide-sm { display: none; } }

/* key/value table on detail pages */
.kv { width: 100%; }
.kv th { position: static; background: none; text-transform: none; letter-spacing: 0; font-size: 14px; width: 40%; color: var(--text); font-weight: 700; }
.kv td, .kv th { padding: 9px 0; }
.kv tr:last-child th { border-bottom: 0; }

/* ---------- stock bars ---------- */
.bar { display: block; position: relative; height: 8px; background: var(--surface-3); border-radius: 999px; min-width: 120px; overflow: visible; }
.bar > i {
  display: block; height: 100%; border-radius: 999px; background: var(--accent);
  transform-origin: left; animation: grow .6s var(--ease) both;
}
.bar.lvl-low > i { background: var(--bad); }
.bar.lvl-warn > i { background: var(--warn); }
.bar.lvl-ok > i { background: var(--ok); }
.bar-row { color: var(--text); border-radius: 8px; margin: 0 -8px; transition: background .15s var(--ease); display: grid; grid-template-columns: 44px minmax(0, 1fr) minmax(220px, 1.2fr); gap: 14px; align-items: center; padding: 10px 8px; border-bottom: 1px solid var(--stroke); }
.bar-row:last-child { border-bottom: 0; }
.bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .qty { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 760px) { .bar-row { grid-template-columns: 36px minmax(0, 1fr); row-gap: 10px; } }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- product pictures ---------- */
.thumb { width: 36px; height: 36px; border-radius: 7px; object-fit: cover; background: var(--surface-3); border: 1px solid var(--stroke); display: block; }
.thumb.ph { display: grid; place-items: center; color: var(--muted); }
.thumb.ph svg { width: 18px; height: 18px; }
.photo { width: 100%; max-width: 360px; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--stroke); background: var(--surface-2); display: block; }
.photo.ph { display: grid; place-items: center; color: var(--muted); }
.photo.ph svg { width: 56px; height: 56px; opacity: .6; }

/* ---------- forms ---------- */
.form { max-width: 620px; }
.field { margin-bottom: 14px; }
.field label, label.lbl { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .row2 { grid-template-columns: 1fr; } }
input[type=text], input[type=password], input[type=date], input[type=number], input[type=file], select, textarea {
  width: 100%; padding: 9px 12px; font: inherit; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--stroke-strong); border-radius: var(--radius-sm);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
input:hover, select:hover, textarea:hover { border-color: rgba(255,255,255,0.2); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 160px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; }
input[type=file] { padding: 7px; }
input[type=file]::file-selector-button { font: inherit; color: var(--text); background: var(--surface-3); border: 1px solid var(--stroke-strong); border-radius: 6px; padding: 5px 10px; margin-right: 10px; cursor: pointer; }
.check { display: flex; align-items: center; gap: 8px; margin: 10px 0; color: var(--text-2); }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input[type=text] { flex: 1 1 240px; width: auto; }
.filters select, .filters input[type=date] { width: auto; flex: 0 1 auto; }

.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 14px; font: inherit; font-weight: 550; font-size: 14px; color: var(--text);
  background: linear-gradient(25deg, var(--surface-3) 0%, #26314a 100%); border: 1px solid var(--stroke-strong); border-radius: var(--radius-sm);
  cursor: pointer; white-space: nowrap;
  transition: background .15s var(--ease), border-color .15s var(--ease), box-shadow .15s var(--ease), transform .18s var(--ease);
}
.btn:hover, button:hover { background: #222b3c; border-color: rgba(255,255,255,0.2); color: var(--text); }
/* subtle grow on hover, small press on click */
.btn:hover, button:hover { transform: scale(1.03); }
.btn:active, button:active { transform: scale(0.98); }
button:disabled:hover { transform: none; }
.btn.primary, button.primary {
  background: var(--accent-btn); border-color: transparent; color: #fff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.30);
}
.btn.primary:hover, button.primary:hover { background: var(--accent-btn-hover); border-color: transparent; box-shadow: 0 6px 18px rgba(59, 130, 246, 0.35); }
.btn.danger, button.danger { background: linear-gradient(25deg, rgba(239,68,68,0.12), rgba(239,68,68,0.24)); border-color: rgba(239,68,68,0.4); color: #fff; }
.btn.ghost { background: transparent; }
.btn svg, button svg { width: 16px; height: 16px; flex: none; }
/* text stays centered in the button, the icon hangs to its left without pushing it */
.btn:has(> svg:first-child), button:has(> svg:first-child), summary.btn { padding-left: 38px; padding-right: 38px; }
.btn > svg:first-child, button > svg:first-child { margin-left: -24px; }
summary.btn > svg:only-child { margin-left: 0; }
summary.btn { padding: 8px 10px; }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 18px; flex-wrap: wrap; }

.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--radius-sm); padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg a { padding: 5px 12px; border-radius: 5px; color: var(--text-2); font-size: 14px; }
.seg a:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.seg a.on { background: var(--surface-3); color: var(--text); }

/* actions on LMT device page */
.act-list { display: grid; gap: 10px; }
.act { background: linear-gradient(25deg, var(--surface) 0%, #172036 100%); border: 1px solid var(--stroke); border-radius: var(--radius); overflow: hidden; }
.act summary { padding: 12px 16px; cursor: pointer; font-weight: 550; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.act summary::-webkit-details-marker { display: none; }
.act summary::after { content: "+"; color: var(--muted); font-weight: 400; transition: transform .2s var(--ease); }
.act[open] summary::after { transform: rotate(45deg); }
.act .body { padding: 0 16px 16px; animation: fade .2s var(--ease) both; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 22px; border-left: 1px solid var(--stroke-strong); margin-left: 4px; }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--surface-3); border: 1px solid var(--accent); }
.timeline .t { font-size: 13px; color: var(--text); opacity: .8; }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: var(--edge); top: var(--edge); z-index: 50; display: grid; gap: 10px; width: min(400px, calc(100vw - 2 * var(--edge))); }
.toast { border-radius: 12px; padding: 12px 40px 12px 14px; position: relative; animation: slide .3s var(--ease) both; font-size: 14px; }
.toast.ok { border-left: 3px solid var(--ok); }
.toast.err { border-left: 3px solid var(--bad); }
.toast .x { position: absolute; right: 6px; top: 6px; background: none; border: 0; padding: 4px 8px; color: var(--muted); font-size: 18px; line-height: 1; }
.toast.out { animation: out .25s var(--ease) both; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: var(--edge); }
.login { width: min(400px, 100%); border-radius: 18px; padding: 32px 28px 28px; animation: rise .35s var(--ease) both; }
.login .logo { display: block; width: 210px; max-width: 80%; height: auto; margin: 0 auto 26px; }
.login button { width: 100%; margin-top: 8px; padding: 10px; }

/* ---------- animations ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes drop { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes slide { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes out { to { opacity: 0; transform: translateX(16px); } }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* stacked status bars (LMT holders report) */
.bar > i.s-IN_STOCK { background: var(--accent); }
.bar > i.s-WITH_TECH { background: var(--warn); }
.bar > i.s-DEFECTIVE { background: var(--bad); }
.bar > i.s-INSTALLED { background: var(--ok); }

/* file picker: hide the browser's own (English) button, use a Latvian label instead */
.file-pick input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-pick { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.file-pick .fname { color: var(--muted); font-size: 13px; }
.file-pick input[type=file]:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }

/* stock level: chip + words + bar that fills up to the minimum */
.lvl { display: grid; gap: 7px; min-width: 0; }
.lvl-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; color: #fff; white-space: nowrap; }
.chip.lvl-low { background: linear-gradient(25deg, rgba(239,68,68,0.30), rgba(239,68,68,0.16)); border: 1px solid rgba(239,68,68,0.55); }
.chip.lvl-warn { background: linear-gradient(25deg, rgba(245,158,11,0.28), rgba(245,158,11,0.14)); border: 1px solid rgba(245,158,11,0.55); }
.chip.lvl-ok { background: linear-gradient(25deg, rgba(16,185,129,0.26), rgba(16,185,129,0.12)); border: 1px solid rgba(16,185,129,0.5); }
.chip.lvl-none { background: rgba(255,255,255,0.05); border: 1px solid var(--stroke-strong); }
.lvl .bar { height: 7px; }
.bar.lvl-ok > i { background: linear-gradient(90deg, #059669, #10b981); }
.bar.lvl-warn > i { background: linear-gradient(90deg, #d97706, #f59e0b); }
.bar.lvl-low > i { background: linear-gradient(90deg, #dc2626, #ef4444); }
.bar-row .qty b { font-size: 16px; }
@media (max-width: 760px) { .bar-row .lvl { grid-row: 2; grid-column: 1 / -1; } }

/* LMT holders: segments with their numbers inside */
.stack { display: flex; gap: 3px; height: 24px; }
.stack > i { display: flex; align-items: center; justify-content: center; min-width: 26px; border-radius: 5px; font-style: normal; font-size: 12px; font-weight: 800; color: #0a0d13; animation: grow .6s var(--ease) both; transform-origin: left; }
.stack > i.s-WITH_TECH, .stack > i.s-DEFECTIVE, .stack > i.s-IN_STOCK { color: #0a0d13; }

/* whole row is clickable: highlight the row, keep the text white */
a.bar-row:hover { color: var(--text); background: rgba(255, 255, 255, 0.035); }
a.bar-row:hover .name { text-decoration: underline; text-decoration-color: rgba(255,255,255,0.3); text-underline-offset: 3px; }

/* avatars */
.avatar { border-radius: 50%; object-fit: cover; flex: none; border: 1px solid var(--stroke-strong); display: inline-block; vertical-align: middle; }
.avatar.ph { display: inline-grid; place-items: center; font-weight: 800; color: #fff; background: var(--accent-btn); border-color: rgba(255,255,255,0.18); }
.who-row { display: flex; align-items: center; gap: 10px; }
.who-row b { display: block; }

/* 2FA */
.qr { display: block; width: 200px; height: 200px; margin: 8px auto 12px; border-radius: 10px; background: #fff; }
.steps { margin: 0 0 6px; padding-left: 20px; }
.steps li { margin: 2px 0; }
.manual { margin: 0 0 12px; font-size: 13px; }
.manual summary { cursor: pointer; color: var(--muted); }
.manual code { display: block; margin-top: 6px; padding: 8px; background: var(--surface-2); border: 1px solid var(--stroke); border-radius: 6px; word-break: break-all; letter-spacing: .08em; }
input.code { font-size: 22px; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; }
