/* Regulatory Suite — theme.css. Reproduces the Sensory Suite visual
   language (CSK red #E31E24, Holland maroon #6E1A2E, charcoal,
   neutral grey surfaces) so this module feels like part of the same family. */
:root {
    --brand-red: #E31E24;
    --brand-red-dark: #B8151A;
    --brand-red-soft: #FBEEEC;
    --brand-maroon: #6E1A2E;
    --brand-maroon-dark: #4D1020;
    --brand-maroon-soft: #F5EAEC;
    --brand-charcoal: #2B2B2B;
    --brand-ink: #1A1A1A;
    --surface-page: #f3f4f6;
    --surface-card: #FFFFFF;
    --surface-muted: #ececec;
    --surface-warm: #ececec;
    --surface-topbar: #FFFFFF;
    --text-primary: #1A1A1A;
    --text-secondary: #565656;
    --text-muted: #8c8c8c;
    --text-on-dark: #F4F0EC;
    --border-soft: #e0e0e0;
    --border-mid: #c8c8c8;
    --border-strong: #8f8f8f;
    --status-draft: #5A6470;
    --status-draft-bg: #E9ECF0;
    --status-ready: #1F7A4D;
    --status-ready-bg: #E1F1E8;
    --status-active: #B8151A;
    --status-active-bg: #FBEEEC;
    --status-complete: #1F7A4D;
    --status-complete-bg: #E1F1E8;
    --status-archived: #8A8278;
    --status-archived-bg: #EDE7DF;
    --status-error: #B8151A;
    --status-error-bg: #FBEEEC;
    --status-warning: #B26A00;
    --status-warning-bg: #FBEFD9;
    --status-info: #1F5B7A;
    --status-info-bg: #E2EEF4;
    --grey-light: #eee;
    --grey-mid: #e0e0e0;
    --grey: #8c8c8c;
    --white: #fff;
    --charcoal: #2B2B2B;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* The user-agent [hidden] rule (display:none) is beaten by any author rule
   that sets display — for example .btn, which is used for the "Load more"
   control. Make the attribute authoritative so hidden controls are really
   hidden (idle/loading/empty/failed/exhausted food-database sources). */
[hidden] { display: none !important; }


body {
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.55;
    color: var(--text-primary);
    background: var(--surface-page);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-red); }
h1, h2, h3, h4, h5 { line-height: 1.25; color: var(--charcoal); }

.skip-link {
    position: absolute; top: -100px; left: 1rem;
    background: var(--charcoal); color: var(--white);
    padding: 0.6rem 1rem; border-radius: 0 0 6px 6px;
    text-decoration: none; font-weight: 600; z-index: 1000;
    transition: top 0.15s ease-in-out;
}
.skip-link:focus, .skip-link:focus-visible { top: 0; outline: 3px solid var(--brand-red); }

.app-shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    grid-template-areas: "sidebar main";
    min-height: 100vh;
    width: 100%;
}
.app-shell-anon { display: block; min-height: 100vh; }
.app-shell-anon .app-main { width: 100%; }

/* ---- Sidebar ---- */
.app-sidebar {
    grid-area: sidebar;
    background: linear-gradient(180deg, #2A2125 0%, #221B1E 100%);
    color: var(--text-on-dark);
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    position: sticky;
    top: 0;
    height: 100vh;
    border-top: 3px solid var(--brand-maroon);
}
.app-brand {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0 1.25rem 1.5rem;
    border-bottom: 1px solid #3a3a3a;
    margin-bottom: 1rem;
}
.brand-logo {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--white); color: var(--brand-red);
    display: flex; align-items: center; justify-content: center;
    flex: 0 0 36px;
}
.brand-logo svg {
    width: 20px; height: 20px; fill: none;
    stroke: currentColor; stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
}
.app-brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.app-brand-name {
    font-size: 1rem; font-weight: 700; color: var(--white);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-brand-sub {
    font-size: 0.75rem; color: var(--grey); margin-top: 0.15rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-nav { display: flex; flex-direction: column; padding: 0 0.75rem; gap: 0.15rem; margin-bottom: 1.5rem; }
.app-nav-section {
    display: block;
    font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.08em; color: #C9C2BB;
    background: rgba(255, 255, 255, 0.06);
    padding: 0.5rem 0.6rem 0.35rem; border-radius: 4px;
    margin: 0.5rem 0.5rem 0.4rem;
}
.app-nav-link {
    display: flex; align-items: center; gap: 0.65rem;
    padding: 0.55rem 0.75rem; color: #d8d8d8; text-decoration: none;
    border-radius: 6px; font-size: 0.92rem; font-weight: 500;
    transition: background 0.12s, color 0.12s;
}
.app-nav-link:hover { background: #3a3a3a; color: var(--white); }
.app-nav-link.is-active {
    background: var(--brand-red); color: var(--white); font-weight: 600;
    box-shadow: inset 3px 0 0 var(--brand-maroon);
}
.app-nav-dot { width: 6px; height: 6px; border-radius: 50%; background: #666; flex: 0 0 6px; }
.app-nav-link:hover .app-nav-dot,
.app-nav-link.is-active .app-nav-dot { background: var(--white); }

.app-quickstart {
    margin-top: auto; padding: 1rem 0.75rem 0.5rem;
    border-top: 1px solid #3A2A30;
}
.quickstart-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.2rem; }
.quickstart-item { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.7rem; border-radius: 6px; }
.quickstart-item:hover { background: rgba(255, 255, 255, 0.04); }
.quickstart-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brand-maroon); flex: 0 0 6px; }
.quickstart-link { display: flex; flex-direction: column; flex: 1; min-width: 0; text-decoration: none; color: var(--white); }
.quickstart-link:hover .quickstart-label { color: var(--brand-red); }
.quickstart-label { font-size: 0.86rem; font-weight: 600; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quickstart-sub { font-size: 0.7rem; color: #aaa; margin-top: 0.1rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- Main column ---- */
.app-main { grid-area: main; display: flex; flex-direction: column; min-width: 0; background: var(--surface-page); }
.app-topbar {
    background: var(--surface-topbar);
    border-bottom: 1px solid var(--border-soft);
    padding: 0.75rem 1.5rem; display: flex; align-items: center;
    justify-content: space-between; gap: 1rem; min-height: 56px;
    position: sticky; top: 0; z-index: 50;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.app-topbar-left { display: flex; align-items: center; gap: 0.75rem; flex: 1; min-width: 0; }
.app-topbar-right { display: flex; align-items: center; gap: 0.85rem; flex-shrink: 0; }
.app-user { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; border-left: 1px solid #e0e0e0; padding-left: 0.85rem; }
.app-user-name { font-weight: 600; color: var(--charcoal); font-size: 0.9rem; }
.app-user-role { font-size: 0.72rem; color: var(--grey); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 0.1rem; }
.app-logout-form { display: inline; margin: 0; }

.app-content { flex: 1; padding: 2rem 2.25rem; max-width: 1600px; width: 100%; margin: 0 auto; }
.app-shell-anon .app-content { max-width: 460px; padding: 4rem 1.5rem; }

/* ---- Page header ---- */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.page-header-text { min-width: 0; }
.page-header h1, .page-header .page-title { margin: 0 0 0.25rem; font-size: 1.6rem; color: var(--charcoal); }
.page-subtitle { color: var(--grey); font-size: 0.95rem; margin: 0; }
.page-header-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

/* ---- Breadcrumbs ---- */
.app-breadcrumb { display: flex; align-items: center; gap: 0.4rem; font-size: 0.88rem; color: var(--grey); flex-wrap: wrap; }
.app-breadcrumb a { color: var(--charcoal); text-decoration: none; font-weight: 500; }
.app-breadcrumb a:hover { color: var(--brand-red); }
.app-breadcrumb .crumb-sep { color: #c0c0c0; }
.app-breadcrumb .crumb-current { color: var(--charcoal); font-weight: 600; }

/* ---- Flash messages ---- */
.flash-container { margin-bottom: 1.25rem; display: flex; flex-direction: column; gap: 0.5rem; }
.flash { padding: 0.75rem 1rem; border-radius: 6px; font-weight: 500; border-left: 4px solid; }
.flash-success, .flash-info { background: var(--status-complete-bg); color: var(--status-complete); border-left-color: var(--status-complete); }
.flash-error, .flash-danger { background: var(--status-error-bg); color: var(--status-error); border-left-color: var(--status-error); }
.flash-warning { background: var(--status-warning-bg); color: var(--status-warning); border-left-color: var(--status-warning); }

/* ---- Cards ---- */
.card {
    background: var(--surface-card);
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    padding: 1.25rem 1.4rem;
    margin-bottom: 1.25rem;
}
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 1rem; padding-bottom: 0.75rem; border-bottom: 1px solid #eee; }
.card-header h2, .card-header h3 { margin: 0; font-size: 1.05rem; }
/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 0.35rem; padding: 0.55rem 1rem;
    border-radius: 6px; font-size: 0.9rem; font-weight: 600;
    border: 1px solid transparent; cursor: pointer;
    font-family: inherit; line-height: 1.4; text-decoration: none;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
a.btn { text-decoration: none; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.82rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--brand-red); color: var(--white); }
.btn-primary:hover { background: var(--brand-red-dark); color: var(--white); }
.btn-secondary { background: var(--brand-maroon); color: var(--white); }
.btn-secondary:hover { background: var(--brand-maroon-dark); color: var(--white); }
.btn-ghost { color: var(--text-secondary); border-color: var(--border-mid); background: transparent; }
.btn-ghost:hover { color: var(--brand-red-dark); border-color: var(--brand-red); background: var(--brand-red-soft); }
.btn-ghost:visited { color: var(--text-secondary); }
.btn:focus-visible { outline: 3px solid var(--brand-red); outline-offset: 2px; }
.btn-primary:focus-visible, .btn-secondary:focus-visible { outline-color: var(--brand-maroon-dark); }

/* ---- Forms ---- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.5rem; }
.form-grid .field-full { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: 0.3rem; }
.form-grid .form-readonly-label { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); }
.form-grid .form-readonly { font-size: 0.95rem; font-weight: 500; color: var(--text-primary); }
.form-grid label, .form-group label { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); }
.form-grid input[type=text], .form-grid input[type=email], .form-grid input[type=number],
.form-grid input[type=url], .form-grid input[type=date], .form-grid select, .form-grid textarea,
.card input[type=text], .card input[type=email], .card input[type=number],
.card input[type=url], .card input[type=date], .card select, .card textarea,
.form-row input, .form-row select, .form-row textarea {
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--border-mid);
    border-radius: 6px;
    background: var(--surface-card);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-primary);
    width: 100%;
}
.form-grid textarea, .card textarea { min-height: 5.5rem; line-height: 1.4; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
    outline: 2px solid var(--brand-red); outline-offset: 1px;
}
.form-help { color: var(--text-secondary); font-size: 0.85rem; line-height: 1.45; margin: 0.2rem 0 0.5rem 0; }
.form-error, .field-error { display: block; color: var(--status-error); font-size: 0.85rem; font-weight: 600; margin-top: 0.3rem; }
/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.data-table th {
    text-align: left; font-weight: 600; font-size: 0.78rem;
    text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--grey); background: var(--surface-muted);
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--grey-mid);
}
.data-table td { padding: 0.7rem 1rem; border-bottom: 1px solid var(--grey-light); vertical-align: middle; }
.data-table tbody tr:hover { background: #fafafa; }
.data-table td a, .data-table th a { color: var(--brand-red); text-decoration: none; font-weight: 500; }
.data-table td a:hover { text-decoration: underline; }
.data-table th:first-child, .data-table td:first-child { padding-left: 1rem; }
.data-table th:last-child, .data-table td:last-child { padding-right: 1rem; }

/* ---- Badges ---- */
.badge {
    display: inline-block; border: 1px solid transparent;
    border-radius: 12px; padding: 0.2rem 0.7rem;
    font-size: 0.75rem; font-weight: 600; line-height: 1.4;
    white-space: nowrap;
}
.badge-DRAFT, .badge-draft { background: var(--status-draft-bg); color: var(--status-draft); border-color: var(--status-draft); }
.badge-ACTIVE, .badge-active { background: var(--status-active-bg); color: var(--status-active); border-color: var(--status-active); }
.badge-UNDER_REVIEW, .badge-under_review { background: var(--status-warning-bg); color: var(--status-warning); border-color: var(--status-warning); }
.badge-APPROVED, .badge-approved { background: var(--status-complete-bg); color: var(--status-complete); border-color: var(--status-complete); }
.badge-REVIEW_REQUIRED, .badge-review_required { background: var(--status-warning-bg); color: var(--status-warning); border-color: var(--status-warning); }
.badge-FAIL, .badge-fail { background: var(--status-error-bg); color: var(--status-error); border-color: var(--status-error); }
.badge-PASS, .badge-pass { background: var(--status-complete-bg); color: var(--status-complete); border-color: var(--status-complete); }
.badge-INFO, .badge-info { background: var(--status-info-bg); color: var(--status-info); border-color: var(--status-info); }
.badge-WARNING, .badge-warning { background: var(--status-warning-bg); color: var(--status-warning); border-color: var(--status-warning); }
.badge-ARCHIVED, .badge-archived { background: var(--status-archived-bg); color: var(--status-archived); border-color: var(--status-archived); }
.badge-COMPLETE, .badge-complete { background: var(--status-complete-bg); color: var(--status-complete); border-color: var(--status-complete); }
.badge-REVIEW, .badge-review { background: var(--status-warning-bg); color: var(--status-warning); border-color: var(--status-warning); }
.badge-DRAFTING { background: var(--status-draft-bg); color: var(--status-draft); border-color: var(--status-draft); }
.badge-CLOSED { background: var(--status-archived-bg); color: var(--status-archived); border-color: var(--status-archived); }
.badge-current { background: var(--status-info-bg); color: var(--status-info); border-color: var(--status-info); }
.badge-current { background: var(--status-info-bg); color: var(--status-info); border-color: var(--status-info); }

/* ---- Source provenance badges (ingredient master) ---- */
.source-badge {
    display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px;
    font-size: 0.72rem; font-weight: 700; letter-spacing: 0.03em;
    border: 1px solid var(--border-mid); color: var(--text-secondary);
    background: var(--surface-muted); white-space: nowrap;
}
.source-usda_fdc { background: var(--brand-red-soft); color: var(--brand-red-dark); border-color: var(--brand-red); }
.source-cnf { background: var(--brand-maroon-soft); color: var(--brand-maroon-dark); border-color: var(--brand-maroon); }
.source-supplier { background: #EAF1FB; color: #1F4E79; border-color: #2F6FA8; }
.source-lab { background: #E7F4EC; color: #1F7A4D; border-color: #1F7A4D; }
.source-user, .source-other { background: var(--surface-muted); color: var(--text-secondary); border-color: var(--border-strong); }
.source-id { font-size: 0.72rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ---- Contextual note panels ---- */
.note-panel {
    border-radius: 8px; padding: 0.75rem 1rem; margin: 1rem 0;
    font-size: 0.88rem; line-height: 1.5; border: 1px solid var(--border-soft);
    background: var(--surface-card);
}
.note-panel--info { border-left: 4px solid var(--status-info); background: var(--status-info-bg); }
.note-panel--warn { border-left: 4px solid var(--status-warning); background: var(--status-warning-bg); color: var(--text-primary); }

/* ---- Product/project workflow status numbers ---- */
.stat-ok { color: var(--status-ready, #1F7A4D); }


/* ---- Dashboard ---- */
.dashboard-welcome {
    margin-bottom: 1.25rem; padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-soft); position: relative;
}
.dashboard-welcome::before {
    content: ""; position: absolute; left: 0; bottom: -1px;
    width: 56px; height: 3px;
    background: linear-gradient(90deg, var(--brand-red) 0%, var(--brand-maroon) 100%);
    border-radius: 2px;
}
.dashboard-welcome h1 { margin: 0 0 0.25rem 0; font-size: 1.6rem; font-weight: 700; color: var(--charcoal); }
.dashboard-welcome p { margin: 0; color: var(--grey); font-size: 0.95rem; }

.stat-strip {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem; margin: 1.5rem 0;
}
.stat-tile {
    background: var(--white); border: 1px solid var(--grey-mid);
    border-radius: 10px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: 0.15rem;
}
.stat-tile-num { font-size: 1.7rem; font-weight: 700; color: var(--charcoal); line-height: 1.1; }
.stat-tile-label { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--grey); }
.stat-tile a { text-decoration: none; }

/* ---- Compact workspace status list (formula-version workspace) ----
   Replaces the tall status-card grid: one compact row per area with the
   status badge and the single short explanation. Extended change-tracking
   wording lives in the expandable .status-details block below the table. */
.status-table { min-width: 34rem; }
.status-table th, .status-table td { padding: 0.45rem 0.75rem; }
.status-table .status-area { font-weight: 600; color: var(--charcoal); white-space: nowrap; }
.status-table .status-value { white-space: nowrap; }
.status-table .status-explanation { color: var(--text-secondary); font-size: 0.88rem; }
.status-details {
    margin-top: 0.75rem; border: 1px solid var(--border-soft);
    border-radius: 8px; background: var(--surface-card);
}
.status-details > summary {
    cursor: pointer; padding: 0.5rem 0.9rem;
    font-size: 0.85rem; font-weight: 600; color: var(--text-primary);
}
.status-details > summary:focus-visible { outline: 2px solid var(--brand-red); outline-offset: 1px; }
.status-details[open] > summary { border-bottom: 1px solid var(--border-soft); }
.status-details-body { padding: 0.35rem 0.9rem 0.75rem; }
.status-details-body dl { margin: 0; }
.status-details-body dt { margin-top: 0.5rem; font-size: 0.82rem; font-weight: 600; color: var(--charcoal); }
.status-details-body dd { margin: 0.1rem 0 0 0; font-size: 0.85rem; color: var(--text-secondary); }

.launcher-grid { display: grid; width: 100%; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.launcher-card {
    display: flex; flex-direction: column; align-items: flex-start; gap: 0.85rem;
    padding: 1.4rem 1.4rem 1.25rem; background: var(--white);
    border: 1px solid var(--grey-mid); border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04); text-decoration: none; color: inherit;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    min-height: 170px; position: relative; overflow: hidden;
}
.launcher-card:hover {
    transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
    border-color: var(--brand-red); color: inherit; text-decoration: none;
}
.launcher-icon-bg {
    width: 48px; height: 48px; border-radius: 12px;
    background: var(--brand-red-soft); color: var(--brand-red);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.launcher-icon { width: 24px; height: 24px; display: block; }
.launcher-icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.launcher-title { font-size: 1.02rem; font-weight: 700; color: inherit; line-height: 1.2; margin: 0; }
.launcher-sub { font-size: 0.85rem; color: var(--grey); line-height: 1.4; margin: 0; flex-grow: 1; }
.launcher-cta { margin-top: auto; font-size: 0.82rem; font-weight: 600; color: var(--brand-red); display: inline-flex; align-items: center; gap: 0.3rem; }
.launcher-cta-arrow { transition: transform 0.15s ease; }
.launcher-card:hover .launcher-cta-arrow { transform: translateX(3px); }

.dashboard-activity { display: grid; width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.activity-card {
    background: var(--white); border: 1px solid var(--grey-mid);
    border-top: 3px solid var(--brand-red); border-radius: 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04); overflow: hidden;
}
.activity-card-head { padding: 0.85rem 1.1rem; border-bottom: 1px solid var(--grey-light); display: flex; align-items: center; justify-content: space-between; }
.activity-card-head h2 { margin: 0; font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--brand-maroon); }
.activity-card-link { font-size: 0.75rem; color: var(--brand-red); text-decoration: none; font-weight: 600; }
.activity-card-link:hover { text-decoration: underline; }
.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-item { padding: 0.75rem 1.1rem; border-bottom: 1px solid var(--grey-light); display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.activity-item:last-child { border-bottom: none; }
.activity-title { font-size: 0.88rem; font-weight: 600; color: var(--charcoal); line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-meta { font-size: 0.75rem; color: var(--grey); display: flex; align-items: center; gap: 0.4rem; margin-top: 0.1rem; }
.activity-open { flex-shrink: 0; font-size: 0.72rem; color: var(--brand-red); text-decoration: none; font-weight: 600; }
.activity-empty { padding: 1.5rem 1.1rem; text-align: center; color: var(--grey); font-size: 0.85rem; }
.dot-sep { color: var(--grey-mid); }

/* ---- Empty states ---- */
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--grey); }
.empty-state .empty-icon { font-size: 2.2rem; margin-bottom: 0.5rem; color: #c0c0c0; }
.empty-state p { color: var(--grey); margin-bottom: 0.75rem; }

/* ---- Pagination ---- */
.pagination { display: flex; align-items: center; gap: 1rem; margin-top: 1.25rem; font-size: 0.9rem; color: var(--grey); }
.pagination .step-links a { color: var(--brand-red); text-decoration: none; font-weight: 600; margin: 0 0.25rem; }
.pagination .step-links a:hover { text-decoration: underline; }

/* ---- Tabs ---- */
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border-soft); margin-bottom: 1.25rem; flex-wrap: wrap; }
.tab {
    padding: 0.5rem 1rem; border-radius: 6px 6px 0 0; font-size: 0.88rem;
    font-weight: 600; color: var(--text-secondary); text-decoration: none;
    border: 1px solid transparent; border-bottom: none; margin-bottom: -1px;
}
.tab:hover { color: var(--brand-red); background: var(--grey-light); }
.tab.is-active { background: var(--white); border-color: var(--border-soft); color: var(--brand-red); }

/* ---- Meta / detail rows ---- */
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem 1.5rem; }
.meta-item { display: flex; flex-direction: column; gap: 0.15rem; }
.meta-item .meta-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--grey); }
.meta-item .meta-value { font-size: 0.95rem; color: var(--text-primary); font-weight: 500; }

/* ---- Workflow steps ---- */
.workflow-steps { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 1.5rem; align-items: center; }
.workflow-step { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); padding: 0.3rem 0.7rem; border-radius: 999px; background: var(--white); border: 1px solid var(--border-mid); }
.workflow-step.is-done { color: var(--status-complete); border-color: var(--status-complete); background: var(--status-complete-bg); }
.workflow-step.is-current { color: var(--brand-red); border-color: var(--brand-red); background: var(--brand-red-soft); }
/* Workflow steps are navigation pills: links, with a neutral selected-tab
   treatment that stays visually separate from any status badge colours. */
.workflow-steps a.workflow-step { text-decoration: none; cursor: pointer; }
.workflow-steps a.workflow-step:hover { border-color: var(--brand-maroon); color: var(--brand-maroon); }
.workflow-step.workflow-step--active { color: var(--text-on-dark); border-color: var(--brand-maroon); background: var(--brand-maroon); }

/* ---- Numeric tables (nutrition) ---- */
.num-table td.num, .num-table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- Add-ingredients dialog (formula workspace) ---- */
.ingredient-dialog {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    background: rgba(26, 26, 26, 0.45); padding: 1.25rem;
}
.ingredient-dialog-card {
    background: var(--surface-card); border-radius: 10px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
    width: min(1000px, 100%); max-height: 88vh;
    display: flex; flex-direction: column; overflow: hidden;
}
.ingredient-dialog-head {
    display: flex; align-items: baseline; gap: .75rem; flex-wrap: wrap;
    padding: 1rem 1.2rem .6rem; border-bottom: 1px solid var(--border-soft);
}
.ingredient-dialog-head h2 { margin: 0; font-size: 1.1rem; }
.ingredient-dialog-head .form-help { flex: 1 1 16rem; margin: 0; }
.ingredient-dialog-toolbar {
    display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
    padding: .7rem 1.2rem; border-bottom: 1px solid var(--border-soft);
}
.ingredient-search-label { font-size: .8rem; font-weight: 600; }
.ingredient-dialog-toolbar input[type="search"] { flex: 1 1 14rem; }
.ingredient-tabs { display: flex; gap: .25rem; flex-wrap: wrap; }
.ingredient-tabs .btn.is-active { border-color: var(--brand-red); color: var(--brand-red-dark); background: var(--brand-red-soft); }
.ingredient-dialog-body {
    display: flex; gap: 1rem; flex: 1 1 auto; min-height: 0;
    padding: .8rem 1.2rem; overflow: hidden;
}
.ingredient-results { flex: 2 1 0; min-width: 0; display: flex; flex-direction: column; }
.ingredient-result-list {
    list-style: none; margin: .35rem 0 0; padding: 0;
    overflow: auto; flex: 1 1 auto; min-height: 0;
    border: 1px solid var(--border-soft); border-radius: 6px;
}
.ingredient-result-row {
    display: grid; grid-template-columns: 1.4rem 1fr auto;
    align-items: center; gap: .6rem;
    padding: .35rem .55rem; border-bottom: 1px solid var(--grey-light);
    cursor: pointer;
}
.ingredient-result-row:hover { background: var(--brand-red-soft); }
.ingredient-result-row[aria-selected="true"] { background: var(--surface-muted); }
/* Keyboard highlight only — never the selection state (the checkbox and
   aria-selected are derived from the staged selection). */
.ingredient-result-row[data-active-row="true"] { outline: 2px solid var(--brand-red); outline-offset: -2px; }
.ingredient-result-name { font-size: .9rem; font-weight: 600; }
.ingredient-result-source { font-size: .75rem; color: var(--text-secondary); white-space: nowrap; }
.ingredient-stage { flex: 1 1 22rem; display: flex; flex-direction: column; min-width: 0; }
.ingredient-stage h3 { margin: 0; font-size: .95rem; }
.ingredient-stage-list {
    list-style: none; margin: .35rem 0 0; padding: 0;
    overflow: auto; flex: 1 1 auto; min-height: 0;
}
.ingredient-stage-row {
    display: grid; grid-template-columns: 1fr auto auto auto;
    align-items: center; gap: .4rem;
    padding: .4rem .5rem; border-bottom: 1px solid var(--grey-light);
}
.ingredient-stage-row .ingredient-stage-name { font-size: .85rem; font-weight: 600; grid-column: 1 / -1; }
.ingredient-stage-row .form-help { grid-column: 1 / -1; margin: 0; }
.ingredient-stage-qty { width: 5.5rem; }
.ingredient-stage-unit { width: 6rem; }
.ingredient-stage-row .field-error { grid-column: 1 / -1; }
.ingredient-dialog-footer {
    display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
    padding: .8rem 1.2rem; border-top: 1px solid var(--border-soft);
    background: var(--surface-muted);
}
.ingredient-dialog-footer .form-help { margin: 0; }
@media (max-width: 820px) {
    .ingredient-dialog-body { flex-direction: column; }
    .ingredient-results, .ingredient-stage { flex: 1 1 auto; }

/* ---- Stored label panel (workspace preview + standalone label page) ----
   The SVG keeps its intrinsic width/height and viewBox for standalone use and
   downloads; inside this container it scales to the available width with the
   aspect ratio preserved (height:auto), so the draft preview is readable
   instead of pinned to the renderer's 300 px intrinsic width. */
.label-panel { margin: .35rem 0 .25rem; }
.label-panel svg { display: block; width: 100%; height: auto; max-width: 520px; }

}

.num-table .row-total { font-weight: 700; }
.num-table .row-sub { padding-left: 1.5rem; font-size: 0.88rem; }

/* ---- List cards ---- */
.mini-card { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.7rem 0; border-bottom: 1px solid var(--grey-light); }
.mini-card:last-child { border-bottom: none; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .app-shell { grid-template-columns: 1fr; grid-template-areas: "main"; }
    .app-sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 260px; z-index: 100; transform: translateX(-100%); transition: transform 0.2s ease-in-out; }
    .app-sidebar.is-open { transform: translateX(0); }
    .app-topbar { padding: 0.6rem 1rem; }
    .app-topbar-left::before { content: "\2630"; display: inline-block; font-size: 1.4rem; color: var(--charcoal); margin-right: 0.5rem; cursor: pointer; padding: 0.25rem 0.5rem; border-radius: 4px; }
    .app-topbar-left::before:hover { background: var(--grey-light); }
    .app-user { display: none; }
    .app-content { padding: 1.25rem 1rem; }
    .launcher-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-activity { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .launcher-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .data-table { font-size: 0.85rem; }
    .data-table th, .data-table td { padding: 0.4rem 0.5rem; }
}

/* ---- Print ---- */
@media print {
    .app-sidebar, .app-topbar, .app-footer, .skip-link { display: none !important; }
    .app-shell { grid-template-columns: 1fr; grid-template-areas: "main"; }
    .app-content { padding: 0; max-width: none; }
}

/* ---- LIVE Nutrition Facts preview ---- */
.workspace-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
    gap: 1rem;
    align-items: start;
}
.workspace-editor { min-width: 0; }
.workspace-preview {
    position: sticky; top: 1rem;
    min-width: 0;
}
.workspace-preview .card { padding: .75rem; }
.workspace-preview .label-panel svg { max-width: 100%; height: auto; }
.preview-notices { margin: .25rem 0 .5rem 1.25rem; padding: 0; list-style: disc; }
.preview-notices li { margin: .15rem 0; }
/* ---- The ingredient row editor: ONE pending amount per line ---- */
/* The amount, its unit and the removal control stay on ONE line at normal
   desktop width and stack into a compact column on narrow screens, so a row
   never needs horizontal scrolling to be edited. */
.line-amount { white-space: normal; min-width: 12rem; }
.line-amount-form { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; }
.line-amount-form input[type="text"],
.line-amount-form select { padding: .15rem .25rem; font-size: .8rem; }
.line-amount-form input[type="text"] { width: 5.5rem; }
.line-amount-form select { max-width: 5.5rem; }
.line-amount-readonly { white-space: nowrap; }
.line-amount .line-remove {
    display: inline-flex; align-items: center; gap: .25rem;
    margin-top: .2rem; font-size: .78rem; white-space: nowrap;
}
/* A component that is excluded (pending) or already removed (stored) is not
   part of the working composition; its derived figures are withdrawn. */
tr[data-line-excluded="1"], tr[data-row-removed="1"] { opacity: .55; }
.working-state[data-working-state="pending"] {
    background: var(--status-warning-bg); color: var(--status-warning);
    border-color: var(--status-warning);
}
.workspace-preview .preview-sync .field-error { margin: .35rem 0 0; }
/* Narrow screens: stack the amount, unit and removal controls compactly. */
@media (max-width: 700px) {
    .line-amount { min-width: 9rem; }
    .line-amount-form { flex-direction: column; align-items: stretch; }
    .line-amount-form input[type="text"],
    .line-amount-form select { width: 100%; max-width: none; }
    .line-amount .line-remove { margin-top: .3rem; }
}
.preview-format { margin-left: auto; }
.preview-format button[aria-pressed="true"] {
    background: var(--status-info-bg); color: var(--status-info);
    border: 1px solid var(--status-info);
}
.workspace-preview[data-preview-state="invalid"] .label-panel,
.workspace-preview[data-preview-outdated="1"] .label-panel { opacity: .55; }
.workspace-preview .badge-info { background: var(--status-info-bg); color: var(--status-info); }
/* Narrow screens: stack editor over preview. */
@media (max-width: 1100px) {
    .workspace-split { grid-template-columns: minmax(0, 1fr); }
    .workspace-preview { position: static; }
}