/* method.chromoshub.ru — Chromos method (.xmtd) viewer. Palette mirrors openchr. */
:root {
    --bg: #0d1117; --bg-2: #161b22; --bg-3: #1c2430; --card: #10151d;
    --line: #26303c; --line-2: #313d4d;
    --txt: #e6edf3; --txt-2: #9aa7b4; --txt-3: #6b7684;
    --accent: #58b0ff; --accent-2: #2f81f7;
    --good: #4ac26b; --warn: #f5a623; --ref: #d29922; --off: #6b7684;
    --mono: "JetBrains Mono", "Cascadia Code", "Fira Code", "DejaVu Sans Mono", "Consolas", monospace;
    --ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
:root[data-theme="light"] {
    --bg: #f4f6fa; --bg-2: #ffffff; --bg-3: #eef1f6; --card: #ffffff;
    --line: #dde3ec; --line-2: #c8d1de;
    --txt: #16202f; --txt-2: #52617a; --txt-3: #808d9b;
    --accent: #1f6feb; --accent-2: #1a5fd0;
    --good: #2f9e44; --warn: #e08600; --ref: #b8860b; --off: #808d9b;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--ui); background: var(--bg); color: var(--txt); min-height: 100vh; display: flex; flex-direction: column; }
code { font-family: var(--mono); font-size: .9em; background: var(--bg-3); padding: 1px 5px; border-radius: 5px; }
.muted { color: var(--txt-3); font-size: 12px; }
.mono { font-family: var(--mono); }

/* topbar */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 13px 18px; border-bottom: 1px solid var(--line); background: var(--bg-2); }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 600; font-size: 15px; }
.brand__mark { font-size: 18px; }
.actions { display: flex; align-items: center; gap: 10px; }
.lang { display: inline-flex; height: 32px; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.lang__btn { font-family: var(--mono); font-size: 11px; font-weight: 600; padding: 0 9px; border: 0; background: var(--bg-3); color: var(--txt-2); cursor: pointer; }
.lang__btn + .lang__btn { border-left: 1px solid var(--line-2); }
.lang__btn:hover { color: var(--accent); }
.lang__btn.is-active { background: var(--accent-2); color: #fff; }
.icon-btn { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line-2); border-radius: 8px; background: var(--bg-3); color: var(--txt-2); cursor: pointer; }
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn .i-moon { display: none; }
:root[data-theme="light"] .icon-btn .i-sun { display: none; }
:root[data-theme="light"] .icon-btn .i-moon { display: block; }

/* toolbar */
.wrap { max-width: 1180px; width: 100%; margin: 0 auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; flex: 1 1 auto; min-height: 0; }
.toolbar { position: relative; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.field { display: inline-flex; align-items: center; gap: 8px; }
.field__lbl { font-size: 13px; color: var(--txt-2); }
.select { font-family: var(--ui); font-size: 13px; background: var(--bg-3); color: var(--txt); border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 10px; cursor: pointer; max-width: 320px; }
.toolbar__or { color: var(--txt-3); font-size: 13px; }
.btn { display: inline-flex; align-items: center; font-size: 13px; font-weight: 500; padding: 8px 14px; border-radius: 8px; cursor: pointer; border: 1px solid var(--accent-2); background: var(--accent-2); color: #fff; }
.btn:hover { background: var(--accent); }
.fname { font-family: var(--mono); font-size: 12px; color: var(--txt-2); }
.toolbar__spacer { flex: 1; }
.status { font-size: 12px; color: var(--txt-3); }
.status.err { color: #f85149; }
.toolbar.drag-over { outline: 2px dashed var(--accent); outline-offset: -3px; }
.drop-hint { display: none; position: absolute; inset: 0; align-items: center; justify-content: center; background: color-mix(in srgb, var(--card) 90%, transparent); color: var(--accent); font-weight: 600; font-size: 14px; border-radius: 12px; }
.toolbar.drag-over .drop-hint { display: flex; }
.mini-btn { font-size: 12px; padding: 5px 11px; border-radius: 7px; cursor: pointer; border: 1px solid var(--line-2); background: var(--bg-3); color: var(--txt-2); }
.mini-btn:hover { color: var(--accent); border-color: var(--accent); }

/* meta bar */
.meta { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 2px 2px; }
.meta__name { font-weight: 600; font-size: 15px; }
.meta__counts { color: var(--txt-2); font-size: 13px; }
.badge { padding: 2px 10px; border-radius: 999px; font-weight: 700; font-size: 12px; background: var(--bg-3); border: 1px solid var(--line-2); color: var(--txt-2); }
.badge.legacy { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 55%, var(--line-2)); }

/* tabs */
.tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--line); }
.tab { border: none; background: transparent; color: var(--txt-2); cursor: pointer; padding: 9px 15px; font-size: 13.5px; font-weight: 600; border-radius: 8px 8px 0 0; border-bottom: 2px solid transparent; }
.tab:hover { color: var(--txt); }
.tab.active { color: var(--txt); border-bottom-color: var(--accent); }
.tab .cnt { color: var(--txt-3); font-weight: 600; font-size: 11px; margin-left: 5px; }
.tab.active .cnt { color: var(--accent); }

/* panes */
.panes { flex: 1 1 auto; min-height: 0; }
.pane { display: none; flex-direction: column; gap: 14px; }
.pane.active { display: flex; }
.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; color: var(--txt-2); padding: 40px 20px; }
.empty__icon { font-size: 44px; opacity: .7; }
.empty p { max-width: 560px; }

/* cards / grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; align-items: start; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; font-size: 13px; color: var(--txt-2); border-bottom: 1px solid var(--line); background: var(--bg-2); }
.panel__head b { color: var(--txt); font-size: 13.5px; }
.panel__head .sub { color: var(--txt-3); font-size: 12px; font-weight: 400; }
.chip { font-family: var(--mono); font-size: 12px; padding: 1px 9px; border-radius: 999px; background: var(--bg-3); border: 1px solid var(--line-2); color: var(--txt-2); }

/* key/value tables */
.kv { width: 100%; border-collapse: collapse; }
.kv td { padding: 7px 14px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: top; }
.kv td:first-child { color: var(--txt-3); white-space: nowrap; width: 46%; }
.kv td:last-child { color: var(--txt); font-family: var(--mono); word-break: break-word; }
.kv tr:last-child td { border-bottom: 0; }

/* data tables */
.table-wrap { overflow: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { position: sticky; top: 0; z-index: 1; background: var(--bg-2); text-align: left; padding: 8px 12px; color: var(--txt-3); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th.num, .tbl td.num { text-align: right; font-family: var(--mono); }
.tbl th[data-sort] { cursor: pointer; user-select: none; }
.tbl th[data-sort]:hover { color: var(--accent); }
.tbl th.sort-asc::after { content: ' ▲'; }
.tbl th.sort-desc::after { content: ' ▼'; }
.tbl td { padding: 7px 12px; border-bottom: 1px solid var(--line); color: var(--txt); }
.tbl tbody tr:hover { background: var(--bg-3); }
.tbl .name { font-weight: 500; }
.tbl .num { font-variant-numeric: tabular-nums; }

/* flags / booleans */
.flags { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 14px; }
.flag { font-size: 12.5px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--txt-3); background: var(--bg-3); }
.flag.on { color: var(--good); border-color: color-mix(in srgb, var(--good) 55%, var(--line-2)); }
.flag.on::before { content: '✓ '; }
.flag.off::before { content: '· '; }
.yes { color: var(--good); } .no { color: var(--txt-3); }
.ref-tag { color: var(--ref); font-size: 11px; font-weight: 700; border: 1px solid color-mix(in srgb, var(--ref) 55%, var(--line-2)); border-radius: 5px; padding: 0 5px; margin-left: 6px; }

/* channel block */
.chan { }
.chan__body { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0; }
.chan__col { border-right: 1px solid var(--line); }
.chan__col:last-child { border-right: 0; }
.chan__col h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--txt-3); font-weight: 700; padding: 9px 14px 4px; }
.events-note { padding: 6px 14px 12px; }
.events-note .evt { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.events-note .evt:last-child { border-bottom: 0; }
.events-note .evt .t { color: var(--txt-3); font-family: var(--mono); }

/* calibration chart */
.cal-chart-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 9px 14px 2px; font-size: 12px; color: var(--txt-3); border-top: 1px solid var(--line); }
.cal-legend { display: inline-flex; align-items: center; gap: 12px; }
.cal-legend .lg { display: inline-flex; align-items: center; gap: 5px; }
.cal-legend .lg::before { content: ''; width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.cal-legend .lg-pt::before { background: var(--accent); }
.cal-legend .lg-off::before { background: transparent; border: 1.5px solid var(--txt-3); }
.cal-legend .lg-fit::before { width: 14px; height: 0; border-radius: 0; border-top: 2px solid var(--ref); }
.cal-chart { padding: 4px 10px 10px; }
.cal-svg { width: 100%; height: auto; display: block; }
.cal-svg .grid { stroke: var(--line); stroke-width: 1; }
.cal-svg .tick { fill: var(--txt-3); font-family: var(--mono); font-size: 9px; }
.cal-svg .axis-title { fill: var(--txt-2); font-family: var(--ui); font-size: 10px; }
.cal-svg .cal-emp { fill: none; stroke: var(--accent); stroke-width: 1; stroke-dasharray: 4 3; opacity: .5; }
.cal-svg .cal-fit { fill: none; stroke: var(--ref); stroke-width: 1.8; stroke-linejoin: round; }
.cal-svg .cal-pt { fill: var(--accent); stroke: var(--card); stroke-width: 1; }
.cal-svg .cal-pt.off { fill: transparent; stroke: var(--txt-3); stroke-width: 1.5; }

/* devices */
.dev-tools { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--bg-2); flex-wrap: wrap; }
.dev-tools .select { max-width: 280px; }
.search { font-family: var(--ui); font-size: 13px; background: var(--bg-3); color: var(--txt); border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 10px; min-width: 180px; flex: 1; }
.dev-params { max-height: 62vh; overflow: auto; }
.dev-params .tbl td:first-child { color: var(--txt-2); font-family: var(--mono); white-space: normal; }
.dev-params .tbl td:last-child { text-align: right; font-family: var(--mono); white-space: nowrap; }
.dev-params .p-lbl { display: block; font-family: var(--ui); color: var(--txt); }
.dev-params .p-raw { display: block; font-family: var(--mono); font-size: 11px; color: var(--txt-3); margin-top: 1px; }
.no-rows { padding: 18px 14px; color: var(--txt-3); font-size: 13px; }

@media (max-width: 720px) {
    .chan__col { border-right: 0; border-bottom: 1px solid var(--line); }
}

/* print */
@media print {
    @page { margin: 12mm; }
    :root { --bg:#fff; --bg-2:#fff; --bg-3:#f4f6fa; --card:#fff; --line:#cbd5e1; --line-2:#b0bccc; --txt:#101820; --txt-2:#333; --txt-3:#555; }
    body { background:#fff; color:#000; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .topbar .actions, .toolbar, .tabs, .drop-hint { display:none !important; }
    .pane { display:flex !important; break-inside: avoid; }
    .dev-params { max-height:none; overflow:visible; }
    .tbl th { position: static; }
}
