/* ==========================================================================
   AlphaCorr — Shared Design System
   Common CSS for all portals (CIM, ARD, IPD, PackOps).
   Hand-written CSS, no frameworks.
   ========================================================================== */

:root {
    /* Brand — AlphaCorr red, matched from alphacorr.com */
    --brand:        #961c1f;
    --brand-light:  #b82528;
    --brand-bg:     #fef2f2;

    /* Grays */
    --gray-900: #111827;
    --gray-700: #374151;
    --gray-500: #6b7280;
    --gray-300: #d1d5db;
    --gray-200: #e5e7eb;
    --gray-100: #f3f4f6;
    --gray-50:  #f9fafb;
    --white:    #ffffff;

    /* Status */
    --success:  #16a34a;
    --success-bg: #f0fdf4;
    --danger:   #dc2626;
    --danger-bg: #fef2f2;
    --warning:  #d97706;

    /* Layout */
    --container-max: 1100px;
    --radius: 6px;
    --radius-lg: 10px;
}

/* ---------- Reset & base ---------- */

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

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--gray-700);
    background: var(--gray-50);
}

a { color: var(--brand); }
a:hover { color: var(--brand-light); }

h1, h2, h3, h4 {
    color: var(--gray-900);
    line-height: 1.3;
}

img { max-width: 100%; }

/* ---------- Nav ---------- */

.nav {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 0 24px;
}

.nav-inner {
    max-width: var(--container-max);
    margin: 0 auto;
    display: flex;
    align-items: center;
    height: 56px;
    gap: 24px;
}

.nav-brand {
    text-decoration: none;
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.nav-brand-name {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--brand);
}

.nav-brand-tag {
    font-size: 0.8rem;
    color: var(--gray-500);
    font-weight: 400;
}

.nav-links {
    display: flex;
    gap: 20px;
    margin-left: auto;
}

.nav-links a {
    text-decoration: none;
    color: var(--gray-700);
    font-size: 0.925rem;
    font-weight: 500;
}

.nav-links a:hover {
    color: var(--brand);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: 16px;
}

/* ---------- Subnav strip ----------
   Secondary navigation rendered under the top nav. Used by the DLG
   dispatcher (Catalog/Cart/Orders/Admin) and the billing pages
   (Wallet/Ledger). Class names match the DLG-side rules in dlg.css
   verbatim; common.css loads first so the styles apply on any page
   that uses the markup, including pages without dlg.css.
*/
.subnav {
    background: var(--gray-100);
    border-bottom: 1px solid var(--gray-200);
}
.subnav-inner {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 8px 24px;
    display: flex;
    gap: 18px;
    align-items: center;
    font-size: 0.92em;
}
.subnav-label {
    color: var(--gray-500);
    font-weight: 600;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-right: 6px;
}
.subnav-inner a {
    color: var(--gray-700);
    text-decoration: none;
    padding: 4px 10px;
    border-radius: 4px;
    transition: background 0.12s;
}
.subnav-inner a:hover {
    background: var(--gray-200);
    color: var(--gray-900);
}
.subnav-inner a.active {
    background: var(--white);
    color: var(--brand);
    font-weight: 600;
    border: 1px solid var(--gray-200);
}

.nav-balance-pill {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--brand-bg);
    color: var(--brand);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid transparent;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.nav-balance-pill:hover {
    background: var(--brand-bg);
    border-color: var(--brand);
    color: var(--brand-light);
}

.nav-balance-unit {
    font-size: 0.75rem;
    font-weight: 500;
    opacity: 0.75;
}

.nav-username {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.nav-dropdown {
    position: relative;
    display: inline-block;
}

.nav-dropdown-toggle {
    background: none;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    padding: 5px 12px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.nav-dropdown-toggle:hover {
    border-color: var(--brand);
    color: var(--brand);
}

.nav-caret {
    font-size: 0.7rem;
    line-height: 1;
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    padding-top: 6px;
    min-width: 200px;
    max-width: 420px;
    /* Above wip-banner (9999) + demo-banner (9998) + demo-watermark (9990)
       so the dropdown isn't covered by the bottom-page banner on short pages. */
    z-index: 10001;
    background: transparent;
}

.nav-dropdown-menu::after {
    content: "";
    position: absolute;
    top: 6px; right: 0; bottom: 0; left: 0;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: -1;
}

.nav-dropdown:hover .nav-dropdown-menu {
    display: block;
}

.nav-dropdown-item {
    display: block;
    padding: 8px 16px;
    font-size: 0.875rem;
    color: var(--gray-700);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-dropdown-item:hover {
    background: var(--gray-50);
    color: var(--brand);
}

/* S193 — external-product link arrow (Rules Desktop → alphacorr.com). */
.nav-ext {
    font-size: 0.7rem;
    color: var(--gray-400);
    margin-left: 2px;
}

/* S193 — "soon" placeholder item (Rules 3D, in development). Non-link:
   muted, no hover affordance, default cursor. */
.nav-dropdown-item.soon {
    color: var(--gray-400);
    cursor: default;
}
.nav-dropdown-item.soon:hover {
    background: transparent;
    color: var(--gray-400);
}
.nav-soon-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--gray-500);
    background: var(--gray-100, #f3f4f6);
    border-radius: 9px;
    vertical-align: middle;
}

/* S122 — "Signed in as" header block at the top of the user dropdown.
   Email is the unique identifier; expose it on a single click. */
.nav-dropdown-header {
    padding: 10px 16px 8px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50, #f9fafb);
}
.nav-dropdown-header-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}
.nav-dropdown-header-email {
    font-size: 0.85rem;
    color: var(--gray-900);
    font-weight: 500;
    word-break: break-all;
}
.nav-dropdown-header-balance {
    font-size: 0.75rem;
    color: var(--gray-600);
    margin-top: 4px;
}
.nav-dropdown-header-balance .nav-balance-amount {
    font-weight: 600;
    color: var(--brand);
}

.nav-dropdown-section {
    padding: 8px 16px 4px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-top: 1px solid var(--gray-200);
    margin-top: 4px;
}

.nav-dropdown-section-end {
    border-top: 1px solid var(--gray-200);
    margin: 4px 0 0;
}

.nav-current-org {
    color: var(--gray-500);
    font-weight: 400;
}

/* Nav-links dropdown — opens flush left, not right */
.nav-links .nav-dropdown-menu {
    right: auto;
    left: 0;
}

/* ---------- Container ---------- */

.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 32px 24px;
}

.container-wide {
    max-width: 1600px;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-block;
    padding: 10px 20px;
    font-size: 0.925rem;
    font-weight: 600;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background 0.15s, border-color 0.15s;
    line-height: 1.4;
}

.btn-primary {
    background: var(--brand);
    color: var(--white);
    border-color: var(--brand);
}

.btn-primary:hover {
    background: var(--brand-light);
    border-color: var(--brand-light);
    color: var(--white);
}

.btn-outline {
    background: transparent;
    color: var(--brand);
    border-color: var(--gray-300);
}

.btn-outline:hover {
    border-color: var(--brand);
    background: var(--brand-bg);
}

.btn-danger {
    color: var(--danger);
    border-color: var(--gray-300);
}

.btn-danger:hover {
    border-color: var(--danger);
    background: var(--danger-bg);
    color: var(--danger);
}

button.btn-danger[type="submit"],
.btn-danger.btn-primary {
    background: var(--danger);
    color: var(--white);
    border-color: var(--danger);
}

button.btn-danger[type="submit"]:hover,
.btn-danger.btn-primary:hover {
    background: #b91c1c;
    border-color: #b91c1c;
    color: var(--white);
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.825rem;
}

.btn-lg {
    padding: 14px 32px;
    font-size: 1.05rem;
}

.btn-block {
    display: block;
    width: 100%;
}

/* ---------- Cards ---------- */

.card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 28px;
}

.card h3 {
    margin: 0 0 8px;
    font-size: 1.1rem;
}

.card p {
    margin: 0;
    color: var(--gray-500);
    font-size: 0.925rem;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
}

/* ---------- Hero (landing) ---------- */

.hero {
    text-align: center;
    padding: 48px 0 40px;
    max-width: 720px;
    margin: 0 auto;
}

.hero-free {
    font-size: 3rem;
    font-weight: 800;
    color: var(--brand);
    margin: 0 0 4px;
    letter-spacing: -0.03em;
}

.hero h1 {
    font-size: 2.25rem;
    margin: 0 0 16px;
    letter-spacing: -0.02em;
    color: var(--gray-500);
    font-weight: 400;
}

.hero-sub {
    font-size: 1.1rem;
    color: var(--gray-700);
    margin: 0 0 28px;
    line-height: 1.7;
}

.hero-context {
    max-width: 720px;
    margin: -16px auto 32px;
    text-align: center;
}

.hero-context p {
    font-size: 0.95rem;
    color: var(--gray-500);
    line-height: 1.7;
}

/* ---------- Why section ---------- */

.why-section {
    max-width: 680px;
    margin: 0 auto 32px;
    text-align: center;
    padding: 32px 24px;
}

.why-section h2 {
    margin: 0 0 12px;
    font-size: 1.35rem;
}

.why-section p {
    margin: 0;
    font-size: 1.05rem;
    color: var(--gray-700);
    line-height: 1.8;
}

/* ---------- Features section ---------- */

.features {
    padding: 24px 0 40px;
}

/* ---------- Early access ---------- */

.early-access {
    background: var(--brand-bg);
    border: 1px solid #fecaca;
    border-radius: var(--radius-lg);
    padding: 32px 36px;
    margin: 8px 0 32px;
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
}

.early-access h2 {
    margin: 0 0 12px;
    font-size: 1.25rem;
}

.free-headline {
    font-size: 1.75rem !important;
    letter-spacing: -0.02em;
}

.free-catch {
    font-weight: 400;
    color: var(--gray-500);
    font-size: 1.25rem;
}

.early-access p {
    margin: 0 0 12px;
    font-size: 0.925rem;
    color: var(--gray-700);
    line-height: 1.7;
}

.early-access p:last-child {
    margin-bottom: 0;
}

.early-access-note {
    font-size: 0.85rem !important;
    color: var(--gray-500) !important;
    font-style: italic;
}

/* ---------- How it works ---------- */

.how-it-works {
    padding: 40px 0;
}

.how-it-works h2 {
    text-align: center;
    margin: 0 0 28px;
}

.steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 24px;
    text-align: center;
}

.step {
    padding: 20px;
}

.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--brand);
    color: var(--white);
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 12px;
}

.step h4 {
    margin: 0 0 6px;
}

.step p {
    margin: 0;
    color: var(--gray-500);
    font-size: 0.925rem;
}

/* ---------- CTA bottom ---------- */

.cta-bottom {
    text-align: center;
    padding: 48px 24px;
    margin: 24px 0 0;
    background: var(--brand-bg);
    border-radius: var(--radius-lg);
}

.cta-bottom h2 {
    margin: 0 0 8px;
}

.cta-bottom p {
    color: var(--gray-500);
    margin: 0 0 24px;
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
}

/* ---------- Page header ---------- */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header h1 {
    margin: 0;
}

/* ---------- Data table ---------- */

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
}

.data-table th,
.data-table td {
    padding: 10px 14px;
    text-align: left;
    font-size: 0.9rem;
}

.data-table thead {
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.data-table th {
    font-weight: 600;
    color: var(--gray-900);
}

.data-table tbody tr {
    border-bottom: 1px solid var(--gray-100);
}

.data-table tbody tr:last-child {
    border-bottom: none;
}

/* ---------- Badges ---------- */

.badge {
    display: inline-block;
    padding: 2px 10px;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 12px;
    text-transform: capitalize;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-failed {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-pending {
    background: var(--gray-100);
    color: var(--gray-500);
}

/* ---------- Empty state ---------- */

.empty-state {
    text-align: center;
    padding: 64px 24px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
}

.empty-state h2 {
    margin: 0 0 8px;
    color: var(--gray-700);
}

.empty-state p {
    color: var(--gray-500);
    margin: 0 0 20px;
}

/* ---------- Forms ---------- */

.form-page {
    display: flex;
    justify-content: center;
    padding: 16px 0;
}

.form-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 520px;
}

.form-card h1 {
    margin: 0 0 4px;
    font-size: 1.5rem;
}

.form-subtitle {
    color: var(--gray-500);
    margin: 0 0 24px;
    font-size: 0.925rem;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--gray-900);
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="tel"],
.form-group select {
    width: 100%;
    padding: 9px 12px;
    font-size: 0.925rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--gray-900);
    transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--brand-light);
    box-shadow: 0 0 0 3px rgba(150, 28, 31, 0.15);
}

.form-group input[type="file"] {
    font-size: 0.9rem;
    color: var(--gray-700);
}

.form-hint {
    display: block;
    margin-top: 4px;
    font-size: 0.8rem;
    color: var(--gray-500);
}

.form-check label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-weight: 400;
    font-size: 0.9rem;
    cursor: pointer;
}

.form-check input[type="checkbox"] {
    margin-top: 4px;
}

.form-radio-row {
    display: flex;
    gap: 24px;
    align-items: center;
    margin-top: 4px;
}

.form-radio {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
    font-size: 0.9rem;
    cursor: pointer;
}

.form-radio input[type="radio"]:disabled + * {
    opacity: 0.5;
}

.form-readonly {
    padding: 8px 10px;
    background: var(--gray-50, #fafafa);
    border: 1px solid var(--gray-200, #e5e7eb);
    border-radius: 4px;
    font-size: 0.95rem;
    color: var(--gray-700, #374151);
}

.form-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 0.9rem;
    color: var(--gray-500);
}

.required {
    color: var(--danger);
}

/* ---------- Alerts ---------- */

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.alert ul {
    margin: 0;
    padding-left: 18px;
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid #fecaca;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid #bbf7d0;
}

/* ---------- Footer ---------- */

.footer {
    border-top: 1px solid var(--gray-200);
    padding: 24px 24px 20px;
    margin-top: auto;
}

.footer-inner {
    max-width: var(--container-max);
    margin: 0 auto;
    text-align: center;
}

.footer-contact {
    margin: 0 0 4px;
    font-size: 0.85rem;
    color: var(--gray-700);
}

.footer-links {
    margin: 8px 0 0;
    font-size: 0.85rem;
}

.footer-links a {
    color: var(--gray-500);
    text-decoration: none;
}

.footer-links a:hover {
    color: var(--brand);
    text-decoration: underline;
}

.footer-copy {
    margin: 10px 0 0;
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* ---------- Preview ---------- */

.preview-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 0;
    border-bottom: 2px solid var(--gray-200);
}

.preview-tab {
    padding: 10px 24px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: 0.925rem;
    font-weight: 600;
    color: var(--gray-500);
    cursor: pointer;
}

.preview-tab.active {
    color: var(--brand);
    border-bottom-color: var(--brand);
}

.preview-tab:hover {
    color: var(--brand-light);
}

.preview-panel {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-top: none;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    min-height: 400px;
}

.svg-container {
    padding: 24px;
    text-align: center;
    overflow: auto;
}

.svg-container img {
    max-width: 100%;
    max-height: 600px;
    height: auto;
}

/* ---------- Privacy ---------- */

.privacy-page {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 0;
}

.privacy-page h1 {
    margin-bottom: 4px;
}

.privacy-updated {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-bottom: 32px;
}

.privacy-page h2 {
    color: var(--brand);
    font-size: 1.25rem;
    margin-top: 32px;
    margin-bottom: 12px;
}

.privacy-page h3 {
    font-size: 1rem;
    margin-top: 20px;
    margin-bottom: 8px;
}

.privacy-page ul {
    margin: 8px 0 16px 24px;
}

.privacy-page .contact-list {
    list-style: none;
    padding-left: 0;
}

.privacy-page .contact-list li {
    margin-bottom: 4px;
}

/* ---------- Balance box ---------- */

.balance-box {
    display: flex;
    gap: 20px;
    justify-content: center;
    padding: 12px 16px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 0.875rem;
    color: var(--gray-700);
}

.balance-box strong {
    color: var(--gray-900);
}

/* ---------- Tip ---------- */

.tip {
    margin-top: 16px;
    padding: 12px 16px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--gray-700);
    line-height: 1.6;
}

/* ---------- Disclaimer ---------- */

.disclaimer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--gray-500);
    margin: 48px auto 0;
    max-width: 600px;
    line-height: 1.6;
}

/* ---------- Utilities ---------- */

.text-muted {
    color: var(--gray-500);
    font-size: 0.85rem;
}

/* ---------- Admin filter bar ---------- */

.admin-filter-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 14px 16px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
}

.admin-filter-input {
    padding: 7px 10px;
    font-size: 0.875rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--gray-900);
    min-width: 200px;
    flex: 1;
}

.admin-filter-input:focus {
    outline: none;
    border-color: var(--brand-light);
    box-shadow: 0 0 0 3px rgba(150, 28, 31, 0.15);
}

.admin-filter-select {
    padding: 7px 10px;
    font-size: 0.875rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--gray-900);
}

/* ---------- Admin table filter row ---------- */

.filter-row {
    background: var(--gray-50);
}

.filter-row td {
    padding: 6px 8px !important;
}

.filter-input {
    width: 100%;
    padding: 4px 6px;
    font-size: 0.8rem;
    border: 1px solid var(--gray-300);
    border-radius: 3px;
    background: var(--white);
    color: var(--gray-900);
    box-sizing: border-box;
}

.filter-input:focus {
    outline: none;
    border-color: var(--brand-light);
    box-shadow: 0 0 0 2px rgba(150, 28, 31, 0.12);
}

select.filter-input {
    padding: 4px 4px;
}

/* ---------- Admin pagination ---------- */

.admin-pagination {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
    justify-content: center;
}

/* ---------- Admin bulk actions ---------- */

.admin-bulk-actions {
    margin-top: 32px;
    padding: 20px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
}

.admin-bulk-actions h3 {
    margin: 0 0 16px;
    font-size: 1rem;
    color: var(--gray-700);
}

.admin-bulk-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.admin-bulk-form label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
}

.admin-bulk-form select {
    flex: 1;
    min-width: 200px;
}

/* ---------- PackOps handoff banner ---------- */

.packops-handoff {
    background: linear-gradient(135deg, var(--gray-900) 0%, #1e293b 100%);
    color: var(--white);
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    margin: 32px 0;
    text-align: center;
}

.packops-handoff h3 {
    color: var(--white);
    margin: 0 0 8px;
    font-size: 1.15rem;
}

.packops-handoff p {
    color: #94a3b8;
    margin: 0 0 16px;
    font-size: 0.925rem;
}

.packops-handoff .btn {
    background: var(--brand);
    color: var(--white);
    border-color: var(--brand);
}

.packops-handoff .btn:hover {
    background: var(--brand-light);
}

/* ---------- Responsive ---------- */

@media (max-width: 768px) {
    .nav-inner {
        flex-wrap: wrap;
        height: auto;
        padding: 12px 0;
        gap: 8px;
    }

    .nav-links {
        order: 3;
        width: 100%;
        margin-left: 0;
        gap: 16px;
    }

    .nav-user {
        margin-left: auto;
    }

    .hero h1 {
        font-size: 1.6rem;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .steps {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .form-card {
        padding: 24px;
    }

    .data-table {
        font-size: 0.825rem;
    }

    .data-table th,
    .data-table td {
        padding: 8px 10px;
    }
}

/* ==========================================================================
   SVG zoom/pan preview (shared partial _svg_preview.html)
   ========================================================================== */

.svg-preview {
    position: relative;
    border: 1px solid var(--gray-200);
    background: white;
    width: 100%;
    aspect-ratio: 4 / 3;
    max-height: 500px;
    overflow: hidden;
    user-select: none;
}

.svg-preview-stage {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    box-sizing: border-box;
}

.svg-preview-stage svg {
    cursor: grab;
}

.svg-preview-stage svg:active {
    cursor: grabbing;
}

.svg-preview-toolbar {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--gray-200);
    border-radius: 4px;
    padding: 2px;
}

.svg-preview-toolbar button {
    font-family: inherit;
    font-size: 0.85rem;
    line-height: 1;
    padding: 6px 10px;
    min-width: 32px;
    border: 0;
    background: transparent;
    color: var(--gray-700);
    cursor: pointer;
    border-radius: 3px;
}

.svg-preview-toolbar button:hover {
    background: var(--gray-100);
    color: var(--brand);
}

/* ==========================================================================
   Shared JSON viewer (shared partial _json_viewer.html)
   ========================================================================== */

.json-viewer {
    border: 1px solid var(--gray-200);
    background: var(--gray-50);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85rem;
}

.jv-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    background: var(--gray-100);
    border-bottom: 1px solid var(--gray-200);
    flex-wrap: wrap;
    gap: 8px;
}

.jv-tabs, .jv-actions {
    display: flex;
    gap: 4px;
}

.jv-toolbar button {
    font-family: inherit;
    font-size: 0.8rem;
    padding: 4px 10px;
    border: 1px solid var(--gray-300);
    background: white;
    color: var(--gray-700);
    border-radius: 3px;
    cursor: pointer;
}

.jv-toolbar button:hover { color: var(--brand); border-color: var(--brand-light); }
.jv-tabs button.active   { color: var(--brand); border-color: var(--brand); background: white; font-weight: 600; }

.jv-stage {
    padding: 10px 12px;
    max-height: 520px;
    overflow: auto;
}

.jv-tree, .jv-body { padding-left: 14px; }
.jv-tree { padding-left: 0; }

.jv-node.jv-collapsed > .jv-body,
.jv-node.jv-collapsed > .jv-tail { display: none; }

.jv-head { cursor: default; white-space: nowrap; }
.jv-head.jv-collapsible { cursor: pointer; }
.jv-head.jv-empty       { cursor: default; }

.jv-toggle  { display: inline-block; width: 12px; color: var(--gray-500); }
.jv-key     { color: var(--gray-700); }
.jv-colon   { color: var(--gray-500); }
.jv-bracket { color: var(--gray-500); }
.jv-summary { color: var(--gray-500); font-style: italic; margin-left: 6px; }
.jv-string  { color: #0b7a3b; }
.jv-number  { color: #b64e00; }
.jv-boolean { color: #5a3ab4; }
.jv-null    { color: var(--gray-500); font-style: italic; }
.jv-leaf    { padding: 1px 0; }

.jv-flat {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.85rem;
}

.jv-parse-error { color: var(--brand); }

/* ==========================================================================
   Result cards (multi-file upload) + tabs
   ========================================================================== */

.result-card {
    margin-bottom: 32px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.result-card-header {
    padding: 14px 18px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.result-card-header h3 { margin: 0; font-size: 1.05rem; }
.result-card-header .meta { color: var(--gray-500); font-size: 0.9rem; }

.result-card-body { padding: 16px 18px; }

.source-pill {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 8px;
    border-radius: 10px;
    vertical-align: middle;
    margin-right: 8px;
}
.source-pill.given     { background: var(--gray-200); color: var(--gray-700); }
.source-pill.generated { background: var(--brand-bg);  color: var(--brand);   }

/* Tab panels — scoped per-card via a data-tab-group attribute */
.tab-panel          { display: none; padding-top: 14px; }
.tab-panel.active   { display: block; }

/* Image-preview stage — needs overflow:hidden so transformed <img> clips */
.image-preview-stage {
    overflow: hidden;
    padding: 0;
    cursor: grab;
}
.image-preview-stage:active { cursor: grabbing; }

/* ==========================================================================
   Matcher page (native ↔ reference pairing, Step 3)
   ========================================================================== */

.matcher-page { max-width: 1100px; margin: 0 auto; padding: 20px 0; }
.matcher-page h1 { margin-bottom: 8px; }
.matcher-page .form-subtitle { margin-bottom: 24px; }

.matcher-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    margin-bottom: 24px;
}

.matcher-col h3 {
    margin: 0 0 12px 0;
    font-size: 0.95rem;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.matcher-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    margin-bottom: 10px;
    background: white;
}

.matcher-item.is-paired { background: var(--brand-bg); border-color: var(--brand-light); }
.matcher-item.is-removed { opacity: 0.35; text-decoration: line-through; }

.matcher-thumb {
    width: 96px;
    height: 96px;
    border: 1px solid var(--gray-200);
    background: var(--gray-50);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    border-radius: 4px;
}
.matcher-thumb img {
    max-width: 100%;
    max-height: 100%;
    display: block;
}
.matcher-thumb .thumb-placeholder {
    font-size: 0.75rem;
    color: var(--gray-500);
    text-align: center;
    padding: 4px;
}

.matcher-item .meta   { flex: 1; min-width: 0; }
.matcher-item .name   { font-weight: 600; word-break: break-all; font-size: 0.9rem; }
.matcher-item .sub    { font-size: 0.8rem; color: var(--gray-500); }

.matcher-item select,
.matcher-item .match-note { font-size: 0.85rem; }

.matcher-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.matcher-actions button {
    font-family: inherit;
    font-size: 0.75rem;
    padding: 4px 8px;
    border: 1px solid var(--gray-300);
    background: white;
    border-radius: 3px;
    cursor: pointer;
    color: var(--gray-700);
}
.matcher-actions button:hover { color: var(--brand); border-color: var(--brand-light); }

.match-note.auto   { color: var(--brand); font-weight: 600; }
.match-note.manual { color: var(--gray-700); }
.match-note.none   { color: var(--gray-500); font-style: italic; }

@media (max-width: 700px) {
    .matcher-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Matcher — single-column native groups (Step 3 revision)
   ========================================================================== */

.matcher-list { display: flex; flex-direction: column; gap: 0; }

.native-group {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    margin-bottom: 14px;
    background: white;
    transition: border-color 0.15s, background 0.15s;
}
.native-group.drop-hot {
    border-color: var(--brand);
    background: var(--brand-bg);
}

.native-row {
    border: 0;
    margin: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.unpaired-group { border-style: dashed; background: var(--gray-50); }
.unpaired-row   { background: transparent; }
.unpaired-row .thumb-placeholder { font-size: 1.2rem; color: var(--gray-300); }

.paired-refs {
    padding: 10px 10px 2px 10px;
    min-height: 56px;
}

.paired-refs:empty::before {
    content: "Drop references here or use the dropdowns.";
    display: block;
    padding: 10px;
    color: var(--gray-500);
    font-style: italic;
    font-size: 0.85rem;
}

.matcher-ref {
    cursor: grab;
    margin-bottom: 8px;
}
.matcher-ref:active,
.matcher-ref.is-dragging { cursor: grabbing; opacity: 0.6; }

/* ==========================================================================
   Upload drop zone (shared across portals)
   ========================================================================== */

.drop-zone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-lg);
    background: var(--gray-50);
    padding: 28px 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.1s;
    outline: none;
}
.drop-zone:hover,
.drop-zone:focus-visible { border-color: var(--brand-light); background: white; }
.drop-zone.is-hot {
    border-color: var(--brand);
    background: var(--brand-bg);
    transform: scale(1.005);
}

.drop-zone-icon {
    font-size: 2rem;
    color: var(--brand);
    margin-bottom: 4px;
    line-height: 1;
}
.drop-zone-primary   { font-size: 1rem;   font-weight: 600; color: var(--gray-900); }
.drop-zone-secondary { font-size: 0.9rem; color: var(--gray-500); margin-top: 2px; }
.drop-zone-link      { color: var(--brand); text-decoration: underline; }
.drop-zone-formats   { font-size: 0.8rem; color: var(--gray-500); margin-top: 8px; font-family: ui-monospace, Menlo, monospace; }

.drop-zone-files {
    list-style: none;
    padding: 0;
    margin: 12px 0 0 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.drop-zone-file {
    display: grid;
    grid-template-columns: 100px 1fr auto auto;
    gap: 10px;
    align-items: center;
    padding: 6px 10px;
    border: 1px solid var(--gray-200);
    border-radius: 4px;
    background: white;
    font-size: 0.9rem;
}
.drop-zone-file .file-kind {
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 2px 8px;
    border-radius: 10px;
    text-align: center;
}
.drop-zone-file.is-native      .file-kind { background: var(--brand-bg); color: var(--brand); }
.drop-zone-file.is-reference   .file-kind { background: var(--gray-200); color: var(--gray-700); }
.drop-zone-file.is-archive     .file-kind { background: #e0e6ee;          color: #2a4365;       }
.drop-zone-file.is-unsupported .file-kind { background: #fff2cd;          color: #8a6d00;       }
.drop-zone-file.is-opaque      .file-kind { background: #fff2cd;          color: #8a6d00;       }

.drop-zone-file .file-name { font-family: ui-monospace, Menlo, monospace; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drop-zone-file .file-size { color: var(--gray-500); font-size: 0.8rem; }
.drop-zone-file .file-remove {
    border: 0; background: transparent; color: var(--gray-400); cursor: pointer;
    font-size: 1.1rem; line-height: 1; padding: 2px 6px; border-radius: 3px;
}
.drop-zone-file .file-remove:hover { background: var(--gray-100); color: var(--gray-700); }

/* Matcher visual-hierarchy polish: prominent natives, indented refs */
.native-row {
    padding: 16px 18px;
    gap: 14px;
}
.native-row .name { font-size: 1.05rem; font-weight: 700; color: var(--gray-900); }
.native-row .sub  { font-size: 0.82rem; }
.native-row .matcher-thumb {
    width: 112px;
    height: 112px;
}
.native-row .matcher-thumb .thumb-placeholder { font-size: 0.9rem; font-weight: 700; color: var(--brand); }

/* Indent every paired reference further beneath its native */
.paired-refs       { padding-left: 56px; }
.paired-refs:empty { padding-left: 56px; }

/* (Guide line removed — indent + badges carry the parent/child hierarchy) */
.native-group { position: relative; }

@media (max-width: 640px) {
    .paired-refs       { padding-left: 24px; }
    .paired-refs:empty { padding-left: 24px; }
}

/* Deeper indent for matcher refs */
.paired-refs       { padding-left: 112px; }
.paired-refs:empty { padding-left: 112px; }

@media (max-width: 640px) {
    .paired-refs       { padding-left: 48px; }
    .paired-refs:empty { padding-left: 48px; }
}

.matcher-thumb { position: relative; }
.matcher-thumb.is-clickable { cursor: zoom-in; }
.matcher-thumb.is-clickable:hover { border-color: var(--brand-light); }

.thumb-ext {
    position: absolute;
    bottom: 4px;
    right: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 2px 6px;
    border-radius: 3px;
    background: rgba(20, 20, 20, 0.75);
    color: white;
    pointer-events: none;
    text-transform: uppercase;
}

/* Native thumbs get a brand-red badge so they stand apart from ref badges */
.native-row .thumb-ext {
    background: var(--brand);
}

/* Blow-up modal */
.blowup {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.blowup[hidden] { display: none; }
.blowup-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 10, 10, 0.78);
}
.blowup-panel {
    position: relative;
    background: white;
    border-radius: var(--radius-lg);
    width: min(92vw, 1200px);
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
}
.blowup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.9rem;
}
.blowup-title { font-family: ui-monospace, Menlo, monospace; color: var(--gray-700); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.blowup-close {
    background: transparent;
    border: 0;
    font-size: 1.4rem;
    line-height: 1;
    color: var(--gray-500);
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 4px;
}
.blowup-close:hover { color: var(--brand); background: var(--gray-100); }
.blowup-body {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
    background: var(--gray-50);
}
.blowup-img { max-width: 100%; max-height: 80vh; height: auto; display: block; }
.blowup-pdf { width: 100%; height: 80vh; border: 0; background: white; }
.blowup-fallback { text-align: center; color: var(--gray-500); }

body.blowup-open { overflow: hidden; }

/* Given-preview: faithful <img>/<iframe> render (no inline SVG injection,
   so user-authored SVG text retains its authored styling). */
.given-preview {
    border: 1px solid var(--gray-200);
    background: white;
    padding: 12px;
    cursor: zoom-in;
    text-align: center;
}
.given-preview:hover { border-color: var(--brand-light); }
.given-preview img {
    max-width: 100%;
    max-height: 600px;
    height: auto;
    display: block;
    margin: 0 auto;
}

/* ==========================================================================
   Capabilities / Machine Passport — POC parity
   Detail-page visual language adopted from the SteelRules Passport POC
   (poc-portal.clearcutdieworks.i-c.cloud) and adapted to packops's
   existing CSS variable palette.
   ========================================================================== */

:root {
    --accent:       #2563eb;
    --accent-light: #3b82f6;
    --accent-bg:    #eff6ff;
    --info:         #0891b2;
    --info-bg:      #e0f2fe;
}

.breadcrumb {
    display: flex;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.breadcrumb a {
    color: var(--accent);
    text-decoration: none;
}
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { color: var(--gray-300); }

.page-header.passport {
    display: block;
    margin-bottom: 16px;
}
.page-header.passport h1 {
    font-size: 1.6rem;
    color: var(--gray-900);
    margin: 0;
}
.page-header.passport h1 .alias {
    color: var(--gray-500);
    font-weight: 400;
}
.page-header.passport .subtitle {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-top: 4px;
}

.passport-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin: -8px 0 16px;
}

.capability-form {
    max-width: 720px;
    margin: 0 auto 32px;
}

.section-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}
.section-nav a {
    display: inline-block;
    padding: 6px 14px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 0.82rem;
    color: var(--gray-700);
    text-decoration: none;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.section-nav a:hover {
    background: var(--accent-bg);
    border-color: var(--accent);
    color: var(--accent);
}

.section {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    overflow: hidden;
}
.section-header {
    padding: 14px 20px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 10px;
}
.section-header h2,
.section-header h3 {
    font-size: 1rem;
    margin: 0;
    color: var(--gray-900);
}
.section-header .count {
    color: var(--gray-500);
    font-weight: 400;
    font-size: 0.85em;
}
.section-body {
    padding: 20px;
}
.section-body.flush {
    padding: 0;
}

.kv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 8px 24px;
}
.kv-item {
    display: flex;
    gap: 8px;
    padding: 4px 0;
    font-size: 0.88rem;
}
.kv-item .kv-label {
    color: var(--gray-500);
    font-weight: 500;
    min-width: 120px;
    flex-shrink: 0;
}
.kv-item .kv-value {
    color: var(--gray-900);
    word-break: break-word;
}

/* Additional badge variants beyond the existing -success/-failed/-pending. */
.badge-active     { background: #dcfce7; color: var(--success); }
.badge-approved   { background: #dcfce7; color: var(--success); }
.badge-best       { background: #dcfce7; color: var(--success); }
.badge-master     { background: #fef3c7; color: #92400e; border: 1px solid #f59e0b; }
.badge-trial      { background: #fef3c7; color: var(--warning); }
.badge-warning    { background: #fef3c7; color: var(--warning); }
.badge-moderate   { background: #fef3c7; color: var(--warning); }
.badge-medium     { background: #fef3c7; color: var(--warning); }
.badge-retired    { background: #fecaca; color: var(--danger); }
.badge-critical   { background: #fecaca; color: var(--danger); }
.badge-high       { background: #fecaca; color: var(--danger); }
.badge-low        { background: var(--info-bg); color: var(--info); }
.badge-info       { background: var(--info-bg); color: var(--info); }
.badge-monitoring { background: var(--info-bg); color: var(--info); }
.badge-draft      { background: var(--gray-100); color: var(--gray-500); }
.badge-deprecated { background: var(--gray-100); color: var(--gray-500); }

.quirk-card {
    border-left: 4px solid var(--gray-300);
    padding: 14px 18px;
    margin-bottom: 12px;
    background: var(--white);
    border-radius: 0 6px 6px 0;
}
.quirk-card.severity-critical { border-left-color: var(--danger); }
.quirk-card.severity-high     { border-left-color: var(--danger); }
.quirk-card.severity-moderate { border-left-color: var(--warning); }
.quirk-card.severity-medium   { border-left-color: var(--warning); }
.quirk-card.severity-low      { border-left-color: var(--info); }
.quirk-card h4 {
    font-size: 0.95rem;
    margin: 0 0 4px;
    color: var(--gray-900);
}
.quirk-card .narrative {
    margin-top: 10px;
    font-size: 0.88rem;
    color: var(--gray-700);
}

.profile-card {
    border-left: 4px solid var(--accent);
    padding: 14px 18px;
    margin-bottom: 12px;
    background: var(--white);
    border-radius: 0 6px 6px 0;
}
.profile-card h4 {
    font-size: 0.95rem;
    margin: 0 0 4px;
    color: var(--gray-900);
}

.data-table .subrow td {
    padding: 4px 14px 10px 28px;
    color: var(--gray-700);
    font-size: 0.85rem;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}
.data-table tbody tr:hover td { background: var(--gray-50); }
.data-table tbody tr.subrow:hover td { background: var(--gray-50); }

.section-empty {
    padding: 28px 20px;
    text-align: center;
    color: var(--gray-500);
    font-style: italic;
    font-size: 0.9rem;
}

/* ---------- Stat grid (Machine Passport dashboard counters) ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 32px;
}
.stat-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 16px;
    text-align: center;
}
.stat-card .number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.2;
}
.stat-card .label {
    font-size: 0.78rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ---------- Card link (clickable card wrapper, used in Quick Access) ---------- */
.card-link {
    display: block;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 20px;
    color: inherit;
    text-decoration: none;
    transition: box-shadow 0.15s, border-color 0.15s;
}
.card-link:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-color: var(--gray-300);
    text-decoration: none;
}
.card-link h3 {
    font-size: 1rem;
    margin: 0 0 4px;
    color: var(--gray-900);
}
.card-link .meta {
    font-size: 0.85rem;
    color: var(--gray-500);
    margin: 4px 0 8px;
}
.card-link .meta a { color: var(--accent); }
.card-link .meta a:hover { text-decoration: underline; }

/* ---------- Filter bar (slice E.8 phase 2) ---------- */

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px 18px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 14px 18px;
    margin: 16px 0 20px;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.filter-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-right: 4px;
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    font-size: 0.825rem;
    font-weight: 500;
    color: var(--gray-700);
    background: var(--gray-100);
    border: 1px solid var(--gray-300);
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
    font-family: inherit;
    line-height: 1.3;
}

.chip:hover {
    background: var(--gray-200);
    border-color: var(--gray-500);
}

.chip.active {
    background: var(--accent-bg);
    border-color: var(--accent);
    color: var(--accent);
}

.filter-clear {
    margin-left: auto;
    padding: 5px 12px;
    font-size: 0.825rem;
    font-weight: 500;
    color: var(--gray-500);
    background: transparent;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
    font-family: inherit;
    line-height: 1.3;
}

.filter-clear:hover {
    background: var(--gray-100);
    color: var(--gray-900);
    border-color: var(--gray-500);
}

.filter-count {
    font-size: 0.85rem;
    color: var(--gray-500);
    font-weight: 400;
}

.filter-empty {
    background: var(--gray-50);
    border: 1px dashed var(--gray-300);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    text-align: center;
    color: var(--gray-500);
}

.filter-empty p {
    margin: 0 0 12px;
}

/* ---------- AI Assistant (slice G) ---------- */

.ai-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.ai-row-secondary {
    font-size: 0.85rem;
}

#ai-question {
    flex: 1 1 320px;
    padding: 9px 12px;
    font-size: 0.9rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-family: inherit;
    color: var(--gray-900);
    background: var(--white);
    line-height: 1.4;
}

#ai-question:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}

.ai-btn {
    padding: 9px 16px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--gray-700);
    background: var(--gray-100);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
    font-family: inherit;
    line-height: 1.3;
}

.ai-btn:hover:not(:disabled) {
    background: var(--gray-200);
    border-color: var(--gray-500);
    color: var(--gray-900);
}

.ai-btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--white);
}

.ai-btn-primary:hover:not(:disabled) {
    background: var(--accent-light);
    border-color: var(--accent-light);
    color: var(--white);
}

.ai-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.ai-hint {
    color: var(--gray-500);
    font-size: 0.82rem;
}

.ai-result {
    margin-top: 14px;
    padding: 14px 16px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--gray-50);
    color: var(--gray-900);
    font-size: 0.92rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.ai-result.ai-loading {
    color: var(--gray-500);
    font-style: italic;
}

.ai-result.ai-error {
    background: var(--danger-bg);
    border-color: var(--danger);
    color: var(--danger);
}

/* ---------- Demo org badge (slice E.10) ---------- */

.badge-demo {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--white);
    background: var(--warning);
    padding: 1px 6px;
    border-radius: 3px;
    vertical-align: middle;
    line-height: 1.4;
    text-transform: uppercase;
}

/* ---------- S145 — cohort badges (BETA / INTERNAL) ---------- */
/* Inline next to the user name in the top nav. Signals to the user that
   they're seeing pre-release features so unexpected nav items aren't
   confusing. Stable cohort gets no badge. */
.badge-cohort {
    display: inline-block;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 1px 6px;
    border-radius: 3px;
    vertical-align: middle;
    line-height: 1.4;
    text-transform: uppercase;
}
.badge-cohort-beta {
    background: #fff4d6;
    color: #8a6500;
    border: 1px solid #f0d488;
}
.badge-cohort-internal {
    background: #d6e9ff;
    color: #14457a;
    border: 1px solid #95bce8;
}

/* ==========================================================================
   S112 — Archive tree (zip ingest on /files)
   Two themes: tree-style--win (default; Windows Explorer feel) and
   tree-style--mac (Finder-ish). Applied at .tree-pane level so each
   archive in a batch can swap themes independently. Toggle persists
   per-user via localStorage("packops.tree.style").
   ========================================================================== */

.tree-pane {
    --tree-row-h:        20px;
    --tree-indent:       18px;
    --tree-color-line:   #c4cad1;
    --tree-color-text:   var(--gray-700);
    --tree-color-meta:   var(--gray-500);
    --tree-color-hover:  #eef3fb;
    --tree-color-focus:  #d6e4fb;
    --tree-font:         "Segoe UI", "Liberation Sans", system-ui, sans-serif;

    font-family: var(--tree-font);
    font-size: 12.5px;
    color: var(--tree-color-text);
    padding: 4px 0;
    user-select: none;
}

.tree-root,
.tree-children {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tree-children {
    padding-left: var(--tree-indent);
    position: relative;
}

.tree-node {
    margin: 0;
    padding: 0;
}

.tree-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: var(--tree-row-h);
    padding: 1px 4px;
    border-radius: 2px;
    cursor: default;
}

.tree-row:hover {
    background: var(--tree-color-hover);
}

.tree-node[aria-selected="true"] > .tree-row,
.tree-row:focus-within {
    background: var(--tree-color-focus);
    outline: none;
}

.tree-toggle {
    flex: 0 0 14px;
    width: 14px;
    height: 14px;
    line-height: 14px;
    font-size: 11px;
    color: var(--tree-color-meta);
    background: transparent;
    border: 0;
    padding: 0;
    cursor: pointer;
    text-align: center;
    transition: transform 80ms linear;
}

.tree-toggle-spacer {
    flex: 0 0 14px;
    width: 14px;
}

.tree-icon {
    flex: 0 0 16px;
    font-size: 13px;
    line-height: 1;
    text-align: center;
}

.tree-label {
    flex: 0 1 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-meta {
    flex: 0 0 auto;
    font-size: 11px;
    color: var(--tree-color-meta);
    margin-left: 4px;
}

.tree-jobs {
    flex: 0 0 auto;
    font-size: 11px;
    margin-left: 8px;
}

.tree-jobs a {
    color: var(--brand);
    text-decoration: none;
}

.tree-jobs a:hover {
    text-decoration: underline;
}

.tree-actions {
    flex: 0 0 auto;
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 4px;
}

.tree-actions .btn {
    font-size: 10.5px;
    padding: 1px 6px;
    line-height: 1.4;
}

.tree-btn-delete {
    background: #fdecea;
    color: #b33a3a;
    border: 1px solid #f5c2c0;
}

/* Collapsed state — hide children, rotate chevron. */
.tree-dir[aria-expanded="false"] > .tree-children {
    display: none;
}

.tree-dir[aria-expanded="false"] > .tree-row > .tree-toggle {
    transform: rotate(-90deg);
}

/* Role-tinted file icons (subtle; CIM/ARD/etc. handled via ext-class
   later if useful). */
.tree-file--reference > .tree-row > .tree-icon {
    opacity: 0.7;
}

/* ----- Windows theme (default) — dotted connectors, sharp chevrons ----- */

.tree-style--win {
    --tree-row-h:      20px;
    --tree-indent:     18px;
    --tree-font:       "Segoe UI", "Liberation Sans", system-ui, sans-serif;
}

.tree-style--win .tree-children {
    border-left: 1px dotted var(--tree-color-line);
    margin-left: 7px;
    padding-left: calc(var(--tree-indent) - 7px);
}

.tree-style--win .tree-icon-dir::before  { content: "📁"; }
.tree-style--win .tree-icon-file::before { content: "📄"; }
.tree-style--win .tree-icon-dir,
.tree-style--win .tree-icon-file        { font-size: 12px; }

/* ----- macOS theme — no connectors, roomier rows, SF Pro ------------- */

.tree-style--mac {
    --tree-row-h:      24px;
    --tree-indent:     20px;
    --tree-font:       -apple-system, "SF Pro Text", "Helvetica Neue", sans-serif;
    font-size: 13px;
}

.tree-style--mac .tree-children {
    border-left: 0;
    margin-left: 0;
    padding-left: var(--tree-indent);
}

.tree-style--mac .tree-row {
    border-radius: 4px;
}

.tree-style--mac .tree-toggle,
.tree-style--mac .tree-toggle-spacer {
    flex: 0 0 12px;
    width: 12px;
}

.tree-style--mac .tree-toggle {
    font-size: 9px;
}

.tree-style--mac .tree-icon-dir::before  { content: "📂"; }
.tree-style--mac .tree-icon-file::before { content: "📄"; }

/* Style-toggle button on archive header — minimal chrome. */
.tree-style-toggle {
    font-size: 10.5px;
    padding: 2px 8px;
    line-height: 1.4;
    cursor: pointer;
}

/* ==========================================================================
   S112 — Data section ("what we've derived from this file")
   Used by /result per-native card, /classify sidebar, /visualize file-
   details panel, and (compact variant) /files archive-header badge.
   ========================================================================== */

.data-section {
    border: 1px solid var(--gray-200);
    border-radius: 4px;
    margin: 8px 0;
    background: var(--white);
    font-size: 12.5px;
}

.data-section[open] {
    background: var(--gray-50);
}

.data-section__header {
    list-style: none;
    cursor: pointer;
    padding: 6px 10px;
    background: var(--gray-100);
    border-bottom: 1px solid var(--gray-200);
    border-radius: 4px 4px 0 0;
    font-weight: 600;
    color: var(--gray-700);
    user-select: none;
}

.data-section__header::-webkit-details-marker { display: none; }
.data-section__header::before {
    content: "▸ ";
    display: inline-block;
    color: var(--gray-500);
    transition: transform 80ms linear;
}
.data-section[open] .data-section__header::before {
    content: "▾ ";
}

.data-section__title {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.data-section__category {
    padding: 8px 12px;
    border-bottom: 1px solid var(--gray-200);
}
.data-section__category:last-child { border-bottom: 0; }

.data-section__cat-header {
    margin: 0 0 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-500);
    font-weight: 700;
}

.data-section__rows {
    display: grid;
    grid-template-columns: max-content 1fr;
    column-gap: 12px;
    row-gap: 3px;
    margin: 0;
    padding: 0;
}
.data-section__rows dt {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-500);
    align-self: center;
}
.data-section__rows dd {
    margin: 0;
    color: var(--gray-700);
    word-break: break-word;
}
.data-section__rows code {
    font-family: ui-monospace, Menlo, monospace;
    background: var(--gray-100);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 11.5px;
}

.data-section__path {
    font-family: ui-monospace, Menlo, monospace;
    font-size: 10.5px;
    color: var(--gray-500);
    word-break: break-all;
}

.data-section__chips {
    margin-top: 6px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: flex-start;
}
.data-section__chip {
    font-size: 10.5px;
    background: #e0e6ee;
    color: #2a4365;
    padding: 1px 8px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    display: inline-block;
    user-select: none;
}
.data-section__chip::-webkit-details-marker { display: none; }
.data-section__chip::before {
    content: "▸ ";
    color: var(--gray-500);
    font-weight: 400;
}
.data-section__expand[open] > .data-section__chip::before { content: "▾ "; }

.data-section__expand {
    flex: 1 1 100%;
}
.data-section__expand-body {
    margin-top: 6px;
    max-height: 360px;
    overflow: auto;
    border: 1px solid var(--gray-200);
    border-radius: 3px;
    background: var(--white);
}

.data-section__records {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    font-family: ui-monospace, Menlo, monospace;
}
.data-section__records thead th {
    text-align: left;
    background: var(--gray-100);
    padding: 4px 8px;
    border-bottom: 1px solid var(--gray-200);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-500);
}
.data-section__records tbody td {
    padding: 4px 8px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: top;
    word-break: break-word;
}
.data-section__records tbody tr:last-child td { border-bottom: 0; }
.data-section__num { width: 80px; color: var(--gray-500); }

.data-section__subvalue {
    display: flex;
    gap: 8px;
    align-items: baseline;
    padding: 1px 0;
}
.data-section__sv-role {
    font-size: 9.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-500);
    min-width: 70px;
}
.data-section__sv-val {
    font-family: ui-monospace, Menlo, monospace;
    color: var(--gray-700);
    word-break: break-word;
}

.data-section__assets {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.data-section__asset {
    display: inline-block;
    padding: 3px 10px;
    font-size: 11px;
    text-decoration: none;
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: 3px;
    color: var(--gray-700);
}
.data-section__asset:hover {
    background: var(--gray-100);
    color: var(--brand);
}

.data-section__jobs {
    list-style: none;
    margin: 0;
    padding: 0;
}
.data-section__jobs li {
    padding: 2px 0;
    font-size: 11.5px;
}
.data-section__jobs a {
    color: var(--brand);
    text-decoration: none;
    font-weight: 600;
}

.data-section__meta {
    color: var(--gray-500);
    font-size: 11px;
}

.data-section__status--success { color: var(--success); font-weight: 600; }
.data-section__status--failed  { color: var(--danger);  font-weight: 600; }
.data-section__status--pending { color: var(--warning); font-weight: 600; }

.data-section__err {
    font-family: ui-monospace, Menlo, monospace;
    font-size: 10.5px;
    color: var(--danger);
    background: var(--danger-bg);
    padding: 4px 6px;
    border-radius: 3px;
    border: 1px solid #f5c2c0;
}

/* Compact one-line variant for /files archive-header badge. */
.project-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    color: var(--gray-700);
}
.project-badge__code {
    font-family: ui-monospace, Menlo, monospace;
    background: #e0e6ee;
    color: #2a4365;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
}
.project-badge__customer { font-weight: 600; }
.project-badge__designer { color: var(--gray-500); }

/* S112 — Debug mode gating. The verbose Data section blocks (4
   categories with collapsible expansion) are admin-only and admin
   must explicitly toggle Debug on (localStorage.packops.debug='1').
   The project chip + archive-header badge remain visible to all and
   are NOT debug-gated.
   `display: revert` restores the element's user-agent default
   (e.g., `block` for <details>, <div>, <section>) — NOT `initial`,
   which forces `inline` on all elements per CSS spec. Hit S112b. */
.debug-only { display: none; }
body.debug-on .debug-only { display: revert; }

/* ==========================================================================
   S112b — Peer-block layout for Data categories.
   Generated DB / Generated 2D / Generated 3D render as top-level peer
   blocks (not nested in a collapsible). JSON-y expansions + Parse log
   live in a single .debug-only collapsible "Debug data" at the bottom.
   ========================================================================== */

.data-block {
    border: 1px solid var(--gray-200);
    border-radius: 4px;
    margin: 8px 0;
    padding: 8px 12px;
    background: var(--white);
    font-size: 12.5px;
    color: var(--gray-700);
}

.data-block__header {
    margin: 0 0 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-500);
    font-weight: 700;
}

.data-block__rows {
    display: grid;
    grid-template-columns: max-content 1fr;
    column-gap: 12px;
    row-gap: 3px;
    margin: 0;
    padding: 0;
}
.data-block__rows dt {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-500);
    align-self: center;
}
.data-block__rows dd {
    margin: 0;
    color: var(--gray-700);
    word-break: break-word;
}
.data-block__rows code {
    font-family: ui-monospace, Menlo, monospace;
    background: var(--gray-100);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 11.5px;
}

.data-block__path {
    font-family: ui-monospace, Menlo, monospace;
    font-size: 10.5px;
    color: var(--gray-500);
    word-break: break-all;
}

.data-block__assets {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.data-block__asset {
    display: inline-block;
    padding: 3px 10px;
    font-size: 11px;
    text-decoration: none;
    background: var(--gray-100);
    border: 1px solid var(--gray-300);
    border-radius: 3px;
    color: var(--gray-700);
    font-weight: 600;
}
.data-block__asset:hover {
    background: var(--white);
    color: var(--brand);
}

.data-block__jobs {
    list-style: none;
    margin: 0;
    padding: 0;
}
.data-block__jobs li {
    padding: 2px 0;
    font-size: 11.5px;
}
.data-block__jobs a {
    color: var(--brand);
    text-decoration: none;
    font-weight: 600;
}
.data-block__meta {
    color: var(--gray-500);
    font-size: 11px;
}

/* Debug data collapsible. Renders only with `debug-only` class — base
   rule .debug-only { display: none } applies until body.debug-on. */
.data-block.debug-only {
    background: var(--gray-50);
    border-color: var(--gray-300);
}
.data-block__debug-header {
    list-style: none;
    cursor: pointer;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-500);
    padding: 2px 0;
    user-select: none;
}
.data-block__debug-header::-webkit-details-marker { display: none; }
.data-block__debug-header::before {
    content: "▸ ";
    color: var(--gray-500);
}
.data-block[open] > .data-block__debug-header::before {
    content: "▾ ";
}
.data-block__debug-pill {
    display: inline-block;
    margin-left: 4px;
    padding: 0 6px;
    font-size: 9.5px;
    background: var(--warning);
    color: var(--white);
    border-radius: 8px;
    font-weight: 700;
}

.data-block__debug-cat {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--gray-200);
}
.data-block__cat-header {
    margin: 0 0 6px;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-500);
    font-weight: 700;
}

.data-block__expand-body {
    max-height: 360px;
    overflow: auto;
    border: 1px solid var(--gray-200);
    border-radius: 3px;
    background: var(--white);
}

.data-block__records {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    font-family: ui-monospace, Menlo, monospace;
}
.data-block__records thead th {
    text-align: left;
    background: var(--gray-100);
    padding: 4px 8px;
    border-bottom: 1px solid var(--gray-200);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-500);
}
.data-block__records tbody td {
    padding: 4px 8px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: top;
    word-break: break-word;
}
.data-block__records tbody tr:last-child td { border-bottom: 0; }
.data-block__num { width: 80px; color: var(--gray-500); }

.data-block__subvalue {
    display: flex;
    gap: 8px;
    align-items: baseline;
    padding: 1px 0;
}
.data-block__sv-role {
    font-size: 9.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-500);
    min-width: 70px;
}
.data-block__sv-val {
    font-family: ui-monospace, Menlo, monospace;
    color: var(--gray-700);
    word-break: break-word;
}

.data-block__status--success { color: var(--success); font-weight: 600; }
.data-block__status--failed  { color: var(--danger);  font-weight: 600; }
.data-block__status--pending { color: var(--warning); font-weight: 600; }
.data-block__err {
    font-family: ui-monospace, Menlo, monospace;
    font-size: 10.5px;
    color: var(--danger);
    background: var(--danger-bg);
    padding: 4px 6px;
    border-radius: 3px;
    border: 1px solid #f5c2c0;
}

/* S112c — Batch Views tab pair (Tree | Assessment).
   Scoped via .batch-views container so multiple instances (e.g. N
   per-batch tabsets on /files) don't collide. Distinct attribute
   names (data-bv-tab / data-bv-panel) keep this from interfering
   with the per-card .preview-tab system inside Assessment cards. */
.batch-views {
    margin: 12px 0;
}
.batch-views-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--gray-300);
    margin-bottom: 0;
}
.batch-views-tab {
    background: transparent;
    border: 1px solid transparent;
    border-bottom: 0;
    padding: 8px 18px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-500);
    border-radius: 4px 4px 0 0;
    position: relative;
    top: 2px;
    transition: color 80ms linear, background 80ms linear;
}
.batch-views-tab:hover {
    color: var(--gray-700);
}
.batch-views-tab.active {
    color: var(--brand);
    background: var(--white);
    border-color: var(--gray-300);
    border-bottom: 2px solid var(--white);
}
.batch-views-panel {
    display: none;
    padding: 14px 0;
}
.batch-views-panel.active {
    display: block;
}

/* Tree-panel flat-list rows for natives / refs outside archives. */
.batch-views__section-header {
    margin: 8px 0 6px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-500);
    font-weight: 700;
}
.batch-views__flat-list {
    list-style: none;
    padding: 0;
    margin: 0 0 12px;
}
.batch-views__flat-list li {
    padding: 6px 0;
    border-bottom: 1px solid var(--gray-100);
}
.batch-views__row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}
.batch-views__row-name {
    display: flex;
    align-items: center;
    gap: 10px;
}
.batch-views__row-thumb {
    max-height: 56px;
    max-width: 72px;
    border: 1px solid var(--gray-200);
    border-radius: 3px;
    background: var(--gray-50);
}
.batch-views__row-jobs {
    margin-top: 4px;
    font-size: 11px;
    color: var(--gray-700);
}
.batch-views__row-jobs a {
    color: var(--brand);
    margin-right: 4px;
    text-decoration: none;
}
.batch-views__row-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: 4px;
    flex-wrap: wrap;
}
.batch-views__ref {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

/* S112b — Upload button busy state (spinner + disabled). */
.upload-btn-busy {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.35);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn.is-busy { cursor: progress; opacity: 0.85; }
.btn[disabled] { cursor: not-allowed; }

/* S112c Idea 2 — hover-thumb popup over tree files + flash-highlight
   for the matching result-card when clicked. */
.tree-thumb-popup {
    position: fixed;
    z-index: 100;
    background: var(--white);
    border: 1px solid var(--gray-300);
    padding: 4px;
    border-radius: 4px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
    pointer-events: none;
    min-width: 80px;
    min-height: 80px;
}
.tree-thumb-popup img {
    display: block;
    max-width: 240px;
    max-height: 240px;
    background: var(--gray-50);
}
.tree-thumb-popup__caption {
    font-size: 10.5px;
    color: var(--gray-500);
    margin-top: 4px;
    text-align: center;
    font-family: ui-monospace, Menlo, monospace;
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tree-file[data-file-uuid] .tree-row {
    cursor: pointer;
}
.tree-file[data-file-uuid] .tree-row:hover .tree-label {
    text-decoration: underline;
    color: var(--brand);
}

@keyframes flash-highlight-anim {
    0%   { box-shadow: 0 0 0 0 rgba(150, 28, 31, 0.5); }
    100% { box-shadow: 0 0 0 8px rgba(150, 28, 31, 0); }
}
.flash-highlight {
    animation: flash-highlight-anim 1.4s ease-out;
}

/* S112b — Database View tab table on /result card. */
.db-view__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.db-view__table tbody th {
    text-align: left;
    padding: 6px 12px 6px 0;
    color: var(--gray-500);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    width: 180px;
    vertical-align: top;
    border-bottom: 1px solid var(--gray-100);
}
.db-view__table tbody td {
    padding: 6px 0;
    color: var(--gray-700);
    word-break: break-word;
    border-bottom: 1px solid var(--gray-100);
}
.db-view__table tbody tr:last-child th,
.db-view__table tbody tr:last-child td { border-bottom: 0; }
.db-view__table code {
    font-family: ui-monospace, Menlo, monospace;
    background: var(--gray-100);
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 12px;
}
.db-view__path {
    font-family: ui-monospace, Menlo, monospace;
    font-size: 11px;
    color: var(--gray-500);
    word-break: break-all;
}

/* S112b — "Other Formats" download picker dropdown. */
.downloads-other {
    position: relative;
    display: inline-block;
}
.downloads-other > summary {
    list-style: none;
    cursor: pointer;
}
.downloads-other > summary::-webkit-details-marker { display: none; }
.downloads-other__menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    min-width: 180px;
    z-index: 10;
    padding: 4px 0;
}
.downloads-other__item {
    display: block;
    padding: 6px 12px;
    text-decoration: none;
    color: var(--gray-700);
    font-size: 12px;
}
.downloads-other__item:hover {
    background: var(--gray-100);
    color: var(--brand);
}

/* Admin nav toggle pill — only rendered when user.is_admin. */
.nav-debug-toggle {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
    border-radius: 12px;
    padding: 2px 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    margin-right: 6px;
}
.nav-debug-toggle[data-debug-on="1"] {
    background: var(--warning);
    color: var(--white);
    border-color: var(--warning);
}

/* S133 — Batch nav tab strip used on /upload/match + /result for
   cross-page navigation between Match | Files Tree | Sets Assessment.
   Visual style matches the inner .batch-views-tabs pair so the two
   layers read as the same UI element. */
.batch-nav-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--gray-200);
    align-items: flex-end;
}
.batch-nav-tab {
    display: inline-block;
    padding: 8px 16px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-bottom: none;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-600);
    text-decoration: none;
    margin-bottom: -1px;
}
.batch-nav-tab:hover {
    background: var(--gray-100);
    color: var(--brand);
}
.batch-nav-tab.active {
    background: var(--white);
    border-color: var(--gray-200);
    border-bottom: 1px solid var(--white);
    color: var(--brand);
}

/* S194 — branded 404 / error page (shared/base_templates/errors/404.html). */
.error-page {
    max-width: 640px;
    margin: 0 auto;
    padding: 4rem 1rem 5rem;
    text-align: center;
}
.error-page .error-code {
    font-size: 6rem;
    line-height: 1;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--brand);
    margin: 0;
}
.error-page .error-title {
    margin: 0.75rem 0 1rem;
}
.error-page .error-lead {
    margin: 0 auto 2rem;
}
.error-page .error-actions {
    margin-top: 1.5rem;
}
