/* =====================================================================
   QMS Document Management System
   Tokens: ink navy for structure, a blue ramp for document levels,
   and stamp colours (green / red / amber) reserved for revision status.
   ===================================================================== */
:root {
  --ink: #1C2740;
  --ink-2: #2B3A5C;
  --paper: #F4F6F9;
  --panel: #FFFFFF;
  --line: #DCE1E9;
  --line-2: #EBEEF3;
  --text: #1C2740;
  --muted: #5D6879;
  --active: #1F7A4D;
  --active-bg: #E7F4EC;
  --ref: #B42318;
  --ref-bg: #FDECEA;
  --draft: #A86B12;
  --draft-bg: #FDF3E1;
  --l1: #1B2A6B;
  --l2: #2F4FA0;
  --l3: #4F7CC4;
  --l4: #9DB3DB;
  --radius: 6px;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-c: "IBM Plex Sans Condensed", "IBM Plex Sans", "Arial Narrow", system-ui, sans-serif;
  --sidebar: 248px;
}

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--paper);
}
a { color: var(--l2); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--l1); }
:focus-visible { outline: 2px solid var(--l3); outline-offset: 2px; }
h1, h2, h3, h4 { color: var(--ink); letter-spacing: -0.005em; }
code { color: var(--ink-2); background: var(--line-2); padding: 1px 5px; border-radius: 4px; font-size: .86em; }
.text-secondary { color: var(--muted) !important; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }

/* ---------------- Buttons ---------------- */
.btn { border-radius: var(--radius); font-weight: 500; }
.btn-ink { background: var(--ink); color: #fff; border: 1px solid var(--ink); }
.btn-ink:hover, .btn-ink:focus { background: var(--ink-2); color: #fff; border-color: var(--ink-2); }
.btn-outline-ink { color: var(--ink); border: 1px solid var(--ink); background: transparent; }
.btn-outline-ink:hover { background: var(--ink); color: #fff; }
.btn-icon { border: 0; background: transparent; color: var(--muted); padding: .2rem .45rem; line-height: 1; }
.btn-icon:hover { color: var(--ink); background: var(--line-2); }
.btn-check:checked + .btn-outline-secondary { background: var(--ink); border-color: var(--ink); }
.form-control, .form-select { border-color: var(--line); border-radius: var(--radius); }
.form-control:focus, .form-select:focus { border-color: var(--l3); box-shadow: 0 0 0 .2rem rgba(79, 124, 196, .18); }
.form-label { font-weight: 500; margin-bottom: .3rem; }

/* ---------------- App shell ---------------- */
body.app { min-height: 100vh; }
.sidebar, .sidebar.offcanvas-lg {
  background: var(--ink) !important;
  color: #C9D2E3;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
}
@media (min-width: 992px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 1030; visibility: visible !important; transform: none !important; }
  .main { margin-left: var(--sidebar); }
}
@media (max-width: 991.98px) { .sidebar.offcanvas-lg { --bs-offcanvas-width: 272px; background: var(--ink); } }
.brand { display: flex; align-items: center; gap: .75rem; padding: 1.1rem 1.1rem 1rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-mark { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 34px; }
.brand-mark span { display: block; height: 5px; border-radius: 1px; }
.brand-mark span:nth-child(1) { width: 10px; background: #fff; }
.brand-mark span:nth-child(2) { width: 18px; background: #C8D5EE; }
.brand-mark span:nth-child(3) { width: 26px; background: #8FA9DA; }
.brand-mark span:nth-child(4) { width: 34px; background: #5C80C4; }
.brand-name { font-family: var(--font-c); font-weight: 700; font-size: 1.12rem; color: #fff; line-height: 1.1; }
.brand-co { font-size: .76rem; color: #93A0B8; max-width: 170px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-main { padding: .75rem .6rem; flex: 1; overflow-y: auto; }
.nav-main .nav-link {
  display: flex; align-items: center; gap: .7rem;
  color: #C9D2E3; padding: .55rem .7rem; border-radius: var(--radius); font-weight: 500; font-size: .94rem;
}
.nav-main .nav-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; color: #8C9AB4; }
.nav-main .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-main .nav-link.active { background: rgba(255,255,255,.11); color: #fff; box-shadow: inset 3px 0 0 #8FA9DA; }
.nav-main .nav-link.active i { color: #fff; }
.nav-badge { margin-left: auto; background: var(--ref); color: #fff; font-size: .72rem; font-weight: 600; border-radius: 10px; padding: 0 .45rem; line-height: 1.35rem; min-width: 1.35rem; text-align: center; }
.nav-badge.amber { background: var(--draft); }
.tabs-line .nav-badge { margin-left: .35rem; }
.nav-sub { display: flex; flex-direction: column; margin: .1rem 0 .4rem 2.55rem; border-left: 1px solid rgba(255,255,255,.12); }
.nav-sub a { color: #A9B5CB; text-decoration: none; font-size: .86rem; padding: .28rem .75rem; }
.nav-sub a:hover, .nav-sub a.active { color: #fff; }
.sidebar-foot { font-size: .72rem; color: #6F7D96; padding: .8rem 1.1rem; border-top: 1px solid rgba(255,255,255,.08); }

.main { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 1020;
  display: flex; align-items: center; gap: .75rem;
  background: rgba(244, 246, 249, .92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line); padding: .6rem 1.5rem;
}
.top-search { position: relative; flex: 1; max-width: 480px; }
.top-search i { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.top-search input { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: var(--radius); padding: .45rem .8rem .45rem 2.2rem; font-size: .92rem; }
.top-search input:focus { outline: none; border-color: var(--l3); box-shadow: 0 0 0 .2rem rgba(79,124,196,.18); }
.user-btn { display: flex; align-items: center; gap: .5rem; border: 0; font-weight: 500; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: .85rem; }
.content { padding: 1.5rem; width: 100%; max-width: 1480px; }
@media (max-width: 575.98px) { .content { padding: 1rem .75rem; } .topbar { padding: .5rem .75rem; } }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.55rem; font-weight: 600; margin: 0; }
.page-sub { color: var(--muted); margin: .25rem 0 0; max-width: 78ch; }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.15rem 1.25rem; }
.panel.p-0 { overflow: hidden; }
.panel-title { font-size: 1rem; font-weight: 600; margin: 0 0 .9rem; display: flex; align-items: baseline; gap: .5rem; }
.panel-link { margin-left: auto; font-size: .84rem; font-weight: 500; }
.empty { color: var(--muted); }
.note-panel { background: #F7F9FC; border: 1px dashed var(--line); border-radius: var(--radius); }
.form-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .5rem; margin-top: 1.1rem; padding-top: 1rem; border-top: 1px solid var(--line-2); }
.bg-soft { background: #F7F9FC !important; }
.alert { border-radius: var(--radius); }
.alert-ref { background: var(--ref-bg); color: var(--ref); border: 1px solid #F3C3BE; }
.breadcrumb { margin-bottom: .6rem; }
.table { --bs-table-border-color: var(--line-2); margin-bottom: 0; }
.table > thead th { font-size: .78rem; font-weight: 600; color: var(--muted); background: #F8FAFC; white-space: nowrap; border-bottom: 1px solid var(--line); }
.click-rows tbody tr[data-href] { cursor: pointer; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain > li { padding: .45rem 0; border-bottom: 1px solid var(--line-2); }
.list-plain > li:last-child { border-bottom: 0; }
.code-block { background: #0F1A30; color: #D6E2FF; border-radius: var(--radius); padding: .85rem 1rem; font-size: .82rem; white-space: pre-wrap; word-break: break-all; }

/* ---------------- Document level chips ---------------- */
.lvl {
  display: inline-flex; align-items: center; gap: .25rem;
  font-family: var(--font-c); font-weight: 600; font-size: .74rem;
  padding: .05rem .42rem; border-radius: 4px; color: #fff; white-space: nowrap; vertical-align: 1px;
}
.lvl-1 { background: var(--l1); }
.lvl-2 { background: var(--l2); }
.lvl-3 { background: var(--l3); }
.lvl-4 { background: var(--l4); color: var(--ink); }
.docno, .docno-input { font-family: var(--font-c); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: .01em; color: var(--ink); text-decoration: none; }
a.docno:hover { color: var(--l2); text-decoration: underline; }
.docno-lg { font-family: var(--font-c); font-weight: 600; font-size: 1.1rem; color: var(--muted); margin-left: .35rem; }

/* ---------------- Status badges ---------------- */
.st { display: inline-block; font-size: .76rem; font-weight: 600; padding: .08rem .5rem; border-radius: 999px; white-space: nowrap; border: 1px solid transparent; }
.st-active { background: var(--active-bg); color: var(--active); border-color: #BFE3CC; }
.st-reference { background: var(--ref-bg); color: var(--ref); border-color: #F3C3BE; }
.st-draft { background: var(--draft-bg); color: var(--draft); border-color: #F0D9AE; }
.st-progress { background: #E8EEFA; color: var(--l2); border-color: #C9D6F1; }
.st-none { background: var(--line-2); color: var(--muted); }
.st-claim-open { background: var(--ref-bg); color: var(--ref); }
.st-claim-analysis { background: var(--draft-bg); color: var(--draft); }
.st-claim-countermeasure { background: #E8EEFA; color: var(--l2); }
.st-claim-closed { background: var(--active-bg); color: var(--active); }

/* The rubber stamp: the one loud element in the interface */
.stamp {
  display: inline-flex; flex-direction: column; align-items: center;
  border: 3px double currentColor; border-radius: 8px;
  padding: .3rem 1rem .25rem; transform: rotate(-4deg);
  font-family: var(--font-c); line-height: 1.05; text-transform: uppercase;
  opacity: .92;
}
.stamp span { font-weight: 700; font-size: 1.25rem; letter-spacing: .07em; }
.stamp small { font-weight: 600; font-size: .78rem; letter-spacing: .12em; }
.stamp-active { color: var(--active); }
.stamp-reference { color: var(--ref); }
.stamp-draft { color: var(--draft); }

/* ---------------- Pyramid ---------------- */
.pyramid { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pyr {
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  height: 52px; color: #fff; text-decoration: none;
  clip-path: polygon(8% 0, 92% 0, 100% 100%, 0 100%);
}
.pyr b { font-family: var(--font-c); font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.pyr span { font-size: .84rem; font-weight: 500; }
.pyr-1 { width: 34%; background: var(--l1); clip-path: polygon(30% 0, 70% 0, 100% 100%, 0 100%); }
.pyr-2 { width: 56%; background: var(--l2); }
.pyr-3 { width: 78%; background: var(--l3); }
.pyr-4 { width: 100%; background: var(--l4); color: var(--ink); }
a.pyr:hover { filter: brightness(1.12); color: #fff; }
a.pyr-4:hover { color: var(--ink); }
.pyr-1 span { display: none; }
.pyramid-lg .pyr { height: 64px; }
.pyramid-lg .pyr-1 span { display: inline; font-size: .72rem; }
.dash-pyr { display: grid; grid-template-columns: minmax(240px, 1.1fr) 1fr; gap: 1.5rem; align-items: center; }
@media (max-width: 575.98px) { .dash-pyr { grid-template-columns: 1fr; } }
.structure { display: grid; grid-template-columns: minmax(240px, 380px) 1fr; gap: 2rem; align-items: start; }
@media (max-width: 767.98px) { .structure { grid-template-columns: 1fr; } }
.struct-dl dt { margin-top: .9rem; }
.struct-dl dt:first-child { margin-top: 0; }
.struct-dl dd { margin: .3rem 0 0; max-width: 72ch; }

/* ---------------- KPI ---------------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: .9rem 1.2rem; margin: 0; }
.kpis > div { border-left: 2px solid var(--line); padding-left: .7rem; }
.kpis dt { font-size: .8rem; font-weight: 500; color: var(--muted); }
.kpis dd { font-family: var(--font-c); font-size: 1.6rem; font-weight: 700; margin: 0; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpis-row { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.t-active { color: var(--active); }
.t-ref { color: var(--ref); }
.t-draft { color: var(--draft); }

/* ---------------- Progress bars ---------------- */
.bar { display: flex; height: 8px; background: var(--line-2); border-radius: 4px; overflow: hidden; }
.bar-done { background: var(--active); }
.bar-prog { background: #E0B45C; }
.bar-thin { height: 4px; margin-top: 3px; }
.step-bars { list-style: none; padding: 0; margin: 0 0 .8rem; display: grid; gap: .85rem; }
.step-bar-head { display: flex; justify-content: space-between; text-decoration: none; color: var(--ink); font-weight: 500; margin-bottom: .25rem; }
.step-bar-head b { font-family: var(--font-c); }
.step-bars small { color: var(--muted); font-size: .76rem; }
.hbar { list-style: none; padding: 0; margin: 0 0 .6rem; display: grid; gap: .45rem; }
.hbar li { display: grid; grid-template-columns: minmax(0, 1.3fr) 1fr 2.2rem; gap: .6rem; align-items: center; font-size: .86rem; }
.hbar-l { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-t { height: 10px; background: var(--line-2); border-radius: 3px; overflow: hidden; }
.hbar-t span { display: block; height: 100%; background: var(--ref); opacity: .8; }
.hbar b { text-align: right; font-family: var(--font-c); }

/* ---------------- Scores ---------------- */
.score-big { display: inline-flex; flex-direction: column; border-left: 4px solid currentColor; padding-left: .8rem; }
.score-big b { font-family: var(--font-c); font-size: 2.5rem; line-height: 1; font-variant-numeric: tabular-nums; }
.score-big span { font-size: .8rem; color: var(--muted); }
.score-big.sc-ok { color: var(--active); }
.score-big.sc-warn { color: var(--draft); }
.score-big.sc-bad { color: var(--ref); }
.score-big.sc-na { color: var(--muted); }
.score-pill { display: inline-block; min-width: 2.4rem; text-align: center; font-family: var(--font-c); font-weight: 700; border-radius: 4px; padding: .05rem .35rem; font-variant-numeric: tabular-nums; }
.score-pill.sc-ok { background: var(--active-bg); color: var(--active); }
.score-pill.sc-warn { background: var(--draft-bg); color: var(--draft); }
.score-pill.sc-bad { background: var(--ref-bg); color: var(--ref); }
.score-pill.sc-na { background: var(--line-2); color: var(--muted); }
.score-bar { position: relative; display: inline-block; width: calc(100% - 3.2rem); height: 10px; background: var(--line-2); border-radius: 3px; vertical-align: middle; }
.score-bar span { display: block; height: 100%; border-radius: 3px; }
.score-bar.sc-ok span { background: var(--active); }
.score-bar.sc-warn span { background: #D39A35; }
.score-bar.sc-bad span { background: var(--ref); }
.score-bar i { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); }
.chart-box { position: relative; height: 260px; margin-top: .8rem; }
.chart-box.tall { height: 360px; }

/* ---------------- Documents list ---------------- */
.level-tabs { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .9rem; }
.level-tabs a {
  text-decoration: none; color: var(--ink); background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: .4rem .8rem; font-weight: 500; font-size: .9rem;
}
.level-tabs a b { font-family: var(--font-c); color: var(--muted); margin-left: .25rem; }
.level-tabs a:hover { border-color: var(--l3); }
.level-tabs a.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.level-tabs a.active b { color: #C8D5EE; }
.level-tabs a.lt-1 { box-shadow: inset 3px 0 0 var(--l1); }
.level-tabs a.lt-2 { box-shadow: inset 3px 0 0 var(--l2); }
.level-tabs a.lt-3 { box-shadow: inset 3px 0 0 var(--l3); }
.level-tabs a.lt-4 { box-shadow: inset 3px 0 0 var(--l4); }
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.filter-bar .form-control, .filter-bar .form-select { width: auto; flex: 1 1 170px; max-width: 320px; }
.doc-title-cell { min-width: 240px; }

/* ---------------- Check lists ---------------- */
.check-list { max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); padding: .25rem; }
.check-list.tall { max-height: 520px; }
.check-item { display: flex; align-items: center; gap: .45rem; padding: .32rem .45rem; border-radius: 4px; font-size: .88rem; cursor: pointer; margin: 0; }
.check-item:hover { background: #F4F7FC; }
.check-item > span:not(.lvl) { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.corr-summary { font-size: .84rem; margin: .5rem 0 0; min-height: 1.4rem; }
.check-item input { flex: none; }
.check-group { font-size: .76rem; font-weight: 600; color: var(--l2); padding: .55rem .45rem .2rem; position: sticky; top: -4px; background: #fff; }

/* ---------------- Document view ---------------- */
.doc-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.doc-head-title { font-size: 1.6rem; font-weight: 600; margin: .3rem 0 .35rem; max-width: 60ch; }
.doc-head-meta { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; color: var(--muted); font-size: .88rem; }
.viewer-panel { padding: 0; overflow: hidden; }
.viewer-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; padding: .7rem 1rem; border-bottom: 1px solid var(--line); }
.viewer { position: relative; background: #EEF1F5; min-height: 180px; }
.viewer iframe { width: 100%; height: 72vh; min-height: 420px; border: 0; display: block; background: #fff; }
.viewer img { display: block; max-width: 100%; margin: 0 auto; }
.viewer.is-ref iframe, .viewer.is-ref img { filter: grayscale(.6); }
.watermark {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-c); font-weight: 700; font-size: clamp(2rem, 7vw, 5.5rem); letter-spacing: .08em;
  color: rgba(180, 35, 24, .22); transform: rotate(-24deg); white-space: nowrap;
}
.file-card { display: flex; align-items: center; gap: 1rem; padding: 1.5rem; background: #fff; }
.file-card > i { font-size: 2.2rem; color: var(--l2); }
.doc-content { background: #fff; padding: 1.25rem 1.5rem; white-space: normal; max-width: 85ch; }
.doc-desc { padding: 1rem 1.25rem; border-top: 1px solid var(--line); }
.rel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 767.98px) { .rel-grid { grid-template-columns: 1fr; } }
.rel-h { font-size: .9rem; font-weight: 600; margin: 0 0 .4rem; color: var(--ink); }
.rel-h small { color: var(--muted); font-weight: 500; }
.rel-h2 { font-size: .78rem; font-weight: 600; color: var(--muted); margin: .7rem 0 .25rem; }
.rel-list { list-style: none; margin: 0; padding: 0; }
.rel-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: .6rem; padding: .45rem 0; border-bottom: 1px solid var(--line-2); }
.rel-list li:last-child { border-bottom: 0; }
.rel-list a { text-decoration: none; color: var(--ink); display: flex; align-items: center; gap: .4rem; min-width: 0; }
.rel-list a .docno { white-space: nowrap; }
.rel-list a:hover .rel-title { color: var(--l2); text-decoration: underline; }
.rel-title { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; min-width: 0; }
.rel-meta { display: flex; align-items: center; gap: .35rem; font-size: .8rem; white-space: nowrap; }
.rel-del { margin: 0; }
.link-form { margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed var(--line); }
.rev-table tr.is-sel td { background: #F2F6FD; }
.qr-panel { text-align: center; }
.qr-panel .stamp { margin: .3rem 0 1rem; }
.qr { display: inline-block; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); line-height: 0; margin-bottom: .5rem; }
.qr img, .qr canvas { display: block; }
.meta-list { margin: 1rem 0; text-align: left; display: grid; gap: .45rem; }
.meta-list > div { display: grid; grid-template-columns: 8.5rem 1fr; gap: .5rem; font-size: .88rem; }
.meta-list dt { color: var(--muted); font-weight: 500; }
.meta-list dd { margin: 0; }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem 1rem; margin: 0; }
.meta-grid dt { font-size: .78rem; color: var(--muted); font-weight: 500; }
.meta-grid dd { margin: 0; font-weight: 500; }
.ack-done { background: var(--active-bg); color: var(--active); border-radius: var(--radius); padding: .6rem .8rem; font-size: .88rem; text-align: left; }
.clause-chips { list-style: none; padding: 0; margin: 0; display: grid; gap: .35rem; }
.clause-chips a { display: block; text-decoration: none; color: var(--ink); font-size: .88rem; padding: .35rem .55rem; border: 1px solid var(--line); border-radius: 4px; }
.clause-chips a:hover { border-color: var(--l3); background: #F4F7FC; }
.clause-chips b { font-family: var(--font-c); color: var(--l2); margin-right: .25rem; }
.doc-chip { display: inline-flex; align-items: center; gap: .3rem; text-decoration: none; font-family: var(--font-c); font-weight: 600; font-size: .8rem; color: var(--ink); border: 1px solid var(--line); border-radius: 4px; padding: .05rem .4rem; margin: 1px 0; }
.doc-chip:hover { border-color: var(--l3); }

/* ---------------- Tabs ---------------- */
.tabs-line { display: flex; flex-wrap: wrap; gap: .2rem; border-bottom: 1px solid var(--line); }
.tabs-line a { text-decoration: none; color: var(--muted); font-weight: 500; padding: .55rem .9rem; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs-line a:hover { color: var(--ink); }
.tabs-line a.active { color: var(--ink); border-bottom-color: var(--ink); }

/* ---------------- Requirements ---------------- */
.clause-nav { display: grid; gap: 2px; position: sticky; top: 72px; }
.clause-nav a { display: flex; align-items: center; gap: .65rem; padding: .5rem .6rem; border-radius: var(--radius); text-decoration: none; color: var(--ink); }
.clause-nav a:hover { background: #fff; }
.clause-nav a.active { background: #fff; box-shadow: inset 3px 0 0 var(--ink), 0 0 0 1px var(--line); }
.clause-nav .cn { flex: none; width: 28px; height: 28px; border-radius: 4px; background: var(--ink); color: #fff; font-family: var(--font-c); font-weight: 700; display: flex; align-items: center; justify-content: center; }
.clause-nav .ct { flex: 1; font-size: .88rem; font-weight: 500; line-height: 1.25; }
.clause-nav .ct small { display: block; color: var(--muted); font-weight: 400; font-size: .74rem; margin-top: 2px; }
.mini-ring { flex: none; width: 20px; height: 20px; border-radius: 50%; background: conic-gradient(var(--active) calc(var(--p) * 1%), var(--line) 0); -webkit-mask: radial-gradient(circle 6px, transparent 98%, #000); mask: radial-gradient(circle 6px, transparent 98%, #000); }
.clause-num { flex: none; width: 56px; height: 56px; border-radius: var(--radius); background: var(--ink); color: #fff; font-family: var(--font-c); font-size: 1.9rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.refs { display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-size: .84rem; color: var(--muted); }
.refs b { color: var(--ink); font-weight: 600; }
.sub-card { padding: 0; overflow: hidden; scroll-margin-top: 80px; }
.sub-card:target { box-shadow: 0 0 0 2px var(--l3); }
.sub-head { display: flex; align-items: flex-start; gap: .8rem; padding: 1rem 1.25rem .6rem; }
.sub-code { font-family: var(--font-c); font-weight: 700; color: var(--l2); background: #EAF0FA; border-radius: 4px; padding: .1rem .5rem; font-size: 1rem; white-space: nowrap; }
.sub-title { font-size: 1.05rem; font-weight: 600; margin: 0; }
.sub-title-id { color: var(--muted); font-size: .9rem; }
.chk-type { font-size: .72rem; font-weight: 600; padding: .1rem .45rem; border-radius: 4px; white-space: nowrap; border: 1px solid var(--line); color: var(--muted); }
.chk-type.t-g { border-color: #BFE3CC; color: var(--active); }
.chk-type.t-d { border-color: #C9D6F1; color: var(--l2); }
.chk-type.t-dg { border-color: #E4D3F1; color: #6A3E91; }
.sub-docs { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; padding: 0 1.25rem .8rem; }
.level-table th[scope="row"], .level-table tbody th { width: 56px; vertical-align: top; }
.level-table td { vertical-align: top; font-size: .88rem; }
.level-table td.guide { color: #3C4658; background: #FAFBFD; width: 46%; }
.req-id { color: var(--muted); font-style: italic; margin-top: .3rem; }
.lv-badge { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; font-family: var(--font-c); font-weight: 700; color: #fff; }
.lv-1 { background: #9AA7BD; }
.lv-2 { background: #7A8BAA; }
.lv-3 { background: var(--l3); }
.lv-4 { background: var(--l2); }
.lv-5 { background: var(--l1); }
.maturity { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: .4rem; max-width: 820px; }
.maturity li { display: grid; grid-template-columns: 15rem 1fr; gap: 1rem; padding: .65rem .9rem; border-radius: var(--radius); background: #F7F9FC; border-left: 4px solid; }
.maturity li span { color: #3C4658; }
.maturity .mt-1 { border-color: #9AA7BD; margin-left: 0; }
.maturity .mt-2 { border-color: #7A8BAA; margin-left: 1.25rem; }
.maturity .mt-3 { border-color: var(--l3); margin-left: 2.5rem; }
.maturity .mt-4 { border-color: var(--l2); margin-left: 3.75rem; }
.maturity .mt-5 { border-color: var(--l1); margin-left: 5rem; }
@media (max-width: 767.98px) { .maturity li { grid-template-columns: 1fr; gap: .2rem; margin-left: 0 !important; } }

/* ---------------- QMS 4 steps ---------------- */
.step-flow { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; counter-reset: s; }
@media (max-width: 991.98px) { .step-flow { grid-template-columns: 1fr 1fr; gap: .75rem; } }
@media (max-width: 575.98px) { .step-flow { grid-template-columns: 1fr; } }
.sf a {
  position: relative; display: grid; gap: .45rem; height: 100%;
  background: #fff; border: 1px solid var(--line); padding: 1.1rem 1.6rem 1.1rem 1.2rem;
  text-decoration: none; color: var(--ink);
}
@media (min-width: 992px) {
  .sf a { clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 50%, calc(100% - 16px) 100%, 0 100%, 16px 50%); padding-left: 2rem; border: 0; background: #fff; }
  .sf:first-child a { clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 50%, calc(100% - 16px) 100%, 0 100%); padding-left: 1.2rem; }
  .sf + .sf { margin-left: -10px; }
  .step-flow { filter: drop-shadow(0 0 0 var(--line)) drop-shadow(0 1px 0 var(--line)); }
}
.sf a:hover { background: #F7F9FC; }
.sf-num { font-family: var(--font-c); font-weight: 700; font-size: .85rem; color: #fff; width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.sf-name { font-weight: 600; font-size: 1.05rem; }
.sf-pc { font-family: var(--font-c); font-size: 2rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.sf-desc { font-size: .82rem; color: var(--muted); }
.sf-count { font-size: .76rem; color: var(--muted); }
.sf-1 .sf-num, .stp-1 { background: #3D5A99; }
.sf-2 .sf-num, .stp-2 { background: #2F7F8F; }
.sf-3 .sf-num, .stp-3 { background: #8A6A1F; }
.sf-4 .sf-num, .stp-4 { background: #5E4A8E; }
.step-tag { display: inline-block; color: #fff; font-size: .72rem; font-weight: 600; padding: .05rem .45rem; border-radius: 4px; margin-right: .3rem; }
.step-tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.step-tabs a { display: inline-flex; align-items: center; gap: .5rem; text-decoration: none; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .45rem .85rem .45rem .5rem; font-weight: 500; }
.step-tabs a > span { width: 24px; height: 24px; border-radius: 50%; color: #fff; font-family: var(--font-c); font-weight: 700; font-size: .8rem; display: inline-flex; align-items: center; justify-content: center; }
.step-tabs a.sf-1 > span { background: #3D5A99; }
.step-tabs a.sf-2 > span { background: #2F7F8F; }
.step-tabs a.sf-3 > span { background: #8A6A1F; }
.step-tabs a.sf-4 > span { background: #5E4A8E; }
.step-tabs a.active { border-color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); }
.step-intro { border-top: 4px solid; }
.step-intro.sf-1 { border-top-color: #3D5A99; }
.step-intro.sf-2 { border-top-color: #2F7F8F; }
.step-intro.sf-3 { border-top-color: #8A6A1F; }
.step-intro.sf-4 { border-top-color: #5E4A8E; }
.step-intro ul { padding-left: 1.1rem; }
.step-intro li { margin-bottom: .25rem; }
.step-matrix th[scope="row"] { font-weight: 500; font-size: .9rem; white-space: nowrap; }
.cn-sm { display: inline-flex; width: 22px; height: 22px; border-radius: 4px; background: var(--ink); color: #fff; align-items: center; justify-content: center; font-family: var(--font-c); font-size: .78rem; font-weight: 700; margin-right: .25rem; }
.cell-prog { display: inline-block; min-width: 72px; text-decoration: none; color: var(--muted); }
.cp-val { font-family: var(--font-c); font-weight: 600; font-variant-numeric: tabular-nums; }
.cp-val.part { color: var(--draft); }
.cp-val.full { color: var(--active); }
.group-row th { background: #F3F6FA; font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.quick-status select { width: auto; min-width: 128px; font-weight: 500; }
.ss-none { color: var(--muted); }
select.ss-progress, .ss.ss-progress { color: var(--draft); border-color: #F0D9AE; background-color: var(--draft-bg); }
select.ss-done, .ss.ss-done { color: var(--active); border-color: #BFE3CC; background-color: var(--active-bg); }
.ss { display: inline-block; font-size: .8rem; font-weight: 600; padding: .1rem .5rem; border-radius: 4px; border: 1px solid var(--line); }
.ss-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.ss-dot.ss-progress { background: #E0B45C; }
.ss-dot.ss-done { background: var(--active); }
.seg { display: inline-flex; flex-wrap: wrap; gap: .35rem; }
.seg .btn { border: 1px solid var(--line); background: #fff; color: var(--muted); }
.btn-check:checked + .seg-none { background: #5D6879; border-color: #5D6879; color: #fff; }
.btn-check:checked + .seg-progress { background: var(--draft); border-color: var(--draft); color: #fff; }
.btn-check:checked + .seg-done { background: var(--active); border-color: var(--active); color: #fff; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: flex; gap: 1rem; padding: .6rem 0; border-bottom: 1px solid var(--line-2); align-items: flex-start; }
.timeline li:last-child { border-bottom: 0; }
.tl-date { flex: none; width: 6.5rem; font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 2px; }
.act-form { margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed var(--line); }

/* ---------------- Audit ---------------- */
.audit-sticky {
  position: sticky; top: 57px; z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1.4rem;
  background: var(--ink); color: #fff; border-radius: var(--radius); padding: .65rem 1rem; margin-bottom: 1rem;
}
.as-stat { display: flex; align-items: baseline; gap: .35rem; }
.as-stat span { font-size: .78rem; color: #A9B5CB; }
.as-stat b { font-family: var(--font-c); font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.audit-sticky .btn-outline-secondary { color: #fff; border-color: rgba(255,255,255,.35); }
.audit-sticky .btn-outline-ink { color: #fff; border-color: #fff; }
.audit-sticky .btn-ink { background: #fff; color: var(--ink); border-color: #fff; }
.audit-item { border-top: 1px solid var(--line-2); padding: .9rem 0; scroll-margin-top: 130px; }
.audit-item:first-of-type { border-top: 0; padding-top: 0; }
.ai-head { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-start; }
.score-sel { display: flex; gap: 3px; border: 0; padding: 0; margin: 0; }
.score-sel .btn { width: 2.35rem; padding: .3rem 0; font-family: var(--font-c); font-weight: 700; border: 1px solid var(--line); background: #fff; color: var(--muted); }
.score-sel .btn:hover { border-color: var(--l3); color: var(--ink); }
.score-sel .btn.sc-na { width: 2.9rem; font-size: .8rem; }
.btn-check:checked + .btn.sc-0, .btn-check:checked + .btn.sc-1 { background: var(--ref); border-color: var(--ref); color: #fff; }
.btn-check:checked + .btn.sc-2 { background: #D39A35; border-color: #D39A35; color: #fff; }
.btn-check:checked + .btn.sc-3, .btn-check:checked + .btn.sc-4, .btn-check:checked + .btn.sc-5 { background: var(--active); border-color: var(--active); color: #fff; }
.btn-check:checked + .btn.sc-na { background: #5D6879; border-color: #5D6879; color: #fff; }
.ai-guide { margin: .6rem 0; }
.ai-guide summary { cursor: pointer; font-size: .84rem; color: var(--l2); font-weight: 500; }
.ai-guide[open] summary { margin-bottom: .4rem; }
.ai-fields { margin: 0; }
.clause-avg { margin-left: auto; }

/* ---------------- Claims ---------------- */
.sev { font-size: .76rem; font-weight: 600; padding: .05rem .45rem; border-radius: 4px; }
.sev-minor { background: var(--line-2); color: var(--muted); }
.sev-major { background: var(--draft-bg); color: var(--draft); }
.sev-critical { background: var(--ref); color: #fff; }
.corr { display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-c); font-weight: 600; font-size: .78rem; border-radius: 4px; padding: 0 .35rem; min-width: 1.5rem; margin-right: .25rem; }
.corr.w9 { background: var(--ref); color: #fff; }
.corr.w3 { background: #F7C9C4; color: #7A1A12; }
.corr.w1 { background: var(--line-2); color: var(--muted); }
.hint-chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.hint-chips .btn { font-size: .78rem; padding: .15rem .55rem; }
.corr-row { cursor: default; }
.corr-row .form-select { width: 66px; flex: none; }
.corr-row .corr-note { width: 130px; flex: none; display: none; }
.corr-row.on { background: #FFF5F4; }
.corr-row.on .corr-note { display: block; }
.corr-row span { color: var(--ink); white-space: normal; }
.claim-flow { list-style: none; display: flex; padding: 0; margin: 0 0 1rem; counter-reset: c; }
.claim-flow li { flex: 1; text-align: center; font-size: .82rem; font-weight: 500; color: var(--muted); padding: .45rem .25rem; border-bottom: 3px solid var(--line); }
.claim-flow li.done { color: var(--active); border-color: var(--active); }
.claim-flow li.cur { color: var(--ink); border-color: var(--ink); font-weight: 600; }
.prio { font-size: .76rem; font-weight: 600; padding: .05rem .5rem; border-radius: 4px; }
.prio-high { background: var(--ref); color: #fff; }
.prio-mid { background: var(--draft-bg); color: var(--draft); }
.prio-low { background: var(--line-2); color: var(--muted); }
.heat td, .heat th { padding: .3rem .4rem; font-size: .8rem; }
.heat td.h1 { background: #FBE3E0; }
.heat td.h3 { background: #F2A59D; color: #5B120C; font-weight: 600; }
.heat td.h9 { background: var(--ref); color: #fff; font-weight: 700; }
.heat-total th { background: #F3F6FA; }

/* ---------------- Settings ---------------- */
.row-pending td { background: #FFFBF2; }
.ust { font-size: .76rem; font-weight: 600; padding: .08rem .5rem; border-radius: 999px; }
.ust-pending { background: var(--draft-bg); color: var(--draft); }
.ust-active { background: var(--active-bg); color: var(--active); }
.ust-rejected, .ust-disabled { background: var(--line-2); color: var(--muted); }
.wa-log li { padding: .35rem 0; }

/* ---------------- Auth pages ---------------- */
body.auth { background: var(--paper); }
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 44%) 1fr; }
.auth-side { background: var(--ink); color: #C9D2E3; padding: 3rem; display: flex; flex-direction: column; justify-content: center; gap: 2rem; }
.auth-co { font-family: var(--font-c); font-weight: 600; font-size: 1.1rem; color: #fff; }
.auth-tag { font-size: 1.15rem; line-height: 1.45; color: #DCE3F0; max-width: 32ch; margin: 0; }
.pyramid-hero { max-width: 380px; width: 100%; }
.pyramid-hero .pyr { height: 56px; }
.pyramid-hero .pyr-4 { background: #C3D2EE; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; }
.auth-card { width: 100%; max-width: 460px; }
.auth-title { font-size: 1.5rem; font-weight: 600; margin-bottom: .35rem; }
@media (max-width: 767.98px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-side { padding: 1.5rem 1.25rem; gap: 1rem; }
  .auth-side .pyramid-hero, .auth-tag { display: none; }
}

/* ---------------- Scan page (mobile first) ---------------- */
body.scan { background: var(--paper); }
.scan-wrap { max-width: 520px; margin: 0 auto; padding: 1rem .85rem 2rem; }
.scan-co { font-size: .8rem; color: var(--muted); margin-bottom: .75rem; }
.scan-card { background: #fff; border: 1px solid var(--line); border-top: 6px solid var(--muted); border-radius: var(--radius); padding: 1.25rem; }
.scan-card.scan-active { border-top-color: var(--active); }
.scan-card.scan-reference { border-top-color: var(--ref); }
.scan-card.scan-draft { border-top-color: var(--draft); }
.scan-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.scan-top .stamp span { font-size: 1.55rem; }
.scan-check { font-size: .76rem; color: var(--muted); text-align: right; }
.scan-docno { font-family: var(--font-c); font-weight: 700; font-size: 1.4rem; color: var(--ink); }
.scan-title { font-size: 1.2rem; font-weight: 600; margin: .1rem 0 .5rem; }
.scan-msg { border-radius: var(--radius); padding: .75rem .9rem; margin-bottom: 1rem; font-size: .95rem; }
.scan-msg i { margin-right: .3rem; }
.scan-msg.ok { background: var(--active-bg); color: #145535; }
.scan-msg.bad { background: var(--ref-bg); color: #7A1A12; }
.scan-msg.warn { background: var(--draft-bg); color: #6E460B; }
.scan-meta { display: grid; gap: .5rem; margin: 0 0 1.2rem; }
.scan-meta > div { display: grid; grid-template-columns: 9rem 1fr; gap: .5rem; border-bottom: 1px solid var(--line-2); padding-bottom: .4rem; }
.scan-meta dt { color: var(--muted); font-weight: 500; font-size: .88rem; }
.scan-meta dd { margin: 0; font-weight: 500; }
.scan-foot { text-align: center; font-size: .76rem; color: var(--muted); margin-top: 1rem; }

/* ---------------- QR labels ---------------- */
body.label-page { background: #E9EDF2; }
.label-toolbar { background: #fff; border-bottom: 1px solid var(--line); padding: .6rem 1rem; position: sticky; top: 0; z-index: 2; }
.labels { display: flex; flex-wrap: wrap; gap: 4mm; padding: 6mm; }
.qlabel {
  width: 70mm; height: 38mm; background: #fff; border: 1px solid #9AA4B2; border-radius: 2mm;
  display: flex; gap: 2.5mm; padding: 2.5mm; overflow: hidden; break-inside: avoid; page-break-inside: avoid;
}
.ql-qr { flex: none; line-height: 0; align-self: center; }
.ql-qr img, .ql-qr canvas { width: 28mm !important; height: 28mm !important; }
.ql-body { display: flex; flex-direction: column; min-width: 0; font-size: 7.5pt; line-height: 1.2; }
.ql-co { font-size: 6pt; color: #5D6879; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ql-no { font-family: var(--font-c); font-weight: 700; font-size: 10.5pt; color: #000; }
.ql-title { font-weight: 500; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ql-rev { margin-top: auto; }
.ql-st { font-family: var(--font-c); font-weight: 700; font-size: 8pt; text-transform: uppercase; letter-spacing: .04em; }
.ql-active .ql-st { color: var(--active); }
.ql-reference .ql-st { color: var(--ref); }
.ql-draft .ql-st { color: var(--draft); }
.ql-hint { font-size: 5.5pt; color: #5D6879; }

/* ---------------- Install ---------------- */
body.install { background: var(--paper); }

/* ---------------- Print ---------------- */
@media print {
  @page { margin: 10mm; }
  .sidebar, .topbar, .no-print, .page-actions, .btn, .label-toolbar, .alert-dismissible .btn-close { display: none !important; }
  .main { margin: 0 !important; }
  body, body.label-page { background: #fff !important; }
  .content { padding: 0; max-width: none; }
  .panel { border-color: #bbb; break-inside: avoid; }
  .labels { padding: 0; gap: 3mm; }
  .qlabel { border-color: #666; }
  .chart-box { height: 240px; }
}
.sub-note { font-size: .82rem; color: #6E460B; background: var(--draft-bg); border-radius: 4px; padding: .3rem .55rem; margin-top: .35rem; max-width: 90ch; }
.doc-table .docno, .docno { white-space: nowrap; }
@media (max-width: 767.98px) {
  .doc-table th:nth-child(4), .doc-table td:nth-child(4),
  .doc-table th:nth-child(7), .doc-table td:nth-child(7),
  .doc-table th:nth-child(8), .doc-table td:nth-child(8),
  .doc-table th:nth-child(9), .doc-table td:nth-child(9) { display: none; }
  .doc-title-cell { min-width: 160px; }
}
