:root {
  --bg: #eef0f4; --panel: #ffffff; --ink: #18202b; --muted: #66707d;
  --line: #e1e5ea; --accent: #2f6fed; --red: #d64545; --radius: 10px;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body { font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }

#topbar { display: flex; align-items: center; gap: 12px; height: 58px; padding: 0 18px; background: var(--panel); border-bottom: 1px solid var(--line); }
#logo { height: 40px; display: block; }
.spacer { flex: 1; }
#lang-sel { -webkit-appearance: none; appearance: none; padding: 6px 28px 6px 11px; border: 1px solid var(--line); border-radius: 8px; background-color: #fbfcfd; background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2366707d' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 10px 6px; font-size: 12.5px; font-weight: 600; color: var(--ink); cursor: pointer; }

#layout { display: flex; height: calc(100vh - 58px); }
#sidebar { width: 372px; min-width: 320px; background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; display: flex; flex-direction: column; }
#sidebar section { padding: 14px 16px; border-bottom: 1px solid var(--line); }
#sidebar h2, .panel-head h2 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); margin-bottom: 10px; }
.panel-head h2 { margin-bottom: 0; }

.sechead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sechead h2 { margin-bottom: 0; }
button.plus { width: 26px; height: 26px; border-radius: 8px; border: 0; background: var(--accent); color: #fff; cursor: pointer; display: grid; place-items: center; padding: 0; }
button.plus:hover { filter: brightness(1.08); }

.cgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cgrid label { font-size: 11px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
input, button { font: inherit; }
input[type="number"], input[type="text"] { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; font-size: 13px; background: #fbfcfd; color: var(--ink); }
input:focus { outline: 2px solid #c7d7fb; border-color: var(--accent); }
.cargo { grid-column: 1 / -1; font-size: 12px; color: var(--muted); padding-top: 2px; }

.prow { display: flex; align-items: center; gap: 9px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.prow:last-child { border-bottom: 0; }
.chip { width: 13px; height: 13px; border-radius: 4px; flex: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.15); }
.pinfo { flex: 1; min-width: 0; }
.pname { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cbadge { display: inline-block; font-size: 9.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; padding: 1px 6px; border-radius: 999px; background: #fff3d6; color: #8a6d1a; vertical-align: 1px; }
.pdims { font-size: 11px; color: var(--muted); }
input.qty { width: 58px; flex: none; text-align: center; }
button.del { flex: none; width: 24px; height: 24px; border: 0; background: transparent; color: var(--muted); font-size: 16px; line-height: 1; border-radius: 6px; cursor: pointer; }
button.del:hover { background: #fdecec; color: var(--red); }

#topbar button.ghost { flex: none; }
.chk { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink); }
.chk input { width: auto; }
button.edit { flex: none; width: 24px; height: 24px; border: 0; background: transparent; color: var(--muted); font-size: 13px; line-height: 1; border-radius: 6px; cursor: pointer; }
button.edit:hover { background: #eef4ff; color: var(--accent); }
.prow.editing { background: #f5f8ff; border-radius: 8px; padding-left: 4px; padding-right: 4px; }
#job-name { margin-bottom: 8px; }
input.invalid { border-color: var(--red); background: #fff6f6; }
.form-err { color: var(--red); font-size: 12px; }
button.danger { border-color: var(--red) !important; color: var(--red) !important; }

#add-form { margin-bottom: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #f8fafc; }
.addgrid { display: flex; flex-direction: column; gap: 8px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.dims4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }

.searchwrap { position: relative; margin-bottom: 8px; }
.drop { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12); z-index: 20; max-height: 260px; overflow-y: auto; }
.drop-item { padding: 7px 10px; cursor: pointer; display: flex; flex-direction: column; gap: 1px; border-bottom: 1px solid #f1f3f6; }
.drop-item:last-child { border-bottom: 0; }
.drop-item b { font-size: 13px; font-weight: 600; }
.drop-item span { font-size: 11px; color: var(--muted); }
.drop-item.active, .drop-item:hover { background: #eef4ff; }
.drop-empty { padding: 9px 10px; font-size: 12px; color: var(--muted); }

.vtabs { display: flex; gap: 6px; margin-bottom: 8px; }
.vtab { flex: 1; padding: 6px 4px; border: 1px solid var(--line); border-radius: 9px; background: #fbfcfd; cursor: pointer; display: flex; flex-direction: column; gap: 1px; align-items: center; }
.vtab span { font-size: 12.5px; font-weight: 700; }
.vtab small { font-size: 10.5px; color: var(--muted); }
.vtab.on { border-color: var(--accent); background: #eef4ff; }
.vtab.on span { color: var(--accent); }
#variant-desc { margin-bottom: 8px; }
#np-add { padding: 8px 10px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 600; font-size: 13px; cursor: pointer; }
#np-add:hover { filter: brightness(1.07); }

.summary { font-size: 13px; margin-bottom: 4px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.pcard { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-top: 10px; }
.pcard-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; margin-bottom: 8px; }
.pcard-head span { color: var(--muted); font-size: 11.5px; }
.bar { height: 6px; border-radius: 4px; background: #eceff3; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.bar.over i { background: var(--red); }
.bar-label { font-size: 11px; color: var(--muted); margin: 3px 0 7px; }
.warn { background: #fdecec; color: #8c2f2f; border-radius: 8px; padding: 9px 11px; font-size: 12px; margin-top: 10px; }

#sidebar footer { padding: 14px 16px; margin-top: auto; }
button.ghost { padding: 7px 10px; border: 1px solid var(--line); background: transparent; border-radius: 8px; font-size: 12.5px; color: var(--muted); cursor: pointer; }
button.ghost:hover { color: var(--ink); border-color: #c6ccd4; }
.hint { font-size: 11px; color: var(--muted); margin-top: 9px; }

#viewport { flex: 1; position: relative; min-width: 0; overflow: hidden; }
#viewport canvas { display: block; }
#tooltip { position: absolute; z-index: 6; background: #141c28; color: #eef2f7; font-size: 12px; line-height: 1.4; padding: 7px 10px; border-radius: 7px; pointer-events: none; box-shadow: 0 4px 14px rgba(10, 16, 24, 0.25); max-width: 260px; }
#banner { position: absolute; z-index: 5; top: 12px; left: 50%; transform: translateX(-50%); background: #fff7de; border: 1px solid #eadfb0; color: #6b5b13; padding: 8px 14px; border-radius: 8px; font-size: 12.5px; white-space: nowrap; }

#view-label { position: absolute; z-index: 5; top: 12px; right: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; box-shadow: 0 4px 14px rgba(10, 16, 28, 0.08); display: flex; flex-direction: column; gap: 1px; align-items: flex-end; text-align: right; }
#view-label b { font-size: 13px; }
#view-label span { font-size: 11px; color: var(--muted); }
.pdata { font-size: 11.5px; color: var(--muted); margin-top: 4px; border-top: 1px dashed var(--line); padding-top: 6px; line-height: 1.55; }
.pdata b { color: var(--ink); font-weight: 600; }

/* catalog in the header */
.cat-btn { display: flex; align-items: center; gap: 7px; }
.cat-btn svg { display: block; }
.xbtn { width: 28px; height: 28px; padding: 0 !important; display: grid; place-items: center; font-size: 15px; }
#catalog-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.25); z-index: 40; }
#catalog-panel { position: fixed; top: 66px; right: 14px; width: 400px; max-width: calc(100vw - 20px); max-height: calc(100vh - 80px); overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 18px 50px rgba(10, 16, 28, 0.18); z-index: 41; padding: 14px 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.panel-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.panel-actions { display: flex; gap: 8px; align-items: center; }
.delbtn { padding: 8px 10px; border: 1px solid #f0c4c4; background: #fff; color: var(--red); border-radius: 8px; font-weight: 600; font-size: 13px; cursor: pointer; }
.delbtn:hover { background: #fdecec; }
.delbtn.armed { background: var(--red); border-color: var(--red); color: #fff; }
.import-note { font-size: 12px; margin-top: 8px; color: #1d7a34; }
.import-note.err { color: var(--red); }
#import-hint { margin-top: 8px; }

/* version & changelog */
.linklike { border: 0; background: none; padding: 0; margin-top: 10px; font-size: 11.5px; color: var(--muted); cursor: pointer; text-align: left; display: block; text-decoration: none; }
.linklike:hover { color: var(--ink); text-decoration: underline; }
.foot-row { display: flex; gap: 14px; align-items: baseline; }
.foot-row .linklike { margin-top: 10px; }
.xbtn.okflash { color: #1d7a34; border-color: #bfe3c8; }
#changelog-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.25); z-index: 40; }
#changelog-panel { position: fixed; left: 14px; bottom: 14px; width: 440px; max-width: calc(100vw - 20px); max-height: 62vh; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 18px 50px rgba(10, 16, 28, 0.18); z-index: 41; padding: 14px 16px; }
.cl-ver { display: flex; justify-content: space-between; align-items: baseline; margin: 14px 0 4px; }
.cl-ver b { font-size: 13px; }
.cl-ver span { font-size: 11px; color: var(--muted); }
#changelog-list > .cl-ver:first-child { margin-top: 0; }
#changelog-list ul { margin: 0 0 4px 18px; padding: 0; font-size: 12.5px; line-height: 1.55; color: var(--ink); }

/* mobile */
@media (max-width: 860px) {
  #topbar { height: 52px; padding: 0 10px; gap: 8px; }
  #logo { height: 30px; }
  .cat-btn span { display: none; }
  #layout { height: calc(100vh - 52px); flex-direction: column; }
  #viewport { order: -1; height: 44%; min-height: 260px; flex: none; }
  #sidebar { width: 100%; min-width: 0; flex: 1; border-right: 0; border-top: 1px solid var(--line); }
  input[type="number"], input[type="text"] { font-size: 16px; } /* prevents iOS focus zoom */
  #catalog-panel { top: 58px; left: 8px; right: 8px; width: auto; max-height: calc(100vh - 70px); }
  #changelog-panel { left: 8px; right: 8px; bottom: 8px; width: auto; }
}
