/* Product Information Manager - styles */
:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --ink: #1c2430;
  --ink-2: #4b5563;
  --muted: #8a93a1;
  --line: #e2e5ea;
  --accent: #1f5f8b;
  --accent-ink: #ffffff;
  --accent-soft: #e6eff6;
  --green: #1f9d55;
  --green-soft: #e4f5ea;
  --red: #d64545;
  --red-soft: #fbe9e9;
  --amber: #c27c0e;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
h3.sub { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); margin-top: 1.2rem; }
.mt { margin-top: 2rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
img { max-width: 100%; }

/* ------------------------------------------------ top bar */
.topbar {
  display: flex; align-items: center; gap: 1.5rem; padding: 0 1.5rem; height: 58px;
  background: #16212e; color: #fff; position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; font-weight: 600; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center; background: var(--accent); color: #fff; font-weight: 800;
  font-size: .75rem; letter-spacing: .06em; width: 38px; height: 30px; border-radius: 6px;
}
.brand-mark.big { width: 64px; height: 48px; font-size: 1.1rem; margin: 0 auto .5rem; display: grid; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 32vw; }
.mainnav { display: flex; gap: .25rem; flex: 1; }
.mainnav a { color: #c4ccd6; padding: .45rem .8rem; border-radius: 6px; }
.mainnav a:hover { background: #223143; color: #fff; text-decoration: none; }
.mainnav a.on { background: #2b3d52; color: #fff; }
.userbox { display: flex; align-items: center; gap: 1rem; font-size: .9rem; }
.userbox a { color: #c4ccd6; }
.role { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; padding: 2px 6px; border-radius: 4px;
        background: #e5e7eb; color: #374151; vertical-align: middle; }
.topbar .role { background: #2b3d52; color: #c4ccd6; }
.role-admin { background: #fde8d7; color: #9a4a0a; }
.role-editor { background: var(--accent-soft); color: var(--accent); }

.wrap { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }
.foot { text-align: center; color: var(--muted); font-size: .75rem; padding: 2rem 0; }

/* ------------------------------------------------ cards, flash, misc */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem 1.5rem; margin-bottom: 1rem; }
.card.narrow, .narrow { max-width: 720px; }
.flash { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.flash-ok { background: var(--green-soft); color: #14653a; }
.flash-err { background: var(--red-soft); color: #a12828; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: .25rem; }
.page-head { display: flex; justify-content: space-between; align-items: center; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); background: var(--card); border-radius: var(--radius); }
.tag { display: inline-block; font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 999px;
       background: #eceef2; color: var(--ink-2); vertical-align: middle; }
.tag-green { background: var(--green-soft); color: #14653a; }
.tag-blue { background: var(--accent-soft); color: var(--accent); }
a.tag:hover { text-decoration: none; filter: brightness(.96); }
.count { font-size: .72rem; background: #eceef2; color: var(--ink-2); border-radius: 999px; padding: 1px 7px; margin-left: 2px; }

.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: middle; }
.dot-red { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.dot-green { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.status-pill { display: inline-flex; align-items: center; gap: .45rem; font-size: .85rem; font-weight: 600; padding: 4px 12px 4px 8px; border-radius: 999px; }
.status-pill.green { background: var(--green-soft); color: #14653a; }
.status-pill.red { background: var(--red-soft); color: #a12828; }

/* ------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; gap: .35rem; padding: .55rem 1rem; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 500;
  cursor: pointer; white-space: nowrap; line-height: 1.2;
}
.btn:hover { background: #f7f8fa; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #194f74; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.small { padding: .3rem .65rem; font-size: .85rem; }
.btn.block { width: 100%; justify-content: center; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-size: .85rem; cursor: pointer; }
button.link:hover { text-decoration: underline; }
button.link.danger { color: var(--red); }

/* ------------------------------------------------ forms */
.form label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; font-weight: 600; color: var(--ink-2); margin-bottom: .9rem; }
.form input:not([type=checkbox]):not([type=file]), .form select, .form textarea, .search-bar input {
  font: inherit; font-weight: 400; color: var(--ink); padding: .55rem .7rem; border: 1px solid #cfd4db;
  border-radius: 8px; background: #fff; width: 100%;
}
.form input:focus, .form select:focus, .form textarea:focus, .search-bar input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.form input[type=file] { font: inherit; font-weight: 400; }
.form .inline-check, .inline-check { flex-direction: row; align-items: center; gap: .45rem; font-weight: 500; color: var(--ink); cursor: pointer; }
.form small { font-weight: 400; }
.form-actions { display: flex; gap: .5rem; margin-top: .5rem; }
.form.inline, form.inline { display: inline; }
fieldset.card { border: 0; }
fieldset legend { font-weight: 700; font-size: 1.05rem; padding: 0; float: left; width: 100%; margin-bottom: 1rem; }
fieldset legend + * { clear: both; }
.grid-2, .grid-3 { display: grid; gap: 0 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.span-2 { grid-column: span 2; }
.checks-row { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; margin-bottom: 1rem; align-items: center; }
.checks-row .lbl { font-size: .85rem; font-weight: 600; color: var(--ink-2); width: 100%; }
.checks-row label { margin: 0; }
.danger-zone { border: 1px solid var(--red-soft); }
.danger-zone summary { cursor: pointer; color: var(--red); font-weight: 600; }
.danger-inline { margin-top: 1rem; }

/* ------------------------------------------------ search & parts list */
.search-bar { display: flex; gap: .75rem; margin-bottom: .75rem; }
.search-bar input { font-size: 1.1rem; padding: .8rem 1rem; box-shadow: var(--shadow); border-color: var(--line); }
.list-meta { display: flex; gap: 1.5rem; align-items: center; font-size: .85rem; color: var(--ink-2); margin-bottom: .75rem; flex-wrap: wrap; }
.legend { margin-left: auto; display: flex; gap: .5rem; align-items: center; color: var(--muted); }
.legend .dot { width: 9px; height: 9px; margin-left: .6rem; }

.parts-grid { display: flex; flex-direction: column; gap: .5rem; }
.part-row {
  display: grid; grid-template-columns: 76px minmax(200px, 2.2fr) 1.2fr 1fr .7fr 70px; gap: 1rem; align-items: center;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: .6rem 1rem .6rem .6rem; color: var(--ink);
  border: 1px solid transparent; transition: border-color .1s, transform .1s;
}
.part-row:hover { text-decoration: none; border-color: var(--accent); }
.part-row.inactive { opacity: .6; }
.thumb { width: 76px; height: 58px; border-radius: 6px; overflow: hidden; background: #eef0f3; display: grid; place-items: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.no-img { font-size: .7rem; color: var(--muted); text-align: center; }
.part-main { display: flex; flex-direction: column; min-width: 0; }
.part-name { font-weight: 650; font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.part-no { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88rem; color: var(--ink-2); }
.part-col { display: flex; flex-direction: column; font-size: .9rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lbl { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.part-status { display: flex; gap: .5rem; align-items: center; justify-content: flex-end; }

/* ------------------------------------------------ part page */
.part-head { display: grid; grid-template-columns: 160px 1fr auto; gap: 1.5rem; align-items: center; }
.part-head-img { width: 160px; height: 120px; border-radius: 8px; overflow: hidden; background: #eef0f3; display: grid; place-items: center; }
.part-head-img img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.part-head h1 { margin: 0 0 .4rem; }
.part-head-nos { display: flex; flex-wrap: wrap; gap: .4rem 1.5rem; margin-bottom: .6rem; }
.part-head-nos b { font-size: 1.05rem; }
.part-head-tags { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.part-head-tags .tag { font-size: .8rem; padding: 4px 10px; }

.tabs { display: flex; gap: .25rem; border-bottom: 2px solid var(--line); margin: 1.25rem 0 1rem; overflow-x: auto; }
.tabs a { padding: .65rem 1rem; color: var(--ink-2); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--accent); border-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.on { display: block; }
.no-js .tab-panel { display: block; }

.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem 1.5rem; }
.field .val { font-size: 1rem; margin-top: .1rem; }
.notes { margin-top: 1.25rem; padding: .9rem 1rem; background: #f8f9fb; border-radius: 8px; border-left: 3px solid var(--line); }
.notes .lbl { margin-bottom: .2rem; }
.meta { margin: 1.25rem 0 0; }

/* gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }
.gallery figure { margin: 0; background: #f8f9fb; border-radius: 8px; overflow: hidden; border: 2px solid transparent; }
.gallery figure.main { border-color: var(--accent); }
.gallery img { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; cursor: zoom-in; }
.gallery figcaption { font-size: .82rem; padding: .4rem .6rem 0; min-height: 1.4em; }
.fig-actions { display: flex; gap: .8rem; padding: .25rem .6rem .5rem; }
.upload-box { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin-top: 1.25rem; padding: 1rem;
              background: #f8f9fb; border: 1px dashed #cfd4db; border-radius: 8px; }
.upload-box label { display: flex; flex-direction: column; gap: .25rem; font-size: .8rem; font-weight: 600; color: var(--ink-2); }
.upload-box input:not([type=file]), .upload-box select { font: inherit; padding: .45rem .6rem; border: 1px solid #cfd4db; border-radius: 6px; }

/* documents */
.table { width: 100%; border-collapse: collapse; background: var(--card); }
.table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: .6rem .75rem; border-bottom: 1px solid var(--line); }
.table td { padding: .7rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr.inactive td { color: var(--muted); }
.table td.actions { text-align: right; white-space: nowrap; }
.table td.actions form { display: inline; margin-left: .6rem; }
body > .wrap > .table { border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.docs { table-layout: fixed; }
.docs td:nth-child(1), .docs th:nth-child(1) { width: 38%; }
.docs td:nth-child(2), .docs th:nth-child(2) { width: 12%; }
.docs td:nth-child(3), .docs th:nth-child(3) { width: 13%; }
.docs td:nth-child(4), .docs th:nth-child(4) { width: 15%; }
.docs tr.superseded td { color: var(--muted); }
.docs tr.superseded .doc-title { color: var(--ink-2); }
.doc-title { font-weight: 600; }
.rev { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; background: #eceef2; padding: 2px 8px; border-radius: 5px; }
.docs tr.current .rev { background: var(--accent-soft); color: var(--accent); }
.old-revs { margin-top: .5rem; }
.old-revs summary { cursor: pointer; color: var(--ink-2); font-size: .9rem; padding: .4rem 0; }
.pdf-preview { margin-top: 1rem; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.pdf-bar { display: flex; justify-content: space-between; padding: .5rem .75rem; background: #f8f9fb; font-size: .85rem; font-weight: 600; }
.pdf-preview iframe { width: 100%; height: 75vh; border: 0; display: block; }
.upload-details { margin-top: 1rem; }
.upload-details > summary { list-style: none; display: inline-flex; }
.upload-details > summary::-webkit-details-marker { display: none; }
.upload-details[open] > summary { margin-bottom: .75rem; }
.upload-details form { background: #f8f9fb; border: 1px dashed #cfd4db; border-radius: 8px; padding: 1rem; }

/* moulds */
.mould { padding-bottom: 1.25rem; margin-bottom: 1.25rem; border-bottom: 1px solid var(--line); }
.mould.retired { opacity: .7; }
.mould-head { display: flex; justify-content: space-between; align-items: center; }

/* timeline */
.timeline { list-style: none; padding: 0; margin: 1rem 0 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 104px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.ev { display: grid; grid-template-columns: 92px 1fr; gap: 28px; padding: .5rem 0; position: relative; }
.ev::before { content: ""; position: absolute; left: 99px; top: 13px; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); border: 2px solid #fff; }
.ev-date { font-size: .82rem; color: var(--ink-2); text-align: right; padding-top: .15rem; }
.ev-details { margin: .3rem 0; color: var(--ink-2); }
.ev-fai::before { background: var(--green); }
.ev-fai .ev-tag { background: var(--green-soft); color: #14653a; }
.ev-modification::before { background: var(--amber); }
.ev-modification .ev-tag { background: #fdf1dc; color: #8a5509; }
.ev-reject::before { background: var(--red); }
.ev-reject .ev-tag { background: var(--red-soft); color: #a12828; }
.ev-revision::before { background: var(--accent); }
.ev-revision .ev-tag { background: var(--accent-soft); color: var(--accent); }

/* change log */
.diff { margin: .3rem 0 0; padding-left: 1rem; font-size: .85rem; color: var(--ink-2); }
del { color: #a12828; background: var(--red-soft); text-decoration: line-through; padding: 0 3px; border-radius: 3px; }
ins { color: #14653a; background: var(--green-soft); text-decoration: none; padding: 0 3px; border-radius: 3px; }
.pager { display: flex; gap: 1rem; align-items: center; justify-content: center; margin-top: 1rem; }

/* companies */
.chips { display: flex; gap: .4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.chip { font: inherit; font-size: .85rem; padding: .35rem .85rem; border-radius: 999px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* lightbox */
#lightbox { position: fixed; inset: 0; background: rgba(10, 14, 20, .92); z-index: 100; display: flex; align-items: center; justify-content: center; }
#lightbox[hidden] { display: none; }
#lightbox figure { margin: 0; max-width: 90vw; max-height: 90vh; text-align: center; }
#lightbox img { max-width: 90vw; max-height: 82vh; border-radius: 4px; }
#lightbox figcaption { color: #dfe3e8; margin-top: .6rem; }
#lightbox button { position: absolute; background: rgba(255,255,255,.12); color: #fff; border: 0; font-size: 2rem; width: 52px; height: 52px; border-radius: 50%; cursor: pointer; }
#lightbox button:hover { background: rgba(255,255,255,.25); }
.lb-close { top: 18px; right: 18px; font-size: 1.3rem !important; }
.lb-prev { left: 18px; }
.lb-next { right: 18px; }

/* login / install */
.login-body { display: grid; place-items: center; min-height: 100vh; background: #16212e; }
.login-card { background: #fff; padding: 2rem; border-radius: 14px; width: 360px; max-width: 92vw; text-align: center; }
.login-card.wide { width: 520px; text-align: left; }
.login-card h1 { font-size: 1.2rem; margin-bottom: 1.5rem; }
.login-card .form { text-align: left; }
.checks { list-style: none; padding: 0; }
.checks .ok { color: var(--green); }
.checks .bad { color: var(--red); font-weight: 600; }

/* ------------------------------------------------ smaller screens */
@media (max-width: 900px) {
  .part-row { grid-template-columns: 64px 1fr 40px; }
  .part-row .part-col { display: none; }
  .thumb { width: 64px; height: 50px; }
  .part-head { grid-template-columns: 1fr; }
  .part-head-img { width: 100%; height: 200px; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .topbar { gap: .75rem; padding: 0 .75rem; }
  .brand-name, .userbox .role { display: none; }
  .wrap { padding: 1rem; }
  .legend { display: none; }
  .docs { table-layout: auto; }
  .docs td:nth-child(4), .docs th:nth-child(4) { display: none; }
  .timeline::before { left: 8px; }
  .ev { grid-template-columns: 1fr; gap: 0; padding-left: 28px; }
  .ev::before { left: 3px; }
  .ev-date { text-align: left; }
}
