/* ═══════════ base.css — общий визуальный язык «Стройки» ═══════════
   Крафт-бумага, синий чертёж, тушь. Те же цвета, что в концепции и презентациях сессии.
   Модули добавляют свои стили в css/<модуль>.css и используют только эти токены. */
:root {
  --paper: #F0EADC;
  --paper-2: #F7F3EA;
  --card: #FFFDF8;
  --ink: #12100C;
  --ink-2: #3A352D;
  --muted: #6E675B;
  --line: #D8CFBD;
  --line-2: #E7E0D0;
  --blue: #2438C8;
  --blue-dk: #1B2A9E;
  --blue-soft: #E4E7F8;
  --green: #2E7D4F;
  --amber: #D08A1E;
  --red: #C0392B;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(18,16,12,.06), 0 6px 18px rgba(18,16,12,.06);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  --display: 'Oswald', 'Arial Narrow', Arial, sans-serif;
  --side-w: 232px;
  --gutter: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--paper); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 600; letter-spacing: .01em; margin: 0; line-height: 1.15; }
h1 { font-size: 30px; text-transform: uppercase; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
p { margin: 0 0 .6em; }
small { color: var(--muted); }
pre { white-space: pre-wrap; font-size: 12px; }
.ic { flex: none; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.loading { padding: 60px 20px; text-align: center; color: var(--muted); }

/* ───────── Каркас ───────── */
#app { min-height: 100vh; }
.side { position: fixed; inset: 0 auto 0 0; width: var(--side-w); background: var(--paper-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 12px; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-size: 22px; font-weight: 700; text-transform: uppercase; color: var(--ink); padding: 4px 8px 18px; letter-spacing: .03em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; border-radius: 6px; background: var(--blue); position: relative; flex: none; }
.brand-mark::after { content: ''; position: absolute; left: 6px; right: 6px; bottom: 6px; height: 9px; border: 2.4px solid var(--paper); border-bottom: none; }
.brand.big { font-size: 34px; justify-content: center; padding-bottom: 8px; }
.brand.big .brand-mark { width: 38px; height: 38px; }
.side-links { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.side-link { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--ink-2); font-weight: 500; }
.side-link:hover { background: var(--line-2); text-decoration: none; }
.side-link.active { background: var(--ink); color: var(--paper); }
.side-foot { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.me-box { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.me-select { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--card); border-radius: 6px; padding: 5px 6px; font: inherit; font-size: 13px; }
.linklike { background: none; border: none; color: var(--muted); font: inherit; font-size: 13px; text-align: left; padding: 2px 4px; cursor: pointer; }
.linklike:hover { color: var(--ink); }
.view { margin-left: var(--side-w); padding: 28px 32px 60px; max-width: 1400px; min-height: 100vh; }
.bottom { display: none; }

@media (max-width: 900px) {
  .side { display: none; }
  .view { margin-left: 0; padding: 18px var(--gutter) 92px; }
  .bottom { display: flex; position: fixed; left: 0; right: 0; bottom: 0; background: var(--paper-2); border-top: 1px solid var(--line); z-index: 30; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bottom-link { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 4px 2px; background: none; border: none; font-family: var(--font); cursor: pointer; }
  .bottom-link.active { color: var(--blue); }
  .bottom-link:hover { text-decoration: none; }
  h1 { font-size: 24px; }
}
.more-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.more-item { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 6px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); background: var(--card); font-size: 13px; text-align: center; }
.more-item:hover { text-decoration: none; border-color: var(--blue); }

/* ───────── Заголовок страницы ───────── */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; padding-bottom: 14px; border-bottom: 2px solid var(--ink); }
.page-sub { color: var(--muted); margin: 6px 0 0; max-width: 720px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.section-title { font-family: var(--display); font-size: 13px; text-transform: uppercase; letter-spacing: .12em; color: var(--blue); margin: 26px 0 10px; font-weight: 600; }
.kicker { font-size: 11px; text-transform: uppercase; letter-spacing: .14em; color: var(--blue); font-weight: 700; }

/* ───────── Кнопки ───────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: 500 14px/1 var(--font); padding: 9px 14px; border-radius: 8px; border: 1px solid var(--ink); background: var(--card); color: var(--ink); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--paper-2); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dk); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--line-2); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger-ghost { border-color: transparent; background: transparent; color: var(--red); }
.btn-small, .btn.small { padding: 6px 10px; font-size: 13px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 7px; border: 1px solid var(--line); background: var(--card); color: var(--ink-2); cursor: pointer; flex: none; }
.icon-btn:hover { border-color: var(--ink); color: var(--ink); }
.icon-btn.btn-ghost { border-color: transparent; background: transparent; }
.icon-btn.btn-ghost:hover { background: var(--line-2); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ───────── Карточки, чипы, бейджи ───────── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card-ink { background: var(--card); border: 1.5px solid var(--ink); border-radius: var(--radius); padding: 16px; }
.card h3 { margin-bottom: 6px; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.chip { --chip: var(--ink-2); display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; color: var(--chip); background: color-mix(in srgb, var(--chip) 11%, transparent); border: 1px solid color-mix(in srgb, var(--chip) 30%, transparent); white-space: nowrap; }
.badge { display: inline-block; padding: 2px 7px; border-radius: 5px; font-size: 11px; font-weight: 700; color: #fff; background: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-family: var(--display); font-size: 30px; font-weight: 600; color: var(--blue-dk); line-height: 1; }
.stat span { font-size: 13px; color: var(--muted); }
.progress { height: 6px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--blue); border-radius: 99px; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); border: 1.5px dashed var(--line); border-radius: var(--radius); background: var(--paper-2); }
.empty h2 { color: var(--ink); margin-bottom: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }

/* ───────── Вкладки ───────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { background: none; border: none; border-bottom: 2.5px solid transparent; padding: 9px 12px; font: 500 14px var(--font); color: var(--muted); cursor: pointer; white-space: nowrap; margin-bottom: -1px; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--blue); }
.tab-count { display: inline-block; margin-left: 6px; font-size: 11px; background: var(--line-2); border-radius: 99px; padding: 1px 6px; color: var(--ink-2); }

/* ───────── Формы ───────── */
input, select, textarea { font: inherit; color: var(--ink); }
.form-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; flex: 1 1 100%; min-width: 0; }
.field.half { flex: 1 1 calc(50% - 6px); }
@media (max-width: 560px) { .field.half { flex-basis: 100%; } }
.field-label { font-size: 12px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .05em; }
.field input, .field select, .field textarea { border: 1px solid var(--line); background: var(--card); border-radius: 7px; padding: 9px 10px; width: 100%; }
.field textarea { resize: vertical; }
.field input[type=color] { padding: 2px; height: 38px; }
.field-check { flex-direction: row; align-items: center; gap: 8px; }
.field-check input { width: 18px; height: 18px; }
.form-section { flex: 1 1 100%; font-family: var(--display); font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--blue); border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; }
.multi { display: flex; flex-wrap: wrap; gap: 6px; max-height: 210px; overflow-y: auto; }
.multi-opt { border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 4px 10px; font: 13px var(--font); cursor: pointer; color: var(--ink-2); }
.multi-opt.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.multi-search { border: 1px solid var(--line); border-radius: 7px; padding: 6px 9px; }
.search-wrap { position: relative; display: flex; align-items: center; }
.search-wrap .ic { position: absolute; left: 10px; color: var(--muted); }
.search { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 8px 10px 8px 32px; min-width: 220px; }
select.inline, input.inline { border: 1px solid var(--line); background: var(--card); border-radius: 7px; padding: 7px 9px; }

/* ───────── Модалки ───────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(18,16,12,.42); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 12px; z-index: 1000; overflow-y: auto; }
.modal { background: var(--paper-2); border-radius: 14px; width: 100%; max-width: 560px; box-shadow: 0 20px 60px rgba(0,0,0,.25); border: 1.5px solid var(--ink); }
.modal-wide { max-width: 880px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px 10px; }
.modal-body { padding: 4px 18px 16px; }
.modal-foot { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); align-items: center; flex-wrap: wrap; }
@media (max-width: 560px) { .modal-backdrop { padding: 0; align-items: stretch; } .modal { border-radius: 0; min-height: 100vh; border: none; } }

/* ───────── Тосты ───────── */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 2000; }
.toast { background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: 8px; font-size: 14px; box-shadow: var(--shadow); transition: opacity .4s, transform .4s; }
.toast-error { background: var(--red); color: #fff; }
.toast-ok { background: var(--green); color: #fff; }
.toast.out { opacity: 0; transform: translateY(6px); }
@media (max-width: 900px) { #toasts { bottom: 84px; left: 16px; } }

/* ───────── Редактируемые таблицы ───────── */
.etable-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.etable { width: 100%; border-collapse: collapse; font-size: 14px; }
.etable th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 9px 8px; border-bottom: 1px solid var(--line); background: var(--paper-2); white-space: nowrap; }
.etable td { border-bottom: 1px solid var(--line-2); padding: 2px 4px; vertical-align: top; }
.etable tr:last-child td { border-bottom: none; }
.etable .cell { width: 100%; border: 1px solid transparent; background: transparent; padding: 6px 5px; border-radius: 5px; font-size: 14px; min-width: 70px; resize: none; overflow: hidden; }
.etable .cell:hover { border-color: var(--line); }
.etable .cell:focus { border-color: var(--blue); background: #fff; outline: none; }
.etable select.cell { cursor: pointer; }
.etable .cell-check { width: 18px; height: 18px; margin: 8px; }
.etable .col-act { width: 1%; white-space: nowrap; text-align: right; }
.etable-empty { padding: 18px; text-align: center; color: var(--muted); font-size: 14px; }
.etable-add { padding: 6px; border-top: 1px solid var(--line-2); }
@media (max-width: 700px) {
  .etable thead { display: none; }
  .etable, .etable tbody, .etable tr, .etable td { display: block; width: 100%; }
  .etable tr { border-bottom: 1px solid var(--line); padding: 6px 4px; }
  .etable td { border: none; display: flex; align-items: center; gap: 8px; padding: 1px 4px; }
  .etable td::before { content: attr(data-label); flex: 0 0 34%; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
  .etable td.col-act::before { content: ''; }
  .etable .col-act { text-align: right; justify-content: flex-end; }
}

/* ───────── Списки ───────── */
.list { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line-2); cursor: pointer; color: var(--ink); }
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--paper-2); text-decoration: none; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 600; }
.list-item .li-sub { font-size: 13px; color: var(--muted); }

/* ───────── Вход ───────── */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--paper) repeating-linear-gradient(0deg, transparent 0 39px, rgba(36,56,200,.06) 39px 40px), repeating-linear-gradient(90deg, transparent 0 39px, rgba(36,56,200,.06) 39px 40px); }
.login-card { background: var(--paper-2); border: 1.5px solid var(--ink); border-radius: 16px; padding: 32px 28px; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.login-card input { border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-size: 16px; background: var(--card); }
.login-sub { color: var(--muted); text-align: center; font-size: 14px; }
.login-err { color: var(--red); min-height: 1.2em; font-size: 14px; text-align: center; }

.more-foot { margin-top: 14px; display: flex; justify-content: center; }
