* { box-sizing: border-box; }
:root {
  --bg: #f4f5f7; --card: #fff; --text: #1d2330; --muted: #6b7385; --line: #e2e5ea;
  --accent: #1f6feb; --accent-d: #1959c2; --green: #1a7f37; --orange: #b35900; --red: #c62828;
}
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 12px; }

.topbar { display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 56px; background: #111827; color: #fff; position: sticky; top: 0; z-index: 10; }
.topbar .brand { color: #fff; font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.logo { width: 28px; height: 28px; display: block; }
.login-brand { display: flex; align-items: center; gap: 10px; }
.login-brand .logo { width: 40px; height: 40px; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { color: #c9d1e0; padding: 8px 12px; border-radius: 6px; }
.topbar nav a.active, .topbar nav a:hover { background: #253047; color: #fff; }

main { max-width: 1300px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.btn { border: 1px solid var(--line); background: #fff; color: var(--text); padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; }
.btn:hover { background: #f0f2f5; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-d); }
.btn.danger { color: var(--red); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }

input, select, textarea { font: inherit; border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; background: #fff; width: 100%; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #b6d0fb; border-color: var(--accent); }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
.field { margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 14px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 14px; }
.span2 { grid-column: span 2; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 4px; }
.stat .l { font-size: 12px; color: var(--muted); }
.pos { color: var(--green); } .neg { color: var(--red); }

.cars { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.car-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; cursor: pointer; transition: box-shadow .15s, transform .15s; color: inherit; display: block; }
.car-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,.08); transform: translateY(-2px); }
.car-card .img { height: 170px; background: #dde1e7 center/cover no-repeat; display: flex; align-items: center; justify-content: center; font-size: 48px; color: #a3abb8; position: relative; }
.car-card .code { position: absolute; top: 10px; left: 10px; background: rgba(17,24,39,.8); color: #fff; font-size: 11px; padding: 3px 8px; border-radius: 5px; font-weight: 600; }
.car-card .body { padding: 12px 14px 14px; }
.car-card .title { font-weight: 700; font-size: 15px; }
.car-card .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.progress { height: 6px; background: #eceef2; border-radius: 3px; overflow: hidden; margin: 10px 0 6px; display: flex; }
.progress span { display: block; height: 100%; }
.progress .sold { background: var(--green); } .progress .listed { background: var(--accent); }
.car-card .nums, .payback .nums { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.payback { margin-top: 10px; }
.payback .progress { height: 8px; margin: 6px 0 4px; }

.car-head { display: grid; grid-template-columns: 300px 1fr; gap: 20px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 20px; }
.car-head .photo { width: 100%; aspect-ratio: 4/3; border-radius: 9px; background: #dde1e7 center/cover no-repeat; display: flex; align-items: center; justify-content: center; font-size: 60px; color: #a3abb8; }
.specs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 16px; margin: 12px 0; }
.specs div b { display: block; font-size: 11px; color: var(--muted); font-weight: 500; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 20px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px; border-bottom: 1px solid #f0f1f4; vertical-align: middle; }
tr:hover td { background: #fafbfc; }
td.num, th.num { text-align: right; white-space: nowrap; }
.thumb { width: 48px; height: 48px; border-radius: 6px; background: #e8eaee center/cover no-repeat; display: inline-flex; align-items: center; justify-content: center; color: #a3abb8; font-size: 18px; }
.sku { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--muted); }

.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 20px; white-space: nowrap; cursor: pointer; border: none; }
.badge.stock { background: #eef0f3; color: #4a5263; }
.badge.listed { background: #e2edff; color: #1959c2; }
.badge.sold { background: #dcf3e3; color: var(--green); }
.badge.warn { background: #fff1e0; color: var(--orange); cursor: default; }

.tabs { display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs button { border: none; background: transparent; padding: 6px 12px; border-radius: 6px; cursor: pointer; color: var(--muted); font-weight: 500; }
.tabs button.on { background: #e8eefb; color: var(--accent); }

.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty .big { font-size: 42px; }

/* modal */
.overlay { position: fixed; inset: 0; background: rgba(15,20,30,.5); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow: auto; z-index: 50; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 760px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { max-width: 980px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; justify-content: space-between; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.x { border: none; background: none; font-size: 22px; cursor: pointer; color: var(--muted); }

.photo-drop { border: 2px dashed var(--line); border-radius: 10px; padding: 14px; text-align: center; color: var(--muted); cursor: pointer; }
.photo-drop:hover { border-color: var(--accent); color: var(--accent); }
.photos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.photos .ph { width: 86px; height: 86px; border-radius: 8px; background: #eee center/cover no-repeat; position: relative; }
.photos .ph button { position: absolute; top: 3px; right: 3px; background: rgba(0,0,0,.65); color: #fff; border: none; border-radius: 50%; width: 20px; height: 20px; cursor: pointer; font-size: 12px; line-height: 20px; padding: 0; }

.checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px 12px; max-height: 340px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.checklist label { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 13px; font-weight: 400; margin: 0; cursor: pointer; }
.checklist input { width: auto; }
.checklist .grp { grid-column: 1 / -1; font-weight: 700; font-size: 12px; color: var(--muted); margin-top: 6px; text-transform: uppercase; }
input[type=checkbox] { width: auto; }

.hint { background: #f6f8fb; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 12.5px; color: #4a5263; margin-bottom: 14px; line-height: 1.5; }
.hint code { background: #e8ebf0; padding: 1px 4px; border-radius: 3px; }

#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 18px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 100; }
#toast.show { opacity: 1; }

/* login */
body.logged-out .topbar nav { display: none; }
.login-card { max-width: 360px; margin: 60px auto; }
.photo-btns { display: none; gap: 8px; margin-bottom: 10px; }
.photo-btns.show { display: flex; max-width: 420px; }
.photo-btns .btn { margin: 0; flex: 1; justify-content: center; text-align: center; }

/* ---------- phone ---------- */
@media (max-width: 760px) {
  body { font-size: 15px; }
  .car-head { grid-template-columns: 1fr; }
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  main { padding: 12px; padding-bottom: 80px; }
  .card { padding: 14px; }
  input, select, textarea { font-size: 16px; } /* no zoom on iPhone */
  .btn { min-height: 40px; }

  /* top bar: brand on top, menu as a bottom tab bar */
  .topbar { height: 50px; padding: 0 14px; }
  .topbar nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: #111827; display: flex; justify-content: space-around;
    gap: 0; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); border-top: 1px solid #253047; }
  .topbar nav a { flex: 1; text-align: center; font-size: 12px; padding: 8px 2px; }

  /* tables become cards */
  table, thead, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tr { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; border: 1px solid var(--line); border-radius: 10px;
    padding: 10px; margin-bottom: 10px; background: #fff; }
  td { width: auto; border: 0; padding: 0; }
  td.main { flex: 1 1 calc(100% - 70px); order: -1; }
  td:has(.thumb) { order: -2; }
  td.num { text-align: left; }
  tr:has(th) { display: none; }

  /* modals fill the screen, buttons stay at the bottom */
  .overlay { padding: 0; align-items: stretch; }
  .modal, .modal.wide, .modal.xl { max-width: none; border-radius: 0; min-height: 100%; display: flex; flex-direction: column; }
  .modal-head { position: sticky; top: 0; background: #fff; z-index: 2; padding: 12px 14px; }
  .modal-body { flex: 1; padding: 14px; }
  .modal-foot { position: sticky; bottom: 0; background: #fff; z-index: 2; flex-wrap: wrap; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
  .modal-foot .row { flex-wrap: wrap; justify-content: flex-end; }
  .lst-sec .photo-btns { display: flex; }
  .lst-sec .photo-zone { display: none; }
  .lst-sec .photos.big .ph { width: calc(33.3% - 6px); height: auto; aspect-ratio: 1; }
  .modal-body .field input, .modal-body .field select, .modal-body .field textarea { max-width: 100%; box-sizing: border-box; }
  .desc-preview { height: 220px; }
  #toast { bottom: 80px; }
  .car-head .photo { aspect-ratio: auto; height: 170px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat .v { font-size: 18px; }
  .page-head { margin-bottom: 14px; }
  .page-head .btn { padding-left: 10px; padding-right: 10px; }
}

h3.sub { font-size: 13px; margin: 18px 0 10px; padding-top: 14px; border-top: 1px solid var(--line); color: #374151; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 13px; }

/* eBay stiliaus skelbimo forma */
.modal.xl { max-width: 880px; }
.lst-sec { padding: 18px 0; border-bottom: 1px solid var(--line); }
.lst-sec:first-child { padding-top: 0; }
.lst-sec:last-child { border-bottom: none; }
.lst-sec h3 { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; margin: 0 0 12px; color: #111827; }
.photo-zone { border: 2px dashed #c3c9d3; border-radius: 12px; min-height: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; background: #fafbfc; transition: .15s; }
.photo-zone:hover, .photo-zone.over { border-color: var(--accent); background: #f0f5ff; }
.photos.big .ph { width: 110px; height: 110px; }
.photos .ph.main { outline: 3px solid var(--accent); outline-offset: 1px; }
.ph-main { position: absolute; left: 4px; bottom: 4px; background: var(--accent); color: #fff; font-size: 10px; padding: 2px 6px; border-radius: 4px; }
.photos .ph .ph-star { right: auto; left: 3px; }
.title-input { font-size: 16px; padding: 10px 12px; }
.price-input { font-size: 18px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { margin: 0; }
.chip input { display: none; }
.chip span { display: inline-block; border: 1px solid #c3c9d3; border-radius: 20px; padding: 7px 14px; cursor: pointer; color: var(--text); font-size: 13px; }
.chip input:checked + span { background: #111827; border-color: #111827; color: #fff; }
.summary { background: #f6f8fb; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 13px; line-height: 1.6; }
.tag { display: inline-block; background: #eef0f3; border-radius: 5px; padding: 2px 7px; margin: 2px 2px 0 0; color: #374151; }
.desc-preview { width: 100%; height: 280px; border: 1px solid var(--line); border-radius: 8px; margin-top: 8px; background: #fff; }
.err-box { background: #fdecec; border: 1px solid #f5c2c2; color: var(--red); border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; }
input:disabled { background: #f3f4f6; color: #4b5563; }

details.ovr { margin-top: 12px; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
details.ovr[open] { background: #fffdf5; border-color: #f0dca8; }
details.ovr summary { cursor: pointer; }

.title-group { display: flex; align-items: stretch; }
.title-pre { display: flex; align-items: center; background: #eef0f3; border: 1px solid var(--line); border-right: none; border-radius: 7px 0 0 7px; padding: 0 12px; font-size: 15px; font-weight: 600; white-space: nowrap; color: #111827; }
.title-group .title-input { border-radius: 0 7px 7px 0; }

.nav-badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: #f59e0b; color: #111827; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.pending-box { border: 1px solid #f0dca8; background: #fffdf5; border-radius: 10px; padding: 12px; margin-bottom: 14px; }

.cat-sugg { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.cat-opt { text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; font: inherit; color: var(--text); }
.cat-opt:hover { border-color: #9aa5b5; }
.cat-opt.on { border-color: var(--accent); background: #f0f5ff; }
.pc-box { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; background: #fafbfc; }
.pc-head { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; margin-bottom: 6px; }
.pc-links { margin-left: auto; display: flex; gap: 12px; font-size: 13px; }
.pc-sub { margin: 8px 0 4px; }
.pc-stats { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: baseline; margin: 6px 0; }
.pc-item { display: flex; gap: 10px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); }
.pc-thumb { flex: 0 0 48px; height: 48px; border-radius: 6px; background: #e5e7eb center/cover no-repeat; }
.pc-info { flex: 1; min-width: 0; }
.pc-title { display: block; font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-btns { display: flex; gap: 6px; flex-shrink: 0; }
.pc-copy { margin-top: 8px; flex-wrap: nowrap; gap: 6px; }
@media (max-width: 760px) {
  .pc-item { flex-wrap: wrap; }
  .pc-info { flex-basis: calc(100% - 60px); }
  .pc-btns { width: 100%; justify-content: flex-end; }
  .pc-links { margin-left: 0; }
}
