/* OnCue Planner – OnCue look: dark #0b0d10, green #3fc883, Inter */
:root { --bg: #0b0d10; --panel: #11151a; --panel2: #161b21; --line: #232a33; --text: #e8ecf1; --sub: #8b95a3; --green: #3fc883; --greenD: #2aa86b; --warn: #ffb547; --err: #ff6b6b;
  --font: Inter, 'Segoe UI', system-ui, -apple-system, sans-serif; }
body[data-theme="light"] { --bg: #f4f6f8; --panel: #ffffff; --panel2: #f1f3f5; --line: #dde2e7; --text: #11151a; --sub: #5b6570; --green: #16804f; --greenD: #11653e; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 13px/1.4 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
.sub { color: var(--sub); font-size: 12px; }
.grow { flex: 1; }
.err { color: var(--err); } .warn { color: var(--warn); }

/* top bar */
.top { height: 52px; display: flex; align-items: center; gap: 8px; padding: 0 10px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 7px; font-size: 15px; white-space: nowrap; margin-right: 6px; }
.brand b { color: var(--green); }
.plan-name { background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 5px 8px; font-size: 15px; font-weight: 600; min-width: 160px; width: 26vw; max-width: 380px; }
.plan-name:hover, .plan-name:focus { border-color: var(--line); outline: none; background: var(--panel2); }
.save-state { font-size: 11px; color: var(--sub); white-space: nowrap; } .save-state.ok { color: var(--green); } .save-state.err { color: var(--err); }
.tb-group { display: flex; gap: 2px; padding-left: 6px; border-left: 1px solid var(--line); align-items: center; }
.tb-btn { background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 6px 8px; cursor: pointer; white-space: nowrap; }
.tb-btn:hover { background: var(--panel2); border-color: var(--line); } .tb-btn:disabled { opacity: .35; cursor: default; }
.tb-btn.ai { color: #0b0d10; background: var(--green); font-weight: 600; } .tb-btn.ai:hover { background: var(--greenD); color: #fff; }
@media (max-width: 1350px) { .tb-btn { font-size: 0; padding: 6px 9px; } .tb-btn::first-letter { font-size: 15px; } .tb-btn.ai { font-size: 13px; } #user { display: none; } }

/* layout */
.main { display: flex; height: calc(100% - 52px); }
.left { width: 268px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.right { width: 300px; background: var(--panel); border-left: 1px solid var(--line); overflow: auto; }
.stage { flex: 1; position: relative; min-width: 0; }
.canvas { width: 100%; height: 100%; display: block; touch-action: none; user-select: none; cursor: default; }
.canvas.grab { cursor: grab; } .canvas.panning { cursor: grabbing; }
.canvas [data-kind="node"] { cursor: move; } .canvas [data-part="zonehead"] { cursor: move; } .canvas [data-kind="cable"] { cursor: pointer; }
.canvas [data-kind="port"]:hover .connname { opacity: 1; }
.zoom { position: absolute; right: 12px; bottom: 12px; display: flex; align-items: center; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
.zoom button { background: none; border: 0; width: 30px; height: 28px; border-radius: 5px; cursor: pointer; font-size: 15px; } .zoom button:hover { background: var(--panel2); }
.zoom span { min-width: 44px; text-align: center; font-size: 12px; color: var(--sub); }
.count { position: absolute; left: 12px; bottom: 12px; }

/* library */
.lib-tabs { display: flex; padding: 8px 8px 0; gap: 4px; }
.lib-tabs button { flex: 1; background: none; border: 0; border-bottom: 2px solid transparent; padding: 7px; cursor: pointer; color: var(--sub); font-weight: 600; }
.lib-tabs button.on { color: var(--text); border-color: var(--green); }
.search { width: 100%; background: var(--panel2); border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; margin: 8px 0; }
.left .search { margin: 8px; width: calc(100% - 16px); }
.library { overflow: auto; padding: 0 8px 20px; flex: 1; }
.cat-h { width: 100%; text-align: left; background: none; border: 0; padding: 8px 4px; font-weight: 700; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--sub); cursor: pointer; display: flex; }
.cat-h span { margin-left: auto; font-weight: 500; } .cat-h::before { content: '▸'; margin-right: 6px; } .cat.open .cat-h::before { content: '▾'; }
.cat-items { display: none; } .cat.open .cat-items { display: block; }
.lib-item { display: flex; align-items: center; gap: 9px; padding: 6px 7px; border-radius: 7px; cursor: grab; border: 1px solid transparent; }
.lib-item:hover { background: var(--panel2); border-color: var(--line); }
.lib-item .ico { width: 30px; height: 30px; border-radius: 7px; background: var(--panel2); display: grid; place-items: center; flex: none; border: 1px solid var(--line); }
.lib-item .t { display: flex; flex-direction: column; min-width: 0; } .lib-item .t b { font-weight: 600; } .lib-item small { color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-item .icon-btn { margin-left: auto; opacity: 0; } .lib-item:hover .icon-btn { opacity: 1; }
.preset { position: relative; padding: 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; background: var(--panel2); }
.preset:hover { border-color: var(--green); } .preset small { color: var(--sub); } .preset .icon-btn { position: absolute; right: 6px; top: 6px; }

/* properties */
.props { padding: 12px 14px 30px; }
.props h3 { margin: 2px 0 12px; font-size: 14px; } .props h4, .modal h4 { margin: 16px 0 6px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--sub); }
.fld { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; flex: 1; min-width: 0; } .fld > span { font-size: 11px; color: var(--sub); }
input:not([type="checkbox"]):not([type="color"]):not([type="file"]), select, textarea { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--green) 50%, transparent); border-color: var(--green); }
input[type="color"] { width: 100%; height: 31px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel2); padding: 2px; }
textarea { resize: vertical; }
.row2, .row3 { display: flex; gap: 8px; align-items: flex-end; } .row2 > .btn { flex: 1; }
.hint { color: var(--sub); font-size: 12px; margin-top: 14px; line-height: 1.5; }
.route { background: var(--panel2); border-radius: 6px; padding: 8px; margin: 0 0 10px; }
table.ports { width: 100%; border-collapse: collapse; margin-bottom: 8px; } table.ports th { text-align: left; font-size: 10px; color: var(--sub); font-weight: 500; padding: 2px; }
table.ports td { padding: 2px; } table.ports input, table.ports select { padding: 4px 5px; font-size: 12px; } table.ports td:last-child { white-space: nowrap; }
.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 7px; padding: 7px 12px; cursor: pointer; font-weight: 500; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover { border-color: var(--sub); } .btn.primary { background: var(--green); border-color: var(--green); color: #0b0d10; font-weight: 600; } .btn.primary:hover { background: var(--greenD); color: #fff; }
.btn.danger { color: var(--err); } .btn.danger:hover { border-color: var(--err); } .btn.small { padding: 5px 9px; font-size: 12px; margin: 3px 0; } .btn.wide { width: 100%; margin-bottom: 4px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-col { display: flex; flex-direction: column; gap: 6px; } .btn-col .btn { justify-content: flex-start; }
.icon-btn { background: none; border: 0; cursor: pointer; padding: 2px 5px; border-radius: 5px; color: var(--sub); } .icon-btn:hover { color: var(--text); background: var(--panel2); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0 10px; }
.chip { background: var(--panel2); border: 1px solid var(--line); border-radius: 20px; padding: 3px 10px; font-size: 12px; cursor: pointer; } .chip:hover { border-color: var(--green); }
.check { display: flex; gap: 7px; align-items: center; margin: 6px 0; cursor: pointer; } .checks { display: flex; flex-wrap: wrap; gap: 4px 18px; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; width: 480px; max-width: 100%; max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
.modal.wide { width: 920px; }
.modal header { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); } .modal h2 { margin: 0; font-size: 16px; flex: 1; }
.modal-body { padding: 14px 18px; overflow: auto; } .modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.modal p { margin: 0 0 10px; }
body.locked .main, body.locked .top { filter: blur(3px); pointer-events: none; }
.tabs { display: flex; gap: 4px; align-items: center; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px; cursor: pointer; color: var(--sub); font-weight: 600; } .tab.on { color: var(--text); border-color: var(--green); }
table.list { width: 100%; border-collapse: collapse; } table.list th { text-align: left; font-size: 11px; color: var(--sub); font-weight: 600; padding: 6px; border-bottom: 1px solid var(--line); }
table.list td { padding: 6px; border-bottom: 1px solid var(--line); vertical-align: top; } table.list td.num { font-weight: 700; width: 50px; }
table.list tr.sec td { font-weight: 700; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--green); padding-top: 14px; }
table.list.rm select { padding: 3px 5px; font-size: 12px; }
.rm-list { max-height: 220px; overflow: auto; display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.rm-proj { text-align: left; background: var(--panel2); border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; cursor: pointer; display: flex; justify-content: space-between; } .rm-proj:hover { border-color: var(--green); }
.builder { display: grid; grid-template-columns: 1fr 260px; gap: 18px; } .gb-preview { background: var(--panel2); border-radius: 8px; padding: 8px; } .gb-preview svg { width: 100%; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, 36px); gap: 4px; margin-bottom: 6px; }
.icon-pick { width: 36px; height: 36px; display: grid; place-items: center; background: var(--panel2); border: 1px solid var(--line); border-radius: 7px; cursor: pointer; color: var(--sub); }
.icon-pick.on { border-color: var(--green); color: var(--green); }
.row-add { display: flex; gap: 6px; align-items: center; } .row-add input[type=number] { width: 64px !important; flex: none; } .row-add select { width: auto !important; flex: none; } .row-add #gb-pname { flex: 1; }
.status-list { list-style: none; padding: 0; margin: 0 0 6px; } .status-list li { padding: 3px 0; }
.keys td:first-child { white-space: nowrap; font-weight: 600; }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--green); border-radius: 50%; animation: sp .8s linear infinite; vertical-align: -2px; }
@keyframes sp { to { transform: rotate(360deg); } }

/* toasts */
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 80; align-items: center; pointer-events: none; }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--sub); padding: 9px 14px; border-radius: 8px; box-shadow: 0 8px 30px rgba(0, 0, 0, .4); transition: opacity .4s; max-width: 560px; }
.toast.ok { border-left-color: var(--green); } .toast.warn { border-left-color: var(--warn); } .toast.err { border-left-color: var(--err); } .toast.out { opacity: 0; }

/* read-only share view */
body.readonly .edit-only { display: none !important; } body.readonly .plan-name { pointer-events: none; }

/* print */
#print-root { display: none; }
@media print {
  body > *:not(#print-root) { display: none !important; }
  html, body { background: #fff !important; height: auto; }
  #print-root { display: block; color: #11151a; font-family: var(--font); }
  #print-root[data-theme="dark"] .pr-page { background: #0b0d10; color: #e8ecf1; }
  .pr-page { page-break-after: always; break-after: page; display: flex; flex-direction: column; height: 190mm; }
  .paper-A3 .pr-page { height: 277mm; }
  .pr-page.list { height: auto; min-height: 190mm; display: block; }
  .paper-A3 .pr-page.list { min-height: 277mm; }
  .pr-page.list .tb { break-inside: avoid; }
  .pr-page table.list tr { break-inside: avoid; }
  .pr-page.list .pr-content { overflow: visible; }
  .pr-page:last-child { page-break-after: auto; break-after: auto; }
  .pr-content { flex: 1; min-height: 0; overflow: hidden; }
  .pr-page.schema .pr-content { position: relative; } .pr-schema { position: absolute; inset: 0; } .pr-schema svg { width: 100%; height: 100%; display: block; }
  .pr-page.list h2 { font-size: 15pt; margin: 0 0 4mm; }
  .pr-page table.list { font-size: 9pt; } .pr-page table.list td, .pr-page table.list th { padding: 1.4mm 2mm; border-bottom: .2mm solid #c8ced5; }
  .pr-page table.list .sub { color: #56606c; font-size: 8pt; } .pr-page tr.sec td { color: #16804f; } td.box { font-size: 12pt; width: 8mm; }
  .tb { display: grid; grid-template-columns: 34mm 1fr repeat(6, auto) 24mm; gap: 0; border: .3mm solid #8f99a6; margin-top: 3mm; font-size: 8.5pt; align-items: stretch; }
  .tb > div { padding: 1.6mm 3mm; border-left: .3mm solid #8f99a6; display: flex; flex-direction: column; justify-content: center; } .tb > div:first-child { border-left: 0; }
  .tb-logo img { max-height: 10mm; max-width: 30mm; object-fit: contain; } .tb-logo b { font-size: 13pt; letter-spacing: .08em; }
  .tb-main b { font-size: 11pt; } .tb-f span, .tb-main span { font-size: 6.5pt; text-transform: uppercase; letter-spacing: .05em; color: #56606c; }
  .tb-brand { font-size: 7pt; color: #16804f; font-weight: 700; text-align: center; }
}

.radios { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.radio { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; background: var(--panel2); }
.radio.on { border-color: var(--green); } .radio input { margin-top: 3px; accent-color: var(--green); } .radio span { display: flex; flex-direction: column; gap: 2px; } .radio small { color: var(--sub); }
