/* ============================================================
   pcad — оснастка вокруг чертежа.
   Тёмный корпус инструмента, светлый вьюпорт как лист бумаги,
   сигнальный оранжевый только на выделении и главном действии.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@400;500;600&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
  --ink: #14171b;
  --steel: #1d222a;
  --steel-2: #242b34;
  --line: #2f3742;
  --line-soft: #262d36;
  --paper: #e7e5de;
  --paper-line: #c9c6bb;
  --text: #dce1e7;
  --muted: #7e8896;
  --dim: #5b6472;
  --signal: #f2600c;
  --alarm: #e5484d;
  --ok: #4fa85c;

  --f-label: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --f-body: 'Inter', system-ui, -apple-system, sans-serif;
  --f-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, monospace;

  --r: 3px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--text);
  font-family: var(--f-body);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--signal); }

/* --- типографские роли --- */

.eyebrow {
  font-family: var(--f-label);
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: 12px;
  font-weight: 600;
  color: var(--dim);
}

.num { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }

/* --- элементы форм --- */

.field { display: flex; flex-direction: column; gap: 5px; }
/* display у .field перебивает браузерный [hidden] — возвращаем его силу. */
.field[hidden] { display: none; }

.field > label {
  font-family: var(--f-label);
  text-transform: uppercase;
  letter-spacing: .1em;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

input[type='text'], input[type='email'], input[type='password'], input[type='number'], select {
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 8px 10px;
  width: 100%;
  outline: none;
  transition: border-color .12s;
}

input[type='number'] { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }

input:focus-visible, select:focus-visible, button:focus-visible {
  border-color: var(--signal);
  outline: 2px solid rgba(242, 96, 12, .35);
  outline-offset: 1px;
}

input:disabled, select:disabled { opacity: .45; }

.btn {
  background: var(--steel-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 500;
  transition: background .12s, border-color .12s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: #2c343f; border-color: #3d4653; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-primary {
  background: var(--signal);
  border-color: var(--signal);
  color: #16110c;
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) { background: #ff7020; border-color: #ff7020; }

.btn-ghost { background: transparent; }
.btn-danger:hover:not(:disabled) { border-color: var(--alarm); color: var(--alarm); }
.btn-sm { padding: 5px 9px; font-size: 13px; }

.notice {
  border-left: 3px solid var(--alarm);
  background: rgba(229, 72, 77, .1);
  padding: 9px 12px;
  border-radius: 0 var(--r) var(--r) 0;
  font-size: 13px;
}
.notice:empty { display: none; }
.notice.ok { border-color: var(--ok); background: rgba(79, 168, 92, .1); }

/* ============================================================
   Вход и список проектов
   ============================================================ */

.gate {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  /* миллиметровка на фоне */
  background-image:
    linear-gradient(rgba(255, 255, 255, .022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .022) 1px, transparent 1px);
  background-size: 32px 32px;
}

.gate-card {
  width: 100%;
  max-width: 380px;
  background: var(--steel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 28px;
}

.brand { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.brand h1 {
  font-family: var(--f-label);
  font-size: 34px;
  font-weight: 600;
  letter-spacing: .04em;
  margin: 0;
  text-transform: uppercase;
}
.brand .tick { color: var(--signal); font-family: var(--f-mono); font-size: 13px; }
.gate-sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; line-height: 1.5; }

.gate-card form { display: flex; flex-direction: column; gap: 14px; }
.tabs { display: flex; gap: 2px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.tabs button {
  background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 8px 12px; cursor: pointer; color: var(--muted);
  font-family: var(--f-label); text-transform: uppercase; letter-spacing: .1em;
  font-size: 13px; font-weight: 600;
}
.tabs button[aria-selected='true'] { color: var(--text); border-bottom-color: var(--signal); }

/* --- список проектов --- */

.shell { max-width: 900px; margin: 0 auto; padding: 32px 24px 80px; }
.shell-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.shell-head .who { color: var(--muted); font-size: 13px; }
.badge-admin { display: inline-block; font-size: 11px; font-weight: 600; background: var(--signal); color: #fff; border-radius: 3px; padding: 1px 5px; vertical-align: middle; margin-left: 4px; }
.gate-divider { display: flex; align-items: center; gap: 10px; margin: 20px 0 16px; color: var(--muted); font-size: 13px; }
.gate-divider::before, .gate-divider::after { content: ''; flex: 1; border-top: 1px solid var(--line); }

.proj-list { display: flex; flex-direction: column; gap: 1px; background: var(--line-soft); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }

.proj {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 18px;
  align-items: center;
  background: var(--steel);
  padding: 14px 16px;
  transition: background .12s;
}
.proj:hover { background: var(--steel-2); }
.proj-name { font-weight: 500; }
.proj-name a { color: inherit; text-decoration: none; }
.proj-name a:hover { color: var(--signal); }
.proj-meta { color: var(--dim); font-size: 12px; margin-top: 3px; }
.proj-dims { font-family: var(--f-mono); font-size: 13px; color: var(--muted); }

.empty { border: 1px dashed var(--line); border-radius: 4px; padding: 40px 24px; text-align: center; color: var(--muted); }
.empty p { margin: 0 0 16px; }

/* --- модальное окно --- */

.modal-back {
  position: fixed; inset: 0; background: rgba(10, 12, 15, .78);
  display: grid; place-items: center; padding: 24px; z-index: 50;
}
.modal {
  background: var(--steel); border: 1px solid var(--line); border-radius: 4px;
  width: 100%; max-width: 460px; padding: 24px;
  /* Подложка — position: fixed, поэтому без своей прокрутки высокое окно
     (диалог ящиков — десяток полей) просто уезжает за край экрана. */
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
}
.modal.wide { max-width: min(1040px, 96vw); }
.modal h2 { font-family: var(--f-label); text-transform: uppercase; letter-spacing: .08em; font-size: 20px; margin: 0 0 4px; }
.modal .hint { color: var(--muted); font-size: 13px; margin: 0 0 20px; line-height: 1.5; }
.modal form { display: flex; flex-direction: column; gap: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.triple { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pair { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (max-width: 520px) {
  .pair, .triple { grid-template-columns: 1fr; }
}

.panel-editor-body { display: flex; gap: 20px; align-items: flex-start; }
.panel-shape-canvas {
  background: var(--ink); border: 1px solid var(--line); border-radius: 4px;
  touch-action: none; cursor: crosshair; flex: none;
}
.panel-editor-side { flex: 1; min-width: 260px; max-height: 70vh; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }

.edge-brush { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.edge-brush .mini { font-family: var(--f-label); text-transform: uppercase; letter-spacing: .08em; font-size: 10px; color: var(--muted); }
.brush-btn { min-width: 40px; }
.brush-btn.active { background: var(--signal); border-color: var(--signal); color: #16110c; }
