:root {
  --ink: #571821;          /* YPN maroon */
  --ink-2: #7a2432;
  --ink-dk: #3a0f17;
  --desk: #f4efee;         /* guilloche lavender */
  --sheet: #ffffff;
  --rule: #e1d5d3;
  --rule-strong: #bfa9a6;
  --text: #241a1c;
  --muted: #6b5b5e;
  --gold: #b8912f;
  --red: #b3261e;
  --green: #1d7148;
  --amber-bg: #fff3d1;
  --amber: #7a4d00;
  --focus: #7a2432;
  --font: 'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'Courier Prime', 'Courier New', monospace;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 88px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; animation: none !important; } }
body { margin: 0; background: var(--desk); color: var(--text); font: 400 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
a { color: var(--ink-2); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 28px; background: #fff; color: var(--ink); border-bottom: 3px solid var(--gold); box-shadow: 0 1px 0 var(--rule); }
.brand { display: flex; align-items: center; gap: 14px; color: var(--ink); text-decoration: none; }
.brand-logo { height: 40px; width: auto; display: block; }
.brand-cap { padding-left: 14px; border-left: 1px solid var(--rule-strong); font-size: 13.5px; color: var(--muted); font-weight: 500; }
.top nav { display: flex; align-items: center; gap: 18px; }
.navlink { color: var(--ink); text-decoration: none; font-weight: 600; padding: 6px 2px; border-bottom: 2px solid transparent; }
.navlink:hover, .navlink[aria-current] { border-bottom-color: var(--gold); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px; border: 1.5px solid var(--ink); background: var(--sheet); color: var(--ink); font: 600 14.5px var(--font); text-decoration: none; border-radius: 3px; cursor: pointer; transition: background .12s; }
.btn:hover { background: #f7efee; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--ink-2); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 13.5px; }
.link { background: none; border: 0; padding: 2px 0; color: var(--ink-2); font: 500 14px var(--font); text-decoration: underline; cursor: pointer; }
.link.danger { color: var(--red); }

/* ---------- pills ---------- */
.pill { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 12.5px; font-weight: 600; border: 1px solid transparent; white-space: nowrap; }
.pill.draft { background: var(--amber-bg); color: var(--amber); border-color: #ecd28b; }
.pill.submitted { background: #f3e0e3; color: var(--ink); border-color: #e0b8be; }
.pill.issued { background: #dcf1e6; color: var(--green); border-color: #a9d8bf; }
.pill.none { color: var(--muted); border-color: var(--rule); background: transparent; font-weight: 500; }

/* ---------- page frame ---------- */
main { padding: 28px; max-width: 1560px; margin: 0 auto; outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 28px; font-weight: 700; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.crumb { font-size: 14px; margin-bottom: 6px; display: inline-block; }

/* ---------- dashboard ---------- */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.search { flex: 1 1 260px; max-width: 380px; }
.search input { width: 100%; height: 40px; padding: 0 12px; border: 1.5px solid var(--rule-strong); background: #fff; font: inherit; border-radius: 3px; }
.seg { display: inline-flex; border: 1.5px solid var(--rule-strong); border-radius: 3px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: 0 14px; height: 37px; font: 500 14px var(--font); cursor: pointer; color: var(--text); }
.seg button + button { border-left: 1px solid var(--rule); }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.ledger { width: 100%; border-collapse: collapse; background: var(--sheet); border: 1px solid var(--rule-strong); }
.ledger th { text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 2px solid var(--ink); background: #fbf7f6; white-space: nowrap; }
.ledger td { padding: 12px 14px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.ledger tr:last-child td { border-bottom: 0; }
.ledger tbody tr:hover { background: #fbf7f6; }
.ledger .num { text-align: right; font-variant-numeric: tabular-nums; }
.ledger .appno { font-variant-numeric: tabular-nums; font-weight: 600; }
.ledger .name { font-weight: 600; }
.ledger .sub { color: var(--muted); font-size: 13px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-start; flex-wrap: wrap; }
.empty { background: var(--sheet); border: 1.5px dashed var(--rule-strong); padding: 48px 24px; text-align: center; }
.empty h2 { font-size: 20px; margin-bottom: 6px; }
.empty p { color: var(--muted); margin: 0 auto 18px; max-width: 46ch; }
@media (max-width: 900px) {
  .ledger thead { display: none; }
  .ledger, .ledger tbody, .ledger tr, .ledger td { display: block; width: 100%; }
  .ledger tr { padding: 10px 4px; border-bottom: 1px solid var(--rule-strong); }
  .ledger td { border: 0; padding: 3px 14px; }
  .ledger .num { text-align: left; }
  .row-actions { justify-content: flex-start; margin-top: 6px; }
}

.form-layout { display: grid; gap: 28px; grid-template-columns: minmax(0, 1fr); align-items: start; padding-bottom: 92px; }
@media (min-width: 1100px) { .form-layout { grid-template-columns: minmax(0, 1fr) 420px; } }
@media (min-width: 1380px) { .form-layout { grid-template-columns: 190px minmax(0, 1fr) 440px; } }
.rail { display: none; position: sticky; top: 92px; }
@media (min-width: 1380px) { .rail { display: block; } }
.rail ol { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--rule-strong); }
.rail a { display: block; padding: 7px 0 7px 14px; margin-left: -2px; border-left: 2px solid transparent; color: var(--muted); text-decoration: none; font-weight: 500; font-size: 14.5px; }
.rail a:hover { color: var(--ink); }
.rail a.active { color: var(--ink); border-left-color: var(--ink); font-weight: 600; }
.rail a.has-error { color: var(--red); }
.rail a.has-error::after { content: 'Needs attention'; display: block; font-size: 12px; font-weight: 500; }

.sheet { background: var(--sheet); border: 1px solid var(--rule-strong); }
.sheet > section { padding: 26px 30px 30px; border-top: 1px solid var(--rule); }
.sheet > section:first-child { border-top: 0; }
.sheet h2 { font-size: 19px; font-weight: 700; color: var(--ink); padding-bottom: 8px; margin-bottom: 18px; border-bottom: 3px double var(--ink); }
.sheet h3 { font-size: 15px; font-weight: 700; margin: 22px 0 10px; }
.hint { color: var(--muted); font-size: 13.5px; margin: -8px 0 14px; }
.grid { display: grid; gap: 16px 20px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.grid > * { grid-column: span 12; }
@media (min-width: 640px) {
  .grid > .c6 { grid-column: span 6; } .grid > .c4 { grid-column: span 4; } .grid > .c3 { grid-column: span 3; } .grid > .c8 { grid-column: span 8; }
}

/* fields: label above, ruled underline like a printed form */
.f { display: block; position: relative; }
.f > span, .grp > .cap { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
.f input, .f select, .f textarea { display: block; width: 100%; min-height: 40px; padding: 8px 8px; font: 500 15.5px/1.35 var(--font); color: var(--text); background: #fcf9f8; border: 0; border-bottom: 1.5px solid var(--rule-strong); border-radius: 2px 2px 0 0; }
.f textarea { resize: vertical; min-height: 70px; }
.f input:hover, .f select:hover, .f textarea:hover { background: #f6efee; }
.f input:focus, .f select:focus, .f textarea:focus { outline: none; background: #fbeef0; border-bottom-color: var(--ink); box-shadow: 0 2px 0 var(--ink); }
.f input[readonly], .f input:disabled, .f textarea:disabled { background: #f3efee; color: var(--muted); }
.f .unit { position: absolute; right: 8px; bottom: 9px; color: var(--muted); font-size: 14px; pointer-events: none; }
.f.has-unit input { padding-right: 62px; }
.f.upper input { text-transform: uppercase; }
.err { display: none; font-style: normal; font-size: 13px; font-weight: 600; color: var(--red); margin-top: 3px; }
.has-error .err { display: block; }
.has-error input, .has-error select, .has-error textarea { border-bottom-color: var(--red); background: #fff6f5; }
.grp.has-error .chip span { border-color: var(--red); }
.note { font-size: 13.5px; color: var(--muted); margin: 4px 0 0; }
.calc { font-size: 13.5px; color: var(--ink); margin: 6px 0 0; font-weight: 500; }

/* choices: square checkbox / round radio "printed form" chips */
.choices { display: flex; flex-wrap: wrap; gap: 8px 10px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.chip span { display: inline-flex; align-items: center; gap: 9px; min-height: 40px; padding: 6px 14px 6px 10px; border: 1.5px solid var(--rule-strong); border-radius: 3px; background: #fff; font-weight: 500; font-size: 14.5px; cursor: pointer; }
.chip span::before { content: ''; width: 16px; height: 16px; border: 1.5px solid var(--ink); border-radius: 2px; background: #fff; flex: none; }
.chip.radio span::before { border-radius: 50%; }
.chip input:checked + span { border-color: var(--ink); background: #f6e6e8; font-weight: 600; }
.chip input:checked + span::before { background: var(--ink); box-shadow: inset 0 0 0 3px #fff; }
.chip input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.chip input:disabled + span { opacity: .55; cursor: not-allowed; }

.person { border: 1.5px solid var(--rule-strong); padding: 16px 18px 20px; margin: 0 0 18px; border-radius: 3px; background: #fefcfb; }
.person-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.person-head h3 { margin: 0; }
.agebadge { font-size: 13px; margin-top: 3px; color: var(--muted); }
.agebadge b { color: var(--ink); }

.photo { display: flex; gap: 16px; align-items: center; }
.photo-box { width: 96px; height: 120px; border: 1.5px dashed var(--rule-strong); display: grid; place-items: center; text-align: center; font-size: 12.5px; color: var(--muted); background: #fcf9f8; overflow: hidden; flex: none; }
.photo-box img { width: 100%; height: 100%; object-fit: cover; }

.declaration { border: 1px solid var(--rule); background: #fbf8f7; padding: 12px 18px 12px 34px; margin: 0 0 16px; font-size: 14px; }
.declaration li { margin: 5px 0; }

/* ---------- live certificate dock ---------- */
.dock { position: sticky; top: 92px; }
@media (max-width: 1099px) { .dock { position: static; } }
.dock h2 { font-size: 16px; margin-bottom: 4px; }
.dock p { margin: 0 0 10px; color: var(--muted); font-size: 13.5px; }
.dock-empty { border: 1.5px dashed var(--rule-strong); background: #f8f3f2; padding: 26px 20px; color: var(--muted); font-size: 14px; }
.dock-empty strong { display: block; color: var(--text); margin-bottom: 4px; }

/* ---------- action bar ---------- */
.actionbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 10px 28px; background: var(--ink-dk); color: #fff; border-top: 3px solid var(--gold); }
.actionbar .state { font-size: 14px; opacity: .92; }
.actionbar .state b { font-weight: 600; }
.actionbar .btns { display: flex; gap: 10px; flex-wrap: wrap; }
.actionbar .btn { border-color: #fff; background: transparent; color: #fff; }
.actionbar .btn:hover { background: rgba(255,255,255,.12); }
.actionbar .btn-primary { background: var(--gold); border-color: var(--gold); color: #191400; }
.actionbar .btn-primary:hover { background: #cfa646; }
@media (max-width: 700px) { .form-layout { padding-bottom: 150px; } .actionbar { padding: 8px 12px; } .actionbar .btns { width: 100%; } .actionbar .btn { flex: 1 1 auto; } main { padding: 16px 12px; } .sheet > section { padding: 20px 16px 24px; } }

.locked-banner { background: #e8f5ee; border: 1px solid #a9d8bf; color: #124d30; padding: 12px 16px; margin-bottom: 18px; font-weight: 500; }

/* ---------- certificate page ---------- */
.bond-layout { display: grid; gap: 24px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1150px) { .bond-layout { grid-template-columns: minmax(0, 1fr) 360px; } }
.panel { background: var(--sheet); border: 1px solid var(--rule-strong); padding: 20px 22px 24px; }
.panel h2 { font-size: 17px; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 3px double var(--ink); color: var(--ink); }
.panel .stack { display: grid; gap: 14px; }
.panel .btns { display: grid; gap: 10px; margin-top: 18px; }
.facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14.5px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- toast + dialog ---------- */
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 82px; z-index: 60; display: grid; gap: 8px; width: min(560px, calc(100vw - 24px)); pointer-events: none; }
.toast { background: var(--ink-dk); color: #fff; padding: 11px 16px; border-left: 5px solid var(--gold); font-weight: 500; box-shadow: 0 6px 24px rgba(58,15,23,.35); animation: tin .18s ease-out; }
.toast.error { border-left-color: #ff8a80; background: #5a1410; }
@keyframes tin { from { opacity: 0; transform: translateY(6px); } }
dialog { border: 0; padding: 0; width: min(440px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(58,15,23,.45); }
dialog::backdrop { background: rgba(58,15,23,.5); }
dialog form { padding: 24px; }
dialog h2 { font-size: 19px; margin-bottom: 8px; }
dialog p { margin: 0 0 20px; color: var(--muted); }
.dlg-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* =====================================================================
   Certificate (HTML twin of the PDF) - laid out on an 842 x 595 canvas
   and scaled to fit its container.
   ===================================================================== */
.cert-fit { width: 100%; position: relative; overflow: hidden; background: #fff; box-shadow: 0 1px 0 var(--rule-strong), 0 10px 30px -12px rgba(58,15,23,.35); }
.cert-sheet { position: absolute; left: 0; top: 0; width: 842px; height: 595px; transform-origin: 0 0; background: #fff; font-family: var(--font); color: #3a0f17; }
.cert-sheet > * { position: absolute; }
.c-frame { left: 28px; top: 44px; width: 786px; height: 520px; border: 6px solid #571821; background-color: #f6efee; }
.c-frame::after { content: ''; position: absolute; inset: 2px; border: 1px solid #b48a35; }
.c-seal { left: 205px; top: 230px; width: 400px; height: 208px; opacity: .07; object-fit: contain; }
.c-logo { left: 311px; right: auto; top: 56px; width: 220px; height: 58px; object-fit: contain; }
.c-tag { left: 0; width: 842px; text-align: center; font-size: 8.5px; letter-spacing: 2.2px; color: #571821; display: flex; justify-content: center; align-items: center; gap: 12px; }
.c-tag i { display: block; width: 62px; height: 1.1px; background: #b48a35; }
.c-addr { left: 68px; width: 706px; text-align: center; font-size: 8px; white-space: nowrap; }
.c-lab { font-weight: 700; font-size: 9.5px; white-space: nowrap; }
.c-val { font-family: 'Courier Prime', 'Courier New', monospace; font-weight: 700; font-size: 11px; color: #2b1519; border-bottom: 1px dotted #555; height: 17px; line-height: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-transform: uppercase; }
.c-val.plain { text-transform: none; }
.c-banner { left: 139px; top: 140px; width: 300px; height: 26px; background: #571821; color: #fff; font-weight: 700; font-size: 15px; line-height: 26px; text-align: center; }
.c-box { left: 574px; width: 216px; height: 42px; background: #fff; border: 1.6px solid #3a0f17; }
.c-box .c-lab { position: absolute; left: 8px; top: 13px; }
.c-box .c-v { position: absolute; right: 8px; left: 84px; top: 0; height: 38px; display: flex; align-items: center; justify-content: flex-end; font-family: 'Courier Prime', 'Courier New', monospace; font-weight: 700; font-size: 12px; color: #2b1519; white-space: nowrap; }
.c-box .c-v.red { color: #c0261d; font-size: 15px; }
.c-pending { font-family: var(--font); font-weight: 500; font-size: 9px; color: #9a8588; }
.c-sig { border-top: .6px solid #3a0f17; height: 0; }
.c-note { left: 54px; top: 518px; width: 724px; font-size: 7.2px; line-height: 1.34; text-align: justify; }
.c-senior { left: 634px; top: 12px; width: 180px; height: 28px; border: 2.2px double #5a5a66; color: #5a5a66; font-weight: 700; font-size: 15px; letter-spacing: 1px; text-align: center; line-height: 24px; }
.c-draftnote { left: 28px; top: 18px; color: #c0261d; font-weight: 700; font-size: 8.5px; }
.c-draftmark { left: 0; top: 190px; width: 842px; text-align: center; font-weight: 700; font-size: 150px; line-height: 1; color: #c0261d; opacity: .11; transform: rotate(-24deg); pointer-events: none; }

.c-addrtext { font-family: 'Courier Prime', 'Courier New', monospace; font-weight: 700; font-size: 10.5px; line-height: 22px; color: #2b1519; text-transform: uppercase; overflow: hidden; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 700px) {
  .top { padding: 6px 12px; gap: 8px; }
  .brand-logo { height: 32px; }
  .brand-cap, .navlink { display: none; }
  .top .btn-primary { min-height: 36px; padding: 6px 10px; font-size: 13.5px; white-space: nowrap; }
  .page-head h1 { font-size: 24px; }
}

/* ------------------------------------------------------------------ */
/*  Login page                                                        */
/*  Hooks: #loginShell .login-card .role-tab .field .has-error        */
/*         .field-err .btn-label .btn-spinner #loginError .shake      */
/* ------------------------------------------------------------------ */

#loginShell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}

/* ------------------------------------------------------------------ */
/*  Card                                                              */
/* ------------------------------------------------------------------ */

.login-card {
  width: 100%;
  max-width: 420px;
  background: #ffffff;
  border: 1px solid #e5e0dc;
  border-radius: 14px;
  box-shadow: 0 20px 40px rgba(87, 24, 33, 0.12);
  padding: 32px 32px 28px;
  position: relative;
  overflow: hidden;
}

/* Thin accent strip at the top of the card */
.login-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: #571821;
}

/* ------------------------------------------------------------------ */
/*  Headings                                                          */
/* ------------------------------------------------------------------ */

.login-card h1 {
  margin: 4px 0 4px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #2b2622;
}

.login-card .sub {
  margin: 0 0 22px;
  font-size: 13.5px;
  color: #7a7269;
  line-height: 1.5;
}

/* ------------------------------------------------------------------ */
/*  Role tabs                                                         */
/* ------------------------------------------------------------------ */

.role-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: #f2eeeb;
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 20px;
}

.role-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: #7a7269;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 9px 8px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, box-shadow 150ms ease;
  white-space: nowrap;
}

.role-tab:hover:not(.is-active) {
  color: #2b2622;
}

.role-tab.is-active {
  background: #ffffff;
  color: #571821;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.role-tab:focus-visible {
  outline: 2px solid #571821;
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ */
/*  Fields                                                            */
/* ------------------------------------------------------------------ */

.field {
  display: block;
  margin-bottom: 14px;
}

.field > span,
.field > label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: #7a7269;
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.field input[type="email"],
.field input[type="password"],
.field input[type="text"] {
  width: 100%;
  padding: 11px 13px;
  font: inherit;
  font-size: 14.5px;
  color: #2b2622;
  background: #ffffff;
  border: 1px solid #d9d2cc;
  border-radius: 9px;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.field input::placeholder {
  color: #b6ada4;
}

.field input:focus {
  border-color: #571821;
  box-shadow: 0 0 0 3px rgba(87, 24, 33, 0.14);
}

/* Password wrapper holds the input + the show/hide button */
.field .password-wrap {
  position: relative;
  display: block;
}

.field .password-wrap input {
  padding-right: 44px;
}


#togglePass {
    position: absolute;
    top: 72%;
    right: 40px;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    font-size: 16px;
    padding: 6px 8px;
    cursor: pointer;
    color: #7a7269;
    border-radius: 6px;
    line-height: 1;
}

#togglePass:hover {
  background: #f2eeeb;
  color: #571821;
}

/* Error state */
.field.has-error input {
  border-color: #b3261e;
  box-shadow: 0 0 0 3px rgba(179, 38, 30, 0.12);
}

.field-err {
  display: block;
  min-height: 16px;
  margin-top: 4px;
  font-size: 12px;
  font-style: normal;
  color: #b3261e;
}

/* ------------------------------------------------------------------ */
/*  Submit button                                                     */

#loginSubmit {
  width: 100%;
  margin-top: 6px;
  padding: 12px 16px;
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  color: #ffffff;
  background: #571821;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  transition: background 150ms ease, transform 60ms ease, opacity 150ms ease;
}

#loginSubmit:hover:not(:disabled) {
  background: #6b1e28;
}

#loginSubmit:active:not(:disabled) {
  transform: translateY(1px);
}

#loginSubmit:disabled {
  opacity: 0.75;
  cursor: not-allowed;
}

#loginSubmit:focus-visible {
  outline: 2px solid #571821;
  outline-offset: 3px;
}

/* Small spinner shown while loading */
.btn-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ------------------------------------------------------------------ */
/*  Global error box                                                  */
/* ------------------------------------------------------------------ */

#loginError {
  margin-top: 14px;
  padding: 10px 12px;
  font-size: 13px;
  color: #7a1d16;
  background: #fbe9e7;
  border: 1px solid #f2c9c5;
  border-radius: 8px;
  line-height: 1.4;
}

#loginError[hidden] {
  display: none;
}

/* ------------------------------------------------------------------ */
/*  Shake on failed login                                             */
/* ------------------------------------------------------------------ */

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}

.login-card.shake {
  animation: shake 320ms ease;
}

/* ------------------------------------------------------------------ */
/*  Small screens                                                     */
/* ------------------------------------------------------------------ */

@media (max-width: 460px) {
  .login-card {
    padding: 24px 20px 22px;
    border-radius: 12px;
  }
  .login-card h1 { font-size: 20px; }
  .role-tab { font-size: 12px; padding: 8px 4px; }
}

/* ------------------------------------------------------------------ */
/*  User chip — sits in the top bar, right side                       */
/*  Hooks:  .user-chip .user-avatar .user-meta .user-name .user-role  */
/*          #logoutBtn                                                 */
/* ------------------------------------------------------------------ */

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 6px 8px;
  background: #ffffff;
  border: 1px solid #e5e0dc;
  border-radius: 999px;
  box-shadow: 0 1px 2px rgba(87, 24, 33, 0.06);
  font-size: 13px;
  line-height: 1.2;
  color: #2b2622;
  white-space: nowrap;
}

.user-chip[hidden] {
  display: none;
}

/* ------------------------------------------------------------------ */
/*  Avatar                                                            */
/* ------------------------------------------------------------------ */

.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #571821;
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  flex-shrink: 0;
  /* Populated by JS via data attribute or text content (e.g. initials) */
}

/* Optional: if the JS sets a background-image on the avatar */
.user-avatar[style*="background-image"] {
  background-size: cover;
  background-position: center;
}

/* ------------------------------------------------------------------ */
/*  Name + role stack                                                 */
/* ------------------------------------------------------------------ */

.user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;              /* allow ellipsis on long names */
  gap: 1px;
  padding-right: 4px;
}

.user-name {
  font-weight: 600;
  font-size: 13px;
  color: #2b2622;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-role {
  font-size: 11.5px;
  color: #7a7269;
  letter-spacing: 0.01em;
  text-transform: capitalize;
}

/* ------------------------------------------------------------------ */
/*  Logout button                                                     */
/* ------------------------------------------------------------------ */

#logoutBtn {
  appearance: none;
  border: 0;
  background: transparent;
  color: #571821;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}

#logoutBtn:hover {
  background: #f7e9eb;
  color: #6b1e28;
}

#logoutBtn:active {
  background: #f0d6da;
}

#logoutBtn:focus-visible {
  outline: 2px solid #571821;
  outline-offset: 2px;
}


@media (max-width: 640px) {
  .user-role { display: none; }
  .user-name { max-width: 110px; }
  #logoutBtn { padding: 6px 10px; font-size: 12px; }
}

@media (max-width: 420px) {
  .user-meta { display: none; }
}

/* ------------------------------------------------------------------ */
/*  HO section tabs                                                   */
/*  Markup: <div class="toolbar" role="tablist">                      */
/*            <button class="seg-btn" data-ho-tab="…">                */
/* ------------------------------------------------------------------ */

.toolbar[role="tablist"] {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #f2eeeb;
  border: 1px solid #e5e0dc;
  border-radius: 10px;
  margin: 0 0 20px;
  width: fit-content;
}

/* The tab buttons */
.seg-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: #7a7269;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, box-shadow 150ms ease;
  white-space: nowrap;
}

.seg-btn:hover:not([aria-selected="true"]) {
  color: #2b2622;
  background: rgba(87, 24, 33, 0.05);
}

/* Active tab — the one whose aria-selected is "true" */
.seg-btn[aria-selected="true"] {
  background: #ffffff;
  color: #571821;
  box-shadow: 0 1px 3px rgba(87, 24, 33, 0.12);
}

.seg-btn:focus-visible {
  outline: 2px solid #571821;
  outline-offset: 2px;
}

.seg-btn:active {
  transform: translateY(1px);
}

.c-tagline {
  position: absolute;
  right: 94px;
  font: 700 7.5px/1 Arial, sans-serif;
  letter-spacing: 0.8px;
  color: #b03a2e; /* or your brand accent */
  text-align: right;
  margin-top: -9px;
}

.c-heading {
    position: absolute;
    top: 72px;
    left: -100px;
    right: 0;
    text-align: center;
    font-weight: 700;
    font-size: 31px;
    color: #8b1e1e;
    text-transform: uppercase;
}

/* Stack multiple pages vertically inside the preview */
.cert-fit { position: relative; display: block; }
.cert-fit .cert-sheet { position: absolute; left: 0; }
.cert-fit .cert-sheet:nth-of-type(1) { top: 0; }
.cert-fit .cert-sheet:nth-of-type(2) { top: calc(595px + 175px); }
/* (If you scale with transform, the top offsets above should be pre-scale.
   In practice the fit() above sets a transform on each sheet, and the
   second sheet's `top` needs to be 595px in *unscaled* units — the browser
   applies the transform after layout, so this works.) */

.cert-back .c-note-back {
  left: 72px;
  top: 130px;
  width: 698px;         
  height: auto;
  font-size: 11.5px;
  line-height: 1.55;
  text-align: justify;
  white-space: normal;
}