/* INControl web */
:root {
  --bg: #f4f5f7; --panel: #ffffff; --text: #1d1f23; --muted: #6b7280; --border: #d4d7dd; --accent: #1f5fbf;
  --green: #1ec31e; --red: #e00000; --header: #22303f;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.4 "Segoe UI", system-ui, -apple-system, sans-serif; color: var(--text); background: var(--bg); }
body.busy, body.busy * { cursor: progress !important; }
a { color: var(--accent); }
button, .button, select, input, textarea { font: inherit; }
button, .button {
  padding: 4px 10px; border: 1px solid #bababa; border-radius: 5px; background: #f3f3f3; cursor: pointer;
  color: var(--text); text-decoration: none; display: inline-block;
}
button:hover:not(:disabled), .button:hover { filter: brightness(0.96); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.green, .button.green { background: rgb(30, 255, 30); }
button.red { background: rgb(255, 0, 0); color: #fff; }
button.link { background: none; border: none; padding: 0; color: var(--accent); }
button.small { padding: 0 6px; }
input, select, textarea { padding: 3px 6px; border: 1px solid var(--border); border-radius: 4px; background: #fff; }
input[type="number"] { width: 90px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: #c00; }
.warning { color: #b46b00; }
.ok { color: #12802e; }
.mono { font-family: Consolas, "Courier New", monospace; font-size: 12px; }
.spacer { flex: 1; }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 4px 0; }
.inline { display: inline; }
label.block { display: block; margin-top: 6px; }

/* ---------- header ---------- */
.topbar { display: flex; align-items: center; gap: 18px; padding: 6px 14px; background: var(--header); color: #fff; }
.topbar a, .topbar button.link { color: #dbe6f5; }
.brand { font-weight: 700; letter-spacing: 0.5px; }
.mainnav { display: flex; gap: 14px; }
.mainnav a { text-decoration: none; padding: 3px 4px; }
.mainnav a.active { border-bottom: 2px solid #8fb8ff; color: #fff; }
.topbar-right { margin-left: auto; display: flex; gap: 14px; align-items: center; font-size: 13px; }
.langs a { text-decoration: none; }
.langs a.active { font-weight: 700; text-decoration: underline; }
.badge { background: #e45; color: #fff; border-radius: 9px; padding: 0 6px; font-size: 11px; }
.processor-status .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #999; margin-right: 4px; }
.processor-status.online .dot { background: #2ecc40; }
.processor-status.offline .dot { background: #ff4136; }

main { padding: 10px 14px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 12px 16px; margin-bottom: 12px; }
.panel.narrow { max-width: 600px; margin: 40px auto; }
.page-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.page-grid .wide { grid-column: 1 / -1; }
h2 { margin: 0 0 8px; font-size: 18px; }
h3 { margin: 10px 0 6px; font-size: 15px; }

/* ---------- login ---------- */
.login-box { max-width: 380px; margin: 80px auto; background: #fff; padding: 24px 28px; border-radius: 8px; border: 1px solid var(--border); }
.login-box label { display: block; margin: 10px 0; }
.login-box input { width: 100%; margin-top: 3px; }
.login-box button { width: 100%; margin-top: 8px; padding: 7px; }

/* ---------- results layout ---------- */
.results-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; height: calc(100vh - 62px); }
.pane { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 8px; display: flex; flex-direction: column; min-height: 0; }
.left-pane { border-right: 3px double #c8c8c8; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.project-select { min-width: 300px; max-width: 50%; }
.icon-btn { min-width: 52px; font-size: 12px; font-weight: 600; }
.table-wrap { overflow: auto; border: 1px solid var(--border); flex: 1 1 auto; min-height: 160px; }
table.results { border-collapse: collapse; width: 100%; font-size: 13px; }
table.results th { position: sticky; top: 0; background: #ececec; border: 1px solid #c8c8c8; padding: 3px 4px; font-weight: 600; font-size: 12px; }
table.results th.sortable { cursor: pointer; }
table.results th.asc::after { content: " ▲"; font-size: 9px; }
table.results th.desc::after { content: " ▼"; font-size: 9px; }
table.results td { border: 1px solid #ddd; padding: 2px 4px; text-align: center; white-space: nowrap; }
table.results tbody tr[data-key] { cursor: pointer; }
table.results tbody tr.selected td:nth-child(3) { outline: 2px solid var(--accent); outline-offset: -2px; font-weight: 600; }
table.results tr.select-all td { background: #fafafa; font-style: italic; }
.gear { padding: 0 6px; }
.legend-text { font-size: 12px; font-weight: 600; color: #333; margin: 6px 2px; }
.stat-errors { background: #fff4e5; border: 1px solid #f0c27a; padding: 4px 8px; font-size: 12px; margin-bottom: 6px; }
.options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; border-top: 1px solid var(--border); padding-top: 6px; }
.option-panel { border: none; border-left: 1px solid #c8c8c8; margin: 0; padding: 0 10px; }
.option-panel:first-child { border-left: none; }
.option-panel legend { font-weight: 600; font-size: 13px; padding: 0; }
.option-panel label { display: block; margin: 2px 0; }
.option-panel .row label { display: inline-block; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 4px; }
.reading-checks { display: flex; gap: 10px; overflow-x: auto; max-width: 520px; white-space: nowrap; border: 1px solid var(--border); padding: 2px 6px; border-radius: 4px; }
.chart { flex: 1 1 auto; min-height: 520px; }
.chart-note { background: #fff8e1; border: 1px solid #f0d27a; font-size: 12px; padding: 3px 8px; margin-bottom: 4px; }

@media (max-width: 1200px) {
  .results-layout { grid-template-columns: 1fr; height: auto; }
  .left-pane { border-right: 1px solid var(--border); }
  .table-wrap { max-height: 60vh; }
  .options { grid-template-columns: 1fr; }
  .option-panel { border-left: none; border-top: 1px solid #ddd; padding: 6px 0; }
  .page-grid { grid-template-columns: 1fr; }
  .project-select { min-width: 200px; max-width: 100%; }
}

/* ---------- dialogs ---------- */
dialog { border: 1px solid var(--border); border-radius: 8px; padding: 14px 18px; max-width: 95vw; box-shadow: 0 8px 30px rgba(0,0,0,0.25); }
dialog::backdrop { background: rgba(20, 30, 40, 0.35); }
dialog.small { width: 440px; }
dialog.large { width: 1100px; max-height: 90vh; }
dialog .buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
dialog .body { white-space: pre-wrap; max-height: 60vh; overflow: auto; }
dialog label { display: block; margin: 4px 0; }
.dialog-toolbar { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.ico { width: 16px; height: 16px; vertical-align: -3px; }
.dialog-table { max-height: 55vh; }
table.measurements { border-collapse: collapse; width: 100%; }
table.measurements th { position: sticky; top: 0; background: #ececec; border: 1px solid #c8c8c8; padding: 3px 6px; }
table.measurements th.clickable { cursor: pointer; text-decoration: underline dotted; }
table.measurements td { border: 1px solid #ddd; padding: 2px 6px; text-align: center; }
table.measurements td.editable { cursor: text; }
table.measurements td.edited { font-weight: 700; background: #fff3b0; }
table.measurements td input { width: 110px; }
table.measurements td.logo img { height: 24px; }
table.measurements tr.disqualified td { color: #9a9a9a; }
table.measurements tr.disqualified td.logo img { opacity: 0.35; }
.switch-layout { display: grid; grid-template-columns: 3fr 4fr; gap: 16px; }
.switch-list { list-style: none; padding: 0; margin: 0; border: 1px solid var(--border); min-height: 220px; max-height: 340px; overflow: auto; }
.switch-list li { padding: 3px 6px; display: flex; justify-content: space-between; align-items: center; }
.switch-list li label { margin: 0; }
.two-lists { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.two-lists select { width: 100%; }
.help { font-weight: 700; margin-left: 8px; }
.picker-list { list-style: none; padding: 0; margin: 0; border: 1px solid var(--border); max-height: 360px; overflow: auto; }
.picker-list li { padding: 2px 6px; }
dialog label.all { border: 1px solid var(--border); border-bottom: none; padding: 4px 6px; margin: 0; }

/* ---------- simple tables, forms ---------- */
table.simple { border-collapse: collapse; }
table.simple.wide, .wide { width: 100%; }
table.simple th, table.simple td { border: 1px solid #ddd; padding: 4px 6px; text-align: left; vertical-align: top; }
table.simple th { background: #f0f0f0; }
td.actions { white-space: nowrap; }
td.actions > * { margin: 1px 2px; }
.dropzone { border: 2px dashed #b8c2cc; border-radius: 8px; padding: 16px; text-align: center; margin-bottom: 10px; }
.dropzone.over { background: #eef5ff; border-color: var(--accent); }
.file-list { text-align: left; }
.import-progress { margin-top: 14px; }
.import-progress .state { font-weight: 600; margin-bottom: 6px; }
.history details { border-bottom: 1px solid #eee; padding: 4px 0; }
.history .delivery { margin: 4px 0 4px 14px; font-size: 13px; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }

.config-layout .toolbar h2 { margin: 0; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: 8px 0; }
.tab { border-radius: 5px 5px 0 0; border-bottom: none; background: #eee; }
.tab.active { background: #fff; font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px 16px; margin: 8px 0; }
.form-grid label { display: flex; flex-direction: column; font-size: 13px; }
.form-grid label.wide { grid-column: 1 / -1; }
.form-grid input[type="checkbox"] { width: auto; }
.form-grid label:has(input[type="checkbox"]) { flex-direction: row; gap: 6px; align-items: center; }
.edit-table input { width: 100%; }
textarea.wide { width: 100%; }
.cfg-message { padding: 6px 10px; border-radius: 4px; margin: 6px 0; white-space: pre-wrap; }
.cfg-message.ok { background: #e7f7ea; border: 1px solid #9ad3a6; }
.cfg-message.error { background: #fdecec; border: 1px solid #f1a9a9; }
.cfg-message.info { background: #eef4ff; border: 1px solid #b7cdf5; }

.help-box { background: #f6f9ff; border: 1px solid #c9d8f2; border-radius: 6px; padding: 6px 12px; margin: 8px 0; font-size: 13px; }
.help-box summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.help-box dl { margin: 6px 0; }
.help-box dt { font-weight: 600; margin-top: 6px; }
.help-box dd { margin: 2px 0 0 14px; }
.help-box ul { margin: 4px 0; }

[hidden] { display: none !important; }
