/* dti-tdm operátori felület — az UI látványterv design-rendszere (terv 7–8.).
   Téma-tudatos (light/dark), DTI arculat, mobil-first, nagy tap-célok. */
:root {
  --bg: #e7eae7; --content-bg: #f5f6f4; --surface: #ffffff; --surface-2: #f4f6f3;
  --text: #18201c; --muted: #667069; --border: #e2e6e2; --border-strong: #cdd4cd;
  --brand: #da1f1a; --ink: #14201b;
  --pass: #12855b; --fail: #c0392b; --warn: #b7791f; --info: #2f6f9f;
  --mono-bg: #f0f3ef; --shadow: 0 1px 2px rgba(20,32,27,.06), 0 8px 24px rgba(20,32,27,.06);
  --sans: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f0d; --content-bg: #0f1411; --surface: #161d19; --surface-2: #121815;
    --text: #dfe6e1; --muted: #8b978f; --border: #262f2a; --border-strong: #313c35;
    --brand: #e5352f; --pass: #3fbe86; --fail: #e57368; --warn: #d6a03f; --info: #5b9dd4;
    --mono-bg: #0e1512; --shadow: 0 1px 2px rgba(0,0,0,.35), 0 10px 28px rgba(0,0,0,.3);
  }
}
:root[data-theme="light"] { --bg:#e7eae7; --content-bg:#f5f6f4; --surface:#fff; --surface-2:#f4f6f3; --text:#18201c; --muted:#667069; --border:#e2e6e2; --border-strong:#cdd4cd; --brand:#da1f1a; --pass:#12855b; --fail:#c0392b; --warn:#b7791f; --info:#2f6f9f; --mono-bg:#f0f3ef; --shadow:0 1px 2px rgba(20,32,27,.06),0 8px 24px rgba(20,32,27,.06); }
:root[data-theme="dark"] { --bg:#0b0f0d; --content-bg:#0f1411; --surface:#161d19; --surface-2:#121815; --text:#dfe6e1; --muted:#8b978f; --border:#262f2a; --border-strong:#313c35; --brand:#e5352f; --pass:#3fbe86; --fail:#e57368; --warn:#d6a03f; --info:#5b9dd4; --mono-bg:#0e1512; --shadow:0 1px 2px rgba(0,0,0,.35),0 10px 28px rgba(0,0,0,.3); }

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.5;
  font-family: var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--info); text-decoration: none; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }

/* elrendezés: bal oldali menüsor (ink, DTI logó) + fő tartalom */
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: var(--ink); color: #c7d2cb; display: flex; flex-direction: column;
  gap: 3px; padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .logo { display: block; padding: 6px 10px 16px; line-height: 0; }
.sidebar .logo img { height: 128px; width: auto; display: block; }
.sidebar .nav { display: flex; flex-direction: column; gap: 3px; }
.sidebar .nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px;
  color: #c7d2cb; text-decoration: none; font-size: 14px; font-weight: 600; min-height: 44px; }
.sidebar .nav a .ic { width: 18px; text-align: center; opacity: .9; }
.sidebar .nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar .nav a.active { background: rgba(255,255,255,.11); color: #fff; box-shadow: inset 3px 0 0 var(--brand); }
.sb-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,.08); }
.sb-user { display: flex; align-items: center; gap: 9px; padding: 4px 8px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg,#3a5348,#25382e);
  color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.sb-user .n { font-size: 13px; color: #e6ece8; font-weight: 600; }
.sb-user .r { font-size: 11px; color: #8fa197; }
.sidebar button.link { background: none; border: none; color: #c7d2cb; font: inherit; font-size: 14px;
  font-weight: 600; padding: 10px 12px; cursor: pointer; min-height: 44px; border-radius: 9px;
  text-align: left; display: flex; align-items: center; gap: 10px; width: 100%; }
.sidebar button.link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar form { margin: 0; }

.main { min-width: 0; }
.wrap { max-width: 1040px; margin: 0; padding: 24px 28px 70px; }
h1 { font-size: clamp(20px, 3vw, 26px); margin: 6px 0 6px; letter-spacing: -.01em; font-weight: 680;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h1.sn { font-family: var(--mono); }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted);
  margin: 26px 0 12px; font-family: var(--mono); font-weight: 600; }
.crumb { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.crumb b { color: var(--text); }
.meta-row { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 8px 0; font-size: 12.5px;
  color: var(--muted); }
.meta-row b { color: var(--text); font-weight: 600; font-family: var(--mono); font-size: 12px; }

/* kártyák */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow: hidden; }
.card-head { padding: 14px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* stat-csempék */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px;
  margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; box-shadow: var(--shadow); }
.tile .lab { font-size: 12px; color: var(--muted); }
.tile .val { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: -.01em;
  font-variant-numeric: tabular-nums; }
.tile .sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.tile .stripe { height: 3px; border-radius: 3px; margin-top: 10px; }

/* táblák */
.tbl-wrap { overflow-x: auto; }
table.data { border-collapse: collapse; width: 100%; min-width: 560px; }
table.data th { text-align: left; font-family: var(--mono); font-size: 10.5px;
  letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 600;
  padding: 9px 12px; border-bottom: 1px solid var(--border); }
table.data td { padding: 11px 12px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--surface-2); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions .btn { min-height: 34px; padding: 5px 10px; font-size: 13px; margin-left: 4px; }
.data th.chk, .data td.chk { width: 36px; text-align: center; padding-right: 4px; }
.chk input[type=checkbox] { width: 18px; height: 18px; cursor: pointer; accent-color: var(--brand); }

/* jelvények */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border-strong);
  color: var(--muted); background: var(--surface); white-space: nowrap; font-family: var(--mono); }
.b-pass { color: var(--pass); border-color: color-mix(in srgb, var(--pass) 35%, transparent);
  background: color-mix(in srgb, var(--pass) 12%, transparent); }
.b-fail { color: var(--fail); border-color: color-mix(in srgb, var(--fail) 40%, transparent);
  background: color-mix(in srgb, var(--fail) 12%, transparent); }
.b-warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent);
  background: color-mix(in srgb, var(--warn) 13%, transparent); }
.b-info { color: var(--info); border-color: color-mix(in srgb, var(--info) 40%, transparent);
  background: color-mix(in srgb, var(--info) 12%, transparent); }
.b-device { color: #fff; background: var(--ink); border: none; }

/* gombok — nagy tap-célok */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px; border-radius: 10px; font-size: 15px; font-weight: 600;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none; font-family: var(--sans); }
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { filter: brightness(1.06); }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn[disabled], .btn:disabled { cursor: not-allowed; opacity: .55; }
.btn[disabled]:hover { border-color: var(--border-strong); }
.btn-primary[disabled], .btn-primary:disabled { background: var(--border-strong);
  border-color: var(--border-strong); color: var(--muted); filter: none; }
.btn-sm { min-height: 40px; padding: 8px 13px; font-size: 13px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }

/* split-gomb: fő művelet + lenyíló opciók (natív <details>, JS csak a kívülre-zárás) */
.split { display: inline-flex; position: relative; }
.split > .btn:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.split-drop { display: inline-flex; }
.split-drop > summary { list-style: none; cursor: pointer; }
.split-drop > summary::-webkit-details-marker { display: none; }
.split-caret { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px;
  padding-left: 12px; padding-right: 12px; gap: 0; }
.split-caret { border-left-color: rgba(255,255,255,.4); }
.split-drop[open] > .split-caret { filter: brightness(1.06); }
.split-menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 60;
  min-width: 220px; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 10px; box-shadow: var(--shadow); padding: 6px; }
.split-menu a { display: block; padding: 8px 12px; border-radius: 7px; text-decoration: none;
  color: var(--text); font-size: 14px; font-weight: 600; }
.split-menu a:hover { background: var(--surface-2); }

/* tétel-részletek: fő + jobb sáv */
.detail { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
.rail { display: flex; flex-direction: column; gap: 14px; }
.facts { list-style: none; margin: 0; padding: 0; }
.facts li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0;
  border-bottom: 1px solid var(--border); font-size: 12.5px; }
.facts li:last-child { border-bottom: none; }
.facts .k { color: var(--muted); } .facts .v { font-family: var(--mono); font-size: 12px; text-align: right; }

/* teszt-futás kártya */
.run { border: 1px solid var(--border); border-radius: 12px; margin-bottom: 14px; overflow: hidden;
  background: var(--surface); box-shadow: var(--shadow); }
.run-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  background: var(--surface-2); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.run-head .t { font-weight: 650; font-size: 14px; }
.run-head .v { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.run-head .sp { flex: 1; }
.run-foot { padding: 8px 16px 12px; font-size: 12px; color: var(--muted); }

/* teszt-típus csoport: legfrissebb futás fent, a többi lenyitható */
.test-group { margin-bottom: 14px; }
.test-group .run { margin-bottom: 0; }
.test-group-older { margin-top: 8px; }
.test-group-older > summary { list-style: none; cursor: pointer; font-size: 12.5px;
  font-weight: 600; color: var(--muted); padding: 4px 2px; }
.test-group-older > summary::-webkit-details-marker { display: none; }
.test-group-older > summary::before { content: "▸ "; }
.test-group-older[open] > summary::before { content: "▾ "; }
.test-group-older[open] > summary { margin-bottom: 10px; }
.test-group-older .run { margin-bottom: 10px; }
.test-group-older .run:last-child { margin-bottom: 0; }

/* genealógia */
.gen-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px;
  background: var(--surface); flex-wrap: wrap; }
.gen-item .ic { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center;
  background: var(--surface-2); font-size: 16px; flex: none; }
.gen-item .info { min-width: 0; flex: 1; }
.gen-item .id { font-family: var(--mono); font-size: 14px; font-weight: 600; }
.gen-item .id.txt { font-family: var(--sans); font-size: 15px; }
.gen-item .sub { font-size: 12px; color: var(--muted); margin-top: 1px; width: 100%; }
.qty { font-family: var(--mono); font-weight: 700; font-size: 14px; margin-left: auto; }
.gen-actions { display: flex; gap: 4px; margin-left: 10px; }
.gen-actions .btn { min-height: 34px; padding: 5px 10px; font-size: 13px; }

/* címke-előnézet (csak QR) */
.label-only { background: #fff; border: 1px solid #d5dbd6; border-radius: 8px; padding: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; }
.label-only img { width: 104px; height: 104px; }
/* 17px ≈ a QR szélessége (104px) 10 monospace karakterrel — a generált azonosító
   (GENERATED_ID_LENGTH=10) pont kitölti, hosszabb azonosítónál a width+overflow vág. */
.label-only .cap { font-family: var(--mono); font-weight: 600; color: var(--text);
  font-size: 17px; width: 104px; text-align: center; white-space: nowrap; overflow: hidden; }
.printer { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted);
  margin: 12px 0; }

/* timeline (log note) */
.tl { position: relative; padding-left: 22px; }
.tl::before { content: ""; position: absolute; left: 7px; top: 4px; bottom: 4px; width: 2px;
  background: var(--border); }
.tl-item { position: relative; margin-bottom: 16px; }
.tl-item::before { content: ""; position: absolute; left: -19px; top: 5px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--muted); }
.tl-item.deviation::before, .tl-item.rework::before { border-color: var(--warn); background: var(--warn); }
.tl-item.incident::before { border-color: var(--fail); background: var(--fail); }
.tl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; }
.tl-head .who { font-weight: 650; } .tl-head .when { color: var(--muted); }
.tl-actions { margin-left: auto; display: inline-flex; gap: 6px; }
.tl-actions .btn { min-height: 30px; padding: 4px 9px; font-size: 13px; }
.tl-body { font-size: 13.5px; margin-top: 5px; }
.tl-item img { max-width: 140px; max-height: 100px; border-radius: 8px;
  border: 1px solid var(--border); margin: 8px 6px 0 0; }

/* keresés / szkennelés */
.search-bar { display: flex; gap: 8px; margin-bottom: 14px; }
.search-bar input { flex: 1; }

/* űrlapok — érintésre méretezve */
form p { margin: 0 0 12px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=number], input[type=password], input[type=datetime-local],
input[type=email], select, textarea { width: 100%; padding: 12px; font-size: 16px;
  border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font-family: inherit; min-height: 48px; }
textarea { min-height: 120px; line-height: 1.6; font-family: var(--mono); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.help { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* mező + ikon-gomb (pl. Odoo-szinkron a cikkszám mellett) */
.field-sync { display: flex; gap: 8px; align-items: stretch; }
.field-sync > input { flex: 1 1 auto; min-width: 0; }
.btn-icon { flex: 0 0 auto; min-width: 48px; padding: 10px 12px; font-size: 19px; }
.btn-icon .ic { display: inline-block; line-height: 1; }
.btn-icon.loading { pointer-events: none; opacity: .7; }
.btn-icon.loading .ic { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.errorlist { color: var(--fail); font-size: 13px; margin: 4px 0; padding-left: 18px; }

/* üzenetek */
.messages { list-style: none; padding: 0; margin: 0 0 14px; }
.messages li { padding: 12px 14px; border-radius: 10px; margin-bottom: 8px; font-size: 14px;
  border: 1px solid var(--border-strong); background: var(--surface); }
.messages li.success { color: var(--pass); border-color: color-mix(in srgb, var(--pass) 35%, transparent);
  background: color-mix(in srgb, var(--pass) 12%, transparent); }
.messages li.error { color: var(--fail); border-color: color-mix(in srgb, var(--fail) 40%, transparent);
  background: color-mix(in srgb, var(--fail) 12%, transparent); }
.messages li.warning { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent);
  background: color-mix(in srgb, var(--warn) 13%, transparent); }

/* oldal-fejléc: cím balra, akció-gomb a jobb felső sarokban */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  margin-bottom: 6px; }
.page-head .ph-main { min-width: 0; }
.page-head .ph-main h1 { margin-top: 0; }
.page-head > .btn { flex: none; margin-top: 2px; }

/* modális ablak — egyedi (nem natív <dialog>), hogy a kamera-overlay (z-index 1000)
   fölé kerülhessen; háttérre / ✕ / Esc zár. */
.modal-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(10,15,12,.5);
  display: grid; place-items: start center; padding: 6vh 16px 24px; overflow-y: auto; }
.modal-overlay[hidden] { display: none; }
.modal { width: min(560px, 96vw); background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 15px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; }
.modal-body { padding: 16px 18px; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 20px; cursor: pointer;
  line-height: 1; padding: 4px 9px; border-radius: 8px; min-height: 40px; }
.modal-close:hover { background: var(--surface-2); color: var(--text); }

/* szegmens-kapcsoló (két felviteli mód a komponens-modálban) */
.seg { display: flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 4px; margin-bottom: 14px; }
.seg-btn { flex: 1; min-height: 40px; border: none; background: none; color: var(--muted);
  font: inherit; font-weight: 600; font-size: 13px; border-radius: 7px; cursor: pointer; }
.seg-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

@media (max-width: 720px) {
  .detail { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head > .btn { width: 100%; }
  /* menüsor mobilon felül, vízszintesen */
  .layout { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; height: auto; position: sticky; top: 0; z-index: 20;
    align-items: center; overflow-x: auto; gap: 2px; padding: 8px 10px; }
  .sidebar .logo { padding: 4px 8px; }
  .sidebar .logo img { height: 72px; }
  .sidebar .nav { flex-direction: row; }
  .sidebar .nav a { padding: 8px 10px; font-size: 13px; }
  .sidebar .nav a .ic { display: none; }
  .sidebar .nav a.active { box-shadow: inset 0 -3px 0 var(--brand); }
  .sb-bottom { margin: 0 0 0 auto; flex-direction: row; align-items: center;
    border-top: none; padding-top: 0; gap: 2px; }
  .sb-user { display: none; }
  .wrap { padding: 16px 14px 70px; }
}
