/* QualPol Handbook — refined-industrial design system
   Navy blueprint backdrop · white cards · navy accent + gold attention · engineered type */

:root {
  --bg:          #173a61;
  --bg-2:        #12304f;
  --paper:       #ffffff;
  --paper-2:     #eef1f5;
  --ink:         #19222e;
  --ink-soft:    #41505f;
  --steel:       #6a7787;   /* secondary text */
  --steel-soft:  #97a3b2;
  --line:        #e2e7ed;
  --line-strong: #ccd4dd;
  --accent:      #235086;   /* QualPol navy — primary actions, focus, links */
  --accent-deep: #18395f;
  --accent-soft: #e7eef6;
  --gold:        #d3881f;   /* attention only — needs-to-sign, pending, modified */
  --gold-deep:   #b06f12;
  --gold-soft:   #f6e7cd;
  --ok:          #2c8a57;  --ok-bg: #e8f3ec;  --ok-line: #c2e0cf;
  --err:         #bf3c2b;  --err-bg: #f9e9e5; --err-line: #edc9bf;
  --info:        #2f6d9c;  --info-bg: #e9f1f7; --info-line: #ccdded;
  --r:   14px;
  --r-sm: 9px;
  --shadow: 0 1px 2px rgba(18,20,24,.05), 0 14px 30px -10px rgba(18,20,24,.28), 0 34px 70px -28px rgba(18,20,24,.34);
  --font-display: 'Archivo', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100svh;
}

/* ---- Auth pages: graphite blueprint backdrop ---- */
body.page-auth {
  background-color: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 50% -12%, rgba(120,165,220,.22), transparent 62%),
    linear-gradient(180deg, rgba(255,255,255,.04), rgba(0,0,0,.12)),
    linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: auto, auto, 30px 30px, 30px 30px;
  background-attachment: fixed;
}
body.page-auth::before {
  /* fine grain */
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.035'/%3E%3C/svg%3E");
}

/* ---- App pages: light, reading-friendly ---- */
body.page-app { background-color: var(--paper-2); }

/* =========================================================
   Brand
   ========================================================= */
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; }
.brand:hover .brand-logo { opacity: .8; }
.monogram {
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  border: 2px solid var(--accent);
  background: radial-gradient(circle at 32% 26%, #ffffff, var(--paper-2));
  font-family: var(--font-display); font-weight: 800; font-size: 15px;
  letter-spacing: .02em; color: var(--ink);
  box-shadow: inset 0 0 0 3px #fff;
}
.wordmark {
  font-family: var(--font-display); font-weight: 800;
  font-size: 22px; letter-spacing: .055em; line-height: 1;
}
.wm-qual { color: var(--ink); }
.wm-pol  { color: var(--steel); }
.page-auth .wm-qual { color: var(--paper); }
.page-auth .wm-pol  { color: var(--steel-soft); }
.brand-logo { display: block; height: 30px; width: auto; transition: opacity .15s; }
.auth-head .brand-logo { height: 38px; }

/* =========================================================
   Auth layout + card
   ========================================================= */
.auth-shell {
  position: relative; z-index: 1;
  min-height: 100svh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 20px;
  gap: 18px;
}
.auth-card {
  width: 100%; max-width: 432px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 34px 32px 32px;
  position: relative;
  overflow: hidden;
  animation: rise .55s cubic-bezier(.2,.7,.2,1) both;
}
.auth-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent) 55%, #5e87bb);
}
.auth-card--center { text-align: center; }

.auth-head { margin-bottom: 22px; }
.auth-head .brand { margin-bottom: 18px; }
.eyebrow {
  margin: 0 0 7px; font-weight: 600; font-size: .68rem;
  text-transform: uppercase; letter-spacing: .17em; color: var(--accent-deep);
}
.auth-title {
  font-family: var(--font-display); font-weight: 700;
  font-size: 1.7rem; line-height: 1.1; letter-spacing: -.01em;
  margin: 0 0 6px; color: var(--ink);
}
.auth-sub { margin: 0; color: var(--ink-soft); font-size: .95rem; line-height: 1.5; }

.auth-foot {
  position: relative; z-index: 1;
  margin: 0; text-align: center;
  color: var(--steel-soft); font-size: .72rem; letter-spacing: .05em;
}

/* =========================================================
   Forms
   ========================================================= */
.form { display: flex; flex-direction: column; gap: 17px; }
.field { display: flex; flex-direction: column; gap: 7px; text-align: left; }
.field label {
  font-size: .74rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .08em; color: var(--ink-soft);
}
.control {
  font-family: var(--font-body); font-size: 16px; color: var(--ink);
  height: 52px; padding: 0 14px;
  background: #fff;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-sm);
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.control::placeholder { color: var(--steel-soft); }
.control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.control--code {
  font-family: var(--font-mono); font-size: 26px; font-weight: 500;
  text-align: center; letter-spacing: .55em; padding-left: calc(14px + .55em);
}
.hint { margin: 0; font-size: .78rem; color: var(--steel); }

/* =========================================================
   Buttons
   ========================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-body); font-weight: 600; font-size: 1rem;
  height: 52px; padding: 0 22px; border-radius: var(--r-sm);
  border: 1.5px solid transparent; cursor: pointer; text-decoration: none;
  transition: transform .08s, box-shadow .15s, background-color .15s, border-color .15s;
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  color: #fff; font-weight: 700; letter-spacing: .01em;
  box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, 0 8px 18px -8px rgba(20,46,80,.6);
}
.btn-primary:hover { box-shadow: 0 1px 0 rgba(255,255,255,.22) inset, 0 12px 24px -8px rgba(20,46,80,.75); }
.btn-primary:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--accent-soft), 0 8px 18px -8px rgba(20,46,80,.6); }
/* Auth/sign forms: the submit button is a direct child of .form and spans full width.
   Buttons nested in an actions row (.editor-section__actions) keep their natural width. */
.form > .btn { width: 100%; margin-top: 4px; }
.btn-ghost {
  height: 42px; padding: 0 16px; font-size: .9rem; font-weight: 600;
  background: transparent; color: var(--ink-soft); border-color: var(--line);
}
.btn-ghost:hover { background: var(--paper-2); border-color: var(--line-strong); color: var(--ink); }

/* =========================================================
   Flash alerts
   ========================================================= */
.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; margin: 0 0 18px;
  border: 1px solid; border-radius: var(--r-sm);
  border-left-width: 4px; font-size: .9rem; line-height: 1.45; text-align: left;
}
.alert__icon { flex: none; width: 18px; height: 18px; margin-top: 1px; border-radius: 50%; position: relative; }
.alert__icon::after {
  content: ""; position: absolute; inset: 0; display: block;
  background: currentColor; -webkit-mask: center/14px no-repeat; mask: center/14px no-repeat;
}
.alert--error   { color: var(--err);  background: var(--err-bg);  border-color: var(--err-line);  border-left-color: var(--err); }
.alert--success { color: var(--ok);   background: var(--ok-bg);   border-color: var(--ok-line);   border-left-color: var(--ok); }
.alert--info    { color: var(--info); background: var(--info-bg); border-color: var(--info-line); border-left-color: var(--info); }
.alert span:last-child { color: var(--ink); }

/* =========================================================
   TOTP enrollment
   ========================================================= */
.qr-frame {
  width: max-content; margin: 4px auto 0;
  padding: 14px; background: #fff;
  border: 1px solid var(--line-strong); border-radius: 12px;
  position: relative;
}
.qr-frame::before, .qr-frame::after {
  content: ""; position: absolute; width: 16px; height: 16px; border: 2px solid var(--accent);
}
.qr-frame::before { top: 6px; left: 6px; border-right: 0; border-bottom: 0; border-top-left-radius: 4px; }
.qr-frame::after  { bottom: 6px; right: 6px; border-left: 0; border-top: 0; border-bottom-right-radius: 4px; }
.qr { display: block; width: 190px; height: 190px; }

.divider {
  display: flex; align-items: center; gap: 12px;
  margin: 18px 0 14px; color: var(--steel-soft);
  font-size: .68rem; text-transform: uppercase; letter-spacing: .15em;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.secret {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  background: var(--paper-2); border: 1px dashed var(--line-strong);
  border-radius: var(--r-sm); padding: 11px 12px; margin-bottom: 20px;
}
.secret code {
  font-family: var(--font-mono); font-size: 14px; letter-spacing: .1em;
  color: var(--ink); word-break: break-all;
}
.copy-btn {
  flex: none; cursor: pointer;
  font-family: var(--font-body); font-size: .76rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--accent-deep); background: #fff;
  border: 1.5px solid var(--line-strong); border-radius: 7px; padding: 7px 11px;
  transition: border-color .15s, color .15s;
}
.copy-btn:hover { border-color: var(--accent); }
.copy-btn.is-copied { color: var(--ok); border-color: var(--ok-line); }

/* =========================================================
   App shell (home / future reader)
   ========================================================= */
.app-topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px; padding: 0 20px;
  background: var(--paper); border-bottom: 1px solid var(--line);
}
.app-topbar .wordmark { font-size: 19px; }
.app-main { max-width: 720px; margin: 0 auto; padding: 32px 20px 60px; }
.panel {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow);
  padding: 30px 30px 26px;
  animation: rise .5s cubic-bezier(.2,.7,.2,1) both;
}
.panel-title {
  font-family: var(--font-display); font-weight: 700; font-size: 1.6rem;
  letter-spacing: -.01em; margin: 0 0 6px;
}
.panel-sub { margin: 0 0 22px; color: var(--ink-soft); line-height: 1.55; }
.meta { display: grid; gap: 1px; margin: 0; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.meta > div { display: flex; justify-content: space-between; gap: 16px; background: #fff; padding: 13px 16px; }
.meta dt { margin: 0; color: var(--steel); font-size: .82rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.meta dd { margin: 0; color: var(--ink); font-weight: 500; }
.badge {
  display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; padding: 3px 9px; border-radius: 999px;
}
.badge--admin    { background: var(--gold-soft); color: var(--gold-deep); }
.badge--employee { background: #e9eef2; color: var(--info); }

/* =========================================================
   Motion + responsive
   ========================================================= */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.auth-card > * { animation: rise .5s cubic-bezier(.2,.7,.2,1) both; }
.auth-card > *:nth-child(1) { animation-delay: .05s; }
.auth-card > *:nth-child(2) { animation-delay: .11s; }
.auth-card > *:nth-child(3) { animation-delay: .17s; }
.auth-card > *:nth-child(4) { animation-delay: .23s; }

@media (max-width: 480px) {
  .auth-card { padding: 28px 22px 26px; border-radius: 12px; }
  .auth-title { font-size: 1.5rem; }
  .app-main { padding: 22px 16px 48px; }
  .panel { padding: 24px 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .auth-card, .panel, .auth-card > * { animation: none; }
}

/* =========================================================
   Topbar actions + home CTA
   ========================================================= */
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.topbar-link { color: var(--ink-soft); text-decoration: none; font-weight: 600; font-size: .92rem; }
.topbar-link:hover { color: var(--ink); }
.cta { width: auto; display: inline-flex; margin-top: 4px; }
.empty-state { text-align: center; }
.empty-state .btn { margin-top: 8px; }

/* =========================================================
   Handbook reader
   ========================================================= */
html { scroll-behavior: smooth; }

.reader {
  max-width: 1080px; margin: 0 auto; padding: 30px 20px 84px;
  display: grid; grid-template-columns: 234px 1fr; gap: 44px; align-items: start;
}
.toc { position: sticky; top: 84px; }
.toc-label {
  margin: 0 0 10px; font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .14em; color: var(--steel);
}
.toc-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column;
  border-left: 2px solid var(--line);
}
.toc-list a {
  display: block; padding: 7px 14px; margin-left: -2px;
  border-left: 2px solid transparent; border-radius: 0 7px 7px 0;
  color: var(--ink-soft); text-decoration: none; font-size: .9rem; line-height: 1.35;
  transition: color .15s, background-color .15s, border-color .15s;
}
.toc-list a:hover { color: var(--ink); background: var(--paper); border-left-color: var(--accent); }

.reader-main { min-width: 0; }
.reader-head { margin-bottom: 8px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.reader-title {
  font-family: var(--font-display); font-weight: 800; font-size: 2rem;
  letter-spacing: -.015em; margin: 0 0 6px; color: var(--ink);
}
.reader-meta { margin: 0; color: var(--steel); font-size: .9rem; }
.pill {
  display: inline-block; font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  padding: 4px 11px; border-radius: 999px; margin-bottom: 12px;
}
.pill--draft { background: var(--gold-soft); color: var(--gold-deep); }

.chapters { counter-reset: ch; }
.chapter { scroll-margin-top: 84px; padding: 30px 0; border-top: 1px solid var(--line); }
.chapter:first-child { border-top: 0; padding-top: 14px; }
.chapter-title {
  font-family: var(--font-display); font-weight: 700; font-size: 1.5rem;
  letter-spacing: -.01em; margin: 0 0 16px; color: var(--ink);
  display: flex; align-items: baseline; gap: 13px;
}
.chapter-title::before {
  counter-increment: ch; content: counter(ch, decimal-leading-zero);
  font-family: var(--font-mono); font-size: .82rem; font-weight: 500;
  color: var(--accent-deep); letter-spacing: .04em;
  border: 1px solid var(--accent-soft); border-radius: 6px; padding: 2px 7px;
}

.prose { max-width: 68ch; color: var(--ink-soft); font-size: 1.02rem; line-height: 1.72; }
.prose h3 { font-family: var(--font-display); font-weight: 700; font-size: 1.14rem; color: var(--ink); margin: 28px 0 9px; }
.prose h4 { font-weight: 600; font-size: 1.02rem; color: var(--ink); margin: 22px 0 7px; }
.prose p { margin: 0 0 15px; }
.prose ul, .prose ol { margin: 0 0 15px; padding-left: 22px; }
.prose li { margin: 0 0 8px; }
.prose li::marker { color: var(--accent); }
.prose strong, .prose b { color: var(--ink); font-weight: 600; }
.prose a { color: var(--accent-deep); text-decoration: underline; text-underline-offset: 2px; }
.prose blockquote { margin: 0 0 15px; padding: 4px 0 4px 16px; border-left: 3px solid var(--line-strong); color: var(--steel); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }

@media (max-width: 860px) {
  .reader { grid-template-columns: 1fr; gap: 0; padding-top: 18px; }
  .toc {
    position: static; margin-bottom: 20px;
    background: var(--paper); border: 1px solid var(--line);
    border-radius: var(--r); padding: 14px 16px;
  }
  .toc-list { border-left: 0; }
  .toc-list a { border-left: 0; border-radius: 7px; }
  .toc-list a:hover { background: var(--paper-2); border-left-color: transparent; }
  .reader-title { font-size: 1.62rem; }
  .chapter-title { font-size: 1.32rem; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* =========================================================
   Acknowledgment — banner, publish bar, sign page, history
   ========================================================= */
.reader-top { max-width: 1080px; margin: 0 auto; padding: 22px 20px 0; }
.reader-top > * + * { margin-top: 14px; }

.ackbar {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  background: linear-gradient(180deg, #fff, var(--gold-soft));
  border: 1px solid var(--gold-soft); border-left: 4px solid var(--gold);
  border-radius: var(--r); padding: 14px 18px; box-shadow: var(--shadow);
}
.ackbar__title { display: block; font-weight: 700; font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: var(--gold-deep); margin-bottom: 2px; }
.ackbar__msg { color: var(--ink); font-size: .95rem; }
.ackbar__btn { width: auto; height: 44px; flex: none; margin-top: 0; }

.admin-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  background: var(--paper); border: 1px solid var(--line); border-left: 4px solid var(--steel);
  border-radius: var(--r); padding: 14px 18px;
}
.admin-bar__text { margin: 0; font-size: .92rem; color: var(--ink-soft); }
.admin-bar__btn { width: auto; height: 44px; flex: none; margin-top: 0; }

.ack-confirm { display: flex; align-items: center; gap: 8px; color: var(--ok); font-weight: 600; font-size: .92rem; margin: 0 0 18px; }
.ack-confirm a { color: var(--accent-deep); }
.ack-confirm__check { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--ok-bg); color: var(--ok); font-size: .72rem; }

.reader-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.reader-tags:empty { display: none; }
.pill--signed { background: var(--ok-bg); color: var(--ok); }

.reader-signoff {
  margin-top: 36px; padding: 24px; text-align: center;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r);
}
.reader-signoff p { margin: 0 0 14px; color: var(--ink-soft); }

/* Sign page + history share a narrow column */
.ack-wrap { max-width: 640px; margin: 0 auto; padding: 30px 20px 72px; }
.ack-wrap .panel { animation: rise .5s cubic-bezier(.2,.7,.2,1) both; }

.statement {
  margin: 18px 0 22px; padding: 16px 18px;
  background: var(--paper-2); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: var(--r-sm); color: var(--ink); font-size: .96rem; line-height: 1.62;
}

.check-row { display: flex; align-items: flex-start; gap: 11px; cursor: pointer; }
.check-row input[type="checkbox"] { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent-deep); flex: none; cursor: pointer; }
.check-row span { color: var(--ink); font-size: .96rem; line-height: 1.45; }

.signed-state { text-align: center; }
.signed-check {
  display: inline-grid; place-items: center; width: 56px; height: 56px; margin: 0 auto 16px;
  border-radius: 50%; background: var(--ok-bg); color: var(--ok); font-size: 1.6rem; font-weight: 700;
}
.ack-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }

.empty-note { color: var(--steel); margin: 8px 0 0; }
.siglist { list-style: none; margin: 20px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.sigitem {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm);
}
.sigitem__check { display: inline-grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 50%; background: var(--ok-bg); color: var(--ok); font-weight: 700; }
.sigitem__body { min-width: 0; }
.sigitem__title { margin: 0 0 2px; font-weight: 600; color: var(--ink); }
.sigitem__ver { color: var(--accent-deep); }
.sigitem__date { margin: 0; font-size: .86rem; color: var(--steel); }

.admin-bar__actions { display: flex; gap: 10px; align-items: center; flex: none; }

@media (max-width: 560px) {
  .ackbar, .admin-bar { flex-direction: column; align-items: stretch; }
  .ackbar__btn, .admin-bar__btn { width: 100%; }
  .admin-bar__actions { width: 100%; }
  .admin-bar__actions .admin-bar__btn, .admin-bar__actions form { flex: 1; }
}

/* =========================================================
   Button variants (sizes, icon, danger, block)
   ========================================================= */
.btn-sm { height: 40px; padding: 0 14px; font-size: .88rem; }
.btn-icon { width: 40px; height: 40px; padding: 0; font-size: 1.05rem; line-height: 1; background: #fff; border-color: var(--line-strong); color: var(--ink-soft); }
.btn-icon:hover { border-color: var(--accent); color: var(--ink); background: var(--paper); }
.btn-danger { background: #fff; color: var(--err); border-color: var(--err-line); height: 40px; padding: 0 14px; font-size: .88rem; }
.btn-danger:hover { background: var(--err-bg); }
.btn-block { width: 100%; }

/* =========================================================
   Handbook editor
   ========================================================= */
.editor-wrap { max-width: 780px; margin: 0 auto; padding: 30px 20px 72px; }
.editor-head { margin-bottom: 20px; }
.editor-head .panel-sub { margin-top: 6px; }

.chapter-list { list-style: none; counter-reset: ed; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.chapter-row {
  display: flex; align-items: center; gap: 14px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 14px 16px;
}
.chapter-row__num {
  counter-increment: ed; flex: none;
  display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 6px;
  font-family: var(--font-mono); font-size: .8rem; font-weight: 500; color: var(--accent-deep);
  background: var(--accent-soft); border-radius: 6px;
}
.chapter-row__num::before { content: counter(ed, decimal-leading-zero); }
.chapter-row__body { flex: 1; min-width: 0; }
.chapter-row__heading { margin: 0 0 2px; font-weight: 600; color: var(--ink); }
.chapter-row__preview { margin: 0; font-size: .85rem; color: var(--steel); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chapter-row__actions { display: flex; align-items: center; gap: 6px; flex: none; }

.add-chapter { margin-bottom: 28px; }

.publish-panel {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r);
  padding: 22px 22px 24px; box-shadow: var(--shadow);
}
.publish-panel__title { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; margin: 0 0 6px; }
.publish-panel__note { margin: 0 0 18px; color: var(--ink-soft); font-size: .92rem; line-height: 1.55; }
.publish-panel__actions { display: flex; gap: 12px; flex-wrap: wrap; }

.control--area { height: auto; min-height: 440px; padding: 14px; font-family: var(--font-mono); font-size: 14px; line-height: 1.6; resize: vertical; }
.hint code { font-family: var(--font-mono); font-size: .82em; background: var(--paper-2); padding: 1px 5px; border-radius: 4px; }
.editor-section__actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 4px; }

@media (max-width: 560px) {
  .chapter-row { flex-wrap: wrap; }
  .chapter-row__actions { width: 100%; justify-content: flex-start; padding-left: 44px; }
  .editor-section__actions { justify-content: stretch; }
  .editor-section__actions .btn { flex: 1; }
}

/* =========================================================
   Admin — users
   ========================================================= */
.admin-wrap { max-width: 880px; margin: 0 auto; padding: 30px 20px 72px; }
.admin-wrap--narrow { max-width: 560px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; }
.page-head .panel-title { margin: 0; }

/* select styled like a text control */
select.control {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236f7882' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
  padding-right: 38px; cursor: pointer;
}

.user-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.user-row {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 14px 16px;
}
.user-row__id { display: flex; align-items: center; gap: 12px; min-width: 200px; flex: 1; }
.avatar {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 32% 26%, #fff, var(--paper-2));
  border: 1.5px solid var(--line-strong);
  font-family: var(--font-display); font-weight: 700; font-size: .82rem; color: var(--ink-soft);
}
.user-row__name { margin: 0; font-weight: 600; color: var(--ink); }
.you { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent-deep); background: var(--accent-soft); padding: 1px 6px; border-radius: 999px; vertical-align: middle; }
.user-row__handle { margin: 0; font-size: .85rem; color: var(--steel); font-family: var(--font-mono); }
.user-row__tags { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-row__login { font-size: .8rem; color: var(--steel-soft); }
.user-row__actions { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.pill--off { background: #ececea; color: var(--steel); }

.cred-fields { margin: 18px 0 24px; display: flex; flex-direction: column; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.cred-field { display: flex; align-items: center; gap: 12px; background: #fff; padding: 14px 16px; }
.cred-field dt { margin: 0; flex: none; width: 150px; color: var(--steel); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.cred-value { margin: 0; font-weight: 600; color: var(--ink); word-break: break-all; }
.cred-value--mono { font-family: var(--font-mono); font-size: 1.05rem; letter-spacing: .04em; }
.cred-field .copy-btn { margin-left: auto; }

@media (max-width: 560px) {
  .page-head { flex-direction: column; align-items: stretch; }
  .user-row__actions { margin-left: 0; width: 100%; }
  .cred-field { flex-wrap: wrap; }
  .cred-field dt { width: auto; }
}

/* =========================================================
   Compliance dashboard
   ========================================================= */
.comp-summary { margin-bottom: 28px; }
.comp-stats { display: flex; gap: 14px; margin-bottom: 18px; }
.comp-stat { flex: 1; text-align: center; padding: 14px 10px; background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r-sm); }
.comp-stat__num { display: block; font-family: var(--font-display); font-weight: 800; font-size: 1.9rem; line-height: 1; color: var(--ink); }
.comp-stat__num--warn { color: var(--gold-deep); }
.comp-stat__label { display: block; margin-top: 6px; font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; color: var(--steel); }
.progress { height: 10px; background: var(--paper-2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.progress__bar { height: 100%; background: linear-gradient(90deg, var(--ok), #3aa873); border-radius: 999px; transition: width .4s; }
.comp-summary__caption { margin: 10px 0 0; font-size: .85rem; color: var(--steel); text-align: right; }

.comp-section { margin-bottom: 26px; }
.comp-section__title { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; color: var(--ink); display: flex; align-items: center; gap: 9px; margin: 0 0 12px; }
.comp-count { font-family: var(--font-mono); font-size: .8rem; font-weight: 500; color: var(--steel); background: var(--paper-2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; }
.comp-count--warn { color: var(--gold-deep); background: var(--gold-soft); border-color: var(--gold-soft); }
.comp-allclear { display: flex; align-items: center; gap: 8px; color: var(--ok); font-weight: 600; background: var(--ok-bg); border: 1px solid var(--ok-line); border-radius: var(--r-sm); padding: 14px 16px; margin: 0; }

.comp-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.comp-row { display: flex; align-items: center; gap: 13px; background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 16px; }
.comp-row__id { flex: 1; min-width: 0; }
.comp-row__status { flex: none; font-size: .85rem; font-weight: 600; }
.comp-row__status--warn { color: var(--steel); }
.comp-row__status--ok { color: var(--ok); }

@media (max-width: 560px) {
  .comp-stats { flex-direction: column; }
  .comp-stat { display: flex; align-items: baseline; justify-content: center; gap: 8px; }
  .comp-stat__num { font-size: 1.4rem; }
  .comp-stat__label { margin-top: 0; }
}

/* =========================================================
   Admin hub (home tools)
   ========================================================= */
.admin-tools { margin-top: 20px; }
.admin-tools__title { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; margin: 0 0 16px; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.tool {
  display: flex; flex-direction: column; gap: 3px;
  padding: 15px 16px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--paper-2); text-decoration: none; transition: border-color .15s, background-color .15s, transform .08s;
}
.tool:hover { border-color: var(--accent); background: #fff; transform: translateY(-1px); }
.tool__name { font-weight: 700; color: var(--ink); }
.tool__desc { font-size: .82rem; color: var(--steel); }

/* =========================================================
   Data table (audit) + pager
   ========================================================= */
.audit-filter { display: flex; gap: 8px; align-items: center; }
.audit-filter .control { height: 44px; width: auto; min-width: 180px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; }
.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.data-table th { text-align: left; padding: 11px 14px; background: var(--paper-2); border-bottom: 1px solid var(--line); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--steel); white-space: nowrap; }
.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--line); color: var(--ink); vertical-align: top; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table .nowrap { white-space: nowrap; }
.data-table .muted { color: var(--steel); }
.data-empty { text-align: center; color: var(--steel); padding: 22px; }
.audit-detail { font-family: var(--font-mono); font-size: .78rem; color: var(--ink-soft); max-width: 280px; word-break: break-word; }
.evt { display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--paper-2); border: 1px solid var(--line); color: var(--ink-soft); white-space: nowrap; }
.evt--bad { background: var(--err-bg); border-color: var(--err-line); color: var(--err); }
.evt--ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }

.pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 20px; }
.pager__label { font-size: .85rem; color: var(--steel); }
.is-disabled { opacity: .45; pointer-events: none; }

/* =========================================================
   Version history + diff
   ========================================================= */
.version-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.version-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 13px 16px; }
.version-row__id { display: flex; align-items: center; gap: 10px; }
.version-row__num { font-family: var(--font-display); font-weight: 800; font-size: 1.05rem; color: var(--ink); }
.version-row__date { color: var(--steel); font-size: .88rem; }
.version-row .btn { margin-left: auto; }

.diff-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.diff-chip { font-size: .8rem; font-weight: 600; padding: 4px 11px; border-radius: 999px; background: var(--paper-2); border: 1px solid var(--line); color: var(--steel); }
.diff-chip--add { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.diff-chip--del { background: var(--err-bg); border-color: var(--err-line); color: var(--err); }
.diff-chip--mod { background: var(--gold-soft); border-color: var(--gold-soft); color: var(--gold-deep); }

.diff-section { margin-bottom: 26px; }
.diff-section__title { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; margin: 0 0 12px; }
.diff-headings { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.diff-headings li { padding: 10px 14px; border-radius: var(--r-sm); font-weight: 600; }
.diff-headings--add li { background: var(--ok-bg); border: 1px solid var(--ok-line); color: var(--ink); }
.diff-headings--del li { background: var(--err-bg); border: 1px solid var(--err-line); color: var(--ink); text-decoration: line-through; }

.diff-chapter { margin-bottom: 16px; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.diff-chapter__title { font-family: var(--font-display); font-weight: 700; font-size: 1rem; margin: 0; padding: 12px 16px; background: var(--paper-2); border-bottom: 1px solid var(--line); }
.diff-chapter__heading-change { margin: 0; padding: 10px 16px; font-size: .85rem; color: var(--accent-deep); background: var(--accent-soft); border-bottom: 1px solid var(--line); }
.diffbox { margin: 0; padding: 12px 16px; font-family: var(--font-mono); font-size: 13px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; background: #fff; }
.diffbox span { display: block; }
.diff-add { background: var(--ok-bg); color: #1c6b40; }
.diff-del { background: var(--err-bg); color: #9a2f20; }
.diff-ctx { color: var(--ink-soft); }

@media (max-width: 560px) {
  .page-head .audit-filter { width: 100%; }
  .audit-filter .control { flex: 1; }
  .version-row .btn { margin-left: 0; }
}
