/* ============================================================
   QCM — Quality Control Management
   Coreidon.AI Design System (shared tokens) + QCM components
   ============================================================ */

:root {
    /* --- Canvas / surfaces (Light) --- */
    --bg-canvas: #FFFFFF;
    --bg-section: #F8F5F0;
    --bg-card: #FFFFFF;
    --bg-elevated: #FFFFFF;
    --bg-subtle: #F8F5F0;

    --text-primary: #000000;
    --text-secondary: #2B303B;
    --text-muted: #6B7280;

    /* --- Brand --- */
    --accent-primary: #091C3A;   /* navy — primary CTA + logo */
    --accent-hover: #0D2A52;
    --accent-cyan: #0284C7;      /* expressive accent — data/links/active */
    --accent-cyan-hover: #0369A1;
    --accent-cyan-soft: rgba(2, 132, 199, 0.12);

    --success: #16A34A;
    --warning: #D97706;
    --danger:  #DC2626;

    --input-border: #E5E7EB;
    --divider: #E5E7EB;

    --btn-primary-bg: #091C3A;
    --btn-primary-text: #FFFFFF;
    --btn-primary-hover: #0D2A52;
    --btn-secondary-bg: #FFFFFF;
    --btn-secondary-text: #2B303B;
    --btn-secondary-border: #E5E7EB;
    --btn-secondary-hover: #F8F5F0;

    --input-bg: #FFFFFF;
    --input-focus-border: var(--accent-cyan);
    --input-placeholder: #9CA3AF;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.08);

    --border-radius-sm: 4px;
    --border-radius-md: 6px;
    --border-radius-lg: 8px;
    --transition-speed: 0.15s;
    --focus-ring: 0 0 0 3px rgba(2,132,199,0.25);
    --modal-backdrop-color: rgba(9,28,58,0.55);

    /* --- QCM workflow status palette (per PS 07-F 07 matrix) --- */
    --st-open:             #CA8A04;  /* yellow */
    --st-validated:        #EA580C;  /* orange */
    --st-action-planning:  #2563EB;  /* blue */
    --st-pending-approval: #0891B2;  /* cyan */
    --st-execution:        #7C3AED;  /* purple */
    --st-closed:        #16A34A;  /* green */
    --st-overdue:       #DC2626;  /* red */
}

[data-theme='dark'] {
    --bg-canvas:   #0A1220;
    --bg-section:  #121B2A;
    --bg-card:     #2B303B;
    --bg-elevated: #243447;
    --bg-subtle:   #1F2A3C;

    --text-primary:   #FFFFFF;
    --text-secondary: rgba(248,245,240,0.75);
    --text-muted:     rgba(248,245,240,0.45);

    --accent-primary: #091C3A;
    --accent-hover:   #0F2A57;
    --accent-cyan:        #38BDF8;
    --accent-cyan-hover:  #7DD3FC;
    --accent-cyan-soft:   rgba(56,189,248,0.18);

    --success: #34D399;
    --warning: #FBBF24;
    --danger:  #FB7185;

    --input-border: #2D3D52;
    --divider: #1F2A3C;

    --btn-primary-bg:    #F8F5F0;
    --btn-primary-text:  #091C3A;
    --btn-primary-hover: #FFFFFF;
    --btn-secondary-bg: #243447;
    --btn-secondary-text: #F8F5F0;
    --btn-secondary-border: #2D3D52;
    --btn-secondary-hover: #2F4258;

    --input-bg: #121B2A;
    --input-placeholder: rgba(248,245,240,0.35);

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.5);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.6);

    --focus-ring: 0 0 0 3px rgba(56,189,248,0.3);
    --modal-backdrop-color: rgba(0,0,0,0.65);

    --st-open:             #EAB308;
    --st-validated:        #FB923C;
    --st-action-planning:  #60A5FA;
    --st-pending-approval: #22D3EE;
    --st-execution:        #A78BFA;
    --st-closed:        #34D399;
    --st-overdue:       #FB7185;
}

html:not([data-theme]) { visibility: hidden; }

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 14px; overflow-x: hidden; }
body {
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-section);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
}
h1,h2,h3,h4,h5,h6 { font-family: 'Space Grotesk', sans-serif; font-weight: 700; color: var(--text-primary); }
a { color: var(--accent-cyan); text-decoration: none; }
a:hover { color: var(--accent-cyan-hover); text-decoration: underline; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--border-radius-sm); }
i { border: none !important; outline: none !important; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--input-border); border-radius: 3px; }

/* --- Demo ribbon --- */
.demo-ribbon {
    background: linear-gradient(90deg, var(--accent-primary), #0D2A52);
    color: #fff;
    font-size: 12px;
    padding: 6px 16px;
    text-align: center;
    letter-spacing: 0.01em;
}
.demo-ribbon i { margin-right: 6px; color: var(--accent-cyan); }
[data-theme='dark'] .demo-ribbon i { color: #38BDF8; }

/* ============================================================
   Header
   ============================================================ */
.app-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--input-border);
    position: sticky; top: 0; z-index: 1000;
}
@media (min-width: 880px) {
    .app-header { flex-wrap: nowrap; justify-content: space-between; height: 60px; padding: 0 1.5rem; gap: 1.5rem; }
}
.header-left { display: flex; flex: 1 1 auto; min-width: 0; align-items: center; gap: 1rem; }
.header-right { display: flex; align-items: center; gap: 0.75rem; }

.header-logo-container { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; }
.header-logo-container svg { width: 100%; height: 100%; }
.app-header h1 { display: flex; align-items: center; gap: 0.7rem; margin: 0; }
.brand-block { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-family: 'Space Grotesk'; font-weight: 700; font-size: 18px; letter-spacing: 0.04em; color: var(--text-primary); }
.brand-sub { font-size: 9px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-muted); }

.hamburger-menu {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; background: var(--bg-card);
    border: 1px solid var(--input-border); color: var(--text-muted);
    border-radius: var(--border-radius-md); cursor: pointer; font-size: 1rem;
}
@media (min-width: 880px) { .hamburger-menu { display: none; } }

.view-switcher { display: none; gap: 0; }
@media (min-width: 880px) { .view-switcher { display: flex; } }
.view-switcher button {
    min-height: 44px; padding: 0 1rem; border: none; background: transparent;
    font-family: 'Space Grotesk'; font-weight: 700; font-size: 12px;
    color: var(--text-muted); cursor: pointer;
    border-bottom: 2px solid transparent; transition: all var(--transition-speed) ease;
    display: inline-flex; align-items: center; gap: 7px;
}
.view-switcher button i { font-size: 11px; }
.view-switcher button.active { color: var(--accent-cyan); border-bottom-color: var(--accent-cyan); }
.view-switcher button:hover:not(.active) { color: var(--text-primary); }

.role-switch {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--bg-subtle); border: 1px solid var(--input-border);
    border-radius: var(--border-radius-md); padding: 0 10px; height: 38px;
}
.role-switch i { color: var(--accent-cyan); font-size: 12px; }
.role-switch select {
    border: none; background: transparent; color: var(--text-primary);
    font-family: 'Inter'; font-weight: 600; font-size: 12px; cursor: pointer;
    outline: none; padding: 4px 2px; max-width: 150px;
}

#themeToggle {
    width: 38px; height: 38px; border-radius: var(--border-radius-md);
    background: var(--bg-subtle); border: 1px solid var(--input-border);
    color: var(--text-secondary); cursor: pointer; transition: all var(--transition-speed) ease;
}
#themeToggle:hover { color: var(--accent-cyan); border-color: var(--accent-cyan); }

.cta-primary {
    min-height: 38px; background-color: var(--btn-primary-bg); color: var(--btn-primary-text);
    border: 1px solid var(--btn-primary-bg); padding: 0 14px;
    font-family: 'Space Grotesk'; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.03em; font-size: 11px; cursor: pointer;
    border-radius: var(--border-radius-md); transition: all var(--transition-speed) ease;
    display: inline-flex; align-items: center; gap: 6px;
}
.cta-primary:hover { background-color: var(--btn-primary-hover); }

/* ============================================================
   Layout
   ============================================================ */
.app-container { display: flex; flex: 1; min-height: 0; }

.sidebar {
    position: fixed; top: 0; left: -100%; width: min(80vw, 260px); height: 100vh; z-index: 1500;
    background-color: var(--bg-card); border-right: 1px solid var(--input-border);
    display: flex; flex-direction: column; padding: 14px 10px; overflow-y: auto;
    transition: left var(--transition-speed) cubic-bezier(.4,0,.2,1); box-shadow: var(--shadow-lg);
}
.sidebar.open { left: 0; }
@media (min-width: 880px) {
    .sidebar { position: sticky; top: 60px; left: auto; width: 250px; height: calc(100vh - 60px); flex-shrink: 0; box-shadow: none; }
}
.sidebar.hidden-view { display: none; }
.sidebar h3 { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin: 16px 0 6px 12px; }
.sidebar h3:first-of-type { margin-top: 2px; }

.nav-list { list-style: none; }
.nav-list li {
    min-height: 38px; padding: 8px 12px; margin-bottom: 2px; border-radius: var(--border-radius-md);
    cursor: pointer; font-weight: 500; font-size: 13px; color: var(--text-secondary);
    transition: all var(--transition-speed) ease;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.nav-list li > span { display: inline-flex; align-items: center; gap: 9px; min-width: 0; }
.nav-list li:hover { background-color: var(--bg-subtle); color: var(--text-primary); }
.nav-list li.active { background-color: var(--accent-cyan-soft); color: var(--accent-cyan); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent-cyan); }
.nav-count { font-size: 11px; font-weight: 700; color: var(--text-muted); background: var(--bg-subtle); padding: 1px 7px; border-radius: 9999px; }
.nav-list li.active .nav-count { color: var(--accent-cyan); background: transparent; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

/* Workflow-status tree: the five live stages nested under the "Open" parent. */
.nav-list li.nav-child { padding-left: 32px; }
.nav-caret {
    background: none; border: 0; padding: 0; cursor: pointer;
    width: 12px; height: 12px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--text-muted); font-size: 10px; line-height: 1;
    transition: transform var(--transition-speed) ease, color var(--transition-speed) ease;
}
.nav-caret:hover { color: var(--text-primary); }
.nav-list li.collapsed .nav-caret { transform: rotate(-90deg); }
.nav-list li.active .nav-caret { color: inherit; }

.main-content { flex: 1; min-width: 0; padding: 1.25rem; overflow-y: auto; background-color: var(--bg-section); }
@media (min-width: 880px) { .main-content { padding: 1.75rem 2rem; } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem; }
.page-head h2 { font-size: clamp(1.3rem, 1rem + 1vw, 1.6rem); letter-spacing: -0.02em; }
.page-head p { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

/* ============================================================
   KPI cards
   ============================================================ */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 1rem; margin-bottom: 1.75rem; }
.kpi-card {
    background: var(--bg-card); border: 1px solid var(--input-border); border-radius: var(--border-radius-lg);
    padding: 16px 18px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.kpi-card .kpi-icon { position: absolute; right: 14px; top: 14px; font-size: 22px; opacity: 0.16; }
/* A KPI that drills into the register. Only cards whose count maps exactly to a
   register filter get this — the affordance has to mean "you can click me". */
.kpi-card.kpi-drillable { cursor: pointer; transition: border-color var(--transition-speed) ease, box-shadow var(--transition-speed) ease, transform var(--transition-speed) ease; }
.kpi-card.kpi-drillable:hover { border-color: var(--accent-cyan); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kpi-card.kpi-drillable:focus-visible { outline: 2px solid var(--accent-cyan); outline-offset: 2px; }
.kpi-card.kpi-drillable:hover .kpi-label { color: var(--accent-cyan); }
.kpi-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.kpi-value { font-family: 'Space Grotesk'; font-weight: 700; font-size: 30px; line-height: 1.1; margin: 8px 0 2px; }
.kpi-value small { font-size: 14px; color: var(--text-muted); font-weight: 600; }
.kpi-trend { font-size: 11px; font-weight: 600; }
.kpi-trend.up { color: var(--success); }
.kpi-trend.down { color: var(--danger); }
.kpi-trend.warn { color: var(--warning); }

/* ============================================================
   Chart widgets
   ============================================================ */
.widget-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 1rem; }
.widget {
    background: var(--bg-card); border: 1px solid var(--input-border); border-radius: var(--border-radius-lg);
    padding: 16px 18px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; min-width: 0;
}
.widget.col-4 { grid-column: span 4; }
.widget.col-6 { grid-column: span 6; }
.widget.col-8 { grid-column: span 8; }
.widget.col-12 { grid-column: span 12; }
@media (max-width: 980px) { .widget.col-4, .widget.col-6, .widget.col-8 { grid-column: span 12; } }
.widget-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.widget-head h3 { font-size: 13px; }
.widget-head .widget-grip { color: var(--text-muted); font-size: 12px; cursor: grab; }
.widget-canvas-wrap { position: relative; flex: 1; min-height: 220px; }
.widget-canvas-wrap.tall { min-height: 260px; }

/* Dashboard analytics widgets — <coreidon-widget> embeds. Each cell is a 12-col
   grid span; the grid stretches cells to the row height (default align-items),
   and the widget (rendered with the `fill` attribute) stretches its card to the
   cell, so row-mates share one height regardless of legend size. width:100% +
   max-width:none override the widget's shadow :host{max-width:640px}. */
.wcell { min-width: 0; }
.wcell coreidon-widget { display: block; width: 100%; max-width: none; height: 100%; margin: 0; }
.wcell.col-4 { grid-column: span 4; }
.wcell.col-6 { grid-column: span 6; }
.wcell.col-8 { grid-column: span 8; }
.wcell.col-12 { grid-column: span 12; }
@media (max-width: 980px) { .wcell.col-4, .wcell.col-6, .wcell.col-8 { grid-column: span 12; } }
.dash-embeds-msg { grid-column: span 12; padding: 2rem; text-align: center; color: var(--text-muted); font-size: 14px; }

/* Status funnel */
.funnel { display: flex; flex-direction: column; gap: 8px; }
.funnel-row { display: flex; align-items: center; gap: 12px; }
.funnel-bar { height: 30px; border-radius: var(--border-radius-md); display: flex; align-items: center; padding: 0 12px; color: #fff; font-size: 12px; font-weight: 700; font-family: 'Space Grotesk'; min-width: 42px; transition: width .4s ease; }
.funnel-label { width: 130px; font-size: 12px; color: var(--text-secondary); font-weight: 600; flex-shrink: 0; }

/* ============================================================
   Registry — NC cards
   ============================================================ */
.registry-toolbar { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-bottom: 1.25rem; }
.search-box { position: relative; flex: 1 1 240px; }
.search-box i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 12px; }
.search-box input {
    width: 100%; background: var(--bg-card); border: 1px solid var(--input-border); border-radius: var(--border-radius-md);
    padding: 9px 12px 9px 32px; font-size: 13px; color: var(--text-primary); outline: none;
}
.search-box input:focus { border-color: var(--input-focus-border); }
.active-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-cyan-soft); color: var(--accent-cyan); border-radius: 9999px; padding: 4px 10px; font-size: 11px; font-weight: 600; cursor: pointer; }
.chip i { font-size: 9px; }

.nc-list { display: flex; flex-direction: column; gap: 10px; }
.nc-card {
    display: flex; align-items: center; gap: 1rem; padding: 14px 18px;
    background: var(--bg-card); border: 1px solid var(--input-border); border-radius: var(--border-radius-lg);
    cursor: pointer; position: relative; overflow: hidden; transition: all var(--transition-speed) ease;
}
.nc-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--st-color, var(--accent-cyan)); }
.nc-card:hover { border-color: var(--accent-cyan); transform: translateX(3px); }
.nc-ref { font-family: 'Space Grotesk'; font-weight: 700; font-size: 13px; color: var(--text-primary); width: 124px; flex-shrink: 0; }
.nc-ref .ifs-tag { display: block; font-size: 10px; color: var(--st-execution); font-weight: 700; margin-top: 2px; }
.nc-main { flex: 1; min-width: 0; }
.nc-title { font-family: 'Space Grotesk'; font-weight: 600; font-size: 14px; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nc-meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 12px; flex-wrap: wrap; }
.nc-meta i { margin-right: 4px; opacity: 0.7; }
.nc-side { display: flex; flex-direction: column; align-items: flex-end; gap: 7px; flex-shrink: 0; }
@media (max-width: 720px) {
    .nc-card { flex-wrap: wrap; }
    .nc-ref { width: auto; }
    .nc-side { width: 100%; flex-direction: row; align-items: center; }
}

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 9999px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.status-badge { color: #fff; }
.cat-badge { background: var(--bg-subtle); color: var(--text-secondary); border: 1px solid var(--input-border); }
.sev-badge { border: 1px solid var(--text-muted); color: var(--text-secondary); background: transparent; }
.sev-badge.major { border-color: var(--danger); color: var(--danger); }
.src-badge { background: transparent; border: 1px solid var(--input-border); color: var(--text-muted); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state i { font-size: 38px; opacity: 0.3; margin-bottom: 14px; }

/* ============================================================
   Modal
   ============================================================ */
.modal { display: none; position: fixed; inset: 0; z-index: 2000; overflow: auto; background: var(--modal-backdrop-color); backdrop-filter: blur(8px); }
.modal.open { display: block; }
.modal-content {
    background: var(--bg-card); border: 1px solid var(--input-border); border-radius: var(--border-radius-lg);
    margin: 4vh auto; padding: 24px; max-width: 720px; width: 92%; box-shadow: var(--shadow-lg);
    position: relative; max-height: 90vh; display: flex; flex-direction: column;
}
.modal-content.modal-xl { max-width: 980px; }
/* Modal body wrappers fill the flex column so inner scroll regions can size/scroll,
   keeping the header (and form footer / action bar) pinned. */
#formModalBody, #ncModalBody { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.close-button {
    position: absolute; top: 16px; right: 16px; color: var(--text-muted); font-size: 18px; cursor: pointer;
    background: none; border: none; width: 32px; height: 32px; border-radius: var(--border-radius-md);
    display: flex; align-items: center; justify-content: center; z-index: 10;
}
.close-button:hover { color: var(--text-primary); background: var(--bg-subtle); }

.modal-scroll { overflow-y: auto; flex: 1; min-height: 0; padding-right: 4px; margin-right: -4px; }
/* Pin the NC-modal chrome (header, stepper, tabs, clarification banner, action bar)
   so ONLY .modal-scroll scrolls. .modal-scroll has flex-basis 0, giving it zero
   weight in the flex shrink algorithm, so a tall tab panel would otherwise make
   flexbox shrink these siblings instead — and since .stepper/.tabs set overflow-x:auto
   they are scroll containers (min-height:auto resolves to 0), so they collapse and
   clip ("get eaten"). Mirrors the form modal's .form-modal-head/.form-footer. */
#ncModalBody > *:not(.modal-scroll) { flex-shrink: 0; }

/* NC detail header */
.nc-detail-head { border-bottom: 1px solid var(--input-border); padding-bottom: 16px; margin-bottom: 18px; padding-right: 40px; }
.nc-detail-head .ref-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.nc-detail-head h2 { font-size: 18px; }
.nc-detail-head .sub { color: var(--text-muted); font-size: 12px; margin-top: 6px; display: flex; gap: 14px; flex-wrap: wrap; }

/* Workflow stepper */
.stepper { display: flex; align-items: center; gap: 0; margin: 4px 0 20px; overflow-x: auto; padding-bottom: 4px; }
.step { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.step-dot {
    width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; background: var(--bg-subtle); color: var(--text-muted); border: 2px solid var(--input-border);
}
.step.done .step-dot { background: var(--st-closed); border-color: var(--st-closed); color: #fff; }
.step.current .step-dot { background: var(--accent-cyan); border-color: var(--accent-cyan); color: #fff; box-shadow: var(--focus-ring); }
.step-name { font-size: 11px; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.step.current .step-name { color: var(--accent-cyan); }
.step.done .step-name { color: var(--text-secondary); }
.step-line { width: 28px; height: 2px; background: var(--input-border); margin: 0 4px; flex-shrink: 0; }
.step.done + .step-line, .step-line.done { background: var(--st-closed); }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--input-border); margin-bottom: 18px; overflow-x: auto; }
.tab { padding: 9px 14px; font-family: 'Space Grotesk'; font-weight: 700; font-size: 12px; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent-cyan); border-bottom-color: var(--accent-cyan); }
.tab .tab-flag { color: var(--st-overdue); font-size: 8px; vertical-align: super; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeUp .25s ease; }
@keyframes fadeUp { from { opacity:0; transform: translateY(6px);} to {opacity:1; transform:none;} }

/* Field grid / definition lists */
.field-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 14px 24px; }
.field-grid.cols-3 { grid-template-columns: repeat(3,1fr); }
@media (max-width: 640px) { .field-grid, .field-grid.cols-3 { grid-template-columns: 1fr; } }
.field-grid.full { grid-template-columns: 1fr; }
.field { min-width: 0; }
.field .k { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); margin-bottom: 3px; }
.field .v { font-size: 13px; color: var(--text-primary); font-weight: 500; word-break: break-word; }
.field .v.muted { color: var(--text-muted); font-style: italic; font-weight: 400; }
.span-2 { grid-column: span 2; }
@media (max-width: 640px) { .span-2 { grid-column: span 1; } }

.section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent-cyan); margin: 22px 0 12px; display: flex; align-items: center; gap: 8px; }
.section-title:first-child { margin-top: 0; }
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--input-border); }

.callout { border: 1px solid var(--input-border); border-left: 3px solid var(--accent-cyan); background: var(--bg-subtle); border-radius: var(--border-radius-md); padding: 12px 14px; font-size: 13px; margin: 8px 0; }
.callout.maint { border-left-color: var(--warning); }
.callout.maint .mt { font-weight: 700; color: var(--warning); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; display: flex; align-items: center; gap: 7px; }
.callout.ifs { border-left-color: var(--st-execution); }
.callout ul { margin: 6px 0 0 16px; color: var(--text-secondary); }
.callout li { margin-bottom: 4px; }

/* Footer bar for a corrective action's Create-task / Edit / Delete buttons */
.action-create-bar { display: flex; justify-content: flex-end; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--input-border); }
.btn.action-danger { color: var(--danger, #dc2626); }
.btn.btn-secondary.action-danger:hover { color: #fff; background: var(--danger, #dc2626); border-color: var(--danger, #dc2626); }
.btn.btn-primary.action-danger { background: var(--danger, #dc2626); border-color: var(--danger, #dc2626); color: #fff; }

/* Open work orders on the selected maintenance asset/group (NC location panel) */
.maint-wos { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--input-border); }
.maint-wos-h { font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-secondary); margin-bottom: 6px; display: flex; align-items: center; gap: 7px; }
.maint-wo { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-secondary); padding: 3px 0; }
.maint-wo-code { font-family: 'Cascadia Code', 'Consolas', ui-monospace, monospace; font-size: 11.5px; color: var(--text-muted); }
.maint-wo-title { flex: 1; min-width: 120px; color: var(--text-primary); }
.maint-wo-status, .maint-wo-prio { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 7px; border-radius: 9999px; }
.maint-wo-status { background: var(--st-validated); color: #fff; }
.maint-wo-prio { background: var(--bg-card); border: 1px solid var(--input-border); color: var(--text-muted); }

/* Clarification gates — Request info / Request changes */
.clar-banner { display: flex; align-items: center; gap: 12px; margin: 14px 0 0; padding: 11px 14px; border-radius: var(--border-radius-md); background: var(--bg-subtle); border: 1px solid var(--input-border); border-left: 3px solid var(--warning); font-size: 13px; }
.clar-banner > i { color: var(--warning); font-size: 16px; flex-shrink: 0; }
.clar-banner-text { flex: 1; }
.clar-banner .clar-cta { color: var(--text-muted); margin-left: 4px; }
.clar-withdraw { flex-shrink: 0; border: 1px solid var(--input-border); background: var(--bg-card); color: var(--text-muted); border-radius: var(--border-radius-sm); padding: 5px 10px; font-size: 11px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.clar-withdraw:hover { color: var(--danger); border-color: var(--danger); }
.clar-panel { margin-top: 22px; }
.clar-msg { border: 1px solid var(--input-border); border-radius: var(--border-radius-md); padding: 10px 12px; margin-bottom: 10px; background: var(--bg-subtle); }
.clar-msg.request { border-left: 3px solid var(--warning); }
.clar-msg.response { border-left: 3px solid var(--st-closed); }
.clar-meta { font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.clar-meta strong { color: var(--text-secondary); }
.clar-tag { margin-left: auto; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; font-size: 9px; padding: 2px 7px; border-radius: 9999px; }
.clar-tag.request { background: rgba(217,119,6,0.14); color: var(--warning); }
.clar-tag.response { background: rgba(22,163,74,0.14); color: var(--st-closed); }
.clar-body { font-size: 13px; line-height: 1.6; color: var(--text-primary); white-space: pre-wrap; }
.clar-composer { margin-top: 12px; }
.clar-composer label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.clar-composer textarea { min-height: 80px; resize: vertical; }
.clar-composer-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.clar-composer-actions .btn.sm { margin-top: 0; }

/* Data tables */
.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-table th { text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 700; padding: 8px 10px; border-bottom: 2px solid var(--input-border); position: sticky; top: 0; background: var(--bg-card); }
.data-table td { padding: 9px 10px; border-bottom: 1px solid var(--input-border); color: var(--text-secondary); vertical-align: top; }
.data-table tr:hover td { background: var(--bg-subtle); }
.table-wrap { overflow-x: auto; border: 1px solid var(--input-border); border-radius: var(--border-radius-lg); background: var(--bg-card); }

.task-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 9999px; }
.task-pill.planned { background: var(--bg-subtle); color: var(--text-muted); }
.task-pill.progress { background: rgba(124,58,237,0.12); color: var(--st-execution); }
.task-pill.resolved { background: rgba(22,163,74,0.12); color: var(--st-closed); }
.task-pill i { font-size: 9px; }
.projex-link { font-size: 11px; color: var(--accent-cyan); text-decoration: none; }
a.projex-link { cursor: pointer; }
a.projex-link:hover { text-decoration: underline; }

.efficacy-bar { height: 6px; background: var(--bg-subtle); border-radius: 9999px; overflow: hidden; width: 60px; display: inline-block; vertical-align: middle; }
.efficacy-bar > span { display: block; height: 100%; background: var(--st-closed); border-radius: 9999px; }

/* Action bar */
.action-bar {
    display: flex; flex-wrap: wrap; gap: 8px; padding-top: 16px; margin-top: 16px; border-top: 1px solid var(--input-border);
    align-items: center;
}
.action-bar .role-note { font-size: 11px; color: var(--text-muted); margin-right: auto; display: inline-flex; align-items: center; gap: 6px; }
.action-bar .role-note i { color: var(--accent-cyan); }

.btn { min-height: 40px; padding: 8px 16px; font-family: 'Space Grotesk'; font-weight: 700; letter-spacing: 0.02em; font-size: 12px; cursor: pointer; border-radius: var(--border-radius-md); transition: all var(--transition-speed) ease; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid transparent; }
.btn-primary { background: var(--btn-primary-bg); color: var(--btn-primary-text); border-color: var(--btn-primary-bg); }
.btn-primary:hover { background: var(--btn-primary-hover); }
.btn-secondary { background: var(--btn-secondary-bg); color: var(--btn-secondary-text); border-color: var(--btn-secondary-border); }
.btn-secondary:hover { color: var(--accent-cyan); border-color: var(--accent-cyan); background: var(--btn-secondary-hover); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { filter: brightness(1.08); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================================
   Forms (new NC)
   ============================================================ */
.form-modal-head { padding-right: 40px; margin-bottom: 6px; flex-shrink: 0; }
.form-modal-head h2 { font-size: 18px; }
.form-modal-head p { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.form-body { overflow-y: auto; padding: 4px 4px 0 0; margin-top: 14px; flex: 1 1 auto; min-height: 0; }
.form-group { margin-bottom: 16px; }
.form-group > label { display: block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 6px; }
.req { color: var(--danger); }
.form-control {
    width: 100%; background: var(--input-bg); border: 1px solid var(--input-border); border-radius: var(--border-radius-md);
    padding: 9px 12px; font-family: 'Inter'; font-size: 13px; color: var(--text-primary); outline: none;
    transition: border-color var(--transition-speed) ease;
}
.form-control:focus { border-color: var(--input-focus-border); }
textarea.form-control { resize: vertical; min-height: 70px; }
.form-row { display: grid; grid-template-columns: repeat(2,1fr); gap: 14px; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }

.autofill { background: var(--bg-subtle); border: 1px solid var(--input-border); border-radius: var(--border-radius-md); padding: 12px 14px; display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.autofill .avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent-primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-family: 'Space Grotesk'; flex-shrink: 0; }
[data-theme='dark'] .autofill .avatar { background: var(--accent-cyan); color: #091C3A; }
.autofill .who { flex: 1; min-width: 0; }
.autofill .who .nm { font-weight: 700; font-size: 14px; }
.autofill .who .ro { font-size: 12px; color: var(--text-muted); }
.autofill .hr-tag { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent-cyan); background: var(--accent-cyan-soft); padding: 3px 8px; border-radius: 9999px; }

/* Segmented source toggle */
.segmented { display: flex; gap: 8px; }
.segmented .seg {
    flex: 1; border: 1px solid var(--input-border); border-radius: var(--border-radius-md); padding: 14px; cursor: pointer;
    text-align: center; transition: all var(--transition-speed) ease; background: var(--bg-card);
}
.segmented .seg:hover { border-color: var(--accent-cyan); }
.segmented .seg.active { border-color: var(--accent-cyan); background: var(--accent-cyan-soft); }
.segmented .seg i { font-size: 18px; color: var(--accent-cyan); margin-bottom: 6px; display: block; }
.segmented .seg .t { font-weight: 700; font-size: 13px; }
.segmented .seg .d { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Compact per-action delivery-target toggle (Projex task vs QCM-own), in a card head */
.action-target { display: inline-flex; border: 1px solid var(--input-border); border-radius: var(--border-radius-md); overflow: hidden; }
.action-target .seg-btn {
    display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; font-size: 11px; font-weight: 600;
    background: var(--bg-card); color: var(--text-muted); border: none; cursor: pointer; white-space: nowrap;
    transition: all var(--transition-speed) ease;
}
.action-target .seg-btn + .seg-btn { border-left: 1px solid var(--input-border); }
.action-target .seg-btn:hover { color: var(--text-primary); }
.action-target .seg-btn.active { background: var(--accent-cyan-soft); color: var(--accent-cyan); }
.action-target .seg-btn i { font-size: 11px; }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px,1fr)); gap: 8px; }
.cat-opt { border: 1px solid var(--input-border); border-radius: var(--border-radius-md); padding: 12px 8px; text-align: center; cursor: pointer; transition: all var(--transition-speed) ease; }
.cat-opt:hover { border-color: var(--accent-cyan); }
.cat-opt.active { border-color: var(--accent-cyan); background: var(--accent-cyan-soft); color: var(--accent-cyan); }
.cat-opt i { font-size: 16px; display: block; margin-bottom: 6px; }
.cat-opt .t { font-size: 12px; font-weight: 600; }

.subform { border: 1px dashed var(--accent-cyan); border-radius: var(--border-radius-lg); padding: 16px; margin-bottom: 18px; background: var(--accent-cyan-soft); }
.subform .subform-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent-cyan); margin-bottom: 12px; display: flex; align-items: center; gap: 7px; }

.form-footer { display: flex; justify-content: flex-end; gap: 8px; padding-top: 16px; margin-top: 8px; border-top: 1px solid var(--input-border); flex-shrink: 0; }

/* ============================================================
   Reports view
   ============================================================ */
.report-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.report-tab { padding: 8px 14px; border: 1px solid var(--input-border); background: var(--bg-card); border-radius: var(--border-radius-md); font-family: 'Space Grotesk'; font-weight: 700; font-size: 12px; color: var(--text-secondary); cursor: pointer; display: inline-flex; align-items: center; gap: 7px; }
.report-tab:hover { border-color: var(--accent-cyan); color: var(--accent-cyan); }
.report-tab.active { background: var(--accent-primary); color: #fff; border-color: var(--accent-primary); }
[data-theme='dark'] .report-tab.active { background: var(--accent-cyan); color: #091C3A; border-color: var(--accent-cyan); }
.report-actions { display: flex; gap: 8px; margin-left: auto; }

/* Reports: period filter bar */
.report-period { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.report-period .chip { background: var(--bg-card); color: var(--text-secondary); border: 1px solid var(--input-border); }
.report-period .chip:hover { border-color: var(--accent-cyan); color: var(--accent-cyan); }
.report-period .chip.active { background: var(--accent-primary); color: #fff; border-color: var(--accent-primary); }
[data-theme='dark'] .report-period .chip.active { background: var(--accent-cyan); color: #091C3A; border-color: var(--accent-cyan); }
.report-period .rp-range { display: inline-flex; align-items: center; gap: 10px; }
.report-period .rp-range label { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-muted); font-weight: 600; }
.report-period .rp-range input[type=date] { font: inherit; font-size: 12px; padding: 4px 8px; border: 1px solid var(--input-border); border-radius: var(--border-radius-md); background: var(--bg-card); color: var(--text-primary); }

/* Reports: corrective-actions filters */
.report-filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 12px; }
.report-filters select { font: inherit; font-size: 12px; padding: 6px 10px; border: 1px solid var(--input-border); border-radius: var(--border-radius-md); background: var(--bg-card); color: var(--text-primary); }
.report-filters .af-check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); cursor: pointer; }

/* Reports: summary tables */
.report-h { font-family: 'Space Grotesk'; font-size: 13px; font-weight: 700; color: var(--text-primary); margin: 20px 0 8px; }
.report-h:first-child { margin-top: 4px; }
.data-table tfoot td { border-top: 2px solid var(--input-border); background: var(--bg-subtle); color: var(--text-primary); }

/* Toasts */
.toast-host { position: fixed; bottom: 20px; right: 20px; z-index: 3000; display: flex; flex-direction: column; gap: 10px; }
.toast {
    background: var(--bg-card); border: 1px solid var(--input-border); border-left: 4px solid var(--accent-cyan);
    border-radius: var(--border-radius-md); box-shadow: var(--shadow-lg); padding: 12px 16px; min-width: 260px; max-width: 360px;
    display: flex; gap: 10px; align-items: flex-start; animation: toastIn .25s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.warn { border-left-color: var(--warning); }
.toast.danger { border-left-color: var(--danger); }
.toast i { font-size: 15px; margin-top: 1px; }
.toast.success i { color: var(--success); }
.toast.warn i { color: var(--warning); }
.toast.danger i { color: var(--danger); }
.toast .tt { font-weight: 700; font-size: 13px; }
.toast .td { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
@keyframes toastIn { from { opacity:0; transform: translateX(20px);} to {opacity:1; transform:none;} }

.scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 1400; display: none; }
.scrim.open { display: block; }
@media (min-width: 880px) { .scrim { display: none !important; } }

/* ============================================================
   Settings (admin)
   ============================================================ */
.set-card { background: var(--bg-card); border: 1px solid var(--input-border); border-radius: var(--border-radius-lg); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.set-card.disabled { opacity: 0.55; }
.set-card-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.cat-ic { width: 38px; height: 38px; border-radius: var(--border-radius-md); background: var(--bg-subtle); display: flex; align-items: center; justify-content: center; color: var(--accent-cyan); font-size: 16px; flex-shrink: 0; }
.inline-lbl { max-width: 210px; font-weight: 700; font-family: 'Space Grotesk'; }
.set-card-head .mini { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); display: inline-flex; align-items: center; gap: 6px; }
.set-card-head .mini.toggle { cursor: pointer; }
.mini-in { width: 130px; }
.set-card-head input[type=color], .list-row input[type=color] { width: 38px; height: 32px; padding: 2px; border: 1px solid var(--input-border); border-radius: var(--border-radius-sm); background: var(--input-bg); cursor: pointer; flex-shrink: 0; }
.mini-btn { width: 28px; height: 28px; border: 1px solid var(--input-border); background: var(--bg-card); border-radius: var(--border-radius-sm); color: var(--text-muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; margin-right: 2px; }
.mini-btn:hover { color: var(--accent-cyan); border-color: var(--accent-cyan); }
.mini-btn.danger:hover { color: var(--danger); border-color: var(--danger); }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: 11px; margin-top: 10px; }
.set-card .data-table td { vertical-align: middle; }
.set-card .data-table .form-control { min-width: 110px; }
.muted-cell { color: var(--text-muted); }
.list-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; max-width: 520px; }
.list-row > .form-control { flex: 1; }
/* Maintenance asset-group checklist (Settings → Production lines) */
.maint-line-list { display: flex; flex-direction: column; gap: 2px; max-width: 520px; max-height: 340px; overflow-y: auto; border: 1px solid var(--input-border); border-radius: var(--border-radius-md); padding: 6px; background: var(--input-bg); }
.maint-line-row { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--border-radius-sm); cursor: pointer; }
.maint-line-row:hover { background: var(--bg-subtle); }
.maint-line-row input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; flex-shrink: 0; }
.maint-line-name { font-size: 13px; color: var(--text-primary); }
.maint-line-count { margin-left: auto; font-size: 11px; color: var(--text-muted); }
code { font-family: 'Space Grotesk', monospace; font-size: 11px; background: var(--bg-subtle); padding: 2px 7px; border-radius: 4px; color: var(--text-secondary); }
#settingsBody .section-title:first-child { margin-top: 4px; }
.callout.success i { color: var(--st-closed); }
.icon-pick-btn i { font-size: 13px; color: var(--accent-cyan); }

/* Icon picker */
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px; max-height: 52vh; overflow-y: auto; padding: 2px; }
.icon-cell { aspect-ratio: 1; border: 1px solid var(--input-border); background: var(--bg-card); border-radius: var(--border-radius-md); color: var(--text-secondary); font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all var(--transition-speed) ease; }
.icon-cell:hover { border-color: var(--accent-cyan); color: var(--accent-cyan); background: var(--accent-cyan-soft); transform: translateY(-1px); }
.icon-cell.active { border-color: var(--accent-cyan); color: var(--accent-cyan); background: var(--accent-cyan-soft); box-shadow: var(--focus-ring); }

/* Editable investigation / action plan */
.factor-wrap { display: flex; flex-wrap: wrap; gap: 6px 14px; padding-top: 4px; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); font-weight: 500; cursor: pointer; }
.chk input { width: auto; }
.modal-scroll .data-table .form-control { min-width: 80px; padding: 6px 9px; font-size: 12px; }
.modal-scroll .data-table td { vertical-align: middle; }

/* Sub-category classification */
.nc-subcat { font-size: 12px; color: var(--accent-cyan); font-weight: 600; margin-bottom: 4px; }
.nc-subcat i { font-size: 10px; opacity: 0.8; margin-right: 3px; }

/* Admin sub-category editor */
.sub-edit { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--input-border); }
.sub-edit-head { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); margin-bottom: 10px; display: flex; align-items: center; gap: 7px; }
.sub-edit-head i { color: var(--accent-cyan); }
.sub-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.sub-chip { display: inline-flex; align-items: center; background: var(--bg-subtle); border: 1px solid var(--input-border); border-radius: 9999px; padding: 2px 4px 2px 10px; }
.sub-chip-in { border: none; background: transparent; color: var(--text-primary); font-size: 12px; font-weight: 500; outline: none; width: auto; min-width: 60px; max-width: 260px; field-sizing: content; }
.sub-chip-x { width: 20px; height: 20px; border: none; background: transparent; color: var(--text-muted); cursor: pointer; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; }
.sub-chip-x:hover { color: var(--danger); background: var(--bg-card); }

/* Photo / image field — upload + camera capture */
.photo-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.photo-thumb { position: relative; width: 88px; height: 88px; border-radius: var(--border-radius-md); overflow: hidden; border: 1px solid var(--divider); background: var(--bg-subtle); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-del { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border: none; border-radius: 50%; background: rgba(0,0,0,0.6); color: #fff; cursor: pointer; font-size: 11px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.photo-del:hover { background: var(--danger); }
.photo-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.photo-pick { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.photo-pick input { display: none; }

/* Live camera capture overlay */
.cam-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.8); display: flex; align-items: center; justify-content: center; z-index: 9999; padding: 16px; }
.cam-box { background: var(--bg-card); border-radius: var(--border-radius-lg); padding: 14px; max-width: 640px; width: 100%; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 20px 60px rgba(0,0,0,0.4); }
.cam-video { width: 100%; max-height: 70vh; background: #000; border-radius: var(--border-radius-md); object-fit: contain; }
.cam-actions { display: flex; justify-content: flex-end; gap: 10px; }
.cam-error { color: var(--danger); font-size: 13px; }

/* Efficacy rating dialog (reuses .cam-overlay backdrop / .cam-actions) */
.eff-box { background: var(--bg-card); border-radius: var(--border-radius-lg); padding: 20px; max-width: 380px; width: 100%; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 20px 60px rgba(0,0,0,0.4); }
.eff-title { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.eff-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.eff-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); }
.eff-hint { font-size: 12px; color: var(--text-muted); }
.eff-box .cam-actions { margin-top: 8px; }
.eff-box input.is-invalid { border-color: var(--danger); }

/* IFS template builder */
.tpl-logo-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tpl-logo-prev { position: relative; display: inline-flex; align-items: center; padding: 6px 10px; border: 1px solid var(--divider); border-radius: var(--border-radius-md); background: var(--bg-subtle); gap: 8px; }
.tpl-logo-prev img { max-height: 44px; max-width: 140px; object-fit: contain; display: block; }
.tpl-brand-readonly { padding: 8px 10px; border: 1px solid var(--divider); border-radius: var(--border-radius-md); background: var(--bg-subtle); font-weight: 600; min-height: 20px; }
.tpl-tokens { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 10px; }
.tpl-token-group { border: 1px solid var(--divider); border-radius: var(--border-radius-md); padding: 8px 10px; background: var(--bg-card); }
.tpl-token-grouph { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 6px; font-weight: 600; }
.tpl-token { display: inline-block; margin: 0 4px 4px 0; padding: 3px 9px; font-size: 12px; border: 1px solid var(--divider); border-radius: 9999px; background: var(--bg-subtle); color: var(--text-primary); cursor: pointer; }
.tpl-token:hover { background: var(--accent-cyan, #0EA5E9); color: #fff; border-color: transparent; }
/* textarea.tpl-body (not just .tpl-body): outranks the generic
   `textarea.form-control { min-height: 70px }` which would otherwise win on
   specificity and collapse the raw-HTML editor to ~70px. */
textarea.tpl-body { min-height: 360px; font-family: 'Cascadia Code', 'Consolas', ui-monospace, monospace; font-size: 12.5px; line-height: 1.6; white-space: pre; overflow-wrap: normal; }

/* WYSIWYG template editor */
.tpl-picker { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.tpl-edithead { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.tpl-fieldbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; background: var(--bg-subtle); border: 1px solid var(--divider); border-radius: var(--border-radius-md); margin-bottom: 10px; }
.tpl-fieldbar-h { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-right: 4px; }
.tpl-toolbar { display: flex; align-items: center; gap: 4px; padding: 6px 8px; border: 1px solid var(--divider); border-bottom: none; border-radius: var(--border-radius-md) var(--border-radius-md) 0 0; background: var(--bg-card); flex-wrap: wrap; }
.tpl-tool { min-width: 32px; height: 30px; padding: 0 8px; border: 1px solid transparent; border-radius: var(--border-radius-sm); background: transparent; color: var(--text-primary); cursor: pointer; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; }
.tpl-tool:hover { background: var(--bg-subtle); border-color: var(--divider); }
.tpl-tool-sep { width: 1px; height: 20px; background: var(--divider); margin: 0 4px; }
.tpl-build { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 980px) { .tpl-build { grid-template-columns: 1fr; } }
.tpl-collabel { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); font-weight: 600; margin-bottom: 4px; }
.tpl-editor { min-height: 360px; max-height: 560px; overflow: auto; padding: 18px 20px; border: 1px solid var(--divider); border-radius: 0 0 var(--border-radius-md) var(--border-radius-md); background: var(--bg-card); font-size: 13px; line-height: 1.6; outline: none; }
.tpl-editor:focus { border-color: var(--accent-cyan, #0EA5E9); }
.tpl-editor h1 { font-size: 18px; margin: 0.4em 0; }
.tpl-editor h2 { font-size: 15px; margin: 0.6em 0 0.3em; }
.tpl-editor p { margin: 0.4em 0; }
.tpl-editor table { border-collapse: collapse; width: 100%; }
.tpl-editor td, .tpl-editor th { border: 1px solid var(--divider); padding: 4px 6px; }
.tpl-chip { display: inline-block; padding: 1px 8px; margin: 0 1px; border-radius: 9999px; background: var(--accent-cyan, #0EA5E9); color: #fff; font-size: 12px; font-weight: 600; white-space: nowrap; user-select: all; }
.tpl-preview { min-height: 360px; max-height: 560px; overflow: auto; border: 1px solid var(--divider); border-radius: var(--border-radius-md); background: #fff; padding: 18px 20px; }
.tpl-preview .tpl-doc { color: #1f2937; font: 12.5px/1.6 'Segoe UI', Roboto, Arial, sans-serif; }
.tpl-preview .tpl-letterhead { display: flex; align-items: center; gap: 16px; border-bottom: 2px solid #0f172a; padding-bottom: 10px; margin-bottom: 14px; }
.tpl-preview .tpl-logo { max-height: 54px; max-width: 160px; object-fit: contain; }
.tpl-preview .tpl-company { font-size: 17px; font-weight: 800; }
.tpl-preview .tpl-docref { font-size: 11px; color: #64748b; text-transform: uppercase; letter-spacing: 0.5px; }
.tpl-preview h1 { font-size: 17px; margin: 14px 0 8px; }
.tpl-preview h2 { font-size: 13px; margin: 16px 0 6px; border-left: 4px solid #0f172a; padding-left: 8px; }
.tpl-preview p { margin: 5px 0; }
.tpl-preview table.tpl-meta, .tpl-preview table.tpl-table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 12px; }
.tpl-editor table, .tpl-preview table { width: 100% !important; }
.tpl-preview table.tpl-meta th, .tpl-preview table.tpl-meta td, .tpl-preview table.tpl-table th, .tpl-preview table.tpl-table td { border: 1px solid #e2e8f0; padding: 5px 7px; text-align: left; vertical-align: top; }
.tpl-preview table.tpl-meta th, .tpl-preview table.tpl-table thead th, .tpl-preview table.tpl-kv th { background: #f8fafc; }
.tpl-preview .tpl-photos { display: flex; flex-wrap: wrap; gap: 6px; }
.tpl-preview .tpl-photos img { width: 96px; height: 96px; object-fit: cover; border-radius: 6px; border: 1px solid #e2e8f0; }
.tpl-preview .tpl-signatures { display: flex; justify-content: space-between; gap: 16px; margin-top: 28px; font-size: 11px; color: #334155; }

/* Template targeting ("Applies to") */
.scope-panel { border: 1px solid var(--divider); border-radius: var(--border-radius-md); padding: 12px 14px; background: var(--bg-subtle); margin-bottom: 12px; }
.scope-row { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.scope-h { flex: 0 0 110px; font-size: 12px; font-weight: 600; color: var(--text-muted); padding-top: 4px; }
.scope-chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.scope-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border: 1px solid var(--divider); border-radius: 9999px; background: var(--bg-card); font-size: 12px; cursor: pointer; }
.scope-chip.on { background: var(--accent-cyan, #0EA5E9); color: #fff; border-color: transparent; }
.scope-chip input { margin: 0; }
.scope-summary { margin-top: 4px; padding-top: 8px; border-top: 1px dashed var(--divider); font-size: 12.5px; color: var(--text-primary); }

/* Floating "generate report" template picker */
.tpl-menu { position: fixed; z-index: 9999; background: var(--bg-card); border: 1px solid var(--divider); border-radius: var(--border-radius-md); box-shadow: 0 12px 36px rgba(0,0,0,0.25); padding: 6px; min-width: 220px; max-width: 320px; }
.tpl-menu-h { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); padding: 4px 8px; font-weight: 600; }
.tpl-menu-item { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 8px 10px; border: none; background: transparent; color: var(--text-primary); font-size: 13px; cursor: pointer; border-radius: var(--border-radius-sm); }
.tpl-menu-item:hover { background: var(--bg-subtle); }

/* Toolbar color picker */
.tpl-colorwrap { gap: 3px; padding: 0 6px; }
.tpl-colorwrap input[type="color"] { width: 18px; height: 18px; padding: 0; border: 1px solid var(--divider); border-radius: 3px; background: none; cursor: pointer; }
.tpl-colorwrap input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.tpl-colorwrap input[type="color"]::-webkit-color-swatch { border: none; border-radius: 2px; }

/* Table size popover */
.tpl-pop { position: fixed; z-index: 10000; background: var(--bg-card); border: 1px solid var(--divider); border-radius: var(--border-radius-md); box-shadow: 0 12px 36px rgba(0,0,0,0.25); padding: 10px; }
.tpl-pop-grid { display: grid; gap: 3px; }
.tpl-pop-cell { width: 16px; height: 16px; border: 1px solid var(--divider); border-radius: 2px; background: var(--bg-subtle); cursor: pointer; }
.tpl-pop-cell.on { background: var(--accent-cyan, #0EA5E9); border-color: transparent; }
.tpl-pop-lbl { margin-top: 8px; font-size: 12px; color: var(--text-muted); text-align: center; }

/* Tables / dividers authored in the editor */
.tpl-editor hr { border: none; border-top: 1px solid #333; margin: 10px 0; }
.tpl-preview hr { border: none; border-top: 1px solid #333; margin: 10px 0; }

/* Signed-in user — shared <coreidon-profile> header widget (from
   human_resources). It brings its own shadow-DOM trigger pill; the host only
   needs to align it in the header row. */
.header-right coreidon-profile { display: inline-flex; align-items: center; }

/* Users & Roles settings — per-user role select */
select[data-userrole] { max-width: 200px; }

/* ============================================================
   HELP & GUIDE
   ============================================================ */
/* Static documentation view (help.js). Content HTML is authored attribute-free
   in the locale files, so every rule here targets bare tags under .help-body. */

.help-search { flex: 0 1 280px; }

/* Panes and cards are toggled with the `hidden` attribute (native, no global
   .hidden utility in this codebase); make that win over any display rule. */
.help-pane[hidden], .help-card[hidden] { display: none; }

.help-pane { max-width: 920px; }
.help-card { margin-bottom: 14px; }
.help-card-title {
    font-family: 'Space Grotesk';
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.help-status { margin-bottom: 14px; }

.help-body { font-size: 13px; line-height: 1.7; color: var(--text-secondary); }
.help-body p { margin: 0 0 8px; }
.help-body p:last-child { margin-bottom: 0; }
.help-body ul, .help-body ol { margin: 0 0 8px 20px; }
.help-body ul { list-style: disc; }
.help-body ol { list-style: decimal; }
.help-body li { margin-bottom: 5px; }
.help-body li:last-child { margin-bottom: 0; }
.help-body strong { color: var(--text-primary); font-weight: 600; }
.help-body em { color: var(--text-muted); font-style: normal; }
.help-body code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    background: var(--bg-subtle);
    border: 1px solid var(--input-border);
    border-radius: var(--border-radius-sm);
    padding: 1px 5px;
}

@media (max-width: 880px) {
    .help-search { flex: 1 1 100%; }
}

/* ============================================================
   External auditor workspace (auditor.html)
   ============================================================ */

/* Password gate — the whole page until a session exists. */
.audit-gate {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg-page);
}
/* `display: flex` above beats the browser's default `[hidden] { display: none }`,
   so the gate needs its own hidden rule — without it, auditGate.hidden = true
   sets the attribute and changes nothing, leaving the login overlay stuck on top
   of the workspace after a successful sign-in. */
.audit-gate[hidden] { display: none; }
.audit-gate-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-card);
    border: 1px solid var(--input-border);
    border-radius: var(--border-radius-lg, 12px);
    padding: 28px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}
.audit-gate-brand {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 18px;
}
.audit-gate-brand .brand-name {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}
.audit-gate-brand .brand-sub { font-size: 12px; color: var(--text-muted); }
.audit-gate-card label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.audit-gate-card .btn { width: 100%; margin-top: 14px; justify-content: center; }
.audit-gate-error {
    margin-top: 10px;
    font-size: 12.5px;
    color: #fff;
    background: var(--st-overdue);
    border-radius: var(--border-radius-sm);
    padding: 7px 10px;
}
.audit-gate-lang {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 18px;
}
.audit-gate-lang button {
    background: none;
    border: 1px solid var(--input-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    padding: 3px 9px;
    cursor: pointer;
}
.audit-gate-lang button:hover { color: var(--text-primary); }

/* Persistent "you are read-only, and this is your scope" badge. */
.audit-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--st-pending-approval);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 4px 10px;
    border-radius: 9999px;
    max-width: 340px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.audit-lang-select {
    background: var(--bg-card);
    border: 1px solid var(--input-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 12px;
    padding: 4px 6px;
}

@media (max-width: 880px) {
    .audit-badge { display: none; }
}

/* Audit-account admin (Settings → Auditor access) */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-subtle);
    border: 1px solid var(--input-border);
    border-radius: 9999px;
    padding: 4px 11px;
    font-size: 12.5px;
    cursor: pointer;
}
.chip-check:hover { border-color: var(--st-pending-approval); }

/* Register field filters (by the category fields declared in Settings → Categories & Forms) */
.field-filter-editor {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    background: var(--bg-subtle);
    border: 1px solid var(--input-border);
    border-radius: var(--border-radius-md);
    padding: 10px 12px;
    margin: -0.5rem 0 1.25rem;
}
.field-filter-editor .form-control { flex: 0 1 220px; min-width: 140px; }
.field-filter-hint {
    font-size: 11.5px;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;
}
.chip strong { font-weight: 600; }

@media (max-width: 720px) {
    .field-filter-editor .form-control { flex: 1 1 100%; }
    .field-filter-hint { margin-left: 0; flex-basis: 100%; }
}

/* ---- API-backed field: filterable dropdown (values fetched from a configured API) ---- */
.api-combo { position: relative; }
.api-combo-list {
    position: absolute; z-index: 40; top: calc(100% + 2px); left: 0; right: 0;
    max-height: 240px; overflow-y: auto;
    background: var(--bg-elevated); border: 1px solid var(--input-border);
    border-radius: var(--border-radius-md); box-shadow: var(--shadow-lg);
}
.api-combo-opt { padding: 8px 12px; font-size: 13px; cursor: pointer; color: var(--text-secondary); }
.api-combo-opt:hover { background: var(--accent-cyan-soft); color: var(--text-primary); }
.api-combo-msg { padding: 10px 12px; font-size: 12px; color: var(--text-muted); }
.api-combo-msg.err { color: var(--danger); }

.api-test-result { margin-top: 10px; font-size: 12px; min-height: 1em; color: var(--text-muted); }
.api-test-result.ok { color: var(--success); }
.api-test-result.err { color: var(--danger); }
.api-test-sample { margin-top: 4px; color: var(--text-muted); font-size: 11px; word-break: break-word; }
