:root {
  --blue: #2F5BFF;
  --blue-dark: #2347D6;
  --yellow: #ffd84a;
  --bg: #f4f6fb;
  --card: #fff;
  --text: #14161c;
  --muted: #6b7080;
  --line: #e5e8ef;
  --red: #e5484d;
  --green: #2f9e5b;
  --orange: #e8890c;
  --head-font: "Unbounded", sans-serif;
  --body-font: "Montserrat", sans-serif;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); }
body { font-family: var(--body-font); color: var(--text); font-size: 14px; }
a { color: var(--blue-dark); text-decoration: none; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--red); font-size: 13px; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.logo { font-family: var(--head-font); font-weight: 800; font-size: 22px; letter-spacing: -1px; }
.logo { display: flex; flex-direction: column; gap: 4px; }
.logo__img { display: block; height: 24px; width: auto; max-width: 100%; }
.login__box .logo__img { height: 30px; }
.logo small { font-family: var(--body-font); font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0; }

/* ---------- Кнопки / поля ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 10px; font-weight: 600; background: #eef1f7; transition: .15s; white-space: nowrap; }
.btn:hover { background: #e2e7f1; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--yellow); }
.btn--primary:hover { background: #f5cc2f; }
.btn--blue { background: var(--blue); color: #fff; }
.btn--blue:hover { background: var(--blue-dark); }
.btn--danger { background: #fde8e8; color: var(--red); }
.btn--danger:hover { background: #fbd5d5; }
.btn--ghost { background: transparent; }
.btn--sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.link { color: var(--blue-dark); font-weight: 600; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea, .input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { border-color: var(--blue); }
.field textarea { resize: vertical; min-height: 70px; }
.hint { font-size: 11px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; }

/* ---------- Вход ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login__box { width: 100%; max-width: 360px; background: var(--card); border-radius: 18px; padding: 32px; box-shadow: 0 20px 50px rgba(20,30,60,.08); display: flex; flex-direction: column; gap: 10px; }
.login__box .logo { font-size: 26px; margin-bottom: 4px; }
.login__box input { padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; outline: none; }
.login__box input:focus { border-color: var(--blue); }
.login__box .btn { padding: 12px; }

/* ---------- Каркас ---------- */
.app { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--card); border-right: 1px solid var(--line); padding: 22px 14px; display: flex; flex-direction: column; gap: 20px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .logo { padding: 0 10px; }
.side__nav { display: flex; flex-direction: column; gap: 2px; }
.side__nav a, .side__links a { display: flex; align-items: center; gap: 6px; padding: 9px 10px; border-radius: 10px; color: var(--text); font-weight: 500; }
.side__nav a:hover, .side__links a:hover { background: #f1f4fa; }
.side__nav a.active { background: #eaf0fe; color: var(--blue-dark); font-weight: 700; }
.side__links { border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 2px; }
.side__user { margin-top: auto; padding: 10px; font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.pill { margin-left: auto; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 20px; }

.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 18px 28px; position: sticky; top: 0; background: rgba(244,246,251,.92); backdrop-filter: blur(6px); z-index: 10; }
.topbar h1 { font-family: var(--head-font); font-size: 20px; font-weight: 700; }
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.burger { display: none; font-size: 22px; }
.sync { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.sync::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.sync.err::before { background: var(--red); }
.sync.busy::before { background: var(--orange); }
.page { padding: 0 28px 40px; }

/* ---------- Карточки / таблицы ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 18px; border: 1px solid var(--line); }
.card + .card { margin-top: 16px; }
.card h2 { font-size: 15px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; }
.card h2 .link { margin-left: auto; font-size: 13px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.kpi__label { color: var(--muted); font-size: 12px; font-weight: 600; }
.kpi__value { font-size: 24px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi__sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.cols2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar .input { width: auto; min-width: 140px; }
.toolbar .search { flex: 1; min-width: 200px; }
.toolbar .spacer { flex: 1; }

.bulkbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 14px; margin-bottom: 12px; background: #eaf0fe; border: 1px solid #c9d8fb; border-radius: 12px; position: sticky; top: 64px; z-index: 5; }
.input--sm { width: auto; padding: 5px 10px; font-size: 12px; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
td input[type=checkbox], th input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--blue); cursor: pointer; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.card .table-wrap { border: 0; border-radius: 0; margin: 0 -18px -18px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; background: #fafbfd; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: #f8faff; }
td .sub { font-size: 12px; color: var(--muted); }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.thumb { width: 42px; height: 42px; border-radius: 8px; background: #f1f3f8; display: grid; place-items: center; overflow: hidden; font-size: 22px; }
.thumb svg { width: 24px; height: 24px; }
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.circle { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; overflow: hidden; }
.circle img { width: 100%; height: 100%; object-fit: cover; }
.circle--tile { border-radius: 11px; background: #F1F4FF; }
.circle--tile svg { width: 22px; height: 22px; }
.circle--tile img { max-width: 84%; max-height: 84%; object-fit: contain; }
.cat-preview { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100px; font-size: 12px; text-align: center; }
.cat-preview .circle { width: 72px; height: 72px; font-size: 34px; }
.cat-preview .circle--tile { border-radius: 18px; }
.cat-preview .circle--tile svg { width: 36px; height: 36px; }
.icon-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 6px; }
.icon-pick button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; border-radius: 12px; border: 2px solid transparent; background: #F7F9FF; }
.icon-pick button:hover { background: #EEF2FF; }
.icon-pick button.on { border-color: var(--blue); background: #EAF0FE; }
.icon-pick img { width: 44px; height: 40px; object-fit: contain; }
.icon-pick small { font-size: 10px; line-height: 1.2; color: var(--muted); text-align: center; }
.conn { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.review-stars { color: #FFB800; letter-spacing: 1px; white-space: nowrap; }
.actions { display: flex; gap: 6px; justify-content: flex-end; }

.tag { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; white-space: nowrap; background: #eef1f7; color: var(--muted); }
.tag--blue { background: #e7efff; color: #3565c9; }
.tag--green { background: #e3f6ea; color: var(--green); }
.tag--red { background: #fde8e8; color: var(--red); }
.tag--orange { background: #fff1dc; color: #b86a00; }
.tag--yellow { background: #fff6cc; color: #8a6d00; }
.tag--violet { background: #efe8ff; color: #6a3fd1; }

/* ---------- Модалка ---------- */
.modal { position: fixed; inset: 0; background: rgba(15,20,35,.45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal__box { background: #fff; border-radius: 18px; padding: 26px; width: 100%; max-width: 720px; max-height: calc(100vh - 32px); overflow-y: auto; position: relative; }
.modal__box h3 { font-family: var(--head-font); font-size: 18px; margin-bottom: 16px; padding-right: 30px; }
.modal__close { position: absolute; top: 12px; right: 16px; font-size: 28px; color: #999; line-height: 1; }
.modal__foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.modal__foot .left { margin-right: auto; }
.section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 10px; }
.info { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 13px; }
.info dt { color: var(--muted); }
.photos { display: flex; flex-wrap: wrap; gap: 10px; }
.photo { width: 96px; height: 96px; border-radius: 10px; border: 2px solid var(--line); position: relative; overflow: hidden; background: #f6f7fa; }
.photo.main { border-color: var(--yellow); }
.photo img { width: 100%; height: 100%; object-fit: contain; }
.photo__bar { position: absolute; inset: auto 0 0 0; display: flex; justify-content: space-between; background: rgba(0,0,0,.55); }
.photo__bar button { color: #fff; font-size: 12px; padding: 3px 7px; }
.upload { width: 96px; height: 96px; border-radius: 10px; border: 2px dashed var(--line); display: grid; place-items: center; text-align: center; font-size: 12px; color: var(--muted); cursor: pointer; }
.upload:hover { border-color: var(--blue); color: var(--blue-dark); }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.history { list-style: none; font-size: 12px; display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; }
.history li { display: flex; gap: 10px; }
.history time { color: var(--muted); white-space: nowrap; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: #14161c; color: #fff; padding: 12px 20px; border-radius: 12px; opacity: 0; pointer-events: none; transition: .25s; z-index: 200; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--red); }

.bars { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding-top: 10px; }
.bars__col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; min-width: 0; }
.bars__bar { width: 100%; max-width: 26px; background: var(--blue); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars__lbl { font-size: 10px; color: var(--muted); }

@media (max-width: 960px) {
  .cols2 { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 50; left: 0; width: 250px; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.15); }
  .side.open { transform: none; }
  .burger { display: block; }
  .topbar { padding: 14px 16px; }
  .page { padding: 0 16px 32px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .info { grid-template-columns: 1fr; gap: 2px; }
  .info dd { margin-bottom: 6px; }
  .hide-sm { display: none; }
}
