/* Санжыра: лист топографической карты. Светлый лист — работа днём в офисе за монитором. */
:root {
  --sheet: #e8ece9;
  --paper: #f4f6f5;
  --white: #ffffff;
  --ink: #1c1c1a;
  --ink-2: #45453f;
  --muted: #5d5d56;
  --rule: #c9cfca;
  --hydro: #2c6aa0;
  --forest: #5e8a4e;
  --contour: #8f5226;
  --contour-wash: #efe3d8;
  --error: #a3271f;
  --bar-h: 56px;
  font-family: Onest, system-ui, sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: var(--sheet);
  font-variant-numeric: tabular-nums;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--sheet); }
::selection { background: var(--contour); color: var(--white); }
:focus-visible { outline: 2px solid var(--contour); outline-offset: 2px; }
* { scrollbar-width: thin; scrollbar-color: var(--rule) transparent; }
button { font: inherit; cursor: pointer; }
.muted { color: var(--muted); }
.error { color: var(--error); }
.center { text-align: center; margin-top: 30vh; }

.app { height: 100vh; display: grid; grid-template-rows: var(--bar-h) 1fr; }

/* Верхняя полоса — чёрная печать. */
.bar { display: flex; align-items: center; gap: 28px; padding: 0 20px; background: var(--ink); color: #eceeea; min-width: 0; }
.brand { font-weight: 700; font-size: 18px; letter-spacing: .01em; }
.layers { display: flex; gap: 24px; overflow-x: auto; min-width: 0; height: 100%; }
.domain { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.domain-name { font-size: 12px; color: #b9bdb6; margin-right: 6px; }
.tab { color: #dfe2dd; text-decoration: none; padding: 0 10px; height: 100%; display: flex; align-items: center; border-bottom: 3px solid transparent; font-weight: 500; }
.tab:hover { color: var(--white); }
.tab.on { color: var(--white); border-bottom-color: var(--contour); }
.who { margin-left: auto; display: flex; align-items: center; gap: 16px; white-space: nowrap; }
.name { display: flex; flex-direction: column; font-size: 14px; line-height: 1.2; }
.name small { color: #b9bdb6; font-size: 12px; }
.quiet { background: none; border: 1px solid #5a5a55; color: #dfe2dd; border-radius: 6px; padding: 5px 12px; font-size: 13px; }
.quiet:hover { border-color: #dfe2dd; }
.langs { display: inline-flex; border: 1px solid #5a5a55; border-radius: 6px; overflow: hidden; }
.lang { background: none; border: 0; color: #b9bdb6; padding: 4px 9px; font-size: 12px; font-weight: 600; letter-spacing: .04em; }
.lang.on { background: #3a3a35; color: var(--white); }

/* Лист и сторона легенды. */
.layer { display: grid; grid-template-columns: minmax(0, 2fr) minmax(380px, 1fr); min-height: 0; }
.sheet { display: grid; grid-template-rows: auto 1fr; padding: 16px 18px 26px 40px; min-height: 0; }
.sheet-head { display: flex; gap: 22px; align-items: baseline; padding: 0 0 8px 2px; font-size: 13px; color: var(--muted); }
.nomenclature { color: var(--ink); font-weight: 600; letter-spacing: .22em; font-size: 13px; }
.sheet-map { position: relative; border: 2px solid var(--ink); outline: 1px solid var(--ink); outline-offset: 4px; min-height: 0; }
.map-canvas { position: absolute; inset: 0; }
.ticks { position: absolute; inset: 0; pointer-events: none; }
.tick { position: absolute; font-size: 11.5px; color: var(--ink-2); white-space: nowrap; }
.tick.lon { bottom: -24px; transform: translateX(-50%); }
.tick.lat { left: -36px; transform: translateY(-50%) rotate(-90deg); transform-origin: center; }
.maplibregl-ctrl-attrib { font-size: 11px; }

.side { background: var(--paper); border-left: 2px solid var(--ink); display: grid; grid-template-rows: minmax(0, 1.15fr) minmax(0, 1fr); min-height: 0; }
.legend { display: grid; grid-template-rows: auto auto 1fr; padding: 18px 20px 0; min-height: 0; border-bottom: 1px solid var(--ink); }
.legend h1 { margin: 0 0 12px; font-size: 24px; font-weight: 700; display: flex; align-items: baseline; gap: 12px; }
.legend h1 small { font-size: 13px; font-weight: 500; color: var(--muted); }
.search { width: 100%; font: inherit; font-size: 14px; padding: 8px 12px; border: 1px solid var(--rule); border-radius: 6px; background: var(--white); color: var(--ink); margin-bottom: 10px; }
.search::placeholder { color: var(--muted); }
.search:focus { border-color: var(--ink); outline: none; }
.legend-scroll { overflow: auto; min-height: 0; padding-bottom: 12px; }
.legend-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.legend-table th { position: sticky; top: 0; background: var(--paper); text-align: left; font-weight: 500; font-size: 12.5px; color: var(--muted); padding: 8px 8px; border-bottom: 1px solid var(--ink); }
.legend-table td { padding: 8px 8px; border-bottom: 1px solid var(--rule); }
.legend-table tr { cursor: pointer; }
.legend-table tr:hover td, .legend-table tr.lit td { background: var(--contour-wash); }
.legend-table tr.sel td { background: var(--contour-wash); box-shadow: inset 0 -2px var(--contour); font-weight: 600; }
.num { text-align: right; }
th.num .sort { text-align: right; }
.sort { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; font-weight: inherit; }
.sort[aria-pressed="true"] { color: var(--ink); text-decoration: underline; text-decoration-color: var(--contour); text-underline-offset: 4px; }
.note { padding: 18px 2px; font-size: 14px; line-height: 1.5; max-width: 46ch; }
.note b { display: block; font-size: 15px; margin-bottom: 4px; }
.note p { margin: 0; color: var(--muted); }

.card { padding: 18px 20px; overflow: auto; min-height: 0; }
.object h2 { margin: 0 0 4px; font-size: 20px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 16px; font-size: 13px; color: var(--muted); }
.fields { display: grid; grid-template-columns: minmax(140px, 1fr) minmax(0, 1.2fr); margin: 0; font-size: 14px; }
.fields dt { color: var(--muted); padding: 7px 12px 7px 0; border-bottom: 1px solid var(--rule); }
.fields dd { margin: 0; padding: 7px 0; border-bottom: 1px solid var(--rule); overflow-wrap: anywhere; }
.fields dd.num { text-align: left; }
.unit { color: var(--muted); }

.message { max-width: 52ch; margin: 18vh auto 0; padding: 0 20px; }
.message h2 { font-size: 22px; margin: 0 0 8px; }
.message p { color: var(--muted); line-height: 1.5; }

/* Вход. */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; padding: 28px; background: var(--paper); border: 2px solid var(--ink); outline: 1px solid var(--ink); outline-offset: 4px; }
.login-head { display: flex; align-items: center; justify-content: space-between; }
.login h1 { margin: 0; font-size: 24px; }
.login p { margin: 0; }
.login label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login input { font: inherit; font-size: 15px; padding: 9px 12px; border: 1px solid var(--rule); border-radius: 6px; background: var(--white); color: var(--ink); }
.login input:focus { border-color: var(--ink); outline: none; }
.login .langs { border-color: var(--rule); }
.login .lang { color: var(--muted); }
.login .lang.on { background: var(--ink); color: var(--white); }
.primary { background: var(--ink); color: var(--white); border: 0; border-radius: 6px; padding: 10px 16px; font-weight: 600; }
.primary:hover { background: var(--contour); }
.primary:disabled { opacity: .55; cursor: progress; }

/* Уже 1024: лист наверх, легенда и карточка под ним. */
@media (max-width: 1024px) {
  .app { height: auto; min-height: 100vh; }
  .layer { grid-template-columns: 1fr; }
  .sheet { height: 62vh; padding: 12px 14px 26px 36px; }
  .side { border-left: 0; border-top: 2px solid var(--ink); grid-template-rows: auto auto; }
  .legend-scroll { max-height: 50vh; }
  .bar { gap: 16px; }
  .name { display: none; }
}

/* Правка, история, очередь. */
.legend-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.ghost { background: none; border: 1px solid var(--rule); color: var(--ink); border-radius: 6px; padding: 6px 12px; font-size: 13px; }
.ghost:hover { border-color: var(--ink); }
.ghost.on { border-color: var(--contour); color: var(--contour); background: var(--contour-wash); }
.ghost.small { padding: 3px 9px; font-size: 12px; }
.danger { background: none; border: 1px solid var(--error); color: var(--error); border-radius: 6px; padding: 8px 14px; font-weight: 600; }
.danger:disabled, .primary:disabled { opacity: .5; cursor: not-allowed; }
.badge { margin-left: 8px; font-size: 11.5px; font-weight: 600; color: var(--contour); border: 1px solid var(--contour); border-radius: 4px; padding: 1px 6px; vertical-align: 1px; }
.hint { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.notice { margin: 0 0 8px; font-size: 13px; color: var(--ink); background: var(--contour-wash); border-radius: 6px; padding: 6px 10px; }
.card-actions { display: flex; gap: 8px; margin-bottom: 12px; }
.edit h2 { margin: 0 0 12px; font-size: 18px; }
.edit-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.edit-field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.edit-field input, .edit-field select, .edit-field textarea, .geometry input, .comment {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--white); border: 1px solid var(--rule); border-radius: 6px; padding: 7px 10px; min-width: 0; }
.edit-field textarea { resize: vertical; }
.edit-field input:focus, .edit-field select:focus, .edit-field textarea:focus, .geometry input:focus, .comment:focus { border-color: var(--ink); outline: none; }
.edit-field.invalid input, .edit-field.invalid select, .edit-field.invalid textarea { border-color: var(--error); }
.field-error { color: var(--error); font-size: 12px; }
.edit > .edit-field { margin-top: 12px; }
.geometry { margin: 14px 0 0; padding: 10px 12px 12px; border: 1px solid var(--rule); border-radius: 6px; display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px 12px; align-items: end; }
.geometry legend { font-size: 12.5px; color: var(--muted); padding: 0 4px; }
.geometry label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 14px; }
.check input { accent-color: var(--contour); width: 16px; height: 16px; }
.actions { display: flex; gap: 10px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.history-block { margin-top: 20px; }
.history-block h3 { font-size: 15px; margin: 0 0 8px; }
.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.entry { border-top: 1px solid var(--rule); padding-top: 8px; font-size: 13.5px; }
.entry-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.status { font-size: 12px; font-weight: 600; }
.st-proposed .status { color: var(--contour); }
.st-approved .status { color: var(--forest); }
.st-rejected .status { color: var(--error); }
.st-withdrawn .status { color: var(--muted); }
.changes { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(0, 1.4fr); margin: 6px 0; }
.changes dt { color: var(--muted); padding: 2px 8px 2px 0; }
.changes dd { margin: 0; padding: 2px 0; overflow-wrap: anywhere; }
.reason { margin: 4px 0; padding-left: 10px; border-left: 2px solid var(--rule); color: var(--ink-2); overflow-wrap: anywhere; }
.decision { margin: 4px 0; color: var(--muted); }
.moderation { max-width: 980px; margin: 0 auto; padding: 24px 20px 48px; overflow: auto; }
.moderation h1 { font-size: 24px; margin: 0 0 16px; }
.queue { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.queue-card { background: var(--paper); border: 1px solid var(--rule); border-radius: 8px; padding: 16px 18px; }
.queue-card p { margin: 4px 0; font-size: 13.5px; }
.diff { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 14px; background: var(--white); }
.diff th { text-align: left; font-weight: 500; font-size: 12.5px; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--ink); }
.diff td { padding: 6px 8px; border-bottom: 1px solid var(--rule); overflow-wrap: anywhere; }
.diff td.was { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--muted); }
.diff td.now { color: var(--contour); font-weight: 600; }
.comment { flex: 1; min-width: 220px; }
@media (max-width: 1024px) { .edit-fields { grid-template-columns: 1fr; } .geometry { grid-template-columns: 1fr 1fr; } }

/* Подключение агентов. */
.connect-guide p { max-width: 72ch; line-height: 1.55; }
.connect-guide h2 { font-size: 17px; color: var(--ink); margin: 26px 0 8px; }
.cmd { background: var(--white); border: 1px solid var(--rule); border-left: 3px solid var(--ink); border-radius: 0 6px 6px 0; padding: 10px 14px; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13.5px; overflow-x: auto; white-space: pre; user-select: all; }
