/* YGX Integrated Management Platform — base styles (locally hosted, no CDN).
   Bundling Bootstrap 5 locally remains an open YGX decision (spec 21.3);
   until decided, this minimal stylesheet keeps the layout dependency-free. */

:root {
    --color-bg: #f5f6f8;
    --color-surface: #ffffff;
    --color-text: #1c2430;
    --color-muted: #5b6675;
    --color-brand: #0751A4;          /* deep blue, sampled from the logo */
    --color-brand-dark: #043B7A;
    --color-accent: #009ABE;         /* teal, sampled from the logo */
    --color-brand-contrast: #ffffff;
    --color-border: #d6dbe1;
    --color-focus: #1d4ed8;

    /* The logo is a single stroke sweeping deep blue -> teal -> blue. That
       sweep is the brand's signature, so it is reused as a hairline rule
       rather than as a fill: no dark panels, no heavy gradient surfaces. */
    --brand-sweep: linear-gradient(90deg, #043B7A 0%, #0751A4 28%, #009ABE 62%, #0751A4 100%);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
}

.visually-hidden {
    position: absolute; width: 1px; height: 1px;
    margin: -1px; padding: 0; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
    position: absolute; left: -999px; top: 0;
    background: var(--color-brand); color: var(--color-brand-contrast);
    padding: 0.5rem 1rem; z-index: 100;
}
.skip-link:focus { left: 0; }

a { color: var(--color-brand); }
a:focus-visible, button:focus-visible {
    outline: 3px solid var(--color-focus);
    outline-offset: 2px;
}

.site-header {
    position: relative;
    display: flex; align-items: center; gap: 0.75rem;
    background: var(--color-surface); color: var(--color-text);
    border-bottom: 1px solid var(--color-border);
    padding: 0.6rem 1rem;
}
.site-header::after {
    content: "";
    position: absolute; left: 0; right: 0; bottom: -1px;
    height: 3px;
    background: var(--brand-sweep);
}
.brand { display: inline-flex; align-items: center; line-height: 0; }
.brand img { display: block; height: 34px; width: auto; }

/* Logo panel at the top of the left navigation (desktop). */
.nav-brand {
    display: none;
    padding: 1.1rem 1rem 0.9rem;
    border-bottom: 1px solid var(--color-border);
}
.nav-brand img { display: block; width: 100%; max-width: 168px; height: auto; }

.nav-toggle {
    display: inline-flex; flex-direction: column; gap: 4px;
    background: none; border: 1px solid var(--color-border);
    border-radius: 4px; padding: 8px; cursor: pointer;
}
.nav-toggle-bar { width: 20px; height: 2px; background: var(--color-brand); }

.site-body { display: block; }

.site-nav {
    display: none;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}
.site-nav.is-open { display: block; }
.site-nav ul { list-style: none; margin: 0; padding: 0.5rem 0; }
.site-nav a {
    display: block; padding: 0.6rem 1rem; text-decoration: none;
}
.site-nav a[aria-current="page"] {
    font-weight: 600;
    color: var(--color-brand);
    box-shadow: inset 3px 0 0 var(--color-accent);
}
.site-nav a:hover { background: var(--color-bg); }

.site-main { padding: 1rem; max-width: 70rem; }

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 1rem;
    margin-top: 1rem;
}

.lead { color: var(--color-muted); }

.site-footer {
    color: var(--color-muted);
    font-size: 0.85rem;
    padding: 1rem;
}

/* Desktop and tablet: persistent left navigation (spec 7.1). */
@media (min-width: 768px) {
    .nav-toggle { display: none; }
    .site-header { display: none; }      /* the left panel carries the mark */
    .nav-brand { display: block; }
    .site-nav { background: var(--color-surface); }
    .site-body { display: flex; min-height: calc(100vh - 6rem); }
    .site-nav {
        display: block; width: 220px; flex-shrink: 0;
        border-bottom: none; border-right: 1px solid var(--color-border);
    }
    .site-main { flex-grow: 1; padding: 1.5rem 2rem; }
}

/* ---------- Phase 1: authentication, cards, tables ---------- */

.auth-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
    padding: 1.5rem;
    background: #f4f5f7;
}

.auth-card {
    width: 100%;
    max-width: 26rem;
    padding: 1.75rem;
    background: #fff;
    border: 1px solid #d8dce2;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

.brand-auth {
    margin: 0 0 1.5rem;
    text-align: center;
}
.brand-auth img {
    display: inline-block;
    width: 100%;
    max-width: 200px;
    height: auto;
}

.auth-footer {
    max-width: 26rem;
    margin-top: 1rem;
    font-size: 0.8125rem;
    color: #5a6472;
    text-align: center;
}

.field {
    margin-bottom: 1rem;
}

.field label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.field input {
    width: 100%;
    padding: 0.55rem 0.6rem;
    font: inherit;
    border: 1px solid #b9c0c9;
    border-radius: 4px;
    background: #fff;
}

.field input:focus-visible {
    outline: 3px solid #1f6feb;
    outline-offset: 1px;
}

.field input:disabled {
    background: #eef0f3;
    color: #5a6472;
}

.field-hint {
    margin: 0.25rem 0 0;
    font-size: 0.8125rem;
    color: #5a6472;
}

.field-error,
.form-error {
    margin: 0.25rem 0 0;
    color: #96271c;
    font-size: 0.875rem;
}

.form-error {
    padding: 0.6rem 0.75rem;
    margin-bottom: 1rem;
    background: #fdeceb;
    border: 1px solid #f0b7b2;
    border-radius: 4px;
}

.notice {
    padding: 0.6rem 0.75rem;
    margin-bottom: 1rem;
    background: #eef6ee;
    border: 1px solid #b7d7b9;
    border-radius: 4px;
    color: #1f5223;
}

.button-primary,
.button-secondary {
    display: inline-block;
    padding: 0.6rem 1.1rem;
    font: inherit;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
}

.button-primary {
    color: #fff;
    background: var(--color-brand);
    border: 1px solid var(--color-brand);
}

.button-primary:hover {
    background: var(--color-brand-dark);
}

.button-secondary {
    color: var(--color-brand);
    background: #fff;
    border: 1px solid #b9c0c9;
}

.button-primary:focus-visible,
.button-secondary:focus-visible {
    outline: 3px solid #1f6feb;
    outline-offset: 2px;
}

.button-danger {
    color: #fff;
    background: #b3261e;
    border: 1px solid #b3261e;
}

.button-danger:hover {
    background: #8c1d17;
}

.button-danger:focus-visible {
    outline: 3px solid #1f6feb;
    outline-offset: 2px;
}

.button-small {
    padding: 0.3rem 0.7rem;
    font-size: 0.875rem;
}

.auth-links {
    margin-top: 1rem;
    font-size: 0.9375rem;
}

.card {
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    background: #fff;
    border: 1px solid #d8dce2;
    border-radius: 6px;
}

.card h2 {
    margin-top: 0;
    font-size: 1.0625rem;
}

.detail-list {
    display: grid;
    grid-template-columns: minmax(8rem, auto) 1fr;
    gap: 0.35rem 1rem;
    margin: 0;
}

.detail-list dt {
    font-weight: 600;
    color: #3c4655;
}

.detail-list dd {
    margin: 0;
}

.catalog-preview {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    padding: 0.85rem;
    margin: 0.25rem 0 1rem;
    background: #f7f8fa;
    border: 1px solid var(--color-border);
    border-radius: 6px;
}

.catalog-preview-thumb {
    flex: 0 0 auto;
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    background: #fff;
}

.catalog-preview-detail {
    display: flex;
    flex-wrap: wrap;
    gap: 0 1.5rem;
    margin: 0;
    flex: 1 1 auto;
}

.catalog-preview-detail > div {
    display: flex;
    gap: 0.35rem;
}

.catalog-preview-detail dt {
    font-weight: 600;
    color: #3c4655;
}

.catalog-preview-detail dd {
    margin: 0;
}

.catalog-preview p.muted {
    flex-basis: 100%;
    margin: 0.5rem 0 0;
}

/*
 * Without this, .catalog-preview's own "display: flex" (an author rule)
 * overrides the browser's built-in "[hidden] { display: none }" rule (a
 * user-agent rule) whenever both match with equal specificity — author
 * styles always win that tie, hidden attribute or not. The panel was
 * showing its empty placeholder state on page load and staying visible
 * even when JS never toggled it, regardless of what the JS did.
 */
.catalog-preview[hidden] {
    display: none;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.5rem 0.6rem;
    text-align: left;
    border-bottom: 1px solid #e3e6ea;
}

.data-table th {
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #5a6472;
}

.muted {
    color: #5a6472;
}

.inline-form {
    margin-top: 1rem;
}

@media (max-width: 30rem) {
    .detail-list {
        grid-template-columns: 1fr;
    }
    .detail-list dt {
        margin-top: 0.5rem;
    }
}

/* ---------- Phase 1 slice 2: projects, products, timeline ---------- */

.breadcrumb {
    margin: 0 0 0.5rem;
    font-size: 0.875rem;
    color: #5a6472;
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 1rem;
}

.filter-bar input[type="search"],
.filter-bar select,
.stacked-form select,
.stacked-form textarea,
.field select,
.field textarea {
    padding: 0.5rem 0.6rem;
    font: inherit;
    border: 1px solid #b9c0c9;
    border-radius: 4px;
    background: #fff;
}

.field select,
.field textarea {
    width: 100%;
}

.filter-bar a.button-primary {
    margin-left: auto;
    text-decoration: none;
}

.tag {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-radius: 3px;
    border: 1px solid transparent;
}

.tag-internal {
    color: #6a4b00;
    background: #fdf3d8;
    border-color: #e6cf8f;
}

.tag-pending_review {
    color: #1f3352;
    background: #e6edf7;
    border-color: #b2c4de;
}

.tag-client_visible {
    color: #1f5223;
    background: #e8f4e9;
    border-color: #b7d7b9;
}

.history-list,
.timeline {
    margin: 0;
    padding: 0;
    list-style: none;
}

.history-list li,
.timeline li {
    padding: 0.6rem 0;
    border-bottom: 1px solid #e3e6ea;
}

.history-list li:last-child,
.timeline li:last-child {
    border-bottom: 0;
}

.history-time {
    display: block;
    font-size: 0.8125rem;
    color: #5a6472;
}

.timeline p {
    margin: 0.35rem 0 0;
}

.disclosure {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e3e6ea;
}

.disclosure summary {
    cursor: pointer;
    font-weight: 600;
}

.stacked-form {
    margin-top: 0.75rem;
    max-width: 34rem;
}

.diff-from {
    background: #fdf1f0;
}

.diff-to {
    background: #eef6ee;
}

@media (max-width: 40rem) {
    .data-table {
        display: block;
        overflow-x: auto;
    }
    .filter-bar a.button-primary {
        margin-left: 0;
    }
}

.error-list {
    margin: 0 0 1rem;
    padding-left: 1.25rem;
    color: #96271c;
}

/* ---------- Phase 1 slice 3: communication log ---------- */

.field-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0 1rem;
}

.field-row .field {
    flex: 1 1 12rem;
}

.field textarea,
.field select {
    width: 100%;
    padding: 0.55rem 0.6rem;
    font: inherit;
    border: 1px solid #b9c0c9;
    border-radius: 4px;
    background: #fff;
}

.field textarea:focus-visible,
.field select:focus-visible {
    outline: 3px solid #1f6feb;
    outline-offset: 1px;
}

.log-body {
    padding: 0.75rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    background: #f6f7f9;
    border: 1px solid #e3e6ea;
    border-radius: 4px;
    font-size: 0.875rem;
}

.breadcrumb {
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

/* ---------- Phase 1 slice 4: tasks and approvals ---------- */

.stat-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.stat {
    flex: 1 1 8rem;
    padding: 0.75rem 1rem;
    background: #fff;
    border: 1px solid #d8dce2;
    border-radius: 6px;
}

.stat-warn {
    border-color: #e0b4ae;
    background: #fdf4f3;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-brand);
}

.stat-label {
    font-size: 0.8125rem;
    color: #5a6472;
}

.tag-warn,
.tag-rejected {
    background: #fdeceb;
    color: #96271c;
    border-color: #f0b7b2;
}

.tag-approved {
    background: #eef6ee;
    color: #1f5223;
    border-color: #b7d7b9;
}

.tag-pending,
.tag-changes_requested {
    background: #fdf6e3;
    color: #7a5b12;
    border-color: #e6d3a3;
}

td.overdue {
    color: #96271c;
    font-weight: 600;
}

.comment-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
}

.comment-list li {
    padding: 0.65rem 0;
    border-bottom: 1px solid #e3e6ea;
}

.comment-meta {
    margin: 0 0 0.25rem;
    font-size: 0.875rem;
}

/* Sign-in card carries the same logo sweep as the application header. */
.auth-card::before {
    content: "";
    position: absolute; top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--brand-sweep);
}

/* Role reference disclosure list. */
.disclosure {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-border);
}
.disclosure:last-of-type { border-bottom: 0; }
.disclosure summary {
    cursor: pointer;
    padding: 0.25rem 0;
}
.disclosure summary:focus-visible {
    outline: 3px solid var(--color-focus);
    outline-offset: 2px;
}
.permission-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0.75rem;
}
.permission-list li {
    padding: 0.15rem 0.45rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 3px;
    font-size: 0.8125rem;
}

/* Attachment lists. */
.file-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.file-list li {
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--color-border);
}
.file-list li:last-child { border-bottom: 0; }
.field input[type="file"] {
    width: 100%;
    padding: 0.45rem;
    background: var(--color-bg);
    border: 1px dashed var(--color-border);
    border-radius: 4px;
}

/* ---------- Notifications ---------- */

.badge {
    display: inline-block;
    min-width: 1.25rem;
    padding: 0 0.35rem;
    background: var(--color-accent);
    color: #fff;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-align: center;
}

.notification-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.notification {
    padding: 0.85rem 1rem;
    margin-bottom: 0.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 6px;
}

.notification-unread {
    border-left: 3px solid var(--color-accent);
}

.notification-meta {
    margin: 0 0 0.25rem;
    font-size: 0.8125rem;
}

.notification-title {
    margin: 0 0 0.25rem;
    font-weight: 600;
}

.tag-action {
    background: #eef3fb;
    color: #1f3352;
    border-color: #c2d3ea;
}

/* ---------- Client branding ---------- */

.brand-client { margin-right: auto; }
.brand-ygx { margin-left: auto; opacity: 0.85; }
.brand-ygx img { height: 26px; width: auto; }

.client-logo-nav {
    display: block;
    max-width: 168px;
    max-height: 48px;
    width: auto;
    height: auto;
}

.client-logo {
    max-width: 220px;
    max-height: 90px;
    width: auto;
    height: auto;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 0.5rem;
    background: #fff;
}

.logo-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    align-items: flex-start;
    margin-bottom: 1.25rem;
}

.logo-preview {
    flex: 0 0 auto;
    min-width: 12rem;
}


/* ==========================================================================
   Shell: black header and footer bands, light working area
   ========================================================================== */

.app-header {
    display: flex;
    align-items: center;
    gap: 2rem;
    /* Generous breathing room around both marks: the band is the first thing
       a client sees, and cramped logos read as unfinished. */
    min-height: 8.5rem;
    padding: 2.25rem 2.75rem;
    background: #000;
    color: #fff;
}

.app-header-org {
    flex: 1 1 auto;
    min-width: 0;
}

/* The client's own logo. Uploaded artwork sits on black, so it is shown as
   supplied rather than filtered: inverting a coloured logo looks wrong. */
/* Deliberately smaller than the YGX mark: this is the client's badge, not
   the platform's own branding. */
.org-logo {
    display: block;
    max-height: 38px;
    max-width: 210px;
    width: auto;
    height: auto;
}

.org-wordmark {
    color: #fff;
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-decoration: none;
}

.app-header-ygx {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
    text-decoration: none;
}

/* The mark is dark blue artwork; on a black band it is rendered white. */
.ygx-mark {
    height: 38px;
    width: auto;
    filter: brightness(0) invert(1);
}

.platform-name {
    color: #fff;
    font-size: 0.95rem;
    font-weight: 500;
    white-space: nowrap;
}

.app-body {
    display: flex;
    align-items: stretch;
    min-height: 60vh;
}

.app-nav {
    flex: 0 0 17rem;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 0 0;
    background: #fff;
    border-right: 1px solid var(--color-border);
}

.app-nav-groups {
    flex: 1 1 auto;
}

.app-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.app-nav a {
    display: block;
    padding: 0.6rem 1.5rem;
    color: var(--color-primary);
    font-size: 1.05rem;
    text-decoration: none;
}

.app-nav a:hover,
.app-nav a:focus {
    background: #eef3fb;
    text-decoration: underline;
}

.app-main {
    flex: 1 1 auto;
    min-width: 0;
    padding: 2rem 2.5rem 3rem;
    background: var(--color-canvas, #f6f7f9);
}

.app-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    /* Taller band with wider side margins, so the tagline and the platform
       name sit clear of the screen edges. */
    padding: 1.75rem 4.5rem;
    background: #000;
    color: #fff;
    font-size: 0.8125rem;
}

.app-footer-left {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.flag-cn {
    width: 42px;
    height: 28px;
    flex: 0 0 auto;
}

.footer-tagline {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    line-height: 1.45;
}

.app-footer-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.2rem;
    line-height: 1.45;
    text-align: right;
}

/* Small screens: the nav collapses behind the toggle, and the bands stack. */
@media (max-width: 860px) {
    .app-header {
        flex-wrap: wrap;
        gap: 1rem;
        min-height: 0;
        padding: 1.35rem 1.15rem;
    }

    .org-logo { max-height: 28px; max-width: 150px; }
    .ygx-mark { height: 32px; }
    .platform-name { font-size: 0.8125rem; }

    .app-body { display: block; }

    .app-nav {
        display: none;
        border-right: 0;
        border-bottom: 1px solid var(--color-border);
    }

    .app-nav.is-open { display: block; }

    .app-main { padding: 1.25rem 1rem 2rem; }

    .app-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.25rem;
        min-height: 0;
        padding: 1.75rem 1.5rem;
    }

    .app-footer-right { align-items: flex-start; text-align: left; }

    /* Wide tables scroll rather than forcing the page sideways. */
    .data-table { display: block; overflow-x: auto; }
}


/* ==========================================================================
   Grouped navigation
   ========================================================================== */

.nav-group-label {
    margin: 1.5rem 0 0.35rem;
    padding: 0 1.5rem;
    color: #6b7580;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.app-nav > ul:first-of-type { margin-top: 0; }
.nav-group-label:first-child { margin-top: 0; }

.app-nav a {
    border-left: 3px solid transparent;
    padding-left: calc(1.5rem - 3px);
}

/* The current section, so a person always knows where they are. */
.app-nav a.is-current {
    background: #eef3fb;
    border-left-color: var(--color-accent);
    font-weight: 600;
    text-decoration: none;
}

/* ==========================================================================
   Forms: two columns on wider screens instead of one long wall
   ========================================================================== */

.field-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: 0 1.25rem;
    align-items: start;
}

/* Long prose fields stay full width; a 15rem textarea helps nobody. */
.field textarea { width: 100%; }

.field input[type="text"],
.field input[type="email"],
.field input[type="date"],
.field input[type="datetime-local"],
.field input[type="number"],
.field input[type="search"],
.field select {
    width: 100%;
}

/* Reading measure: a form that runs the full width of a wide monitor is hard
   to scan, because the eye loses the label-to-field relationship. */
.app-main form,
.app-main .card {
    max-width: 68rem;
}

.card h3 {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
    font-size: 0.95rem;
    letter-spacing: 0.01em;
}

.card h3:first-of-type { border-top: 0; padding-top: 0; }

/* ==========================================================================
   Client chrome: the same application, visibly not the internal one
   ========================================================================== */

body.is-client .app-main { background: #fbfbfc; }

body.is-client .nav-group-label { color: #7a8590; }

/* ==========================================================================
   Small screens
   ========================================================================== */

@media (max-width: 860px) {
    .nav-group-label { padding: 0 1rem; margin-top: 1rem; }
    .app-nav a { padding-left: calc(1rem - 3px); padding-right: 1rem; }

    .field-row { grid-template-columns: 1fr; gap: 0; }

    .app-main form,
    .app-main .card { max-width: none; }

    /* Tables keep their shape and scroll inside their own box, with a hint
       that there is more to the right. */
    .table-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table { min-width: 34rem; }
}


.build-stamp {
    color: #8a929b;
    font-size: 0.6875rem;
    letter-spacing: 0.02em;
}

/* ==========================================================================
   File thumbnails
   ========================================================================== */

.file-list {
    list-style: none;
    margin: 0 0 1.25rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.file-list-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.file-thumb-link {
    flex: 0 0 auto;
    display: block;
    line-height: 0;
}

.file-thumb {
    display: block;
    width: 84px;
    height: 84px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    background: #f2f3f5;
}

.file-thumb-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8a929b;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.file-thumb-icon {
    display: block;
    overflow: hidden;
}

/* Wraps a thumbnail so its delete button and upload-progress overlay can be
   positioned relative to the thumbnail itself, not the whole row. */
.file-thumb-wrap {
    position: relative;
    flex: 0 0 auto;
    display: inline-block;
    line-height: 0;
}

.file-delete-form {
    position: absolute;
    top: -6px;
    right: -6px;
    margin: 0;
    line-height: 0;
}

.file-delete-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #b3261e;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.file-delete-btn:hover {
    background: #8c1d17;
}

.file-delete-btn:focus-visible {
    outline: 2px solid #1f6feb;
    outline-offset: 1px;
}

/* Upload-in-progress overlay, drawn over a thumbnail placeholder. */
.file-thumb-uploading .file-thumb,
.file-thumb-uploading .file-thumb-fallback {
    opacity: 0.55;
}

.file-thumb-progress-pct {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

.file-thumb-progress-track {
    position: absolute;
    left: 3px;
    right: 3px;
    bottom: 4px;
    height: 5px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.55);
    overflow: hidden;
}

.file-thumb-progress-fill {
    display: block;
    height: 100%;
    width: 0%;
    background: var(--color-brand);
    transition: width 0.15s ease;
}

.file-thumb-error {
    border-color: #f0b7b2 !important;
}

.file-thumb-error-text {
    color: #96271c;
    font-size: 0.75rem;
}

.file-list-detail {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.file-caption {
    font-size: 0.875rem;
    color: #3c4655;
}

/*
 * Attachments specifically show as a 3-per-row thumbnail grid — scoped to
 * .js-attach-list rather than the shared .file-list rule, since .file-list
 * is also used for text-heavy rows elsewhere (supplier catalog listings,
 * the standalone files page) that suit a vertical list better.
 */
.js-attach-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.1rem;
}

.js-attach-list .file-list-item {
    flex-direction: row;
    align-items: center;
    text-align: left;
    gap: 0.75rem;
}

.js-attach-list .file-thumb,
.js-attach-list .file-thumb-fallback,
.js-attach-list .file-thumb-icon {
    width: 128px;
    height: 128px;
}

.js-attach-list .file-thumb-wrap {
    display: inline-block;
    width: auto;
    flex-shrink: 0;
}

.js-attach-list .file-thumb-link {
    display: block;
}

.js-attach-list .file-delete-btn {
    width: 26px;
    height: 26px;
    font-size: 16px;
    border-width: 2px;
}

.js-attach-list .file-delete-form {
    top: -4px;
    right: -4px;
}

.js-attach-list .file-list-detail {
    align-items: flex-start;
    width: auto;
    flex: 1 1 auto;
    min-width: 0;
}

.js-attach-list .js-attach-empty {
    grid-column: 1 / -1;
}

@media (max-width: 640px) {
    .js-attach-list {
        grid-template-columns: repeat(2, 1fr);
    }
}

.js-delete-photo-form {
    margin-left: auto;
    flex: 0 0 auto;
}


/* ==========================================================================
   Signed-in user, bottom of the left panel
   ========================================================================== */

.nav-user {
    flex: 0 0 auto;
    margin-top: 1.5rem;
    padding: 1rem 1.5rem 1.5rem;
    border-top: 1px solid var(--color-border);
    background: #fafbfc;
}

.nav-user-name {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--color-primary);
}

.nav-user-email {
    display: block;
    color: #6b7580;
    font-size: 0.78rem;
    word-break: break-word;
}

.nav-user-role {
    display: inline-block;
    margin-top: 0.4rem;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    background: #eef3fb;
    color: #1f3352;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.nav-user form {
    margin-top: 0.75rem;
}

.nav-user .button-secondary {
    width: 100%;
    text-align: center;
    font-size: 0.8125rem;
    padding: 0.4rem 0.75rem;
}

@media (max-width: 860px) {
    .nav-user { padding: 1rem; }
}

/* ==========================================================================
   Dashboard: stats and charts
   ========================================================================== */

.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat {
    padding: 1rem 1.1rem;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 8px;
}

.stat-value {
    display: block;
    font-size: 1.9rem;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1.1;
}

.stat-label {
    display: block;
    margin-top: 0.25rem;
    color: #6b7580;
    font-size: 0.8125rem;
}

.stat-warn .stat-value { color: #b23c2e; }

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
    gap: 1.25rem;
    align-items: start;
}

.chart-bars {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.chart-bar-row {
    display: grid;
    grid-template-columns: 8rem 1fr 2.5rem;
    align-items: center;
    gap: 0.6rem;
}

.chart-bar-label {
    font-size: 0.8125rem;
    color: #3a4250;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chart-bar-track {
    display: block;
    height: 0.65rem;
    background: #eef0f3;
    border-radius: 999px;
    overflow: hidden;
}

.chart-bar-fill {
    display: block;
    height: 100%;
    border-radius: 999px;
}

.chart-bar-value {
    text-align: right;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #3a4250;
}

.chart-donut-wrap {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.donut-chart { flex: 0 0 auto; transform: rotate(0deg); }

.chart-legend {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.8125rem;
}

.legend-swatch {
    display: inline-block;
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 2px;
    margin-right: 0.4rem;
    vertical-align: middle;
}

@media (max-width: 860px) {
    .chart-bar-row { grid-template-columns: 5.5rem 1fr 2rem; }
}

/* ==========================================================================
   Channel sync
   ========================================================================== */

.sync-panel-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--color-border);
}

.sync-panel-row:last-child {
    border-bottom: 0;
}

.sync-panel-label {
    min-width: 16rem;
    font-weight: 600;
}

.js-sync-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

/* Indeterminate: a sweeping segment rather than a filling bar, because the
   server reports nothing until the whole sync is done. */
.sync-bar {
    position: relative;
    width: 140px;
    height: 6px;
    border-radius: 3px;
    background: #e4e7ec;
    overflow: hidden;
}

.sync-bar::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 40%;
    border-radius: 3px;
    background: var(--color-brand);
    animation: sync-sweep 1.1s ease-in-out infinite;
}

@keyframes sync-sweep {
    0%   { left: -40%; }
    100% { left: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .sync-bar::after {
        animation: none;
        left: 0;
        width: 100%;
        opacity: 0.5;
    }
}

.sync-status {
    font-size: 0.875rem;
}
