:root {
  --bg: #f4f5f7; --card: #fff; --ink: #1d2330; --muted: #6b7280; --line: #e3e6ea;
  --accent: #e8590c; --accent-ink: #fff; --ok: #2f9e44; --warn: #f59f00; --bad: #c92a2a;
  --avito: #00aaff; --drom: #db2828;
  --r: 10px; font-size: 15px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
[hidden] { display: none !important; }
a { color: inherit; }
input, select, textarea, button { font: inherit; color: inherit; }

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.brand.big { font-size: 1.3rem; margin-bottom: 8px; }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 800; }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 18px; padding: 10px 24px; background: var(--card); border-bottom: 1px solid var(--line); }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { text-decoration: none; padding: 7px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.topbar nav a.active { background: var(--bg); color: var(--ink); }
.spacer { flex: 1; }
main { max-width: 1200px; margin: 0 auto; padding: 22px 24px 80px; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); padding: 8px 14px; border-radius: 8px; cursor: pointer; text-decoration: none; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: #c8cdd3; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: .87rem; }

.warn { background: #fff4e6; border-bottom: 1px solid #ffd8a8; padding: 8px 24px; font-size: .92rem; }

/* Вход */
.login { min-height: 100vh; display: grid; place-items: center; }
.login-card { background: var(--card); padding: 32px; border-radius: 14px; width: min(360px, 92vw); display: grid; gap: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.06); }
.err { color: var(--bad); margin: 0; min-height: 1.2em; font-size: .9rem; }

/* Поля */
label { display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; gap: 5px; font-size: .85rem; color: var(--muted); font-weight: 500; }
input[type=text], input[type=number], input[type=password], input[type=search], input:not([type]), select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); font-size: .95rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }
textarea { resize: vertical; min-height: 140px; line-height: 1.45; }
.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: .95rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* Список */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar input[type=search] { max-width: 340px; }
.toolbar select { width: auto; }
.count { color: var(--muted); font-size: .9rem; margin-left: auto; }
.stats { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 16px; min-width: 130px; }
.stat b { display: block; font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .82rem; }

.table { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.row { display: grid; grid-template-columns: 32px 64px 1fr 110px 120px 92px 96px; gap: 12px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); cursor: pointer; }
.row:first-child { border-top: 0; }
.row:hover { background: #fafbfc; }
.row.head { cursor: default; background: #fafbfc; font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 8px 14px; }
.row.dim { opacity: .55; }
.thumb { width: 64px; height: 48px; border-radius: 6px; object-fit: cover; background: var(--bg); display: grid; place-items: center; color: #b0b6bd; font-size: .7rem; }
.t-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-meta { color: var(--muted); font-size: .84rem; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.price { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; }
.chip.active { background: #ebfbee; color: var(--ok); }
.chip.sold { background: #f1f3f5; color: var(--muted); }
.chip.hidden { background: #fff4e6; color: #d9480f; }
.badges { display: flex; gap: 4px; }
.badge { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; font-size: .72rem; font-weight: 800; color: #fff; }
.badge.avito { background: var(--avito); }
.badge.drom { background: var(--drom); }
.badge.off { background: #e9ecef; color: #adb5bd; }
.empty { padding: 50px 20px; text-align: center; color: var(--muted); }

.bulk { position: sticky; bottom: 16px; margin-top: 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: var(--r); box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.bulk .btn { background: #2c3445; border-color: #2c3445; color: #fff; }
.bulk input { width: 80px; padding: 6px 8px; }

/* Редактор */
.editor-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.editor-head h1 { font-size: 1.35rem; margin: 0; flex: 1; min-width: 200px; }
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.editor > * { min-width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.card + .card { margin-top: 18px; }
.card h2 { font-size: .95rem; margin: 0 0 14px; }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.with-btn { display: flex; gap: 6px; }
.hint { font-size: .8rem; color: var(--muted); font-weight: 400; }
.hint.over { color: var(--bad); }

.drop { border: 2px dashed var(--line); border-radius: var(--r); padding: 18px; text-align: center; color: var(--muted); cursor: pointer; transition: .15s; }
.drop.over { border-color: var(--accent); background: #fff4e6; color: var(--ink); }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.ph { position: relative; aspect-ratio: 4/3; border-radius: 8px; overflow: hidden; background: var(--bg); }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph .main { position: absolute; left: 4px; top: 4px; background: var(--accent); color: #fff; font-size: .68rem; padding: 1px 6px; border-radius: 4px; font-weight: 700; }
.ph .ctl { position: absolute; inset: auto 0 0 0; display: flex; justify-content: space-between; padding: 3px; background: linear-gradient(transparent, rgba(0,0,0,.55)); opacity: 0; transition: .15s; }
.ph:hover .ctl { opacity: 1; }
.ph .ctl button { border: 0; background: rgba(255,255,255,.9); border-radius: 5px; width: 26px; height: 24px; cursor: pointer; font-size: .85rem; }

.feed { display: flex; gap: 8px; align-items: center; }
.feed code { flex: 1; min-width: 0; background: var(--bg); padding: 8px 10px; border-radius: 8px; font-size: .82rem; overflow-x: auto; white-space: nowrap; }

.sub { font-size: .85rem; color: var(--muted); font-weight: 500; margin-bottom: 6px; }
.regions { display: grid; gap: 6px; margin: 4px 0 6px; }
.reg { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 6px 8px; padding: 10px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 8px; }
.reg-opts { grid-column: 1 / -1; display: flex; gap: 16px; align-items: center; }
.reg-opts [data-del] { margin-left: auto; }
.reg .check { font-size: .85rem; white-space: nowrap; }
.vid { width: 100%; max-height: 260px; border-radius: 8px; background: #000; display: block; margin-bottom: 8px; }
@media (max-width: 900px) { .reg { grid-template-columns: 1fr 1fr; } }
.howto { margin: 0 0 12px; padding-left: 20px; line-height: 1.6; }
.bar { height: 10px; background: var(--bg); border-radius: 99px; overflow: hidden; margin: 6px 0 10px; }
.bar > div { height: 100%; background: var(--accent); transition: width .4s; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 50; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast.bad { background: var(--bad); }

@media (max-width: 900px) {
  .editor { grid-template-columns: 1fr; }
  .row { grid-template-columns: 28px 56px 1fr 90px; }
  .row > :nth-child(5), .row > :nth-child(6), .row > :nth-child(7) { display: none; }
  .g3, .g4 { grid-template-columns: 1fr 1fr; }
  .topbar { padding: 10px 14px; gap: 10px; }
  main { padding: 16px 12px 80px; }
}
