:root {
  --ink: #10212b;
  --ink-2: #304955;
  --muted: #6b818c;
  --line: #dbe5e9;
  --line-strong: #c5d4da;
  --bg: #f2f6f7;
  --panel: #ffffff;
  --sidebar: #0b1c26;
  --sidebar-2: #102936;
  --accent: #0f9f90;
  --accent-dark: #0a7d71;
  --accent-soft: #e2f6f2;
  --blue: #2c6bed;
  --blue-soft: #e9efff;
  --amber: #b5720a;
  --amber-soft: #fff3d9;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --ok: #167744;
  --ok-soft: #e6f6ec;
  --shadow: 0 10px 30px rgba(11, 28, 38, .07);
  --shadow-sm: 0 2px 8px rgba(11, 28, 38, .06);
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar-w: 252px;
  --font: "Segoe UI", "Inter", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 650; letter-spacing: -.015em; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
mark { background: #fff0a8; color: inherit; border-radius: 3px; padding: 0 2px; }
[hidden] { display: none !important; }

/* ---------- boot / login ---------- */
.app-root { min-height: 100vh; }
.boot-screen {
  min-height: 100vh; display: flex; flex-direction: column; gap: 18px;
  align-items: center; justify-content: center; color: var(--muted);
}
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--accent), #08766b); color: #fff;
  font-weight: 750; letter-spacing: -.04em; font-size: 14px; flex: 0 0 auto;
}
.brand-mark.large { width: 62px; height: 62px; border-radius: 17px; font-size: 21px; }
.spinner {
  width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
.spinner.sm { width: 17px; height: 17px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

.login-wrap {
  min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr;
}
.login-hero {
  position: relative; overflow: hidden; padding: 58px;
  display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(1000px 540px at 82% 15%, rgba(22, 184, 166, .22), transparent 60%),
    radial-gradient(700px 400px at 8% 94%, rgba(44, 107, 237, .15), transparent 65%),
    linear-gradient(150deg, #07151d, #0b2531 60%, #0b1c26);
  color: #eaf6f4;
}
.login-hero::after {
  content: ""; position: absolute; inset: 0; opacity: .18; pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.12) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at 60% 35%, #000, transparent 72%);
}
.login-hero > * { position: relative; z-index: 1; }
.login-brand { display: flex; align-items: center; gap: 13px; font-size: 19px; font-weight: 700; }
.login-hero h1 { font-size: clamp(34px, 4.2vw, 56px); line-height: 1.03; letter-spacing: -.045em; max-width: 620px; }
.login-hero h1 em { font-style: normal; color: #5fe0cf; }
.login-hero .lead { color: #a9c4c8; font-size: 17px; max-width: 560px; margin-top: 22px; }
.hero-points { display: grid; gap: 12px; margin-top: 30px; }
.hero-point { display: flex; gap: 12px; align-items: flex-start; color: #bcd4d6; font-size: 14px; }
.hero-point i { width: 21px; height: 21px; flex: 0 0 auto; border-radius: 50%; background: rgba(95,224,207,.14); color: #5fe0cf; display: grid; place-items: center; font-style: normal; font-size: 12px; }
.login-foot { color: #6f939b; font-size: 12.5px; }

.login-panel { display: flex; align-items: center; justify-content: center; padding: 34px; background: #fbfdfd; }
.login-card { width: 100%; max-width: 404px; }
.login-card h2 { font-size: 27px; letter-spacing: -.03em; }
.login-card > p { color: var(--muted); margin: 9px 0 28px; }
.login-card .brand-mark { margin-bottom: 22px; }
.field { display: grid; gap: 7px; margin-bottom: 17px; }
.field > label, .label { font-size: 12.8px; font-weight: 650; color: var(--ink-2); letter-spacing: .01em; }
.field .hint, .hint { color: var(--muted); font-size: 12.2px; line-height: 1.45; }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--line-strong); background: #fff; border-radius: 10px;
  padding: 11px 13px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15,159,144,.13);
}
.input:disabled, .select:disabled, .textarea:disabled { background: #f1f5f6; color: var(--muted); }
.textarea { min-height: 112px; resize: vertical; line-height: 1.55; }
.input-lg { padding: 14px 16px; font-size: 16px; }
.password-wrap { position: relative; }
.password-wrap .input { padding-right: 82px; }
.password-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--muted); font-size: 12px; padding: 8px;
}
.form-error { display: none; background: var(--danger-soft); color: var(--danger); padding: 10px 12px; border-radius: 9px; font-size: 13px; margin-bottom: 15px; }
.form-error.show { display: block; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--sidebar), #0a1921);
  color: #c4d6da; display: flex; flex-direction: column; min-height: 100vh;
  position: sticky; top: 0; max-height: 100vh;
}
.sidebar-top { padding: 21px 20px 16px; display: flex; align-items: center; gap: 11px; }
.sidebar-brand { font-size: 17px; font-weight: 720; color: #f1fbfa; letter-spacing: -.025em; }
.sidebar-brand span { color: #5fe0cf; }
.sidebar-caption { padding: 0 24px 18px; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: #62828c; }
.nav { padding: 0 11px; display: grid; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 9px;
  color: #a9c0c6; font-size: 13.6px; font-weight: 500; border: 1px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #f4fbfa; text-decoration: none; }
.nav-item.active { background: rgba(22,184,166,.14); border-color: rgba(95,224,207,.16); color: #eafffb; }
.nav-item .ico { width: 17px; height: 17px; opacity: .9; }
.nav-sep { height: 1px; background: rgba(255,255,255,.075); margin: 13px 22px; }
.sidebar-foot { margin-top: auto; padding: 16px; }
.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 11px;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.06);
}
.avatar {
  width: 33px; height: 33px; border-radius: 50%; background: rgba(22,184,166,.18);
  color: #7ce8d9; display: grid; place-items: center; font-weight: 700; font-size: 12px;
  flex: 0 0 auto; text-transform: uppercase;
}
.user-chip-body { min-width: 0; flex: 1; }
.user-chip-name { color: #edf8f7; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip-role { color: #7598a1; font-size: 11px; }
.icon-btn {
  width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: currentColor;
}
.icon-btn:hover { background: rgba(255,255,255,.07); }
.sidebar .icon-btn { color: #7f9ea6; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 67px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 32px; background: rgba(255,255,255,.82); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 20;
}
.breadcrumbs { color: var(--muted); font-size: 12.8px; display: flex; align-items: center; gap: 8px; }
.breadcrumbs strong { color: var(--ink); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 9px; }
.content { padding: 28px 32px 54px; max-width: 1480px; width: 100%; margin: 0 auto; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 23px; }
.page-head h1 { font-size: 27px; letter-spacing: -.03em; }
.page-head p { color: var(--muted); margin-top: 6px; max-width: 760px; }
.page-actions { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.section { margin-top: 26px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 13px; }
.section-head h2 { font-size: 16px; }
.section-head .muted { font-size: 12.5px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 9px; border: 1px solid var(--line-strong); background: #fff;
  color: var(--ink-2); padding: 9px 14px; font-size: 13.2px; font-weight: 600;
  white-space: nowrap; transition: .15s ease; text-decoration: none;
}
.btn:hover { border-color: #aabcc4; background: #f8fbfc; text-decoration: none; }
.btn:focus-visible { outline: 3px solid rgba(15,159,144,.22); outline-offset: 1px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.danger { color: var(--danger); border-color: #f0c8c2; background: #fff; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 12.2px; border-radius: 8px; }
.btn.icon { padding: 8px; width: 34px; height: 34px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.link-btn { border: 0; background: transparent; color: var(--accent-dark); font-weight: 600; padding: 2px; font-size: 13px; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }

/* ---------- cards / metrics ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 21px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; }
.metric { padding: 18px 19px; position: relative; overflow: hidden; }
.metric-label { color: var(--muted); font-size: 12.3px; font-weight: 600; }
.metric-value { font-size: 31px; font-weight: 700; letter-spacing: -.04em; margin-top: 5px; }
.metric-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.metric-accent { position: absolute; right: -20px; top: -20px; width: 78px; height: 78px; border-radius: 50%; background: var(--accent-soft); opacity: .65; }
.metric.warn .metric-accent { background: var(--amber-soft); }
.metric.bad .metric-accent { background: var(--danger-soft); }
.metric.blue .metric-accent { background: var(--blue-soft); }

/* ---------- search ---------- */
.search-hero { padding: 23px; border-radius: var(--radius); background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); }
.search-bar { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px; }
.search-input-wrap { position: relative; }
.search-input-wrap .search-ico { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-input { padding-left: 45px; font-size: 16.5px; height: 52px; background: #fbfdfd; }
.search-examples { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 11px; align-items: center; }
.example { border: 1px dashed var(--line-strong); background: transparent; color: var(--muted); border-radius: 20px; padding: 4px 10px; font-size: 11.7px; }
.example:hover { color: var(--accent-dark); border-color: var(--accent); background: var(--accent-soft); }
.scope-row { margin-top: 18px; display: grid; gap: 8px; }
.scope-label { font-size: 12px; font-weight: 650; color: var(--ink-2); }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line-strong);
  border-radius: 999px; padding: 6px 11px 6px 8px; background: #fff; color: var(--ink-2);
  font-size: 12.4px; font-weight: 550; cursor: pointer; user-select: none;
}
.chip input { accent-color: var(--accent); width: 14px; height: 14px; }
.chip.selected { border-color: rgba(15,159,144,.45); background: var(--accent-soft); color: #08685e; }
.chip .count { color: var(--muted); font-size: 10.8px; }
.search-options { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 17px; padding-top: 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.ai-switch { display: flex; align-items: center; gap: 10px; }
.switch { position: relative; display: inline-flex; width: 40px; height: 23px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 30px; background: #c9d7dc; transition: .2s; }
.switch span::after { content: ""; position: absolute; width: 17px; height: 17px; border-radius: 50%; background: #fff; left: 3px; top: 3px; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.18); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(17px); }
.switch input:disabled + span { opacity: .45; }
.search-options .select { width: auto; min-width: 200px; padding: 7px 10px; font-size: 12.5px; }
.ai-note { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11.8px; }

.results-layout { display: grid; grid-template-columns: minmax(0,1fr); gap: 17px; margin-top: 19px; }
.results-layout.with-ai { grid-template-columns: minmax(0,1fr) 390px; align-items: start; }
.results-meta { display: flex; align-items: center; justify-content: space-between; gap: 15px; color: var(--muted); font-size: 12.5px; margin: 16px 2px 10px; }
.results-list { display: grid; gap: 11px; }
.result-card { padding: 18px 19px; position: relative; transition: .15s ease; }
.result-card:hover { border-color: #b9cdd4; box-shadow: var(--shadow); }
.result-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.result-title { font-size: 15.5px; font-weight: 650; letter-spacing: -.01em; }
.result-title button { border: 0; background: transparent; padding: 0; text-align: left; color: var(--ink); font-weight: inherit; }
.result-title button:hover { color: var(--accent-dark); }
.result-catalog { color: var(--muted); font-size: 11.8px; margin-top: 3px; }
.score-pill { flex: 0 0 auto; border-radius: 7px; padding: 3px 7px; background: var(--accent-soft); color: #08786c; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.result-snippet { margin: 10px 0 13px; color: var(--ink-2); font-size: 13.4px; line-height: 1.62; }
.result-snippet mark { background: #d9f8f2; color: #075e55; font-weight: 600; }
.result-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.source-tag { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 11.8px; background: #f4f8f9; border: 1px solid var(--line); border-radius: 7px; padding: 4px 8px; }
.source-tag b { font-weight: 700; color: var(--accent-dark); font-size: 10px; letter-spacing: .05em; }
.badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 3px 8px; font-size: 10.6px; font-weight: 650; letter-spacing: .01em; white-space: nowrap; }
.badge.green { background: var(--ok-soft); color: var(--ok); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.gray { background: #eef3f5; color: var(--muted); }

.ai-card { position: sticky; top: 84px; overflow: hidden; }
.ai-head { padding: 15px 17px; background: linear-gradient(135deg, #0b2531, #0d3340); color: #dff7f3; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ai-head-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 650; }
.ai-body { padding: 17px; }
.ai-answer { font-size: 13.7px; line-height: 1.7; color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-answer strong { color: var(--ink); }
.ai-empty { color: var(--muted); font-size: 12.6px; }
.ai-cites { margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--line); display: grid; gap: 7px; }
.cite-link { display: flex; align-items: flex-start; gap: 9px; width: 100%; text-align: left; border: 1px solid var(--line); border-radius: 8px; background: #fbfdfd; padding: 8px 9px; font-size: 11.8px; color: var(--ink-2); }
.cite-link:hover { border-color: var(--accent); background: var(--accent-soft); }
.cite-num { width: 20px; height: 20px; border-radius: 6px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 10px; font-weight: 750; flex: 0 0 auto; }
.ai-warning { margin-top: 11px; background: var(--amber-soft); color: #74500c; border-radius: 8px; padding: 8px 9px; font-size: 11.3px; }
.ai-loading { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 12.5px; }

.empty { padding: 52px 20px; text-align: center; color: var(--muted); }
.empty .empty-icon { width: 52px; height: 52px; border-radius: 15px; margin: 0 auto 13px; background: #eef4f5; display: grid; place-items: center; color: #8ba2aa; }
.empty h3 { color: var(--ink-2); font-size: 15px; margin-bottom: 5px; }
.empty p { max-width: 430px; margin: 0 auto; font-size: 12.8px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-size: 10.8px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); font-weight: 700; padding: 11px 14px; border-bottom: 1px solid var(--line);
  background: #f8fbfb; white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid #edf2f4; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fbfdfd; }
.table .strong { font-weight: 600; color: var(--ink); }
.table .sub { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn { margin-left: 4px; }
.table-scroll { max-height: 64vh; overflow: auto; }

/* ---------- forms / panels ---------- */
.panel-grid { display: grid; grid-template-columns: minmax(0, 1fr) 370px; gap: 17px; align-items: start; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.form-grid .full { grid-column: 1 / -1; }
.form-section { padding: 22px; }
.form-section + .form-section { border-top: 1px solid var(--line); }
.form-section h3 { font-size: 15px; margin-bottom: 4px; }
.form-section > .hint { margin-bottom: 17px; }
.inline-check { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--ink-2); }
.inline-check input { accent-color: var(--accent); width: 16px; height: 16px; }
.tabs { display: flex; gap: 3px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tab { border: 0; background: transparent; padding: 10px 13px; color: var(--muted); font-weight: 600; font-size: 12.8px; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: var(--accent-dark); border-bottom-color: var(--accent); }
.tab-count { font-size: 10px; background: #eef3f5; border-radius: 10px; padding: 1px 5px; margin-left: 4px; }
.info-box { background: #f6fafb; border: 1px solid var(--line); border-radius: 9px; padding: 12px 13px; color: var(--muted); font-size: 12.2px; line-height: 1.55; }
.info-box.warn { background: var(--amber-soft); border-color: #f2dba9; color: #6f500f; }
.info-box.danger { background: var(--danger-soft); border-color: #f3cbc6; color: #7d2a20; }
.progress { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.progress progress { width: 86px; height: 6px; border: 0; border-radius: 10px; overflow: hidden; appearance: none; }
.progress progress::-webkit-progress-bar { background: #e8eff1; border-radius: 10px; }
.progress progress::-webkit-progress-value { background: var(--accent); border-radius: 10px; }
.progress progress::-moz-progress-bar { background: var(--accent); border-radius: 10px; }
.progress span { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

.catalog-card { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.catalog-card:hover { border-color: #b9cdd4; box-shadow: var(--shadow); }
.catalog-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.catalog-name { font-size: 15.5px; font-weight: 650; }
.catalog-desc { color: var(--muted); font-size: 12.4px; margin-top: 4px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.catalog-stats { display: flex; gap: 16px; color: var(--muted); font-size: 11.8px; padding-top: 4px; }
.catalog-stats b { color: var(--ink-2); font-weight: 650; }
.catalog-card-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-top: 11px; border-top: 1px solid #edf2f4; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; }

.model-card { padding: 18px; display: flex; flex-direction: column; gap: 13px; }
.model-head { display: flex; align-items: flex-start; gap: 11px; justify-content: space-between; }
.model-name { font-size: 14.7px; font-weight: 650; }
.model-url { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10.9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 290px; }
.model-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.model-foot { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid #edf2f4; padding-top: 11px; gap: 8px; }

/* ---------- modal / toast ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(7, 21, 29, .56);
  display: flex; align-items: flex-start; justify-content: center; padding: 5vh 18px 30px;
  overflow-y: auto; backdrop-filter: blur(2px);
}
.modal {
  width: 100%; max-width: 580px; background: #fff; border-radius: 16px;
  box-shadow: 0 30px 80px rgba(0,0,0,.25); overflow: hidden; animation: modal-in .16s ease;
}
.modal.wide { max-width: 820px; }
@keyframes modal-in { from { transform: translateY(8px); opacity: 0; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 19px 22px 15px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 18px; letter-spacing: -.02em; }
.modal-head p { color: var(--muted); font-size: 12.3px; margin-top: 3px; }
.modal-body { padding: 20px 22px; max-height: 68vh; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; background: #fbfdfd; }
.modal-close { border: 0; background: transparent; color: var(--muted); font-size: 23px; width: 30px; height: 30px; border-radius: 7px; line-height: 1; }
.modal-close:hover { background: #eef4f5; color: var(--ink); }
.toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: grid; gap: 8px; width: min(380px, calc(100vw - 36px)); }
.toast { background: var(--ink); color: #f4fbfa; border-radius: 10px; padding: 11px 13px; font-size: 12.8px; box-shadow: 0 10px 30px rgba(0,0,0,.22); display: flex; gap: 9px; align-items: flex-start; animation: toast-in .18s ease; }
.toast.ok { background: #0d5c47; }
.toast.error { background: #8f2b20; }
.toast.warn { background: #76510d; }
@keyframes toast-in { from { transform: translateY(7px); opacity: 0; } }

/* ---------- source ---------- */
.source-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 15px; }
.meta-cell { background: #f7fafb; border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; }
.meta-cell .label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.meta-cell .value { font-size: 12.6px; margin-top: 2px; overflow-wrap: anywhere; }
.source-chunks { display: grid; gap: 9px; }
.source-chunk { border: 1px solid var(--line); border-radius: 9px; padding: 11px 12px; background: #fff; }
.source-chunk.current { border-color: rgba(15,159,144,.45); background: #f3fcf9; }
.source-chunk-head { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 10.8px; margin-bottom: 6px; }
.source-chunk pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--font); font-size: 12.4px; color: var(--ink-2); line-height: 1.55; }
.download-box { margin-top: 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--amber-soft); border-radius: 9px; padding: 10px 12px; font-size: 11.8px; color: #72520e; }

/* ---------- misc ---------- */
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.nowrap { white-space: nowrap; }
.flex { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.spacer { flex: 1; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.6px; background: #f1f5f6; border-radius: 5px; padding: 2px 5px; }
.kbd { border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px; font-size: 10.5px; color: var(--muted); }
.check-list { display: grid; gap: 10px; }
.check-item { display: flex; align-items: flex-start; gap: 9px; font-size: 12.5px; color: var(--ink-2); }
.check-item .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-top: 6px; flex: 0 0 auto; }
.hr { height: 1px; background: var(--line); margin: 17px 0; }
.highlight-line { background: #f8fbfb; border-left: 3px solid var(--accent); padding: 10px 12px; border-radius: 0 8px 8px 0; color: var(--muted); font-size: 12.3px; }
.error-text { color: var(--danger); font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 1180px) {
  .results-layout.with-ai { grid-template-columns: minmax(0,1fr); }
  .ai-card { position: static; }
  .panel-grid { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 900px) {
  :root { --sidebar-w: 76px; }
  .sidebar-brand, .sidebar-caption, .nav-item span, .user-chip-body, .sidebar .user-chip .icon-btn { display: none; }
  .sidebar-top { justify-content: center; padding: 18px 0; }
  .nav { padding: 0 10px; }
  .nav-item { justify-content: center; padding: 12px 0; }
  .nav-item .ico { width: 20px; height: 20px; }
  .sidebar-foot { padding: 10px; }
  .user-chip { justify-content: center; padding: 7px; }
  .topbar { padding: 0 18px; }
  .content { padding: 22px 18px 44px; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .login-panel { min-height: 100vh; }
}
@media (max-width: 700px) {
  .form-grid, .grid-2, .grid-3, .grid-4, .source-meta { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .page-head { flex-direction: column; }
  .search-bar { grid-template-columns: 1fr; }
  .search-bar .btn { height: 46px; }
  .topbar { height: 58px; }
  .breadcrumbs { display: none; }
  .content { padding: 18px 13px 38px; }
  .modal-backdrop { padding: 2vh 8px 20px; }
  .modal-body { max-height: 76vh; }
  .result-top { flex-direction: column; gap: 5px; }
}

/* ---------- utilities ---------- */
.btn-block { width: 100%; }
.h-46 { height: 46px; }
.boot-mini { min-height: 40vh; }
.mt-18 { margin-top: 18px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.wordbreak { overflow-wrap: anywhere; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.6px; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; font-family: var(--font); font-size: 12.4px; line-height: 1.55; }
.toast.hide { opacity: 0; transition: opacity .22s; }
.upload-zone { border: 1.5px dashed var(--line-strong); border-radius: 11px; padding: 22px; text-align: center; background: #fbfdfd; }
.upload-zone:hover { border-color: var(--accent); background: #f6fcfb; }
.upload-zone .up-icon { width: 42px; height: 42px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-dark); display: grid; place-items: center; margin: 0 auto 9px; }
.upload-zone h4 { font-size: 13.5px; margin-bottom: 3px; }
.upload-zone p { color: var(--muted); font-size: 11.6px; }
.file-input { display: block; margin: 12px auto 0; max-width: 100%; font-size: 12px; }
.doc-name { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.action-row { display: flex; gap: 5px; justify-content: flex-end; flex-wrap: wrap; }
.tab-panel { animation: fade-in .16s ease; }
@keyframes fade-in { from { opacity: 0; } }
.inline-fields { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-fields .field { margin-bottom: 0; }
.checkbox-line { display: flex; align-items: center; gap: 9px; font-size: 12.8px; color: var(--ink-2); }
.checkbox-line input { accent-color: var(--accent); width: 16px; height: 16px; }
.preview-box { background: #f6fafb; border: 1px solid var(--line); border-radius: 9px; padding: 12px; min-height: 70px; }
.warning-line { display: flex; gap: 8px; align-items: flex-start; font-size: 12.2px; color: #74500c; background: var(--amber-soft); border-radius: 8px; padding: 9px 11px; }
.compact-pad { padding-bottom: 8px; }

/* icon sizing */
.ico { width: 17px; height: 17px; flex: 0 0 auto; vertical-align: -3px; }
.btn .ico, .link-btn .ico { width: 15px; height: 15px; }
.badge .ico { width: 12px; height: 12px; }
.nav-item .ico { width: 17px; height: 17px; }

/* ---------- chunked upload progress ---------- */
.upload-queue { display: grid; gap: 9px; }
.upload-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fbfdfd; }
.upload-item.done { border-color: #b9e2cb; background: #f4fcf7; }
.upload-item.error { border-color: #efc6c0; background: #fff7f6; }
.upload-item-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.upload-item-name { font-weight: 600; font-size: 12.8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item-pct { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.upload-item progress { width: 100%; height: 6px; border: 0; border-radius: 10px; overflow: hidden; appearance: none; margin: 8px 0 5px; }
.upload-item progress::-webkit-progress-bar { background: #e8eff1; border-radius: 10px; }
.upload-item progress::-webkit-progress-value { background: var(--accent); border-radius: 10px; }
.upload-item progress::-moz-progress-bar { background: var(--accent); border-radius: 10px; }
.upload-item.done progress::-webkit-progress-value { background: var(--ok); }
.upload-item.error progress::-webkit-progress-value { background: var(--danger); }
.upload-item-meta { color: var(--muted); font-size: 11.3px; }
.upload-item-error { color: var(--danger); font-size: 11.5px; margin-top: 4px; }

/* ---------- document chunks / markdown ---------- */
.chunk-list { display: grid; gap: 14px; }
.chunk-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.chunk-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; padding: 13px 17px; background: #f8fbfb; border-bottom: 1px solid var(--line); }
.chunk-number { font-weight: 700; font-size: 13px; color: var(--ink); }
.chunk-location { color: var(--muted); font-size: 11.8px; margin-left: 8px; }
.md-content { padding: 16px 19px; font-size: 13px; line-height: 1.65; color: var(--ink-2); overflow-wrap: anywhere; }
.md-content h1, .md-content h2, .md-content h3 { margin: 0 0 9px; }
.md-content h2 { font-size: 16px; }
.md-content h3 { font-size: 14px; }
.md-content p { margin: 0 0 9px; }
.md-content ul, .md-content ol { padding-left: 21px; margin: 0 0 10px; }
.md-content pre { margin: 10px 0; padding: 12px 14px; background: #0e222c; color: #dff3ee; border-radius: 9px; overflow-x: auto; font-size: 11.8px; line-height: 1.55; }
.md-content code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
.md-content p code, .md-content li code { background: #eef3f5; border-radius: 4px; padding: 1px 4px; }
.md-content blockquote { margin: 10px 0; padding: 9px 12px; border-left: 3px solid var(--accent); background: #f5fbfa; color: var(--muted); }
.md-content table { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: 12px; }
.md-content th, .md-content td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; }
.chunk-raw { border-top: 1px solid var(--line); padding: 9px 17px; }
.chunk-raw summary { color: var(--accent-dark); font-size: 11.8px; cursor: pointer; }
.chunk-raw pre { margin: 10px 0 3px; padding: 12px; background: #f4f8f9; border: 1px solid var(--line); border-radius: 8px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 11.5px; line-height: 1.55; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 18px; }
.md-content > h2:first-child,
.md-content > p:first-of-type { display: none; }

/* ---------- chunk field table ---------- */
.chunk-table-wrap { padding: 14px 17px; overflow-x: auto; }
.chunk-table { width: 100%; border-collapse: collapse; font-size: 12.4px; line-height: 1.5; }
.chunk-table th { width: 30%; text-align: left; vertical-align: top; padding: 8px 10px; background: #f4f8f9; color: var(--ink-2); font-weight: 650; border: 1px solid var(--line); overflow-wrap: anywhere; }
.chunk-table td { vertical-align: top; padding: 8px 10px; border: 1px solid var(--line); color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.chunk-table tr:nth-child(even) td, .chunk-table tr:nth-child(even) th { background: #fbfdfd; }

.segmented { display: flex; gap: 8px; flex-wrap: wrap; }
.upload-zone { cursor: pointer; }
.upload-zone.dragover { border-color: var(--accent); background: var(--accent-soft); }


/* --- домен 1С --- */
.c1-card {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-soft, rgba(127, 127, 127, 0.06));
  font-size: 13px;
  line-height: 1.45;
}
.c1-line:first-child { font-weight: 600; }
.c1-result { display: grid; gap: 10px; margin-bottom: 12px; }
.c1-toolbar { margin-bottom: 16px; }
.c1-tree { margin-top: 12px; border-top: 1px solid var(--border, rgba(127,127,127,.2)); padding-top: 12px; }
.c1-tree-list { display: flex; flex-wrap: wrap; gap: 6px; max-height: 240px; overflow: auto; }
.c1-tree-item {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--border, rgba(127,127,127,.25));
  background: transparent; border-radius: 8px; padding: 6px 10px;
  font: inherit; font-size: 13px; cursor: pointer;
}
.c1-tree-item:hover { background: var(--bg-soft, rgba(127,127,127,.08)); }
.field-wide { grid-column: span 2; }

/* --- API-ключи --- */
.keys-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
.key-card { display: grid; gap: 8px; }
.key-card .result-title { font-weight: 600; }
