/* ==========================================================================
   OPQH shared UI layer
   --------------------------------------------------------------------------
   Safety rules for this file (read before editing):
   1. Every decorative rule lives inside `@media screen`. Print output is
      generated by printThis.js, which re-applies the host page CSS inside a
      hidden iframe. Keeping chrome inside a screen media query guarantees the
      printed sheet can never inherit a UI style.
   2. No `*` / bare-element selectors and no global box-sizing reset. The label
      sheets rely on `content-box` table metrics; a border-box reset would move
      every cell by a fraction of a millimetre.
   3. `body` font-family is deliberately NOT set here, so untouched label cells
      keep inheriting the same default as before.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Design tokens
   -------------------------------------------------------------------------- */
:root {
    --opqh-brand: #3b5bdb;
    --opqh-brand-dark: #2c44a8;
    --opqh-brand-soft: #eef1fd;
    --opqh-brand-ring: rgba(59, 91, 219, 0.28);

    --opqh-ink: #1c2333;
    --opqh-ink-soft: #4a5468;
    --opqh-muted: #6b7488;

    --opqh-bg: #f5f7fb;
    --opqh-surface: #ffffff;
    --opqh-surface-alt: #fafbfe;
    --opqh-border: #e2e6ef;
    --opqh-border-strong: #cfd6e4;

    --opqh-ok: #1f8a4c;
    --opqh-ok-soft: #e8f6ee;
    --opqh-no: #c92a2a;
    --opqh-no-soft: #fdecec;
    --opqh-warn: #a35c00;
    --opqh-warn-soft: #fff5e6;

    --opqh-radius-sm: 6px;
    --opqh-radius: 10px;
    --opqh-radius-lg: 16px;

    --opqh-shadow-sm: 0 1px 2px rgba(28, 35, 51, 0.06);
    --opqh-shadow: 0 2px 8px rgba(28, 35, 51, 0.07);
    --opqh-shadow-lg: 0 10px 30px rgba(28, 35, 51, 0.1);

    --opqh-maxw: 1180px;
    --opqh-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --opqh-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* --------------------------------------------------------------------------
   Print: strip chrome, keep only the sheet
   -------------------------------------------------------------------------- */
@media print {
    .opqh-no-print {
        display: none !important;
    }

    /* The sheet itself must survive a native Ctrl+P. printThis.js clones the
       table into a bare body, but the browser's own print dialog prints this
       document as-is — so the stage must stay visible and must not contribute
       any offset of its own. */
    .opqh-stage,
    .opqh-stage-inner {
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: visible !important;
        min-width: 0 !important;
        background: none !important;
    }

    .opqh-page {
        padding: 0 !important;
        background: none !important;
    }

    /* .opqh-sr-only is defined inside @media screen, so without this it would
       become a visible, full-width line of text on the printed sheet. */
    .opqh-sr-only {
        display: none !important;
    }
}

/* ==========================================================================
   Screen-only chrome
   ========================================================================== */
@media screen {

    .opqh-page {
        margin: 0;
        padding: 0 0 64px;
        background: var(--opqh-bg);
        color: var(--opqh-ink);
        font-family: var(--opqh-font);
        font-size: 16px;
        line-height: 1.6;
        -webkit-font-smoothing: antialiased;
    }

    .opqh-page *,
    .opqh-page *::before,
    .opqh-page *::after {
        box-sizing: border-box;
    }

    .opqh-page h1,
    .opqh-page h2,
    .opqh-page h3,
    .opqh-page h4 {
        margin: 0 0 12px;
        line-height: 1.25;
        color: var(--opqh-ink);
        font-weight: 700;
        letter-spacing: -0.015em;
    }

    .opqh-page h1 {
        font-size: clamp(26px, 4vw, 38px);
    }

    .opqh-page h2 {
        font-size: clamp(20px, 2.6vw, 26px);
    }

    .opqh-page h3 {
        font-size: 18px;
    }

    .opqh-page p {
        margin: 0 0 14px;
    }

    .opqh-page a {
        color: var(--opqh-brand);
        text-decoration-color: var(--opqh-brand-ring);
        text-underline-offset: 2px;
    }

    .opqh-page a:hover {
        color: var(--opqh-brand-dark);
    }

    .opqh-wrap {
        width: 100%;
        max-width: var(--opqh-maxw);
        margin: 0 auto;
        padding: 0 24px;
    }

    /* ----------------------------------------------------------------------
       Top bar
       ---------------------------------------------------------------------- */
    .opqh-topbar {
        position: sticky;
        top: 0;
        z-index: 40;
        background: rgba(255, 255, 255, 0.88);
        backdrop-filter: saturate(180%) blur(12px);
        border-bottom: 1px solid var(--opqh-border);
    }

    .opqh-topbar-inner {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 16px;
        min-height: 62px;
    }

    .opqh-brand {
        display: inline-flex;
        align-items: center;
        gap: 10px;
        font-weight: 700;
        font-size: 18px;
        letter-spacing: -0.02em;
        color: var(--opqh-ink);
        text-decoration: none;
    }

    .opqh-brand img {
        height: 30px;
        width: auto;
        display: block;
    }

    .opqh-topbar-actions {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    /* ----------------------------------------------------------------------
       Language switcher
       ---------------------------------------------------------------------- */
    .opqh-lang {
        position: relative;
    }

    .opqh-lang-btn {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        height: 38px;
        padding: 0 12px;
        border: 1px solid var(--opqh-border-strong);
        border-radius: var(--opqh-radius-sm);
        background: var(--opqh-surface);
        color: var(--opqh-ink);
        font: inherit;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
    }

    .opqh-lang-btn:hover {
        border-color: var(--opqh-brand);
        background: var(--opqh-brand-soft);
    }

    .opqh-lang-btn:focus-visible {
        outline: none;
        box-shadow: 0 0 0 3px var(--opqh-brand-ring);
    }

    .opqh-lang-globe {
        width: 17px;
        height: 17px;
        flex: none;
        color: var(--opqh-brand);
    }

    .opqh-lang-caret {
        width: 9px;
        height: 9px;
        flex: none;
        opacity: 0.55;
        transition: transform 0.18s;
    }

    .opqh-lang-btn[aria-expanded="true"] .opqh-lang-caret {
        transform: rotate(180deg);
    }

    .opqh-lang-menu {
        position: absolute;
        right: 0;
        top: calc(100% + 8px);
        min-width: 190px;
        padding: 6px;
        margin: 0;
        list-style: none;
        background: var(--opqh-surface);
        border: 1px solid var(--opqh-border);
        border-radius: var(--opqh-radius);
        box-shadow: var(--opqh-shadow-lg);
        z-index: 60;
    }

    .opqh-lang-menu[hidden] {
        display: none;
    }

    .opqh-lang-menu button {
        display: flex;
        align-items: center;
        gap: 10px;
        width: 100%;
        padding: 9px 10px;
        border: 0;
        border-radius: var(--opqh-radius-sm);
        background: transparent;
        color: var(--opqh-ink-soft);
        font: inherit;
        font-size: 14px;
        text-align: left;
        cursor: pointer;
    }

    .opqh-lang-menu button:hover {
        background: var(--opqh-surface-alt);
        color: var(--opqh-ink);
    }

    .opqh-lang-menu button[aria-current="true"] {
        background: var(--opqh-brand-soft);
        color: var(--opqh-brand-dark);
        font-weight: 600;
    }

    .opqh-lang-code {
        display: inline-block;
        min-width: 26px;
        font-family: var(--opqh-mono);
        font-size: 11px;
        letter-spacing: 0.06em;
        color: var(--opqh-muted);
        text-transform: uppercase;
    }

    .opqh-lang-menu button[aria-current="true"] .opqh-lang-code {
        color: var(--opqh-brand);
    }

    .opqh-lang-native {
        margin-left: auto;
        font-size: 13px;
        color: var(--opqh-muted);
    }

    /* ----------------------------------------------------------------------
       Hero
       ---------------------------------------------------------------------- */
    .opqh-hero {
        padding: 46px 0 34px;
        text-align: center;
    }

    .opqh-hero-logo {
        width: min(320px, 78vw);
        height: auto;
        margin: 0 auto 20px;
        display: block;
    }

    .opqh-eyebrow {
        display: inline-block;
        margin-bottom: 12px;
        padding: 5px 12px;
        border-radius: 999px;
        background: var(--opqh-brand-soft);
        color: var(--opqh-brand-dark);
        font-size: 13px;
        font-weight: 600;
        letter-spacing: 0.01em;
    }

    .opqh-lead {
        max-width: 62ch;
        margin: 0 auto;
        text-align: center;
        color: var(--opqh-ink-soft);
        font-size: 16.5px;
    }

    /* ----------------------------------------------------------------------
       Sections & cards
       ---------------------------------------------------------------------- */
    .opqh-section {
        padding: 22px 0 0;
    }

    .opqh-card {
        padding: 26px 28px;
        background: var(--opqh-surface);
        border: 1px solid var(--opqh-border);
        border-radius: var(--opqh-radius-lg);
        box-shadow: var(--opqh-shadow-sm);
    }

    .opqh-card + .opqh-card {
        margin-top: 20px;
    }

    .opqh-card-title {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-bottom: 6px;
    }

    .opqh-card-sub {
        margin: 0 0 20px;
        color: var(--opqh-muted);
        font-size: 15px;
    }

    .opqh-steps {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px 18px;
        margin: 0 0 6px;
        padding: 0;
        list-style: none;
        font-weight: 600;
        color: var(--opqh-ink-soft);
    }

    .opqh-steps li {
        display: inline-flex;
        align-items: center;
        gap: 8px;
    }

    .opqh-step-dot {
        display: inline-grid;
        place-items: center;
        width: 22px;
        height: 22px;
        flex: none;
        border-radius: 50%;
        background: var(--opqh-brand);
        color: #fff;
        font-size: 12px;
        font-weight: 700;
    }

    .opqh-step-warn .opqh-step-dot {
        background: var(--opqh-no);
    }

    /* ----------------------------------------------------------------------
       Template table
       ---------------------------------------------------------------------- */
    .opqh-table-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: var(--opqh-radius);
        border: 1px solid var(--opqh-border);
    }

    .opqh-table {
        width: 100%;
        min-width: 780px;
        border-collapse: collapse;
        font-size: 14.5px;
    }

    .opqh-table th,
    .opqh-table td {
        padding: 12px 14px;
        text-align: left;
        border-bottom: 1px solid var(--opqh-border);
        vertical-align: middle;
    }

    .opqh-table thead th {
        position: sticky;
        top: 0;
        background: var(--opqh-surface-alt);
        color: var(--opqh-ink-soft);
        font-size: 12.5px;
        font-weight: 700;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        white-space: nowrap;
        border-bottom: 1px solid var(--opqh-border-strong);
    }

    .opqh-table tbody tr:last-child td {
        border-bottom: 0;
    }

    .opqh-table tbody tr:hover {
        background: var(--opqh-surface-alt);
    }

    .opqh-table td.opqh-td-center,
    .opqh-table th.opqh-td-center {
        text-align: center;
    }

    .opqh-app {
        display: inline-flex;
        align-items: center;
        gap: 10px;
        color: inherit;
        text-decoration: none;
        font-weight: 600;
    }

    .opqh-app img {
        width: 30px;
        height: 30px;
        flex: none;
        border-radius: var(--opqh-radius-sm);
        object-fit: contain;
        background: var(--opqh-surface);
        box-shadow: var(--opqh-shadow-sm);
    }

    .opqh-app:hover {
        color: var(--opqh-brand-dark);
    }

    .opqh-badge {
        display: inline-block;
        padding: 3px 10px;
        border-radius: 999px;
        font-size: 12.5px;
        font-weight: 700;
        letter-spacing: 0.02em;
    }

    .opqh-badge--ok {
        background: var(--opqh-ok-soft);
        color: var(--opqh-ok);
    }

    .opqh-badge--no {
        background: var(--opqh-no-soft);
        color: var(--opqh-no);
    }

    .opqh-badge--muted {
        background: var(--opqh-surface-alt);
        color: var(--opqh-ink-soft);
        border: 1px solid var(--opqh-border);
    }

    .opqh-margins {
        margin: 0;
        padding: 0;
        list-style: none;
        font-size: 13.5px;
        line-height: 1.45;
        color: var(--opqh-ink-soft);
        font-variant-numeric: tabular-nums;
    }

    /* ----------------------------------------------------------------------
       Notes / tips
       ---------------------------------------------------------------------- */
    .opqh-notes {
        margin: 0;
        padding: 0;
        list-style: none;
        display: grid;
        gap: 12px;
    }

    .opqh-notes li {
        position: relative;
        padding: 13px 16px 13px 44px;
        background: var(--opqh-surface-alt);
        border: 1px solid var(--opqh-border);
        border-radius: var(--opqh-radius);
        color: var(--opqh-ink-soft);
        font-size: 14.5px;
    }

    .opqh-notes li::before {
        content: "";
        position: absolute;
        left: 16px;
        top: 17px;
        width: 16px;
        height: 16px;
        border-radius: 50%;
        background: var(--opqh-brand-soft);
        box-shadow: inset 0 0 0 4px var(--opqh-brand);
    }

    .opqh-notes--warn li::before {
        background: var(--opqh-no-soft);
        box-shadow: inset 0 0 0 4px var(--opqh-no);
    }

    .opqh-note-strong {
        color: var(--opqh-no);
        font-weight: 700;
    }

    /* ----------------------------------------------------------------------
       Buttons
       ---------------------------------------------------------------------- */
    .opqh-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        height: 40px;
        padding: 0 18px;
        border: 1px solid var(--opqh-border-strong);
        border-radius: var(--opqh-radius-sm);
        background: var(--opqh-surface);
        color: var(--opqh-ink);
        font: inherit;
        font-size: 15px;
        font-weight: 600;
        line-height: 1;
        text-decoration: none;
        cursor: pointer;
        transition: background 0.15s, border-color 0.15s, color 0.15s,
            box-shadow 0.15s, transform 0.08s;
    }

    .opqh-btn:hover {
        border-color: var(--opqh-brand);
        color: var(--opqh-brand-dark);
        background: var(--opqh-brand-soft);
    }

    /* Anchors styled as buttons must beat the global link colour, otherwise
       white-on-brand text renders as brand-on-brand and looks empty. */
    a.opqh-btn {
        color: var(--opqh-ink);
        text-decoration: none;
    }

    a.opqh-btn:hover {
        color: var(--opqh-brand-dark);
    }

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

    .opqh-btn:focus-visible {
        outline: none;
        box-shadow: 0 0 0 3px var(--opqh-brand-ring);
    }

    .opqh-btn--primary {
        background: var(--opqh-brand);
        border-color: var(--opqh-brand);
        color: #fff;
        box-shadow: var(--opqh-shadow-sm);
    }

    .opqh-btn--primary:hover {
        background: var(--opqh-brand-dark);
        border-color: var(--opqh-brand-dark);
        color: #fff;
    }

    a.opqh-btn--primary,
    a.opqh-btn--primary:hover {
        background: var(--opqh-brand);
        border-color: var(--opqh-brand);
        color: #fff;
    }

    a.opqh-btn--primary:hover {
        background: var(--opqh-brand-dark);
        border-color: var(--opqh-brand-dark);
        color: #fff;
    }

    .opqh-btn--danger {
        color: var(--opqh-no);
    }

    .opqh-btn--danger:hover {
        background: var(--opqh-no-soft);
        border-color: var(--opqh-no);
        color: var(--opqh-no);
    }

    .opqh-btn--lg {
        height: 46px;
        padding: 0 24px;
        font-size: 16px;
    }

    .opqh-btn svg {
        width: 17px;
        height: 17px;
        flex: none;
    }

    /* ----------------------------------------------------------------------
       Print editor toolbar (print pages)
       ---------------------------------------------------------------------- */
    .opqh-editor-head {
        padding: 26px 0 6px;
        text-align: center;
    }

    .opqh-editor-head .opqh-brand img {
        height: 44px;
    }

    .opqh-editor-intro {
        max-width: 70ch;
        margin: 14px auto 0;
        color: var(--opqh-muted);
        font-size: 14.5px;
        line-height: 1.65;
    }

    .opqh-toolbar {
        position: sticky;
        top: 62px;
        z-index: 30;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: center;
        gap: 10px 14px;
        margin: 20px auto 0;
        padding: 14px 18px;
        max-width: 1100px;
        background: var(--opqh-surface);
        border: 1px solid var(--opqh-border);
        border-radius: var(--opqh-radius-lg);
        box-shadow: var(--opqh-shadow);
    }

    .opqh-tool-group {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .opqh-tool-group + .opqh-tool-group {
        padding-left: 14px;
        border-left: 1px solid var(--opqh-border);
    }

    .opqh-field {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        font-size: 14px;
        color: var(--opqh-ink-soft);
        white-space: nowrap;
    }

    .opqh-field > span {
        font-weight: 600;
    }

    .opqh-range {
        width: 118px;
        accent-color: var(--opqh-brand);
        cursor: pointer;
    }

    .opqh-range-val {
        min-width: 2ch;
        font-variant-numeric: tabular-nums;
        font-weight: 700;
        color: var(--opqh-ink);
        text-align: right;
    }

    .opqh-check {
        display: inline-flex;
        align-items: center;
        gap: 7px;
        font-size: 14px;
        color: var(--opqh-ink-soft);
        cursor: pointer;
        user-select: none;
    }

    .opqh-check input {
        width: 16px;
        height: 16px;
        accent-color: var(--opqh-brand);
        cursor: pointer;
    }

    .opqh-help-link {
        display: inline-grid;
        place-items: center;
        width: 30px;
        height: 30px;
        border-radius: 50%;
        border: 1px solid var(--opqh-border-strong);
        background: var(--opqh-surface);
        color: var(--opqh-ink-soft);
        font-size: 15px;
        font-weight: 700;
        text-decoration: none;
    }

    .opqh-help-link:hover {
        border-color: var(--opqh-brand);
        background: var(--opqh-brand-soft);
        color: var(--opqh-brand-dark);
    }

    /* Font picker widget inherits the toolbar look */
    .opqh-toolbar .font-picker.fp-select {
        border-radius: var(--opqh-radius-sm);
        border-color: var(--opqh-border-strong);
        font-family: var(--opqh-font);
        font-size: 14px;
        line-height: 26px;
        height: 32px;
    }

    /* ----------------------------------------------------------------------
       Sheet stage (screen-only framing around the printable area)
       ---------------------------------------------------------------------- */
    .opqh-stage {
        padding: 26px 0 10px;
        text-align: center;
        overflow-x: auto;
    }

    .opqh-stage-inner {
        display: inline-block;
        min-width: 100%;
        padding-bottom: 6px;
    }

    .opqh-stage-caption {
        margin: 14px 0 0;
        color: var(--opqh-muted);
        font-size: 13.5px;
    }

    /* ----------------------------------------------------------------------
       Footer
       ---------------------------------------------------------------------- */
    .opqh-footer {
        margin-top: 40px;
        padding: 34px 0 0;
        border-top: 1px solid var(--opqh-border);
        text-align: center;
    }

    .opqh-footer-title {
        margin-bottom: 14px;
        font-size: 17px;
        font-weight: 700;
    }

    .opqh-store {
        display: inline-block;
        padding: 8px;
        border: 1px solid var(--opqh-border);
        border-radius: var(--opqh-radius);
        background: var(--opqh-surface);
        line-height: 0;
        box-shadow: var(--opqh-shadow-sm);
    }

    .opqh-store img {
        width: min(300px, 72vw);
        height: auto;
        display: block;
    }

    .opqh-pow {
        margin: 18px 0 0;
        color: var(--opqh-muted);
        font-size: 13.5px;
    }

    /* ----------------------------------------------------------------------
       Media / video
       ---------------------------------------------------------------------- */
    .opqh-video {
        position: relative;
        width: 100%;
        padding-top: 56.25%;
        border-radius: var(--opqh-radius);
        overflow: hidden;
        background: #000;
        box-shadow: var(--opqh-shadow);
    }

    .opqh-video iframe {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        border: 0;
    }

    .opqh-figure {
        margin: 26px 0 0;
        text-align: center;
    }

    .opqh-figure img {
        max-width: min(420px, 90vw);
        height: auto;
        border-radius: var(--opqh-radius);
        border: 1px solid var(--opqh-border);
        box-shadow: var(--opqh-shadow-sm);
    }

    .opqh-figcaption {
        margin: 14px 0 0;
        color: var(--opqh-warn);
        font-size: 15px;
        font-weight: 700;
    }

    /* ----------------------------------------------------------------------
       Toast
       ---------------------------------------------------------------------- */
    .opqh-toast {
        position: fixed;
        left: 50%;
        bottom: 26px;
        transform: translate(-50%, 16px);
        z-index: 90;
        padding: 12px 18px;
        border-radius: 999px;
        background: rgba(28, 35, 51, 0.94);
        color: #fff;
        font-size: 14.5px;
        font-weight: 600;
        box-shadow: var(--opqh-shadow-lg);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s, transform 0.2s;
    }

    .opqh-toast.is-visible {
        opacity: 1;
        transform: translate(-50%, 0);
    }

    /* ----------------------------------------------------------------------
       Help page
       ---------------------------------------------------------------------- */
    .opqh-prose {
        max-width: 74ch;
    }

    .opqh-prose p {
        font-size: 15.5px;
        color: var(--opqh-ink-soft);
    }

    .opqh-back {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        margin-bottom: 18px;
        font-size: 14.5px;
        font-weight: 600;
        text-decoration: none;
    }

    /* ----------------------------------------------------------------------
       Utilities
       ---------------------------------------------------------------------- */
    .opqh-sr-only {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .opqh-center {
        text-align: center;
    }

    .opqh-mt-0 {
        margin-top: 0;
    }

    .opqh-nowrap {
        white-space: nowrap;
    }

    /* ----------------------------------------------------------------------
       Responsive
       ---------------------------------------------------------------------- */
    @media (max-width: 860px) {
        .opqh-wrap {
            padding: 0 16px;
        }

        .opqh-card {
            padding: 20px 18px;
        }

        .opqh-toolbar {
            top: 0;
            border-radius: 0;
            border-left: 0;
            border-right: 0;
            padding: 12px 16px;
        }

        .opqh-tool-group + .opqh-tool-group {
            padding-left: 0;
            border-left: 0;
        }

        .opqh-range {
            width: 92px;
        }
    }

    @media (max-width: 560px) {
        .opqh-hero {
            padding: 28px 0 22px;
        }

        .opqh-steps {
            flex-direction: column;
            align-items: flex-start;
            gap: 8px;
        }

        .opqh-brand span {
            display: none;
        }

        .opqh-table {
            min-width: 640px;
        }
    }

    @media (prefers-reduced-motion: reduce) {
        .opqh-lang-caret,
        .opqh-btn,
        .opqh-toast,
        .opqh-lang-btn {
            transition: none;
        }
    }
}
