/* Parts Manager Academy — design tokens
   Slate workshop ink + parts-bin label yellow. Barlow Condensed for headings, Barlow for text. */
:root {
  color-scheme: light;
  --ink: #1D2B36;
  --text: #22303B;
  --muted: #5B6B78;
  --bg: #EEF1F4;
  --surface: #FFFFFF;
  --line: #D3DAE1;
  --tag: #F4B400;
  --tag-ink: #1D2B36;
  --shelf: #3A4A57;
  --ok: #2E7D4F;
  --ok-bg: #E4F2E9;
  --bad: #B8322A;
  --bad-bg: #FBE9E7;
  --info-bg: #E8EEF4;
  --warn-bg: #FFF4D6;
  --accent-fill: #F4B400;
  --radius-s: 4px;
  --radius-m: 8px;
  --font-head: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --font-body: "Barlow", "Segoe UI", Roboto, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ink: #0F171D;
    --text: #E3E9EE;
    --muted: #9AABB8;
    --bg: #141C23;
    --surface: #1C262F;
    --line: #2E3C48;
    --shelf: #5D7080;
    --ok: #6FCB93;
    --ok-bg: #173325;
    --bad: #F08A80;
    --bad-bg: #3A1C19;
    --info-bg: #1F2D39;
    --warn-bg: #3A3014;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 17px/1.6 var(--font-body); }
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 700; line-height: 1.15; color: var(--text); margin: 0 0 .5em; letter-spacing: .01em; }
h1 { font-size: clamp(2rem, 4vw, 2.75rem); }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.3rem; }
h4 { font-size: 1.2rem; margin-top: 1.4em; }
a { color: inherit; }
p { margin: 0 0 1em; }
img { max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.lead { font-size: 1.15rem; max-width: 62ch; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.pad { padding: 2rem; }
:focus-visible { outline: 3px solid var(--tag); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 44px; padding: .55rem 1.1rem; border: 2px solid var(--text); border-radius: var(--radius-s); background: transparent; color: var(--text); font: 600 1rem var(--font-body); text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--info-bg); }
.btn.primary { background: var(--tag); border-color: var(--tag); color: var(--tag-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.wide { width: 100%; }
.small-btn { min-height: 36px; padding: .3rem .8rem; font-size: .9rem; }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.25rem; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: var(--ink); color: #fff; padding: clamp(2rem, 6vw, 5rem); display: flex; flex-direction: column; justify-content: center; }
.big-tag { position: relative; align-self: flex-start; background: var(--tag); color: var(--tag-ink); font: 700 clamp(2.4rem, 5vw, 4rem)/1 var(--font-head); padding: 1.6rem 2rem 1.6rem 4.2rem; border-radius: 10px; transform: rotate(-2deg); box-shadow: 0 0 0 3px var(--tag-ink) inset; max-width: 12ch; }
.big-tag .hole { position: absolute; left: 1.4rem; top: 50%; width: 1.4rem; height: 1.4rem; margin-top: -.7rem; border-radius: 50%; background: var(--ink); }
.login-sub { font: 600 1.4rem/1.3 var(--font-head); margin-top: 2.5rem; color: #fff; max-width: 26ch; }
.login-stats { color: #B9C6D0; max-width: 40ch; }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 2rem; background: var(--surface); }
.login-form { width: 100%; max-width: 380px; }
.login-form label, .inline-form label { display: block; font-weight: 600; margin-bottom: 1rem; }
input[type=text], input:not([type]), input[type=password], input[type=search] { display: block; width: 100%; margin-top: .35rem; min-height: 46px; padding: .6rem .8rem; border: 2px solid var(--line); border-radius: var(--radius-s); background: var(--bg); color: var(--text); font: 400 1rem var(--font-body); }
input:focus { border-color: var(--text); outline: none; }
.error { color: var(--bad); min-height: 1.4em; font-weight: 500; }
.demo-note { margin-top: 1.25rem; padding: .8rem 1rem; background: var(--warn-bg); border-left: 4px solid var(--tag); font-size: .95rem; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--ink); color: #fff; padding: 1.5rem 1rem; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; font: 700 1.35rem/1.1 var(--font-head); color: #fff; }
.brand-tag { width: 30px; height: 20px; border-radius: 4px; background: var(--tag); position: relative; flex: none; }
.brand-tag::after { content: ""; position: absolute; left: 5px; top: 7px; width: 6px; height: 6px; border-radius: 50%; background: var(--ink); }
.side-brand { margin: 0 .5rem 2rem; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { padding: .7rem .9rem; border-radius: var(--radius-s); text-decoration: none; color: #C9D4DC; font-weight: 500; border-left: 4px solid transparent; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { color: #fff; background: rgba(255,255,255,.08); border-left-color: var(--tag); }
.side-foot { margin-top: auto; padding: 1rem .5rem 0; border-top: 1px solid rgba(255,255,255,.12); }
.side-foot .muted { color: #9AABB8; margin: 0; }
.who { font-weight: 600; margin: 0 0 .75rem; }
.side-foot .btn { color: #fff; border-color: rgba(255,255,255,.4); }
.side-foot .btn:hover { background: rgba(255,255,255,.08); }
.topbar { display: none; }
.content { min-width: 0; }
.main { max-width: 980px; padding: clamp(1.25rem, 4vw, 3rem); outline: none; }
.banner { margin: 0; padding: .8rem 1.25rem; background: var(--bad-bg); color: var(--bad); font-weight: 500; }

/* ---------- Page heads, crumbs ---------- */
.page-head { margin-bottom: 2rem; }
.crumbs { font-size: .95rem; color: var(--muted); margin-bottom: 1.25rem; }
.crumbs a { color: var(--muted); }
.meter { height: 12px; background: var(--line); border-radius: 6px; overflow: hidden; max-width: 520px; }
.meter span { display: block; height: 100%; background: var(--tag); }
.note-ok { color: var(--ok); font-weight: 600; }

/* ---------- Learning path: racks, shelves and bins ---------- */
.tag { display: inline-block; position: relative; background: var(--tag); color: var(--tag-ink); font: 700 1rem/1 var(--font-head); padding: .35rem .6rem .35rem 1.25rem; border-radius: 4px; letter-spacing: .03em; }
.tag::before { content: ""; position: absolute; left: .4rem; top: 50%; width: .4rem; height: .4rem; margin-top: -.2rem; border-radius: 50%; background: var(--tag-ink); }
.tag.big { font-size: 1.3rem; padding: .45rem .8rem .45rem 1.6rem; margin-bottom: 1rem; }
.tag.big::before { left: .55rem; width: .5rem; height: .5rem; margin-top: -.25rem; }
.rack { margin-bottom: 2.75rem; }
.rack-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem 1rem; margin-bottom: .75rem; }
.rack-head h2 { margin: 0; }
.rack-head p { margin: 0; color: var(--muted); }
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1rem; padding: 1rem 1rem 1.25rem; background: var(--surface); border: 1px solid var(--line); border-bottom: 8px solid var(--shelf); border-radius: var(--radius-m) var(--radius-m) 2px 2px; }
.bin { display: flex; flex-direction: column; align-items: flex-start; gap: .6rem; padding: .9rem; min-height: 150px; text-decoration: none; background: var(--bg); border: 2px solid var(--line); border-radius: var(--radius-s); }
a.bin:hover { border-color: var(--text); }
.bin.locked { opacity: .55; }
.bin-title { font: 600 1.2rem/1.2 var(--font-head); }
.bin-meta { align-self: stretch; margin-top: auto; display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem .5rem; font-size: .85rem; color: var(--muted); }
.state { font-weight: 600; }
.state-passed { color: var(--ok); }
.state-in-progress { color: var(--text); }
.state-locked { color: var(--muted); }

/* ---------- Module steps ---------- */
.steps { list-style: none; padding: 0; margin: 0; border-left: 3px solid var(--line); }
.steps li { position: relative; margin: 0 0 .75rem 1.25rem; }
.steps a, .steps .fake-link { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 1rem; padding: 1rem 1.1rem; background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius-s); text-decoration: none; font-weight: 500; }
.steps a:hover { border-color: var(--text); }
.steps .is-locked .fake-link { opacity: .6; }
.step-no { display: grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: 50%; border: 2px solid var(--text); font: 700 1.05rem var(--font-head); }
.steps .done .step-no { background: var(--ok); border-color: var(--ok); color: #fff; }
.step-state { font-size: .9rem; color: var(--muted); }
.steps .done .step-state { color: var(--ok); font-weight: 600; }

/* ---------- Lesson prose ---------- */
.lesson { max-width: 760px; }
.prose { font-size: 1.05rem; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin-bottom: .35rem; }
.tbl-wrap, .prose { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; margin: 1rem 0 1.5rem; background: var(--surface); font-size: .97rem; }
th, td { text-align: left; vertical-align: top; padding: .65rem .8rem; border-bottom: 1px solid var(--line); }
thead th { font-family: var(--font-head); font-size: 1.05rem; background: var(--info-bg); border-bottom: 2px solid var(--text); }
.mono-line { font: 600 1.05rem var(--font-head); background: var(--surface); border: 2px dashed var(--line); padding: .7rem 1rem; border-radius: var(--radius-s); letter-spacing: .02em; }
.callout { padding: 1rem 1.2rem; border-radius: var(--radius-s); margin: 1.25rem 0; border-left: 5px solid; }
.callout p:last-child { margin-bottom: 0; }
.callout.india { background: var(--warn-bg); border-color: var(--tag); }
.callout.tip { background: var(--info-bg); border-color: var(--shelf); }
.callout.warn { background: var(--bad-bg); border-color: var(--bad); }
.callout.task { background: var(--surface); border: 2px solid var(--text); border-left-width: 5px; }
.lesson-nav { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .75rem; margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }

/* ---------- Revision ---------- */
.recap { background: var(--surface); border: 2px solid var(--line); border-top: 6px solid var(--tag); padding: 1.25rem 1.5rem; margin-bottom: 2rem; border-radius: var(--radius-s); max-width: 760px; }
.recap ul { margin: 0; padding-left: 1.2rem; }
.recap li { margin-bottom: .4rem; }
.quiz { max-width: 760px; }
.q { border: 2px solid var(--line); border-radius: var(--radius-s); background: var(--surface); padding: 1rem 1.2rem 1.1rem; margin: 0 0 1rem; }
.q legend { display: flex; gap: .7rem; align-items: baseline; font-weight: 600; padding: 0 .3rem; font-size: 1.05rem; }
.q-no { font: 700 1.2rem var(--font-head); color: var(--muted); }
.opt { display: flex; gap: .7rem; align-items: flex-start; padding: .55rem .7rem; margin-top: .35rem; border-radius: var(--radius-s); cursor: pointer; }
.opt:hover { background: var(--bg); }
.opt input { margin-top: .35rem; width: 1.1rem; height: 1.1rem; accent-color: var(--text); flex: none; }
.q.right { border-color: var(--ok); }
.q.wrong { border-color: var(--bad); }
.q .opt.is-answer { background: var(--ok-bg); font-weight: 600; }
.why { margin: .75rem 0 0; padding-top: .75rem; border-top: 1px dashed var(--line); }
.q.right .why { color: var(--ok); }
.q.wrong .why { color: var(--text); }
.result { padding: 1.5rem; border-radius: var(--radius-s); border: 3px solid; margin-top: 1rem; }
.result.pass { border-color: var(--ok); background: var(--ok-bg); }
.result.fail { border-color: var(--bad); background: var(--bad-bg); }
.score { font: 700 3.5rem/1 var(--font-head); margin: 0 0 .5rem; }

/* ---------- Parts library ---------- */
.search input { max-width: 520px; }
.part-svg { width: 72px; height: 72px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; color: var(--text); }
.part-svg .acc { fill: var(--accent-fill); }
.part-svg.big { width: 110px; height: 110px; flex: none; }
.part-svg.hero { width: 100%; height: auto; max-width: 240px; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; }
.cat { display: flex; flex-direction: column; align-items: flex-start; gap: .5rem; padding: 1.1rem; background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius-s); text-decoration: none; }
.cat:hover { border-color: var(--text); }
.cat-name { font: 700 1.35rem/1.15 var(--font-head); }
.cat-head { display: flex; gap: 1.5rem; align-items: center; }
.part-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.part-tile { position: relative; display: flex; flex-direction: column; gap: .4rem; padding: 1.1rem 1.1rem 1rem 2.4rem; background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius-s) 14px 14px var(--radius-s); text-decoration: none; }
.part-tile:hover { border-color: var(--text); }
.part-tile .hole { position: absolute; left: .8rem; top: 1.2rem; width: .75rem; height: .75rem; border-radius: 50%; border: 2px solid var(--line); background: var(--bg); }
.part-name { font: 700 1.25rem/1.15 var(--font-head); }
.part-meta { color: var(--muted); font-size: .9rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .25rem; }
.chip { display: inline-block; font-size: .8rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; border: 1.5px solid var(--line); }
.chip.mv-fast { border-color: var(--ok); color: var(--ok); }
.chip.mv-medium { border-color: var(--shelf); }
.chip.mv-slow { color: var(--muted); }
.chip.safety { border-color: var(--bad); color: var(--bad); }
.part-hero { display: grid; grid-template-columns: minmax(160px, 240px) 1fr; gap: 2rem; align-items: center; margin-bottom: 2rem; }
.part-hero:has(.photo) { grid-template-columns: minmax(140px, 200px) minmax(160px, 260px) 1fr; }
.figure { margin: 0; background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius-m); padding: 1.25rem; text-align: center; }
.figure figcaption { font-size: .8rem; color: var(--muted); margin-top: .4rem; }
.figure.photo img { border-radius: var(--radius-s); display: block; margin: 0 auto; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.facts section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 1rem 1.2rem; }
.facts h2 { font-size: 1.2rem; }
.facts ul { padding-left: 1.2rem; margin: 0; }
.facts p { margin: 0; }
.facts .warnish { border: 2px solid var(--tag); background: var(--warn-bg); }
.related { margin-top: 1.5rem; }

/* ---------- Checklists ---------- */
.sheet-block { margin-bottom: 2.5rem; }
.sheet td { height: 2.2rem; }

/* ---------- Account ---------- */
.account { margin-top: 2.5rem; max-width: 420px; }

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login-art { padding: 2.5rem 1.5rem; }
  .login-sub { margin-top: 1.5rem; }
  .app { grid-template-columns: 1fr; }
  .topbar { display: flex; align-items: center; gap: .75rem; position: sticky; top: 0; z-index: 20; background: var(--ink); padding: .6rem 1rem; }
  .menu-btn { width: 44px; height: 44px; display: grid; place-content: center; gap: 5px; background: transparent; border: 0; cursor: pointer; }
  .menu-btn span { display: block; width: 22px; height: 2px; background: #fff; }
  .sidebar { position: fixed; z-index: 30; top: 0; left: 0; width: 280px; transform: translateX(-100%); transition: transform .2s ease; }
  .menu-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); }
  .part-hero, .part-hero:has(.photo) { grid-template-columns: 1fr; }
  .figure { max-width: 260px; }
  .steps a, .steps .fake-link { grid-template-columns: auto 1fr; }
  .step-state { grid-column: 2; }
  .cat-head { flex-direction: column; align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* ---------- Print (checklists) ---------- */
@media print {
  .sidebar, .topbar, .page-head .btn, .banner { display: none !important; }
  .app { display: block; }
  body { background: #fff; color: #000; font-size: 12px; }
  .main { max-width: none; padding: 0; }
  .sheet-block { page-break-after: always; }
  table, thead th { background: #fff; }
}

/* ---------- Content editor ---------- */
.ed-tabs { display: flex; flex-wrap: wrap; gap: .25rem; border-bottom: 2px solid var(--line); margin-bottom: 1.5rem; }
.ed-tabs a { padding: .65rem 1rem; text-decoration: none; font-weight: 600; color: var(--muted); border-bottom: 4px solid transparent; margin-bottom: -2px; }
.ed-tabs a.active { color: var(--text); border-bottom-color: var(--tag); }
.ed-bar { margin-bottom: 1rem; }
.ed-table td { vertical-align: middle; }
.row-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.part-svg.small { width: 40px; height: 40px; }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.danger:hover { background: var(--bad-bg); }
.btn.primary-outline { border-color: var(--tag); }
.ed-form { max-width: 860px; }
.ed-form label { display: block; font-weight: 600; margin-bottom: 1rem; }
.ed-form textarea, .ed-form select { display: block; width: 100%; margin-top: .35rem; padding: .6rem .8rem; border: 2px solid var(--line); border-radius: var(--radius-s); background: var(--bg); color: var(--text); font: 400 1rem/1.5 var(--font-body); }
.ed-form select { min-height: 46px; }
.ed-form textarea:focus, .ed-form select:focus { border-color: var(--text); outline: none; }
.ed-form textarea.code { font: 400 .92rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.hint { font-weight: 400; color: var(--muted); font-size: .9rem; margin-left: .35rem; }
.ed-card { background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius-m); padding: 1.25rem 1.4rem .5rem; margin: 0 0 1.5rem; }
section.ed-card { padding-bottom: 1.25rem; }
.ed-card legend { font: 700 1.3rem var(--font-head); padding: 0 .4rem; }
.ed-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 1rem; align-items: end; }
.ed-section { margin: 2rem 0; }
.ed-list { counter-reset: blk; }
.ed-block { counter-increment: blk; background: var(--surface); border: 2px solid var(--line); border-left: 6px solid var(--tag); border-radius: var(--radius-s); padding: 1rem 1.2rem .25rem; margin-bottom: 1rem; }
.ed-block-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.ed-num { font: 700 1.2rem var(--font-head); }
.ed-num::after { content: " " counter(blk); }
.ed-block-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.ed-toolbar { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .6rem; }
.ed-preview { border: 2px dashed var(--line); border-radius: var(--radius-s); padding: 1rem 1.2rem; margin-bottom: 1rem; background: var(--bg); }
.ed-opts { border: 0; padding: 0; margin: 0 0 1rem; }
.ed-opts legend { font-weight: 600; margin-bottom: .4rem; }
.ed-opt { display: flex; gap: .6rem; align-items: center; margin-bottom: .4rem; }
.ed-opt input[type=radio] { width: 1.2rem; height: 1.2rem; accent-color: var(--ok); flex: none; }
.ed-opt input:not([type=radio]) { margin-top: 0; }
.ed-icon { display: flex; align-items: flex-end; gap: .75rem; }
.ed-icon label { flex: 1; }
.ed-icon-prev { margin-bottom: 1rem; }
.ed-icon-prev .part-svg { width: 48px; height: 48px; }
.ed-check { display: flex !important; align-items: center; gap: .5rem; min-height: 46px; }
.ed-check input { width: 1.2rem; height: 1.2rem; accent-color: var(--text); }
.ed-photo { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem; margin-bottom: 1rem; }
.ed-photo label:first-child { flex: 1 1 320px; margin-bottom: 0; }
.ed-upload { cursor: pointer; margin: 0 !important; }
.ed-upload.busy { opacity: .6; pointer-events: none; }
.ed-upload.busy::after { content: "…"; }
.ed-photo-prev { width: 120px; height: 90px; object-fit: cover; border-radius: var(--radius-s); border: 2px solid var(--line); }
.ed-save { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; padding: 1rem 0; background: var(--bg); border-top: 2px solid var(--line); }
.ed-save .error { margin: 0; }
.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 150%); background: var(--ok); color: var(--bg); padding: .8rem 1.25rem; border-radius: var(--radius-s); font-weight: 600; z-index: 50; transition: transform .2s ease; max-width: 90vw; }
.toast.bad { background: var(--bad); }
.toast.show { transform: translate(-50%, 0); }
.prose figure { margin: 1.25rem 0; }
.prose figure img { border-radius: var(--radius-s); border: 1px solid var(--line); }
.prose figcaption { font-size: .9rem; color: var(--muted); margin-top: .3rem; }
.video { position: relative; aspect-ratio: 16 / 9; margin: 1.25rem 0; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: var(--radius-s); }
