:root {
  --bg: #f4f4f6;
  --surface: #fff;
  --ink: #0b0b0c;
  --ink-2: #55555c;
  --muted: #8d8d94;
  --line: #e7e7ea;
  --accent: #d7262e;
  --ok: #1f9d55;
  --warn: #c98a00;
  --radius: 14px;
  --side: 248px;
  --font: 'Urbanist', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
svg { width: 20px; height: 20px; flex: none; }
[hidden] { display: none !important; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 20% 0%, #2a2a2e, #0b0b0c 60%); }
.login .box { width: 100%; max-width: 380px; background: #fff; border-radius: 20px; padding: 32px 28px; }
.login h1 { margin: 16px 0 4px; font-size: 26px; }
.login p { color: var(--ink-2); margin: 0 0 20px; }
.hint { background: var(--bg); border-radius: 10px; padding: 10px 12px; font-size: 13px; color: var(--ink-2); margin-top: 14px; }
.logo { font-weight: 900; font-size: 22px; letter-spacing: -.03em; }
.logo b { color: var(--accent); }
.logo small { font-size: 10px; letter-spacing: .2em; color: var(--muted); margin-left: 4px; font-weight: 700; }

/* Shell */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { background: var(--ink); color: #c9c9ce; padding: 22px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.side .logo { color: #fff; padding: 0 10px 22px; }
.side a.nav { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; font-weight: 600; }
.side a.nav:hover { background: #1c1c1f; color: #fff; }
.side a.nav.on { background: #fff; color: var(--ink); }
.side .badge { margin-left: auto; background: var(--accent); color: #fff; border-radius: 999px; font-size: 11px; padding: 2px 7px; font-weight: 800; }
.side .bottom { margin-top: auto; display: grid; gap: 4px; }
.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(244,244,246,.92); backdrop-filter: blur(10px); display: flex; align-items: center; gap: 12px; padding: 16px 28px; border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 22px; letter-spacing: -.01em; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .back { display: none; }
.content { padding: 24px 28px 100px; max-width: 1200px; }
.tabbar { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .topbar { padding: 12px 16px; }
  .topbar h1 { font-size: 19px; }
  .content { padding: 16px 16px 110px; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: #fff; border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a { display: grid; justify-items: center; gap: 2px; font-size: 11px; font-weight: 700; color: var(--muted); padding: 6px 0; position: relative; }
  .tabbar a.on { color: var(--ink); }
  .tabbar a.add span.plus { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; margin-top: -22px; box-shadow: 0 6px 16px rgba(215,38,46,.4); }
  .tabbar .dot { position: absolute; top: 4px; left: 56%; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
}

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 10px; border: 1px solid var(--ink); background: var(--ink); color: #fff; font-weight: 700; cursor: pointer; white-space: nowrap; font-size: 14px; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ink); }
.btn.red { background: var(--accent); border-color: var(--accent); }
.btn.danger { background: #fff; color: var(--accent); border-color: #f2c4c6; }
.btn.danger:hover { background: var(--accent); color: #fff; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn.icon { padding: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
@media (max-width: 600px) { .topbar .btn .lbl { display: none; } }

/* Cards / stats */
.panel { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); padding: 20px; }
.panel + .panel { margin-top: 18px; }
.panel h2 { font-size: 17px; margin: 0 0 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.panel h2 a { font-size: 13px; color: var(--accent); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.stat small { color: var(--muted); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.stat b { display: block; font-size: 28px; letter-spacing: -.02em; margin-top: 4px; }
.stat.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.two { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }
@media (max-width: 1000px) { .stats { grid-template-columns: 1fr 1fr; } .two { grid-template-columns: 1fr; } }
@media (max-width: 380px) { .stat b { font-size: 22px; } }

/* Inventory list */
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .search { flex: 1; min-width: 200px; position: relative; }
.toolbar .search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; }
.toolbar input, .toolbar select { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff; outline: none; }
.toolbar .search input { padding-left: 38px; }
.toolbar select { width: auto; }
.seg { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 3px; overflow-x: auto; max-width: 100%; }
.seg button { border: 0; background: none; padding: 7px 12px; border-radius: 7px; font-weight: 700; font-size: 13px; cursor: pointer; color: var(--ink-2); white-space: nowrap; }
.seg button.on { background: var(--ink); color: #fff; }

.rows { display: grid; gap: 10px; }
.row { display: grid; grid-template-columns: 110px 1fr auto auto auto; gap: 16px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.row .thumb { width: 110px; aspect-ratio: 4/3; border-radius: 10px; object-fit: cover; background: #ddd; }
.row h3 { margin: 0 0 4px; font-size: 16px; }
.row .meta { color: var(--ink-2); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.row .price { font-weight: 800; font-size: 16px; white-space: nowrap; }
.row .acts { display: flex; gap: 6px; }
.row select.status { padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); font-weight: 700; font-size: 13px; background: #fff; }
.pill { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; background: #e8f6ee; color: var(--ok); }
.pill.Sold { background: #fde8e9; color: var(--accent); }
.pill.Reserved { background: #fff4dc; color: var(--warn); }
.pill.feat { background: #111; color: #fff; }
@media (max-width: 760px) {
  .row { grid-template-columns: 92px 1fr; gap: 10px 12px; align-items: start; }
  .row .thumb { width: 92px; grid-row: span 2; }
  .row .price { font-size: 15px; }
  .row .ctrl { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; }
  .row .ctrl select.status { flex: 1; }
}
@media (min-width: 761px) { .row .ctrl { display: contents; } }
.empty { text-align: center; padding: 50px 20px; color: var(--ink-2); background: #fff; border-radius: var(--radius); border: 1px dashed var(--line); }

/* Form */
.form-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 1000px) { .form-grid { grid-template-columns: 1fr; } }
.fields { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.fields.three { grid-template-columns: repeat(3, 1fr); }
.fields .full { grid-column: 1 / -1; }
@media (max-width: 600px) { .fields, .fields.three { grid-template-columns: 1fr 1fr; } }
@media (max-width: 380px) { .fields, .fields.three { grid-template-columns: 1fr; } }
label.f { display: grid; gap: 6px; font-size: 12px; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: .06em; }
label.f input, label.f select, label.f textarea { width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: #fafafb; outline: none; font-size: 15px; text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--ink); }
label.f input:focus, label.f select:focus, label.f textarea:focus { border-color: var(--ink); background: #fff; }
label.f textarea { min-height: 110px; resize: vertical; }
label.f .help { font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--muted); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fafafb; cursor: pointer; font-weight: 600; }
.switch input { width: 42px; height: 24px; appearance: none; background: #d4d4d8; border-radius: 999px; position: relative; cursor: pointer; transition: .2s; flex: none; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { left: 21px; }

/* Photos */
.drop { border: 2px dashed #cfcfd4; border-radius: var(--radius); padding: 22px; text-align: center; color: var(--ink-2); cursor: pointer; transition: .15s; background: #fafafb; }
.drop.over { border-color: var(--accent); background: #fff5f5; }
.drop b { color: var(--ink); }
.drop .btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 14px; }
.photo { position: relative; border-radius: 10px; overflow: hidden; background: #ddd; aspect-ratio: 4/3; border: 2px solid transparent; }
.photo.cover { border-color: var(--accent); }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo .cov { position: absolute; top: 6px; left: 6px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 800; padding: 3px 7px; border-radius: 6px; letter-spacing: .06em; }
.photo .tools { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; padding: 6px; background: linear-gradient(transparent, rgba(0,0,0,.65)); }
.photo .tools button { width: 30px; height: 30px; border-radius: 8px; border: 0; background: rgba(255,255,255,.92); display: grid; place-items: center; cursor: pointer; }
.photo .tools button svg { width: 16px; height: 16px; }
.photo .tools button.del { background: var(--accent); color: #fff; }
.photo[draggable=true] { cursor: grab; }
.photo.dragging { opacity: .4; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: #fafafb; }
.tags span { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 5px 6px 5px 11px; font-size: 13px; font-weight: 600; display: inline-flex; gap: 4px; align-items: center; }
.tags span button { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 16px; line-height: 1; padding: 0 4px; }
.tags input { flex: 1; min-width: 140px; border: 0; background: none; outline: none; padding: 5px; }

.savebar { position: sticky; bottom: 0; margin: 18px -28px -100px; padding: 14px 28px; background: rgba(255,255,255,.95); backdrop-filter: blur(8px); border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; z-index: 10; }
@media (max-width: 900px) {
  .savebar { position: fixed; left: 0; right: 0; bottom: calc(62px + env(safe-area-inset-bottom)); margin: 0; padding: 10px 16px; }
  .savebar .btn { flex: 1; }
}

/* Leads */
.lead { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); align-items: start; }
.lead:last-child { border-bottom: 0; }
.lead .av { width: 40px; height: 40px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-weight: 800; }
.lead.unread .av { background: var(--accent); color: #fff; }
.lead h4 { margin: 0; font-size: 15px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.lead p { margin: 4px 0 6px; color: var(--ink-2); }
.lead .car-link { font-size: 13px; font-weight: 700; color: var(--accent); }
.lead .when { font-size: 12px; color: var(--muted); white-space: nowrap; }
.lead .lacts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
@media (max-width: 600px) { .lead { grid-template-columns: auto 1fr; } .lead .when { grid-column: 2; grid-row: 1; justify-self: end; } }

/* Modal + toast */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: grid; place-items: center; padding: 16px; z-index: 100; }
.modal .box { background: #fff; border-radius: 18px; padding: 24px; width: 100%; max-width: 440px; max-height: 90vh; overflow: auto; }
.modal .box.wide { max-width: 760px; }
.modal h3 { margin: 0 0 8px; font-size: 20px; }
.modal p { color: var(--ink-2); margin: 0 0 18px; }
.modal .acts { display: flex; gap: 10px; justify-content: flex-end; }
.lib { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; margin: 14px 0; }
.lib button { padding: 0; border: 3px solid transparent; border-radius: 10px; overflow: hidden; cursor: pointer; aspect-ratio: 4/3; background: #ddd; }
.lib button.on { border-color: var(--accent); }
.lib img { width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 600px) { .modal { align-items: end; padding: 0; } .modal .box { border-radius: 18px 18px 0 0; max-height: 85vh; } }
.toast { position: fixed; left: 50%; bottom: 150px; transform: translate(-50%, 160px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; z-index: 200; transition: transform .3s; max-width: calc(100vw - 32px); }
.toast.show { transform: translate(-50%, 0); }
@media (min-width: 901px) { .toast { bottom: 24px; } }
.progress { font-size: 13px; color: var(--ink-2); margin-top: 8px; }
