/* =====================================================================
   Shell of the applications that show the events (Event Control): the page header, the view tabs, the counters, the
   language switcher and the fields, as Unit Control draws them (PBI #1135). Each section is a verbatim copy of the rules
   of the file named in its comment (panel: agency.css, components.css; Unit Control: cmd-ux.css, ux-shared.css), in the
   cascade order they have there. Unit Control and the panel keep their own files (their rules are interleaved with the
   layout of their pages); EventControlShellTests fails when a copy drifts from its source. The wizard (uc-wizard.css)
   is the one sheet both applications load. Radius: the tokens give 3 px in Event Control and the web, 6 px in Unit Control.
   ===================================================================== */


/* ==== from ux-shared.css (§1, tokens of the pass) ==== */

@layer app {
    :root {
        --ux-topbar-h:0px;
        --ux-tabbar-h:0px;
        --ux-gap:8px;
        --ux-tap:36px;
    }
    @media (max-width: 720px) {
        :root { --ux-tap:44px; }
    }
}

/* ==== from agency.css ==== */

@layer shared {
    .entity-page-header {
        position:relative;
        display:grid;
        grid-template-columns:minmax(180px,auto) minmax(0,1fr) auto;
        align-items:center;
        gap:18px;
        padding:10px 16px;
        border:1px solid var(--ag-line);
        background:linear-gradient(110deg,var(--ag-panel-2) 0%,var(--ag-panel) 60%,var(--ag-panel) 100%);
        overflow:hidden;
    }
    .entity-page-header::before {
        content:"";
        position:absolute;
        left:0;
        top:0;
        bottom:0;
        width:3px;
        background:var(--ag-gold);
        box-shadow:0 0 14px rgba(201,162,74,.5);
    }
    .agency-header-main { min-width:0; }
    .agency-breadcrumb { color:var(--ag-gold); font-size:var(--fs-meta); letter-spacing:.2em; }
    .entity-page-header h1 {
        margin:0;
        overflow:hidden;
        color:var(--on-surface-title);
        font-family:var(--ag-display);
        font-size:clamp(1.3rem,1.8vw,1.9rem);
        font-weight:700;
        letter-spacing:.06em;
        line-height:1.05;
        text-overflow:ellipsis;
        text-transform:uppercase;
        white-space:nowrap;
    }
    .agency-stats { display:flex; gap:8px; }
    .agency-stats > div { min-width:96px; padding:6px 12px; border:1px solid var(--ag-line-2); background:rgba(4,7,10,.6); }
    .agency-stats small { display:block; color:var(--on-surface-muted); font-size:var(--fs-label); }
    .agency-stats strong {
        display:block;
        margin-top:2px;
        color:var(--on-surface-title);
        font-family:var(--ag-display);
        font-size:1.4rem;
        font-weight:600;
        letter-spacing:.06em;
        line-height:1;
        font-variant-numeric:tabular-nums;
    }
}
@layer shared {
    @media (max-width:1400px) {
        .entity-page-header { grid-template-columns:minmax(0,1fr) auto; }
    }
}
@layer shared {
    @media (max-width:1100px) {
        .entity-page-header { grid-template-columns:minmax(0,1fr) auto; }
    }
}
@layer shared {
    @media (max-width:700px) {
        .entity-page-header { grid-template-columns:minmax(0,1fr); gap:10px; }
        .entity-page-header h1 { white-space:normal; }
    }
}
@layer shared {
    .agency-lang {
        position:relative;
        z-index:1;
        display:inline-flex;
        flex:none;
        justify-self:start;
        align-items:center;
        gap:5px;
        height:20px;
        margin:0;
        padding:0 6px 0 8px;
        border:1px solid var(--ag-line-2);
        color:var(--on-surface-2);
        cursor:pointer;
    }
    .agency-lang .agency-lang-current {
        display:inline;
        margin:0;
        font-family:inherit;
        font-size:var(--fs-label);
        font-weight:700;
        letter-spacing:.14em;
        line-height:18px;
        color:inherit;
    }
    .agency-lang .agency-lang-caret { width:8px; height:5px; flex:none; }
    .agency-lang select {
        position:absolute;
        inset:0;
        width:100%;
        height:100%;
        opacity:0;
        cursor:pointer;
        font-size:var(--uc-fs-label, .8rem);
    }
    .agency-lang:hover { background:var(--ag-gold-dim); color:var(--ag-gold-2); }
    .agency-lang:focus-within { outline:2px solid var(--ag-gold-2); outline-offset:1px; }
    .entity-page-header > .agency-stats { justify-self:end; }
}

/* ==== from components.css ==== */

@layer shared {
    .auth-ok {
        padding:6px 8px; border-left:3px solid var(--uc-green-paper); background:rgba(47,122,79,.12); color:var(--ok-text); font-size:var(--uc-fs-label, .78rem);
    }
    .name-line { display:inline-flex; align-items:center; gap:8px; min-width:0; max-width:100%; vertical-align:middle; }
    .name-line > :last-child { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
    .fcc-field { display:flex; flex-direction:column; gap:6px; min-width:0; }
    .fcc-field-label { display:flex; align-items:baseline; flex-wrap:wrap; gap:4px 6px; }
    .fcc-field-req { color:var(--uc-amber); font-weight:700; }
    .fcc-field-help { color:var(--on-surface-muted); font-size:var(--fs-label); }
    .fcc-field-error { display:flex; align-items:flex-start; gap:6px; color:var(--uc-red); font-size:var(--fs-label); }
    .fcc-field-error svg { flex:none; margin-top:1px; }
}

/* ==== from cmd-ux.css ==== */

@layer app {
    .agency-stats small {
        color:var(--uc-label-dark);
        font-size:var(--uc-label-size);
        font-weight:var(--uc-label-weight);
        letter-spacing:var(--uc-label-tracking);
    }
    .uc-tab-head {
        display:flex;
        flex-wrap:wrap;
        align-items:center;
        justify-content:space-between;
        gap:12px;
    }
    .uc-tab-head .ux-head-actions { margin-left:auto; }
}

/* ==== from ux-shared.css ==== */

@layer app {
    .entity-main-panel .entity-page-header {
        display:flex;
        flex-wrap:wrap;
        align-items:flex-end;
        gap:12px 18px;
        padding:20px 0 16px;
        border:0;
        border-bottom:1px solid var(--ag-line);
        background:none;
        overflow:visible;
    }
    .entity-main-panel .entity-page-header::before { content:none; }
    .entity-main-panel .entity-page-header .agency-breadcrumb {
        display:flex;
        align-items:center;
        gap:12px;
        margin-bottom:10px;
        color:var(--ag-gold-2);
        font:600 var(--fs-stamp) var(--ag-mono);
        letter-spacing:.14em;
        text-transform:uppercase;
    }
    .entity-main-panel .entity-page-header .agency-breadcrumb::before { content:""; flex:none; width:28px; height:2px; background:var(--ag-gold); }
    .entity-main-panel .entity-page-header h1 {
        overflow:visible;
        color:var(--on-surface-title);
        font-size:clamp(2rem, 1.5rem + 1.2vw, 2.25rem);
        letter-spacing:.04em;
        line-height:1.08;
        white-space:normal;
        overflow-wrap:anywhere;
    }
    .entity-main-panel .ux-page-lead { max-width:70ch; margin:10px 0 0; color:var(--site-text-2); font-size:1.05rem; line-height:1.6; }
    .entity-main-panel .entity-page-header > .agency-header-main { flex:1 1 220px; min-width:0; }
    .entity-main-panel .entity-page-header > .agency-stats { margin-left:auto; }
    .ux-head-actions {
        display:flex;
        flex-wrap:wrap;
        align-items:center;
        align-self:center;
        gap:var(--ux-gap);
        margin-left:auto;
    }
    .agency-stats + .ux-head-actions { margin-left:0; }
}
@layer app {
    @media (max-width: 720px) {
        .entity-main-panel .entity-page-header > .agency-stats { width:100%; margin-left:0; }
        .ux-head-actions { width:100%; margin-left:0; }
        .ux-head-actions .btn { flex:1 1 auto; }
        .entity-main-panel .entity-page-header { gap:8px 12px; }
        .entity-main-panel .entity-page-header > .agency-stats {
            flex-wrap:nowrap;
            gap:6px;
            overflow-x:auto;
            overscroll-behavior-x:contain;
            scrollbar-width:none;
        }
        .entity-main-panel .entity-page-header > .agency-stats > * {
            display:inline-flex;
            flex:none;
            align-items:baseline;
            gap:8px;
            min-width:0;
            min-height:36px;
            padding:4px 10px;
        }
        .entity-main-panel .entity-page-header > .agency-stats > * > small { display:inline; white-space:nowrap; }
        .entity-main-panel .entity-page-header > .agency-stats > * > strong { margin-top:0; font-size:1.1rem; line-height:1.2; }
        .entity-main-panel .entity-page-header > .ux-head-actions:has(> .btn-primary:only-child > svg) { order:1; width:auto; margin-left:auto; }
        .entity-main-panel .entity-page-header > .ux-head-actions > .btn-primary:only-child:has(> svg) {
            display:inline-flex;
            flex:none;
            align-items:center;
            justify-content:center;
            width:44px;
            height:44px;
            padding:0;
            font-size:0;
        }
        .entity-main-panel .entity-page-header > .ux-head-actions > .btn-primary:only-child > svg { width:20px; height:20px; }
    }
}
@layer app {
    .ux-count {
        display:inline-flex;
        align-items:center;
        min-width:22px;
        height:20px;
        padding:0 6px;
        border:1px solid var(--ag-line-2);
        border-radius:var(--uc-radius);
        color:var(--ag-gold-2);
        font-family:var(--ag-mono);
        font-size:var(--fs-label);
    }
    .cmd-view-row { display:contents; }
    .cmd-view-tabs {
        flex:none;
        display:flex;
        gap:2px;
        margin:0;
        overflow-x:auto;
        overflow-y:hidden;
        border-bottom:1px solid var(--ag-line-2);
        scrollbar-width:none;
        scroll-snap-type:x proximity;
        overscroll-behavior-x:contain;
    }
    .cmd-view-tabs::-webkit-scrollbar { display:none; }
    .cmd-view-tab {
        flex:none;
        display:inline-flex;
        align-items:center;
        gap:8px;
        min-height:44px;
        margin-bottom:-1px;
        padding:7px 16px;
        border:1px solid transparent;
        border-bottom-color:var(--ag-line-2);
        background:transparent;
        color:var(--on-surface-2);
        font:600 var(--fs-action) var(--ag-sans);
        text-decoration:none;
        white-space:nowrap;
        cursor:pointer;
        scroll-snap-align:start;
        transition:color var(--dur-fast), background var(--dur-fast);
    }
    .cmd-view-tab:hover { color:var(--ag-gold-2); background:color-mix(in srgb, var(--ag-gold) 5%, transparent); }
    .cmd-view-tab.is-active {
        border-color:var(--ag-line-2);
        border-bottom-color:var(--ag-bg);
        background:linear-gradient(180deg, var(--ag-panel-2), var(--ag-bg));
        color:var(--ag-gold-2);
        box-shadow:inset 0 2px 0 var(--ag-gold);
    }
    .cmd-view-tab:focus-visible { outline:2px solid var(--ag-gold-2); outline-offset:-3px; }
    .cmd-view-tab[aria-disabled="true"] { color:var(--on-surface-muted); cursor:not-allowed; }
    .cmd-view-tab .ux-count { height:18px; min-width:18px; }
    .cmd-view-tab .ux-count.is-zero { opacity:.6; }
    .cmd-view-tab .ux-count.is-due { border-color:var(--uc-amber); background:var(--uc-amber); color:var(--uc-cta-text); }
    .cmd-view-tabs.is-inner { border-bottom-style:dashed; }
    .cmd-view-tabs.is-inner .cmd-view-tab { padding:5px 12px; font-size:var(--fs-label); min-height:42px; }
    .entity-main-panel .entity-page-header.uc-head-view {
        padding:0;
        border:0;
        background:none;
        display:flex;
        flex-wrap:wrap;
        justify-content:flex-end;
        gap:8px 12px;
    }
    .entity-main-panel .uc-head-view > .agency-header-main { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
    .entity-main-panel .uc-head-view .agency-breadcrumb { display:none; }
    .entity-main-panel .uc-head-view .agency-stats { align-items:center; gap:6px; }
    .entity-main-panel .uc-head-view .agency-stats > div { display:flex; align-items:center; gap:8px; min-width:0; min-height:36px; padding:0 12px; }
    .entity-main-panel .uc-head-view .agency-stats strong { margin-top:0; font-size:1.15rem; }
    .entity-main-panel .uc-head-view .agency-stats { flex-wrap:wrap; }
    .uc-navbar { display:flex; flex:none; flex-wrap:wrap; align-items:center; gap:8px 16px; margin-bottom:12px; }
    .uc-navbar > .cmd-view-tabs, .uc-navbar > .cmd-view-row > .cmd-view-tabs { flex:1 1 auto; min-width:0; }
    .uc-navbar > .uc-head-view { flex:0 0 auto; margin-left:auto; }
    .entity-main-panel .entity-page-header.uc-head-bar { display:flex; flex-wrap:wrap; align-items:center; gap:8px 16px; }
    .uc-head-bar > .agency-header-main { display:flex; flex:1 1 auto; align-items:baseline; gap:4px 10px; min-width:0; }
    .uc-head-bar .agency-breadcrumb::after { content:":"; }
}
@layer app {
    @media (max-width: 900px) {
        .uc-navbar > .uc-head-view { flex:1 1 100%; margin-left:0; justify-content:flex-start; }
        .entity-main-panel .uc-head-view .agency-stats > div { flex:1 1 auto; }
    }
}
@layer app {
    @media (prefers-reduced-motion: reduce) {
        .cmd-view-tab { transition:none; }
    }
}
@layer app {
    @media (max-width: 900px) {
        .cmd-view-tab { padding:7px 14px; }
    }
}
