:root {
  --bg: #f4f5fb; --surface: #ffffff; --surface-2: #f8f9fc; --text: #161a2d; --muted: #6c7389; --line: #e8eaf2;
  --primary: #4ade80; --primary-2: #86efac; --primary-soft: #e6f9ed; --primary-ink: #053b1c; --primary-text: #15803d;
  --green: #12a150; --green-soft: #e3f7eb; --amber: #c27803; --amber-soft: #fff3d6;
  --red: #e02d3c; --red-soft: #fde7e9; --blue: #1d8cf8; --blue-soft: #e3f1ff;
  --shadow: 0 1px 2px rgba(22,26,45,.04), 0 4px 16px rgba(22,26,45,.05);
  --radius: 14px; --sidebar: 256px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0e1120; --surface: #161a2e; --surface-2: #1c2138; --text: #e8eaf4; --muted: #949bb4; --line: #262c47;
  --primary: #4ade80; --primary-2: #6ee7a0; --primary-soft: #12301f; --primary-ink: #052e16; --primary-text: #6ee7a0;
  --green: #45d483; --green-soft: #143425; --amber: #f5b83d; --amber-soft: #3a2e12;
  --red: #ff6b78; --red-soft: #3d1a20; --blue: #5cb0ff; --blue-soft: #15294a;
  --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.55 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; font-weight: 700; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1rem; font-weight: 600; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .82rem; }
.icon { width: 18px; height: 18px; flex: none; }

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 20px 14px; z-index: 30; transition: transform .2s; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.02rem; color: var(--text); padding: 4px 8px 22px; }
.logo:hover { text-decoration: none; }
.logo-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: var(--primary-ink);
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); box-shadow: 0 6px 14px -4px var(--primary); }
.nav-label { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 0 10px 8px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary-text); font-weight: 600; }
.nav .count { margin-left: auto; font-style: normal; font-size: .72rem; font-weight: 700; background: var(--red); color: #fff; border-radius: 999px; padding: 1px 7px; }
.sidebar-user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid var(--line); }
.sidebar-user .who { min-width: 0; flex: 1; line-height: 1.3; }
.sidebar-user strong, .sidebar-user small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user small { color: var(--muted); font-size: .75rem; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 50%; font-weight: 700; font-size: .8rem;
  background: var(--primary-soft); color: var(--primary-text); }
.avatar.sm { width: 34px; height: 34px; }

.content { flex: 1; min-width: 0; margin-left: var(--sidebar); display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; height: 64px; padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-search { position: relative; flex: 1; max-width: 420px; margin-right: auto; }
.top-search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; }
.top-search input { margin: 0; padding-left: 36px; background: var(--surface); }
.icon-btn { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); cursor: pointer; }
.icon-btn:hover { color: var(--text); }
#theme-toggle .icon:last-child { display: none; }
:root[data-theme="dark"] #theme-toggle .icon:first-child { display: none; }
:root[data-theme="dark"] #theme-toggle .icon:last-child { display: block; }
.sidebar-user .icon-btn { width: 34px; height: 34px; border: 0; background: transparent; }
.menu-btn, .scrim { display: none; }

.page { padding: 28px; flex: 1; width: 100%; max-width: 1400px; }
.page-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; }
.page-head p { margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.foot { padding: 18px 28px; color: var(--muted); font-size: .8rem; border-top: 1px solid var(--line); }
.foot a { color: var(--primary-text); text-decoration: none; }
.foot a:hover { text-decoration: underline; }
.captcha { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0 8px; }
.captcha img { border-radius: 10px; border: 1px solid var(--line); max-width: 100%; height: auto; }
.auth-box .switch.support { margin-top: 10px; font-size: .85rem; }

/* ---------- Cards & stats ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.card-body { padding: 20px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.stat { padding: 20px; display: flex; gap: 14px; align-items: flex-start; }
.stat .chip { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 12px; flex: none; }
.stat .chip .icon { width: 22px; height: 22px; }
.stat span { display: block; color: var(--muted); font-size: .82rem; font-weight: 500; }
.stat strong { display: block; font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.25; margin-top: 2px; }
.stat small { color: var(--muted); font-size: .78rem; }
.chip.violet { background: var(--primary-soft); color: var(--primary-text); }
.chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.blue { background: var(--blue-soft); color: var(--blue); }
.chip.red { background: var(--red-soft); color: var(--red); }
.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; margin-bottom: 18px; }
.chart-box { position: relative; height: 280px; }
.legend { display: grid; gap: 8px; margin-top: 16px; }
.legend div { display: flex; align-items: center; gap: 8px; font-size: .85rem; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
.legend b { margin-left: auto; font-weight: 600; }

/* ---------- Forms & buttons ---------- */
label { display: block; font-weight: 500; font-size: .85rem; margin-bottom: 16px; }
input, select, textarea { display: block; width: 100%; margin-top: 6px; padding: 10px 12px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn .icon { width: 16px; height: 16px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); box-shadow: 0 6px 14px -6px var(--primary); }
.btn.primary:hover { background: var(--primary-2); }
.btn.full { width: 100%; padding: 12px; }
.btn.ghost { background: transparent; }
.act { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); cursor: pointer; }
.act .icon { width: 15px; height: 15px; }
.act:hover { color: var(--primary-text); border-color: var(--primary-text); }
.act.danger:hover { color: var(--red); border-color: var(--red); }
form.inline { display: inline; }

.alert { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; }
.alert .icon { width: 18px; }
.alert.error { background: var(--red-soft); color: var(--red); }
.alert.success { background: var(--green-soft); color: var(--green); }
.alert[hidden] { display: none; }
.pay-failed { align-items: flex-start; }
.pay-failed div { display: grid; gap: 4px; }
.pay-failed small { font-weight: 400; opacity: .9; }

/* ---------- Tables ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filters input, .filters select { margin: 0; width: auto; padding: 8px 12px; }
.filters input[type=search] { min-width: 220px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 20px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; }
td.actions { text-align: right; }
td.actions > * { margin-left: 4px; }
.product { display: flex; align-items: center; gap: 12px; }
.thumb { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; flex: none; background: var(--primary-soft); color: var(--primary-text); font-weight: 700; font-size: .8rem; }
.product strong { display: block; font-weight: 600; }
.product small { color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--green-soft); color: var(--green); }
.pill.low { background: var(--amber-soft); color: var(--amber); }
.pill.out { background: var(--red-soft); color: var(--red); }
.tag { display: inline-block; padding: 2px 9px; border-radius: 6px; font-size: .75rem; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line); }
.empty { text-align: center; color: var(--muted); padding: 48px 20px; }
.empty .chip { margin: 0 auto 12px; width: 52px; height: 52px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.span2 { grid-column: span 2; }
.section-title { grid-column: span 2; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 6px 0 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 20px; border-top: 1px solid var(--line); }

/* ---------- Auth ---------- */
.auth { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 100vh; }
.auth-art { position: relative; overflow: hidden; display: flex; flex-direction: column; padding: 40px 48px; color: #053b1c;
  background: radial-gradient(circle at 85% 15%, rgba(255,255,255,.18), transparent 40%), linear-gradient(150deg, #4ade80, #86efac 60%, #d1fae5); }
.auth-art .logo { color: #053b1c; padding: 0; }
.auth-art .logo-mark { background: rgba(255,255,255,.5); box-shadow: none; color: #053b1c; }
.auth-pitch { margin: auto 0; max-width: 440px; }
.auth-pitch h2 { font-size: 2rem; line-height: 1.2; font-weight: 700; letter-spacing: -.02em; }
.auth-pitch p { opacity: .85; font-size: 1rem; }
.auth-pitch ul { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 12px; }
.auth-pitch li { display: flex; gap: 10px; align-items: center; font-weight: 500; }
.auth-pitch li .icon { background: rgba(255,255,255,.55); border-radius: 50%; padding: 3px; width: 22px; height: 22px; }
.auth-foot { opacity: .7; font-size: .85rem; }
.auth-main { display: grid; place-items: center; padding: 40px 16px; }
.auth-box { width: 100%; max-width: 400px; }
.auth-box h1 { margin-bottom: 6px; }
.auth-box .lead { color: var(--muted); margin: 0 0 26px; }
.auth-box .switch { text-align: center; color: var(--muted); margin-top: 22px; }
.auth-box .mail-chip { margin-bottom: 18px; width: 56px; height: 56px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.25); }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(10,12,25,.4); z-index: 25; }
  .content { margin-left: 0; }
  .menu-btn { display: grid; }
  .topbar, .page { padding-left: 16px; padding-right: 16px; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
}
@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .span2, .section-title { grid-column: auto; }
  .filters input[type=search] { min-width: 0; flex: 1; }
  th, td { padding: 12px 14px; }
}

/* ---------- Layout fixes ---------- */
.grid-2 > *, .stats > * { min-width: 0; }
.logo { white-space: nowrap; }
.auth-mobile-logo { display: none; color: var(--text); padding: 0 0 28px; }
@media (max-width: 860px) { .auth-mobile-logo { display: flex; } }
.inv td { padding-top: 12px; padding-bottom: 12px; }
.inv th, .inv td { padding-left: 14px; padding-right: 14px; }
.inv th:first-child, .inv td:first-child { padding-left: 20px; }
.inv th:last-child, .inv td:last-child { padding-right: 20px; }
.qty { display: inline-flex; align-items: center; gap: 8px; }
.qty strong { min-width: 24px; text-align: right; }

/* ---------- IMEI scanner ---------- */
.input-group { display: flex; gap: 8px; margin-top: 6px; }
.input-group input { margin: 0; flex: 1; min-width: 0; }
.imei-list { display: grid; gap: 12px; margin-bottom: 6px; }
.imei-row { display: block; }
.imei-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); gap: 8px; margin: 6px 0; }
.imei-choice { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; font-weight: 400; }
.imei-choice input { width: auto; margin: 0; flex: none; }
#imei-limit[hidden], .scan-btn[hidden] { display: none; }
.scan-btn { flex: none; background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.scan-btn:hover { background: var(--primary-2); }
.hint { display: block; margin-top: 6px; font-weight: 400; color: var(--muted); font-size: .8rem; }
.hint.ok { color: var(--green); font-weight: 600; }
.scanner { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgba(5, 10, 20, .7); }
.scanner[hidden] { display: none; }
.scanner-box { width: 100%; max-width: 480px; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.scanner-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
#scan-reader { background: #000; min-height: 240px; }
#scan-reader video { display: block; width: 100% !important; height: auto !important; }
.scanner-msg { margin: 0; padding: 12px 16px; color: var(--muted); font-size: .88rem; }
.scanner-msg.warn { color: var(--amber); font-weight: 500; }
body.no-scroll { overflow: hidden; }

/* ---------- Sell / sales ---------- */
.stats.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sell-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; max-width: 900px; }
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.sell-btn { padding: 6px 12px; font-size: .82rem; background: var(--primary); border-color: var(--primary); color: var(--primary-ink); vertical-align: middle; }
.sell-btn:hover { background: var(--primary-2); }
.field-label { display: block; font-weight: 500; font-size: .85rem; margin-bottom: 6px; }
.photo-field { margin-bottom: 16px; }
.photo-drop { position: relative; display: grid; place-items: center; min-height: 130px; margin: 0; border: 2px dashed var(--line); border-radius: 12px;
  background: var(--surface-2); cursor: pointer; overflow: hidden; font-weight: 500; color: var(--muted); }
.photo-drop:hover { border-color: var(--primary); }
.photo-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.photo-drop .ph { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: .85rem; pointer-events: none; }
.photo-drop .ph .icon { width: 26px; height: 26px; color: var(--primary-text); }
.photo-drop img { display: none; width: 100%; max-height: 220px; object-fit: contain; pointer-events: none; }
.photo-drop.has { border-style: solid; border-color: var(--primary); background: var(--surface); }
.photo-drop.has .ph { display: none; }
.photo-drop.has img { display: block; }
.photo-drop.face { max-width: 260px; }
.photo-field .check { display: flex; align-items: center; gap: 6px; margin: 8px 0 0; font-weight: 400; font-size: .82rem; color: var(--muted); }
.photo-field .check input { width: auto; margin: 0; }
.agreement { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; font-size: .88rem; color: var(--text); margin-bottom: 18px; }
.agreement p { margin: 0 0 10px; line-height: 1.7; }
.agreement ol { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--muted); }
.sign-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.sign-head { display: flex; align-items: center; justify-content: space-between; }
.small-btn { padding: 4px 10px; font-size: .78rem; }
.sign-pad { display: block; width: 100%; height: 170px; background: #fff; border: 2px dashed var(--line); border-radius: 12px; touch-action: none; cursor: crosshair; }
.sign-pad.signed { border-style: solid; border-color: var(--primary); }
.facts { display: grid; grid-template-columns: 110px 1fr; gap: 10px 12px; margin: 0; }
.facts dt { color: var(--muted); font-size: .85rem; }
.facts dd { margin: 0; }
.facts .pill { margin: 0 4px 4px 0; }
.buyer { display: flex; gap: 18px; align-items: flex-start; }
.buyer .facts { flex: 1; }
.buyer-photo { width: 110px; height: 130px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.gallery figure { margin: 0; }
.gallery img { width: 100%; height: 160px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.gallery figcaption { font-size: .8rem; color: var(--muted); margin-top: 6px; }
@media (max-width: 860px) { .stats.three { grid-template-columns: 1fr; } }
@media (max-width: 560px) {
  .sign-grid { grid-template-columns: 1fr; }
  .buyer { flex-direction: column; }
  .photo-drop.face { max-width: none; }
  .page-actions .btn { flex: 1; }
}
@media (max-width: 1600px) { .inv .col-upd { display: none; } }
td.actions { white-space: nowrap; }
.inv td:first-child { white-space: normal; min-width: 210px; max-width: 280px; }
@media (max-width: 1350px) { .inv .col-cost { display: none; } }
td.actions > * { vertical-align: middle; }
.pick-list { display: flex; flex-direction: column; }
.pick { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-bottom: 1px solid var(--line); color: var(--text); }
.pick:last-child { border-bottom: 0; }
.pick:hover { background: var(--surface-2); text-decoration: none; }
.pick-main { flex: 1; min-width: 0; }
.pick-main strong, .pick-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-main small { color: var(--muted); }
.pick-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
@media (max-width: 560px) { .pick { padding: 12px 14px; gap: 10px; } .pick .sell-btn { display: none; } }

/* ---------- Inventory as cards on phones ---------- */
.m-label { display: none; }
@media (max-width: 1100px) {
  .inv thead { display: none; }
  .inv, .inv tbody { display: block; }
  .inv tr { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px 12px;
    grid-template-areas: "prod prod prod" "cat cat stock" "imei imei imei" "price cost act"; padding: 16px; border-bottom: 1px solid var(--line); }
  .inv tbody tr:last-child { border-bottom: 0; }
  .inv tbody tr:hover td { background: none; }
  .inv td, .inv td:first-child, .inv td:last-child { display: block; padding: 0; border: 0; white-space: normal; min-width: 0; max-width: none; text-align: left; }
  .inv .c-prod { grid-area: prod; }
  .inv .c-stock { grid-area: stock; justify-self: end; }
  .inv .c-cat { grid-area: cat; }
  .inv .c-imei { grid-area: imei; font-size: .78rem; color: var(--muted); overflow-wrap: anywhere; }
  .inv .c-imei.is-empty { display: none; }
  .inv .c-price { grid-area: price; }
  .inv .c-cost, .inv .col-cost { grid-area: cost; display: block; color: var(--muted); }
  .inv .col-upd { display: none; }
  .inv .c-act { grid-area: act; justify-self: end; display: flex; gap: 6px; align-items: center; }
  .inv .c-act > * { margin: 0; }
  .inv .c-price, .inv .c-cost { line-height: 1.25; }
  .inv .c-price { font-weight: 700; font-size: 1rem; }
  .inv .c-price .m-label, .inv .c-cost .m-label { display: block; font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
  .inv .c-imei .m-label { display: inline; font-weight: 600; }
  .inv .product strong { font-size: .95rem; }
  .inv .thumb { width: 38px; height: 38px; }
  .act { width: 36px; height: 36px; }
  .sell-btn { padding: 8px 12px; }
}
@media (max-width: 560px) {
  .filters { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .filters input[type=search] { grid-column: 1 / -1; width: 100%; min-width: 0; }
  .filters select { width: 100%; min-width: 0; }
  .filters .btn { width: 100%; }
  .filters .btn:only-of-type, .filters > .btn:last-child:nth-child(4) { grid-column: 1 / -1; }
  .card-head { padding: 14px 16px; }
  .page-head { align-items: center; }
  .page-head h1 { font-size: 1.3rem; }
}
@media (max-width: 1100px) {
  .inv .c-cat { justify-self: start; }
  .inv .product small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
}
@media (max-width: 560px) {
  .filters > .btn + .btn { grid-column: auto; }
}
@media (max-width: 1100px) {
  .inv tbody { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; padding: 12px; }
  .inv tr, .inv tbody tr:last-child { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
  .inv .col-cost, .inv .c-cost { display: block; }
}
@media (max-width: 400px) {
  .inv tbody { grid-template-columns: 1fr; padding: 10px; gap: 10px; }
  .inv tr { padding: 14px; }
}
.settings-grid { display: grid; gap: 20px; max-width: 640px; }
.settings-grid .card a { color: var(--primary-text); }
/* Free plan limit and subscription */
.plan-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; padding: 14px 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.plan-bar > div { display: grid; gap: 4px; min-width: 220px; flex: 1; }
.plan-bar .muted { font-size: .85rem; }
.plan-bar.full { border-color: var(--amber); background: var(--amber-soft); }
.plan-meter { display: block; height: 6px; max-width: 280px; border-radius: 999px; background: var(--line); overflow: hidden; }
.plan-meter i { display: block; height: 100%; background: var(--primary); }
.plan-bar.full .plan-meter i { background: var(--amber); }
.plan-limit h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; font-size: 1.15rem; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; max-width: 1040px; }
.plan .card-body { display: grid; gap: 12px; }
.plan.current { border: 2px solid var(--primary); }
.plan-name { font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: .78rem; color: var(--muted); }
.plan.pro .plan-name { color: var(--primary-text); }
.plan-price { font-size: 2rem; font-weight: 800; }
.plan-price small { font-size: .9rem; font-weight: 500; color: var(--muted); }
.plan ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.plan li { display: flex; align-items: center; gap: 8px; }
.plan li .icon, .plan-status .icon { width: 18px; color: var(--primary-text); }
.plan-status { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 600; color: var(--primary-text); }
.plan .hint a { color: var(--primary-text); }
.plan .hint[hidden] { display: none; }
/* Public pages and account deletion */
.legal-page { background: var(--bg); color: var(--text); }
.legal-head { padding: 18px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.legal-head .logo { max-width: 760px; margin: 0 auto; }
.legal { max-width: 760px; margin: 0 auto; padding: 28px 16px 40px; line-height: 1.65; }
.legal h1 { font-size: 1.7rem; margin: 0 0 8px; }
.legal h2 { font-size: 1.1rem; margin: 28px 0 8px; }
.legal p { margin: 0 0 12px; }
.legal ul, .legal ol { margin: 0 0 12px; padding-left: 22px; }
.legal li { margin-bottom: 6px; }
.legal a, .settings-grid .card p a { color: var(--primary-text); }
.legal-foot { text-align: center; }
.btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger:hover { filter: brightness(.92); }
.danger-card { border-color: var(--red); }
.danger-card .card-head h2 { color: var(--red); }
.condition-head { flex-wrap: wrap; gap: 10px; }
.condition-tabs { display: flex; flex-wrap: wrap; gap: 8px; }

/* Public home page */
.home-page { background: var(--bg); color: var(--text); }
.home-wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.home-head { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.home-head .home-wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; padding-bottom: 12px; }
.home-head .logo { padding: 0; }
.home-nav { display: flex; align-items: center; gap: 8px; }
.home-nav > a:not(.btn) { color: var(--muted); font-weight: 600; padding: 8px 10px; }
.home-hero { padding: 64px 0 48px; text-align: center; background: radial-gradient(60% 80% at 50% 0%, var(--primary-soft), transparent 70%); }
.home-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-text); font-weight: 600; font-size: .85rem; }
.home-pill .icon { width: 16px; }
.home-hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1.1; letter-spacing: -.02em; margin: 18px auto 14px; max-width: 760px; }
.home-hero h1 em { font-style: normal; color: var(--primary-text); }
.home-lead { font-size: 1.1rem; color: var(--muted); max-width: 640px; margin: 0 auto; }
.home-cta { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 26px; }
.home-cta .btn { padding: 12px 20px; font-size: 1rem; }
.home-section { padding: 48px 0; }
.home-section h2 { font-size: 1.8rem; text-align: center; margin: 0 0 6px; }
.home-sub { text-align: center; color: var(--muted); margin: 0 0 28px; }
.home-features { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.home-feature { padding: 20px; }
.home-feature h3 { margin: 12px 0 6px; font-size: 1.02rem; }
.home-feature p { margin: 0; color: var(--muted); }
.home-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--primary-soft); color: var(--primary-text); }
.home-ic .icon { width: 20px; }
.home-plans { margin: 0 auto; }
.home-plans .btn { margin-top: 4px; }
.home-alt { margin: -6px 0 0; }
.home-note { text-align: center; max-width: 680px; margin: 20px auto 0; }
.home-final { text-align: center; background: var(--surface); border-top: 1px solid var(--line); }
.home-foot { text-align: center; }
@media (max-width: 560px) {
  .home-nav > a:not(.btn) { display: none; }
  .home-nav .btn { padding: 8px 12px; }
  .home-head .logo { font-size: .95rem; min-width: 0; }
  .home-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (max-width: 400px) {
  .home-name { display: none; }
  .home-hero { padding: 40px 0 32px; }
}

/* Android app download in the sidebar */
.app-download { display: flex; align-items: center; gap: 10px; margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--primary-soft); color: var(--primary-text); }
.app-download:hover { text-decoration: none; filter: brightness(.97); }
.app-download .icon { width: 18px; flex: none; }
.app-download span { display: grid; line-height: 1.25; }
.app-download small { font-size: .75rem; opacity: .85; }
.home-ver { margin: 14px 0 0; }
/* Sold tab on the Inventory page */
.inv.sold .d-label { font-weight: 600; color: var(--text); }
@media (max-width: 1100px) {
  .inv.sold tr { grid-template-areas: "prod prod stock" "buyer buyer buyer" "imei imei imei" "date date date" "price price act"; }
  .inv.sold .c-buyer { grid-area: buyer; }
  .inv.sold .c-date { grid-area: date; }
  .inv.sold .m-label { display: inline; font-weight: 600; color: var(--muted); }
  .inv.sold .c-price .m-label { display: block; }
}

/* Purchase date in the stock list */
.inv .c-bought { white-space: nowrap; }
@media (max-width: 1100px) {
  .inv:not(.sold) tr { grid-template-areas: "prod prod prod" "cat cat stock" "imei imei imei" "bought bought bought" "price cost act"; }
  .inv:not(.sold) .c-bought { grid-area: bought; }
  .inv:not(.sold) .c-bought .m-label { display: inline; font-weight: 600; color: var(--text); }
}
@media (min-width: 1101px) and (max-width: 1350px) {
  .inv:not(.sold) th:nth-child(2), .inv:not(.sold) td.c-cat { display: none; }
}
/* Homepage: feature groups, how it works, FAQ */
.home-group { font-size: 1.15rem; margin: 30px 0 12px; }
.home-group:first-of-type { margin-top: 0; }
.home-feature h4 { margin: 12px 0 6px; font-size: 1.02rem; }
.home-band { background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.home-steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.home-step { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 800; }
.home-narrow { max-width: 780px; }
.home-faq { display: grid; gap: 10px; }
.home-faq details { padding: 14px 18px; }
.home-faq summary { cursor: pointer; font-weight: 700; }
.home-faq details p { margin: 10px 0 0; color: var(--muted); }

/* Public feature pages (/features, /features/<slug>) */
.feature-hero { padding-top: 28px; }
.feature-crumbs { font-size: .85rem; color: var(--muted); margin: 0 0 22px; }
.feature-crumbs a { color: var(--muted); }
.feature-crumbs a:hover { color: var(--primary-text); }
.feature-prose { max-width: 760px; line-height: 1.7; }
.feature-prose h2 { text-align: left; font-size: 1.35rem; margin: 28px 0 10px; }
.feature-prose h2:first-child { margin-top: 0; }
.feature-prose p { margin: 0 0 14px; }
.feature-links a.card { color: inherit; display: block; transition: border-color .15s, transform .15s; }
.feature-links a.card:hover { text-decoration: none; border-color: var(--primary); transform: translateY(-2px); }
.feature-more { display: inline-block; margin-top: 10px; font-weight: 600; color: var(--primary-text); }
