/* Оформление: деловое и плотное. Инженер сидит в этом окне часами, поэтому
   никаких крупных отступов и декоративных карточек — данные, а не воздух. */

:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #16181d;
  --muted: #6b7280;
  --line: #dfe3e8;
  --accent: #1f5fbf;
  --error: #c02626;
  --warn: #b4740a;
  --ok: #1a7f37;
  --radius: 6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.45 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button, input, select, textarea { font: inherit; color: inherit; }

button {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 12px;
  cursor: pointer;
}
button:hover { border-color: #b9c0c9; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #1a4f9f; }
button.danger { color: var(--error); }
button:disabled { opacity: .5; cursor: default; }

input, select, textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 8px;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #cfe0fb; border-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }

a { color: var(--accent); }

/* ── каркас ───────────────────────────────────────────────────────────────── */

header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
header .logo { font-weight: 600; letter-spacing: .2px; }
header .spacer { flex: 1; }
header nav button { border: none; background: none; padding: 6px 10px; color: var(--muted); }
header nav button.active { color: var(--ink); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); }

main { padding: 18px; max-width: 1400px; margin: 0 auto; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.panel > h2 { margin: 0 0 12px; font-size: 15px; }
.panel > h3 { margin: 18px 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }

.grid { display: grid; gap: 10px 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
label { display: block; }
label span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line); font-size: 13px; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
td input, td select { padding: 4px 6px; }

/* ── список объектов ──────────────────────────────────────────────────────── */

.objects { display: grid; gap: 8px; }
.object-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; cursor: pointer;
}
.object-card:hover { border-color: var(--accent); }
.object-card .title { font-weight: 600; }
.object-card .spacer { flex: 1; }

.badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line); }
.badge.ok { color: var(--ok); border-color: #b7e0c1; background: #f2fbf4; }
.badge.error { color: var(--error); border-color: #f0c2c2; background: #fdf3f3; }
.badge.warn { color: var(--warn); border-color: #f0dfb8; background: #fdf9f0; }

/* ── вкладки карточки ─────────────────────────────────────────────────────── */

.tabs { display: flex; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border-radius: 99px; padding: 5px 14px; }
.tabs button.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.issues { display: grid; gap: 6px; }
.issue { display: flex; gap: 8px; padding: 7px 10px; border-radius: var(--radius); background: #fbfbfc; border: 1px solid var(--line); }
.issue.ERROR { border-color: #f0c2c2; background: #fdf5f5; }
.issue.WARN { border-color: #f0e2c0; background: #fdfaf3; }
.issue .level { font-size: 11px; font-weight: 600; letter-spacing: .3px; }
.issue.ERROR .level { color: var(--error); }
.issue.WARN .level { color: var(--warn); }
.issue.INFO .level, .issue .level { color: var(--muted); }
.issue .hint { color: var(--muted); font-size: 12px; }

/* ── разметчик ────────────────────────────────────────────────────────────── */

.planner { display: grid; grid-template-columns: minmax(420px, 1fr) minmax(360px, 460px); gap: 16px; }
@media (max-width: 1100px) { .planner { grid-template-columns: 1fr; } }

.canvas-wrap {
  position: relative; background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  /* Высота задаётся стилем, а не атрибутом: иначе canvas, растянутый по ширине,
     раздувает собственный bounding box и с каждым перерисовыванием растёт. */
  height: min(64vh, 660px); min-height: 380px;
}
canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }

.abris-wrap { position: relative; overflow: auto; max-height: 520px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.abris-wrap img { display: block; width: 100%; }
.abris-wrap .mark { position: absolute; border: 1.5px solid rgba(192, 38, 38, .8); border-radius: 2px; }
.abris-wrap .mark.sure { border-color: rgba(26, 127, 55, .75); }
.abris-wrap .mark span {
  position: absolute; top: -16px; left: 0; font-size: 10px; background: rgba(0,0,0,.75);
  color: #fff; padding: 0 3px; border-radius: 2px; white-space: nowrap;
}

.rooms-table td:first-child { width: 60px; }
.rooms-table input { text-align: right; }
.rooms-table input.name { text-align: left; }
.rooms-table tr.selected td { background: #eef4fe; }
.rooms-table tr.flagged td:first-child { border-left: 3px solid var(--warn); }

.files { display: grid; gap: 6px; }
.file-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius); }

.previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.previews figure { margin: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.previews img { width: 100%; display: block; }
.previews figcaption { font-size: 12px; padding: 6px 8px; color: var(--muted); border-top: 1px solid var(--line); }

.login { max-width: 340px; margin: 12vh auto; }
.toast {
  position: fixed; right: 18px; bottom: 18px; background: var(--ink); color: #fff;
  padding: 10px 14px; border-radius: var(--radius); font-size: 13px; opacity: 0;
  transition: opacity .2s; pointer-events: none; max-width: 420px;
}
.toast.show { opacity: 1; }
.hidden { display: none !important; }
.spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
