:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #17191c;
  --muted: #737b8c;
  --line: #e3e6ea;
  --blue: #1e4fd8;
  --blue-soft: #e8eefc;
  --green: #0f7a4a;
  --red: #e5484d;
  --red-soft: #fdecec;
  --dark: #17191c;
  --radius: 14px;
  font-family: -apple-system, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 14px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.blue { color: var(--blue); }
h1, h2, h3 { margin: 0; }
a { color: var(--blue); }

/* Вход */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--card); padding: 32px; border-radius: 20px; width: min(380px, 100%); display: grid; gap: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.06); text-align: center; }
.login-logo { width: 72px; height: 72px; object-fit: contain; margin: 0 auto; }
.login-card label { text-align: left; }

/* Каркас */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--card); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand img { width: 44px; height: 44px; object-fit: contain; }
.brand div { display: flex; flex-direction: column; line-height: 1; font-size: 15px; font-weight: 900; letter-spacing: .5px; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--text); text-decoration: none; font-weight: 500; }
nav a:hover { background: var(--bg); }
nav a.active { background: var(--dark); color: #fff; }
nav .nav-ico { width: 20px; text-align: center; }
.sidebar-foot { margin-top: auto; display: grid; gap: 6px; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 18px 28px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar h2 { font-size: 20px; flex: 1; }
.topbar-actions { display: flex; gap: 8px; }
.menu-btn { display: none; }
.content { padding: 24px 28px 60px; }

/* Кнопки и поля */
.btn { border: 1px solid var(--line); background: var(--card); color: var(--text); padding: 9px 16px; border-radius: 999px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #c9ced6; }
.btn.primary { background: var(--dark); color: #fff; border-color: var(--dark); }
.btn.primary:hover { background: #33373d; }
.btn.blue { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn.danger { color: var(--red); border-color: #f3c3c5; }
.btn.danger:hover { background: var(--red-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--bg); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.icon { padding: 6px 10px; }
.btn.wide { width: 100%; padding: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
label { display: grid; gap: 6px; font-weight: 600; font-size: 13px; }
label .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
input, select, textarea { font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--text); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-soft); border-color: var(--blue); }
textarea { min-height: 90px; resize: vertical; }
input[type=checkbox] { width: 18px; height: 18px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.error { color: var(--red); min-height: 18px; font-size: 13px; }

/* Карточки и таблицы */
.card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); }
.card-pad { padding: 20px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat { padding: 18px; }
.stat .num { font-size: 28px; font-weight: 800; margin-top: 6px; }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input, .toolbar select { max-width: 280px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; background: #fafbfc; }
tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: #fafbfc; }
.thumb { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; background: var(--bg); display: block; }
.thumb.sq { border-radius: 8px; object-fit: contain; }
.cell-main { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bg); }
.badge.green { background: #e3f4ea; color: var(--green); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.red { background: var(--red-soft); color: var(--red); }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* Модальное окно и формы */
.modal { position: fixed; inset: 0; background: rgba(23,25,28,.45); display: grid; place-items: start center; padding: 40px 16px; overflow-y: auto; z-index: 20; }
.modal-card { background: var(--card); border-radius: 20px; width: min(760px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 22px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; justify-content: space-between; margin-top: 22px; flex-wrap: wrap; }
.form-actions .right { display: flex; gap: 10px; margin-left: auto; }
.image-field { display: flex; gap: 12px; align-items: center; }
.image-field img { width: 72px; height: 72px; border-radius: 12px; object-fit: cover; background: var(--bg); border: 1px solid var(--line); }
.image-field .img-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.section { margin-top: 26px; }
.section h4 { margin: 0 0 10px; font-size: 15px; display: flex; justify-content: space-between; align-items: center; }
.sub-row { display: grid; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.sub-row:last-child { border-bottom: none; }
.qa { display: grid; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; }
.vote-bar { height: 8px; border-radius: 99px; background: var(--bg); overflow: hidden; margin-top: 4px; }
.vote-bar div { height: 100%; background: var(--blue); }
.note { background: var(--blue-soft); color: #1a3a99; padding: 12px 14px; border-radius: 12px; font-size: 13px; line-height: 1.45; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--dark); color: #fff; padding: 12px 20px; border-radius: 999px; z-index: 30; font-weight: 600; }
.toast.err { background: var(--red); }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 30% 0 0; z-index: 15; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-block; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
}
