:root {
  --bg: #f3f5fa; --card: #fff; --ink: #0a1429; --muted: #5d6880; --line: #dfe5ef; --soft: #eef2f9;
  --accent: #1560f0; --accent-soft: #e6eeff; --danger: #c8322b; --ok: #12824a; --navy: #071226;
  --font: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
.muted { color: var(--muted); }
.boot { padding: 40px; text-align: center; color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Кнопки и поля */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 15px; border-radius: 10px;
  border: 1px solid transparent; font-weight: 600; text-decoration: none; white-space: nowrap; background: var(--soft);
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #0f4fd0; }
.btn.ghost { background: var(--card); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--accent); }
.btn.ghost.light { background: transparent; border-color: rgba(255, 255, 255, .3); color: #fff; }
.btn.danger { background: var(--card); border-color: var(--line); color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.sm { padding: 6px 11px; font-size: 13.5px; border-radius: 8px; }
.btn.big { padding: 13px 18px; font-size: 16px; }
.btn.wide { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.inp {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); outline: 0;
}
.inp:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.inp { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.fld { display: grid; gap: 5px; min-width: 0; }
.fld > span { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.fld.grow { flex: 1 1 240px; }
.form-err { margin: 0; color: var(--danger); font-weight: 500; }
.ib { width: 30px; height: 30px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 14px; }
.ib:hover:not(:disabled) { background: var(--soft); color: var(--ink); }
.ib.del:hover { background: #fdecea; color: var(--danger); }
.ib:disabled { opacity: .3; cursor: default; }

/* Вход */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(800px 400px at 80% 0%, rgba(40, 120, 255, .5), transparent 60%), var(--navy); }
.auth-card { width: min(400px, 100%); display: grid; gap: 14px; padding: 32px; border-radius: 22px; background: var(--card); box-shadow: 0 30px 80px rgba(0, 0, 0, .35); }
.auth-card h1 { font-size: 24px; }
.auth-card p { margin: 0; }
.auth-card .inp { height: 48px; font-size: 16px; }
.back { color: var(--muted); font-size: 14px; text-decoration: none; text-align: center; }
.logo { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; color: #fff; font-weight: 700; background: linear-gradient(140deg, #4d9bff, #1250d8); }
.logo.sm { width: 34px; height: 34px; border-radius: 10px; font-size: 13px; }

/* Каркас */
#app { min-height: 100%; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 18px; padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--line); }
.tb-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tab { padding: 8px 14px; border: 0; border-radius: 9px; background: none; font-weight: 600; color: var(--muted); white-space: nowrap; }
.tab:hover { color: var(--ink); background: var(--soft); }
.tab.on { color: var(--accent); background: var(--accent-soft); }
.tb-right { display: flex; gap: 8px; }
.view { flex: 1; min-height: 0; }

/* Прайс */
.view-price { display: grid; grid-template-columns: 300px minmax(0, 1fr); align-items: start; }
.side { position: sticky; top: 55px; height: calc(100vh - 55px); display: flex; flex-direction: column; gap: 10px; padding: 16px; border-right: 1px solid var(--line); background: var(--card); }
.side-body { flex: 1; overflow-y: auto; margin: 0 -8px; padding: 0 8px; }
.side-label { margin: 14px 8px 4px; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.side-label:first-child { margin-top: 2px; }
.side-empty { margin: 2px 8px; font-size: 13px; color: var(--muted); }
.side-item { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 0; border-radius: 9px; background: none; text-align: left; font-weight: 500; }
.side-item small { flex: none; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.side-item:hover { background: var(--soft); }
.side-item.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-item.off span { color: var(--muted); text-decoration: line-through; }

.editor { padding: 22px 24px 120px; min-width: 0; }
.blank { padding: 80px 20px; text-align: center; display: grid; gap: 10px; justify-items: center; }
.ed-head { display: grid; gap: 14px; padding: 18px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; }
.ed-fields { display: flex; flex-wrap: wrap; gap: 12px; }
.ed-fields .fld:not(.grow) { flex: 0 1 220px; }
.title-inp { font-weight: 700; font-size: 17px; }
.ed-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.switch { display: inline-flex; align-items: center; gap: 8px; margin-right: auto; font-weight: 500; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }

.cols { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.cols-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.col-chip { display: inline-flex; align-items: center; height: 36px; padding: 0 4px 0 2px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.col-chip input { height: 30px; max-width: 280px; padding: 0 8px; border: 0; outline: 0; background: none; font-weight: 600; border-radius: 7px; }
.col-chip input:focus { background: var(--accent-soft); }
.col-chip button { width: 24px; height: 26px; border: 0; background: none; color: var(--muted); border-radius: 6px; font-size: 12px; }
.col-chip button:hover:not(:disabled) { background: var(--soft); color: var(--ink); }
.col-chip button:disabled { opacity: .25; cursor: default; }

.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 16px 0 10px; }
.tools .filter { width: 260px; margin-left: auto; }

.tbl-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 16px; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { padding: 10px 8px; text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); background: var(--card); vertical-align: bottom; }
.tbl td { padding: 2px 4px; border-bottom: 1px solid var(--soft); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .c-drag { width: 30px; padding-left: 8px; }
.tbl th.c-price { width: 130px; min-width: 110px; text-align: right; padding-right: 14px; }
.tbl .c-act { width: 106px; white-space: nowrap; text-align: right; padding-right: 8px; }
.tbl td:nth-child(2) { min-width: 200px; }
.tbl td:nth-child(3) { min-width: 190px; }
.drag { display: inline-block; padding: 4px; color: #b3bccb; cursor: grab; user-select: none; }
.drag[draggable="false"] { opacity: .3; cursor: not-allowed; }
.cell { width: 100%; height: 36px; padding: 0 8px; border: 1px solid transparent; border-radius: 8px; background: none; outline: 0; }
.cell:hover { border-color: var(--line); }
.cell:focus { border-color: var(--accent); background: var(--card); box-shadow: 0 0 0 3px var(--accent-soft); }
.cell.name { font-weight: 600; }
.cell.note { color: var(--muted); }
.cell.price { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.cell::placeholder { color: #b9c1cf; font-weight: 400; }
.tbl tr.off .cell { color: #a6afbf; text-decoration: line-through; }
.tbl tr.dragging { opacity: .4; }
.tbl tr.over td { box-shadow: inset 0 2px 0 var(--accent); }
.tbl tr.flash td { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: #fff3c4; } to { background: transparent; } }
.tbl td.none { padding: 28px; text-align: center; color: var(--muted); }
.hint { margin: 10px 4px 0; font-size: 13px; color: var(--muted); }

/* Настройки и прочие страницы */
.page { width: min(900px, 100% - 32px); margin: 22px auto 120px; display: grid; gap: 14px; }
.page.narrow { width: min(460px, 100% - 32px); }
.card { display: grid; gap: 12px; padding: 22px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; }
.card h2 { font-size: 18px; }
.card > p { margin: -6px 0 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; flex: 1; }
.stack { display: grid; gap: 10px; flex: 1; }
.list-ed { display: grid; gap: 10px; justify-items: start; }
.list-row { width: 100%; display: flex; align-items: flex-start; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.list-row > .inp { flex: 1; }
.list-btns { display: flex; flex: none; }
.bk-list { display: grid; }
.bk { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; border-top: 1px solid var(--soft); }

/* Панель сохранения */
.savebar { position: fixed; z-index: 40; left: 50%; bottom: 18px; transform: translate(-50%, 140%); display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 18px;
  border-radius: 16px; background: var(--navy); color: #fff; font-weight: 500; box-shadow: 0 16px 40px rgba(7, 18, 38, .35); transition: transform .2s; max-width: calc(100% - 20px); }
.savebar.show { transform: translate(-50%, 0); }

/* Окна и уведомления */
.modal { width: min(460px, calc(100% - 24px)); padding: 24px; border: 0; border-radius: 18px; background: var(--card); color: var(--ink); box-shadow: 0 30px 80px rgba(0, 0, 0, .3); }
.modal::backdrop { background: rgba(7, 18, 38, .5); }
.modal h3 { font-size: 19px; margin-bottom: 14px; }
.form { display: grid; gap: 12px; }
.form p { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
#toasts { position: fixed; z-index: 60; top: 14px; right: 14px; display: grid; gap: 8px; max-width: min(380px, calc(100% - 28px)); }
.toast { padding: 12px 16px; border-radius: 12px; background: var(--navy); color: #fff; font-weight: 500; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); }
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }

@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: 8px 12px; padding: 10px 14px; }
  .tabs { order: 3; flex-basis: 100%; }
  .tb-right { margin-left: auto; }
  .view-price { grid-template-columns: 1fr; }
  .side { position: static; height: auto; max-height: 46vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .editor { padding: 16px 12px 120px; }
  .tools .filter { width: 100%; margin-left: 0; }
  .row2, .grid4 { grid-template-columns: 1fr; }
  .savebar span { display: none; }
  .savebar { padding: 8px; }
}
