/* Палитра — та же, что orin-console/fleet-monitor, для визуальной
   консистентности между инструментами (см. project_agx_orin_llm_stack). */
:root {
  --bg: #0f1115;
  --panel: #171a21;
  --border: #262b36;
  --text: #e4e6eb;
  --muted: #8b93a5;
  --accent: #4f8cff;
  --ok: #2ecc71;
  --warn: #f1c40f;
  --bad: #e74c3c;
  --unknown: #5c6270;

  /* Spacing scale — every margin/gap/padding in the app should resolve to
     one of these instead of a one-off pixel value. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  /* Form control widths — three sizes cover every text input in the app. */
  --w-xs: 70px;
  --w-sm: 140px;
  --w-md: 200px;
  --w-lg: 240px;

  --radius: 8px;
  --radius-sm: 5px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2) var(--space-5); padding: var(--space-3) var(--space-5);
  background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand { display: flex; flex-direction: column; line-height: 1.15; white-space: nowrap; }
.brand-main { font-weight: 700; font-size: 1.05em; }
.brand-sub { font-size: 0.62em; letter-spacing: 0.06em; text-transform: lowercase; color: var(--muted); }
.topbar nav { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); flex: 1; }
.topbar nav a {
  display: flex; align-items: center; color: var(--muted); text-decoration: none; cursor: pointer;
  font-size: 0.92em; padding: 0 var(--space-1); border-bottom: 2px solid transparent;
}
.topbar nav a.active, .topbar nav a:hover { color: var(--text); }
.topbar nav a.active { border-bottom-color: var(--accent); font-weight: 500; }

main { padding: var(--space-5) var(--space-5) var(--space-6); max-width: 1200px; margin: 0 auto; }
h1 { font-size: 1.4em; margin: 0; font-weight: 600; display: flex; align-items: center; }
h2 { font-size: 1.05em; color: var(--muted); font-weight: 600; margin: 0; }
.muted { color: var(--muted); font-size: 0.9em; }
.muted.error { color: var(--bad); }
.muted.warn { color: var(--warn); }
a { color: var(--accent); }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-4); margin-bottom: var(--space-4); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-3); }

table { width: 100%; border-collapse: collapse; }
th, td { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; font-size: 0.92em; }
th { color: var(--muted); font-weight: 500; font-size: 0.8em; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; flex: none; }
.dot-ok { background: var(--ok); }
.dot-off { background: var(--unknown); }
.dot-bad { background: var(--bad); }

button, .btn { background: var(--accent); color: #fff; border: none; border-radius: var(--radius-sm); padding: 6px 14px; font-size: 0.88em; font-weight: 500; cursor: pointer; line-height: 1.4; }
button:hover, .btn:hover { filter: brightness(1.08); }
button.secondary { background: transparent; border: 1px solid var(--border); color: var(--text); }
button.secondary:hover { border-color: var(--muted); filter: none; }
button.danger { background: transparent; border: 1px solid rgba(231, 76, 60, 0.5); color: var(--bad); }
button.danger:hover { background: var(--bad); border-color: var(--bad); color: #fff; filter: none; }
button.compact { padding: 3px 10px; font-size: 0.82em; }
button:disabled, button:disabled:hover { opacity: 0.45; cursor: default; filter: none; }

input, select, textarea { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 10px; font-size: 0.92em; font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input::placeholder { color: var(--muted); }

/* Form control width scale — replaces one-off inline widths on inputs. */
.w-xs { width: var(--w-xs); }
.w-sm { width: var(--w-sm); }
.w-md { width: var(--w-md); }
.w-lg { width: var(--w-lg); }
.w-full { width: 100%; }
.flex-1 { flex: 1; min-width: 160px; }

.row { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.row-top { align-items: flex-start; }
.row-gap-lg { gap: var(--space-4); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.76em; background: var(--border); color: var(--muted); }
.pill.ok { background: var(--ok); color: #06240f; }
.pill.bad { background: var(--bad); color: #fff; }

/* Labeled field: a small caps label stacked over its control, used instead
   of bare placeholder-only inputs so multi-field forms read as a form. */
.field { display: flex; flex-direction: column; gap: var(--space-1); }
.field-label { font-size: 0.76em; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.form-grid { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3) var(--space-4); }
.form-actions { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; margin-top: var(--space-3); }
.form-grid > .form-actions { margin-top: 0; }
.no-underline { text-decoration: none; display: inline-block; }
.pre-wrap { white-space: pre-wrap; }

/* Margin-top/bottom utilities, mapped 1:1 to the spacing scale — replaces
   inline style="margin-top:8px" etc. scattered through markup/JS. */
.mt-1 { margin-top: var(--space-1); } .mb-1 { margin-bottom: var(--space-1); }
.mt-2 { margin-top: var(--space-2); } .mb-2 { margin-bottom: var(--space-2); }
.mt-3 { margin-top: var(--space-3); } .mb-3 { margin-bottom: var(--space-3); }
.mt-4 { margin-top: var(--space-4); } .mb-4 { margin-bottom: var(--space-4); }
.mt-5 { margin-top: var(--space-5); } .mb-5 { margin-bottom: var(--space-5); }
.ml-2 { margin-left: var(--space-2); }
.font-semibold { font-weight: 600; }

/* Page / card section rhythm. */
.page-head { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-1); }
h2.section-head { margin-top: var(--space-6); margin-bottom: var(--space-3); }
h2:first-child.section-head { margin-top: 0; }

/* Hover-only info affordance — replaces standing explanatory paragraphs. */
.hint { display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; border-radius: 50%; border: 1px solid var(--border); color: var(--muted); font-size: 0.66em; font-weight: 700; cursor: help; flex: none; user-select: none; }
.hint:hover { color: var(--text); border-color: var(--muted); }

/* Two-column layout (chat log + side panel, wiki nav + content). */
.two-col { display: flex; align-items: flex-start; gap: var(--space-4); }
.two-col > .col-main { flex: 2; min-width: 0; }
.two-col > .col-side { flex: 1; min-width: 220px; }

/* Vertical rhythm inside cards/modal sections — children get consistent
   gap instead of hand-tuned margin-top on each element. */
.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.stack-tight { display: flex; flex-direction: column; gap: var(--space-1); }

.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: var(--space-5); text-align: center; color: var(--muted); cursor: pointer; }
.dropzone.dragover { border-color: var(--accent); color: var(--text); }

.token-value { font-family: ui-monospace, monospace; background: var(--bg); border: 1px solid var(--border); padding: var(--space-2); border-radius: var(--radius-sm); word-break: break-all; user-select: all; }

.hidden { display: none !important; }

#login-screen { max-width: 420px; margin: 15vh auto; text-align: center; }
#login-screen input { width: 100%; margin: var(--space-3) 0; }

.bar { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; margin-top: var(--space-1); }
.bar > span { display: block; height: 100%; background: var(--accent); }
.bar > span.warn { background: var(--warn); }
.bar > span.bad { background: var(--bad); }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6);
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-5); z-index: 100;
}
.modal-panel { max-width: 640px; width: 100%; max-height: 85vh; overflow-y: auto; position: relative; padding-top: var(--space-5); }
.modal-close {
  position: absolute; top: var(--space-3); right: var(--space-3);
  width: 28px; height: 28px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; line-height: 1;
}
.modal-header { display: flex; flex-direction: column; gap: var(--space-1); padding-right: var(--space-6); }
.modal-header h1 { margin-bottom: var(--space-1); }
.modal-section { margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--border); }
.modal-section:first-of-type { margin-top: var(--space-5); }
.modal-section > h2 { margin-bottom: var(--space-3); }
.stat-item { display: flex; flex-direction: column; gap: var(--space-1); }

#chat-log { display: flex; flex-direction: column; min-height: 320px; max-height: 55vh; overflow-y: auto; gap: var(--space-2); padding: var(--space-1); }
.chat-bubble { max-width: 78%; padding: var(--space-2) var(--space-3); border-radius: 10px; font-size: 0.92em; }
.chat-bubble-user { align-self: flex-end; background: var(--accent); color: #fff; }
.chat-bubble-user .muted { color: rgba(255,255,255,0.75); }
.chat-bubble-assistant { align-self: flex-start; background: var(--bg); border: 1px solid var(--border); }
.chat-bubble-role { font-size: 0.78em; margin-bottom: 2px; }
.chat-bubble-text { white-space: pre-wrap; }

#chat-info { display: flex; flex-direction: column; gap: var(--space-2); }
.info-block { display: flex; flex-direction: column; gap: 2px; }
.info-block-title { font-weight: 600; font-size: 0.92em; }
.info-block-text { font-size: 0.9em; color: var(--text); }

.wiki-nav { display: flex; flex-direction: column; gap: var(--space-1); flex: 0 0 200px; }
.wiki-nav a { color: var(--muted); text-decoration: none; padding: 6px 8px; border-radius: 5px; }
.wiki-nav a:hover { color: var(--text); background: var(--bg); }
.wiki-nav a.active { color: var(--text); background: var(--bg); font-weight: 600; }
#wiki-content { line-height: 1.55; }
#wiki-content h1, #wiki-content h2, #wiki-content h3 { color: var(--text); }
#wiki-content h2 { margin-top: 20px; }
#wiki-content code { background: var(--bg); border-radius: 3px; padding: 1px 4px; font-size: 0.92em; }
#wiki-content pre { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 10px; overflow-x: auto; }
#wiki-content pre code { background: none; padding: 0; }
#wiki-content table { margin: 8px 0 16px; }
#wiki-content .mermaid { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 12px; margin: 12px 0; overflow-x: auto; }
