/* CPC X DAIKIN Dashboard — "Focus" theme: ultra-clean white, navy ink, Daikin blue */
:root {
    --bg:        #f6f9fc;  /* cool near-white ground */
    --surface:   #ffffff;  /* clean white cards */
    --surface-2: #eef3f9;  /* cool inset for inputs / rows */
    --ink:       #0b2740;  /* deep navy primary text */
    --ink-2:     #44607b;  /* secondary */
    --ink-3:     #5f7c98;  /* tertiary (AA-legible on white) */
    --line:      #e6edf4;  /* cool hairline */
    --accent:    #0090d4;  /* Daikin blue */
    --accent-2:  #00a3ec;
    --green:     #1d8a4e;
    --amber:     #b35309;
    --red:       #d12f2f;
}

* { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
    color: var(--ink);
    background:
        radial-gradient(130% 78% at 50% -12%, #e9f3fc 0%, transparent 55%),
        var(--bg);
    background-attachment: fixed;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
                 "Helvetica Neue", "Segoe UI", Roboto, Arial, sans-serif;
    letter-spacing: -0.01em;
    margin: 0;
    padding: 0;
}

/* Login */
.login-container {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: 0 1px 2px rgba(11, 39, 64, 0.04), 0 28px 64px -22px rgba(11, 39, 64, 0.22);
}

/* Cards */
.dashboard-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: 0 1px 2px rgba(11, 39, 64, 0.03), 0 10px 30px -20px rgba(11, 39, 64, 0.18);
    transition: box-shadow 0.35s cubic-bezier(0.4, 0, 0.2, 1), transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.dashboard-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 2px 4px rgba(11, 39, 64, 0.05), 0 24px 52px -26px rgba(11, 39, 64, 0.28);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn 0.5s ease-out forwards; }

.logo-container img, .logo-container svg { max-height: 48px; object-fit: contain; }

/* KPI cards */
.kpi-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(11, 39, 64, 0.03), 0 10px 30px -22px rgba(11, 39, 64, 0.2);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(11, 39, 64, 0.05), 0 18px 40px -24px rgba(11, 39, 64, 0.26);
}
/* Brief highlight pulse when a KPI value updates live. */
.kpi-flash { animation: kpiFlash 0.7s ease-out; }
@keyframes kpiFlash {
    0%   { box-shadow: 0 0 0 0 rgba(0, 144, 212, 0.35); }
    100% { box-shadow: 0 0 0 14px rgba(0, 144, 212, 0); }
}
.kpi-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-3);
    font-weight: 600;
}
.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
    margin-top: 0.2rem;
    color: var(--ink);
    letter-spacing: -0.02em;
}
.kpi-sub {
    font-size: 0.72rem;
    color: var(--ink-3);
    margin-top: 0.2rem;
}

/* Progress bars */
.progress-track {
    width: 100%;
    height: 8px;
    background: #e8e8ed;
    border-radius: 999px;
    overflow: hidden;
}
.progress-fill {
    position: relative;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #0090d4, #35b6ff);
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}
.progress-fill.complete { background: linear-gradient(90deg, #1d8a4e, #34c759); }
.progress-fill.behind   { background: linear-gradient(90deg, #c2410c, #ff9f0a); }

/* Animated shimmer sweep on in-progress bars (stops once complete). */
.progress-fill::after {
    content: "";
    position: absolute; inset: 0;
    background-image: linear-gradient(90deg,
        rgba(255,255,255,0) 0%, rgba(255,255,255,0.45) 50%, rgba(255,255,255,0) 100%);
    background-size: 60px 100%;
    background-repeat: no-repeat;
    animation: shimmer 1.8s linear infinite;
}
.progress-fill.complete::after { animation: none; content: none; }
@keyframes shimmer {
    from { background-position: -60px 0; }
    to   { background-position: 260px 0; }
}

/* Segmented, batch-coloured progress bar — replaces .progress-track/.progress-fill
   on multi-batch SORs. One segment per batch, sized to its share of the SOR's
   units, tinted with that batch's colour (matches the batch pills / mini rings). */
.batch-progress-row {
    width: 100%;
    display: flex;
    gap: 3px;
}
.batch-progress-seg {
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    min-width: 6px;
}
.batch-progress-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Stage pills */
.stage-pill {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 700;
    padding: 0.14rem 0.55rem;
    border-radius: 999px;
    white-space: nowrap;
}

/* SOR production-pipeline stage pills */
.stage-pending    { background: #ececef; color: #6e6e73; }
.stage-design     { background: #fce7f0; color: #b21e6a; }
.stage-cutting    { background: #e3f2fd; color: #0a6cc4; }
.stage-bending    { background: #e7ecff; color: #3b4fd6; }
.stage-welding    { background: #fff2dd; color: #b35309; }
.stage-paint      { background: #f3e8ff; color: #8a3ffc; }
.stage-packing    { background: #e0f7fa; color: #007a8a; }
.stage-dispatched { background: #e6f0ff; color: #0059c9; }
.stage-delivered  { background: #e3f7eb; color: #1d8a4e; }

/* SOR card */
.sor-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 1rem 1.15rem;
    box-shadow: 0 1px 2px rgba(11,39,64,0.03), 0 8px 24px -18px rgba(11,39,64,0.2);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.sor-card:hover { box-shadow: 0 14px 30px -18px rgba(11,39,64,0.28); transform: translateY(-1px); }

/* Completed-orders group at the bottom of the SOR list */
.completed-divider {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.7rem 0.5rem 0.3rem;
    font-size: 0.85rem; font-weight: 600; color: #1d8a4e;
    cursor: pointer; user-select: none;
    border-top: 1px solid var(--line); margin-top: 0.5rem;
    border-radius: 10px;
    transition: background 0.15s ease;
}
.completed-divider:hover { background: var(--surface-2); }
.completed-caret { color: #86868b; font-size: 0.75rem; width: 0.8rem; }
.completed-group {
    max-height: 0; opacity: 0; overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}
.completed-group.open { max-height: 6000px; opacity: 1; }

/* Clickable SOR header (collapses/expands its units) */
.sor-head {
    display: flex; align-items: center; gap: 0.75rem;
    cursor: pointer; user-select: none;
    border-radius: 12px;
    transition: background 0.15s ease;
}
.sor-head:hover { background: var(--surface-2); }
.sor-caret { color: #86868b; font-size: 0.8rem; width: 0.9rem; flex-shrink: 0; }

/* Collapsible units section under an SOR */
.sor-units {
    max-height: 0; opacity: 0; margin-top: 0; overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, margin-top 0.3s ease;
}
.sor-units.open { max-height: 6000px; opacity: 1; margin-top: 0.75rem; }

/* Unit row inside an SOR */
.unit-row {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.6rem 0.8rem;
    transition: background 0.15s ease, box-shadow 0.2s ease;
}
.unit-row:hover { background: #ececef; box-shadow: 0 4px 14px -10px rgba(0,0,0,0.25); }
.unit-head {
    display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
    cursor: pointer; user-select: none;
}
.unit-caret { color: #86868b; font-size: 0.7rem; width: 0.8rem; }
.batch-pill {
    font-size: 0.62rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.03em; padding: 0.12rem 0.5rem; border-radius: 999px; white-space: nowrap;
}

/* Quantity pill — shown when a unit represents multiple identical pieces */
.qty-pill {
    font-size: 0.66rem; font-weight: 800; white-space: nowrap;
    padding: 0.12rem 0.45rem; border-radius: 999px;
    background: #0b2740; color: #fff;
}

/* Smooth slide-open for a unit's component detail (toggled via .open) */
.unit-detail {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease, margin-top 0.35s ease;
}
.unit-detail.open {
    max-height: 800px;
    opacity: 1;
    margin-top: 0.625rem;
}
.unit-caret { transition: transform 0.25s ease; }

/* Material stock — collapsible category group (click "GI"/"MS" to slide open) */
.stock-group-head {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.9rem 1.1rem;
    cursor: pointer; user-select: none;
    border-radius: 14px;
    transition: background 0.15s ease;
}
/* Only non-metal heads get the light hover fill; metal tabs keep their metal
   background (the [class*="metal-"]:hover rule below just brightens it). Without
   this exclusion the light fill would repaint MS's dark tab and hide its white text. */
.stock-group-head:not([class*="metal-"]):hover { background: var(--surface-2); }
.stock-group-caret { color: #86868b; font-size: 0.7rem; width: 0.8rem; transition: transform 0.25s ease; }
.stock-group-body {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    padding: 0 0.75rem;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, padding 0.3s ease;
}
.stock-group-body.open {
    max-height: 3000px;
    opacity: 1;
    padding: 0 0.75rem 0.9rem;
}
.stock-group-body > .admin-row { margin-top: 0.5rem; }

/* Component row inside a unit */
.comp-row {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.7rem 0.85rem;
}

/* 7-segment component pipeline tracker */
.track { display: flex; gap: 3px; margin-top: 0.5rem; }
.track-seg {
    flex: 1; height: 6px; border-radius: 999px; background: #e3e3e6;
    position: relative; transition: background 0.3s ease;
}
.track-seg.done      { background: #0090d4; }
.track-seg.delivered { background: #1d8a4e; }
.track-labels {
    display: flex; gap: 3px; margin-top: 4px;
    font-size: 8.5px; color: #86868b; letter-spacing: -0.02em;
}
.track-labels span { flex: 1; text-align: center; overflow: hidden; white-space: nowrap; }
.track-labels span.at { color: #0090d4; font-weight: 700; }
.track-labels span.at-del { color: #1d8a4e; font-weight: 700; }

/* Urgency badges */
.badge-high   { background-color: #ffe5e5; color: #c11717; }
.badge-medium { background-color: #fff2dd; color: #b35309; }
.badge-low    { background-color: #e3f2fd; color: #0a6cc4; }

/* High-urgency alert animation — a red pulse to draw the eye */
.badge-high-pulse { animation: badgePulse 1.6s ease-in-out infinite; }
@keyframes badgePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(193, 23, 23, 0.45); }
    50%      { box-shadow: 0 0 0 5px rgba(193, 23, 23, 0); }
}
.note-card {
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.note-card:hover {
    box-shadow: 0 8px 22px -16px rgba(0,0,0,0.3);
    transform: translateY(-1px);
}
.note-high-alert {
    border-color: #f3b8b8 !important;
    animation: noteHighGlow 1.6s ease-in-out infinite;
}
@keyframes noteHighGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(193, 23, 23, 0.16); }
    50%      { box-shadow: 0 0 0 3px rgba(193, 23, 23, 0.06); }
}

/* Inputs */
.field {
    background: var(--surface-2);
    border: 1px solid var(--line);
    color: var(--ink);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.field::placeholder { color: var(--ink-3); }
.field:focus {
    outline: none;
    background: var(--surface);
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(0, 144, 212, 0.15);
}

/* Primary button (pill) — Daikin blue with a subtle vertical sheen */
.btn-primary {
    background: linear-gradient(180deg, #12abee, #0086cf);
    color: #fff;
    border-radius: 980px;
    font-weight: 600;
    box-shadow: 0 6px 16px -8px rgba(0, 144, 212, 0.55);
    transition: filter 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
}
.btn-primary:hover  { filter: brightness(1.05); box-shadow: 0 8px 20px -8px rgba(0, 144, 212, 0.6); }
.btn-primary:active { transform: scale(0.985); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }

/* Secondary / ghost button (pill) */
.btn-ghost {
    background: #ffffff;
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 980px;
    font-weight: 500;
    transition: background 0.2s ease, border-color 0.2s ease;
}
.btn-ghost:hover { background: #eef4fa; border-color: #cfdcea; }
.btn-ghost.notif-on { background: #e3f7eb; border-color: #b8e6c9; color: #1d8a4e; }
.btn-ghost.notif-denied { opacity: 0.6; cursor: not-allowed; }

/* Custom scrollbars (light) */
.scroll-area::-webkit-scrollbar { width: 8px; }
.scroll-area::-webkit-scrollbar-thumb { background: #d2d2d7; border-radius: 999px; }
.scroll-area::-webkit-scrollbar-track { background: transparent; }

/* ---- Live indicator ---- */
.live-dot {
    width: 8px; height: 8px; border-radius: 999px; background: #1d8a4e;
    box-shadow: 0 0 0 0 rgba(29, 138, 78, 0.5);
    animation: livePulse 2s infinite;
}
@keyframes livePulse {
    0%   { box-shadow: 0 0 0 0 rgba(29, 138, 78, 0.45); }
    70%  { box-shadow: 0 0 0 7px rgba(29, 138, 78, 0); }
    100% { box-shadow: 0 0 0 0 rgba(29, 138, 78, 0); }
}

/* ============================================================================
   Enhanced motion — bolder entrance, live-change flashes, micro-interactions,
   and delivery celebrations. All of it is switched off under
   prefers-reduced-motion (guard at the bottom of this block).
   ============================================================================ */

/* Bolder staggered card entrance (dashboard first paint only, via .rise-in). */
@keyframes riseIn {
    from { opacity: 0; transform: translateY(24px) scale(0.975); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}
.rise-in { animation: riseIn 0.6s cubic-bezier(0.22, 1, 0.36, 1) both; }

/* Live stage change — a green pulse sweeps the unit row that just moved. */
@keyframes rowFlash {
    0%   { background: rgba(52, 199, 89, 0.30); box-shadow: inset 0 0 0 2px rgba(52, 199, 89, 0.6); }
    100% { background: transparent;             box-shadow: inset 0 0 0 2px rgba(52, 199, 89, 0); }
}
.row-flash { animation: rowFlash 1.7s ease-out; border-radius: 12px; }

/* Springier hover lifts on the interactive cards / rows / notes. */
.sor-card { transition: box-shadow 0.3s cubic-bezier(0.22,1,0.36,1), transform 0.3s cubic-bezier(0.22,1,0.36,1); }
.sor-card:hover { transform: translateY(-3px); box-shadow: 0 2px 4px rgba(11,39,64,0.05), 0 22px 46px -26px rgba(11,39,64,0.30); }
.unit-row { transition: background 0.2s ease, transform 0.18s cubic-bezier(0.22,1,0.36,1); }
.unit-row:hover { transform: translateX(3px); }
.note-card { transition: box-shadow 0.28s cubic-bezier(0.22,1,0.36,1), transform 0.28s cubic-bezier(0.22,1,0.36,1); }
.note-card:hover { transform: translateY(-2px); box-shadow: 0 16px 34px -22px rgba(11,39,64,0.32); }

/* Bolder button press + a click ripple (ripple span injected by JS). */
.btn-primary:active, .btn-ghost:active { transform: scale(0.93); }
.btn-primary, .btn-ghost { position: relative; overflow: hidden; }
.ripple {
    position: absolute; border-radius: 999px; transform: scale(0); pointer-events: none;
    background: rgba(255, 255, 255, 0.55); animation: ripple 0.6s ease-out forwards;
}
.btn-ghost .ripple { background: rgba(0, 144, 212, 0.25); }
@keyframes ripple { to { transform: scale(2.6); opacity: 0; } }

/* KPI value "lands" with a brief pop as it finishes counting up. */
@keyframes valuePop { 0% { transform: scale(1); } 40% { transform: scale(1.14); } 100% { transform: scale(1); } }
.kpi-value.pop { animation: valuePop 0.5s ease-out; display: inline-block; }

/* Confetti + celebration badge for a delivered unit / completed order. */
.confetti-piece {
    position: fixed; top: -14px; width: 9px; height: 15px; z-index: 9999;
    pointer-events: none; border-radius: 2px; animation: confettiFall linear forwards;
}
@keyframes confettiFall {
    0%   { transform: translateY(0)      rotateZ(0deg);   opacity: 1; }
    100% { transform: translateY(104vh)  rotateZ(760deg); opacity: 0.9; }
}
.celebrate-pop {
    position: fixed; left: 50%; top: 34%; z-index: 10000; pointer-events: none;
    padding: 18px 30px; border-radius: 20px; white-space: nowrap;
    background: linear-gradient(180deg, #1db954, #128a3e); color: #fff;
    font-weight: 800; font-size: 22px; box-shadow: 0 20px 50px -18px rgba(18, 138, 62, 0.7);
    animation: celebratePop 2.2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes celebratePop {
    0%   { transform: translate(-50%, -50%) scale(0.4);  opacity: 0; }
    14%  { transform: translate(-50%, -50%) scale(1.08); opacity: 1; }
    26%  { transform: translate(-50%, -50%) scale(1);    opacity: 1; }
    84%  { transform: translate(-50%, -50%) scale(1);    opacity: 1; }
    100% { transform: translate(-50%, -58%) scale(0.96); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .rise-in, .row-flash, .kpi-value.pop, .ripple, .confetti-piece, .celebrate-pop { animation: none !important; }
    .confetti-piece, .celebrate-pop, .ripple { display: none !important; }
}

/* ---- Admin panel ---- */
.admin-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(11, 39, 64, 0.03), 0 10px 30px -22px rgba(11, 39, 64, 0.18);
}
.admin-input {
    background: #fff;
    border: 1px solid var(--line);
    color: var(--ink);
    border-radius: 10px;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.admin-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 144, 212, 0.15);
}
/* Keyboard focus ring for every clickable control. :focus-visible only fires
   on keyboard navigation, so mouse clicks stay visually clean. */
button:focus-visible, a:focus-visible, [role="button"]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 6px;
}
.admin-row {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    transition: box-shadow 0.2s ease;
}
.admin-row:hover { box-shadow: 0 8px 22px -16px rgba(0,0,0,0.3); }
.admin-row.dirty { border-color: #f5b955; box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.12); }

/* Low material stock */
.admin-row.material-low { border-color: #f3b8b8; background: #fff9f9; }
.stock-low-input { border-color: #f3b8b8 !important; color: #c11717; font-weight: 700; }

/* Mobile: bigger touch targets for the production manager on the floor */
@media (max-width: 640px) {
    .admin-row .btn-primary, .admin-row .btn-ghost { min-height: 40px; padding: 0.5rem 0.9rem; }
    .admin-input { min-height: 40px; }
    .stock-group-head { padding: 1rem 0.9rem; }
}

/* Toast */
#toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: #0b2740; color: #fff; padding: 0.7rem 1.2rem; border-radius: 999px;
    font-size: 0.85rem; font-weight: 500; opacity: 0; pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease; z-index: 100;
    box-shadow: 0 14px 32px -10px rgba(11,39,64,0.5);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: #c11717; }

/* ============================================================================
   Shared top-nav account menu (nav.js) — one clean dropdown replacing the old
   row of many header buttons.
   ============================================================================ */
.nav-menu { position: relative; display: inline-block; }
.nav-trigger {
    display: inline-flex; align-items: center; gap: 0.35rem;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 999px; padding: 0.25rem 0.5rem 0.25rem 0.3rem; cursor: pointer;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.nav-trigger:hover { border-color: #d2d2d7; box-shadow: 0 4px 14px -8px rgba(0,0,0,0.25); }
.nav-avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 999px;
    background: linear-gradient(135deg, #34b6ff, #0086cf); color: #fff;
    font-weight: 700; font-size: 0.8rem; flex-shrink: 0;
}
.nav-avatar.lg { width: 40px; height: 40px; font-size: 1.05rem; }
.nav-caret { color: var(--ink-3); font-size: 0.7rem; padding-right: 0.15rem; }

.nav-panel {
    position: absolute; right: 0; top: calc(100% + 8px); z-index: 60;
    width: 260px; max-width: calc(100vw - 24px);
    background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
    box-shadow: 0 18px 44px -18px rgba(0,0,0,0.34); padding: 0.5rem;
    animation: navPop 0.16s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes navPop { from { opacity: 0; transform: translateY(-6px) scale(0.98); } to { opacity: 1; transform: none; } }
.nav-panel-head {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.5rem 0.6rem 0.7rem; border-bottom: 1px solid var(--line); margin-bottom: 0.4rem;
}
.nav-email { font-size: 0.8rem; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-role  { font-size: 0.72rem; color: var(--ink-3); }
.nav-links { display: flex; flex-direction: column; gap: 1px; }
.nav-link {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.55rem 0.6rem; border-radius: 10px;
    font-size: 0.86rem; font-weight: 500; color: var(--ink); text-decoration: none;
    transition: background 0.12s ease;
}
.nav-link:hover { background: var(--surface-2); }
.nav-link.active { background: #e6f4fc; color: var(--accent); font-weight: 600; }
.nav-link-ic { width: 1.2rem; text-align: center; font-size: 0.95rem; }
.nav-dot { margin-left: auto; color: var(--accent); }
.nav-signout {
    width: 100%; margin-top: 0.4rem; padding: 0.55rem; border-radius: 10px;
    border: none; background: transparent; color: var(--red);
    font-size: 0.86rem; font-weight: 600; cursor: pointer; text-align: left;
    padding-left: 0.6rem; border-top: 1px solid var(--line); border-radius: 0 0 10px 10px;
}
.nav-signout:hover { background: #fff1f1; }

/* ============================================================================
   Loading splash (loading.js) — animated screen shown while auth resolves, so
   the login view never flashes on page load / navigation.
   ============================================================================ */
#app-loading {
    position: fixed; inset: 0; z-index: 9999;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 30px;
    background: radial-gradient(130% 78% at 50% 32%, #eef6fd 0%, var(--bg) 62%);
    transition: opacity 0.5s ease, visibility 0.5s ease;
}
#app-loading.done { opacity: 0; visibility: hidden; pointer-events: none; }
.load-logos {
    display: flex; align-items: center; gap: 18px;
    animation: loadPulse 1.9s ease-in-out infinite;
}
.load-logo { height: 42px; object-fit: contain; }
.load-div { color: #cdd8e4; font-size: 28px; font-weight: 200; }
.load-bar {
    width: 190px; height: 4px; border-radius: 999px;
    background: #e0e9f2; overflow: hidden; position: relative;
}
.load-bar span {
    position: absolute; top: 0; height: 100%; width: 42%; border-radius: 999px;
    background: linear-gradient(90deg, #00a3ec, #0067b3);
    animation: loadSlide 1.15s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
@keyframes loadSlide { 0% { left: -45%; } 100% { left: 100%; } }
@keyframes loadPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.68; } }
@media (prefers-reduced-motion: reduce) {
    .load-logos { animation: none; }
    .load-bar span { animation: none; left: 29%; }
}

/* ============================================================================
   Material Stock — brushed-metal category tabs + quantity steppers
   ============================================================================ */
/* Metal textures (used on both the category head and its swatch chip). Layered:
   a fine brushed-line pattern over a diagonal metallic gradient. */
.metal-gi {
    background:
        repeating-linear-gradient(122deg, rgba(255,255,255,0.5) 0 1px, rgba(120,140,160,0.05) 1px 4px),
        linear-gradient(135deg, #eef2f6 0%, #ccd7e0 48%, #f3f7fa 56%, #d6dfe6 100%);
}
.metal-ms {
    background:
        repeating-linear-gradient(0deg, rgba(255,255,255,0.06) 0 1px, rgba(0,0,0,0.11) 1px 3px),
        linear-gradient(135deg, #46525e 0%, #6d7b87 50%, #4f5c68 100%);
}
/* SS 304 — bright, near-white neutral stainless (vertical brush). */
.metal-ss304 {
    background:
        repeating-linear-gradient(90deg, rgba(255,255,255,0.5) 0 1px, rgba(40,55,70,0.05) 1px 3px),
        linear-gradient(135deg, #f2f6fa 0%, #d9e2ea 50%, #eaeff4 100%);
}
/* SS 316 — distinctly cooler, deeper marine blue-grey so it can't be mistaken
   for 304 (also a slightly different brush angle). */
.metal-ss316 {
    background:
        repeating-linear-gradient(80deg, rgba(255,255,255,0.32) 0 1px, rgba(12,38,66,0.11) 1px 4px),
        linear-gradient(135deg, #cbdcee 0%, #9ab6d2 50%, #b6cbe2 100%);
}
/* Aluminum — very light warm-white silver with a fine angled brush. */
.metal-alu {
    background:
        repeating-linear-gradient(105deg, rgba(255,255,255,0.55) 0 1px, rgba(120,128,138,0.06) 1px 5px),
        linear-gradient(135deg, #f6f8f9 0%, #e0e5e9 45%, #f8fafb 60%, #e5eaee 100%);
}
.metal-default {
    background: linear-gradient(135deg, #eef1f4, #dbe2e8);
}

/* The category tab uses the metal as its background; keep it on hover (base
   .stock-group-head:hover would otherwise repaint it) and just brighten. */
.stock-group-head[class*="metal-"] { transition: filter 0.15s ease; }
.stock-group-head[class*="metal-"]:hover { filter: brightness(1.04); }
.stock-group-head .mat-name { color: #17293a; }
.stock-group-head .mat-sub  { color: #4a5a6a; }
.stock-group-head.mat-dark .mat-name { color: #ffffff; }
.stock-group-head.mat-dark .mat-sub  { color: rgba(255,255,255,0.82); }
.stock-group-head.mat-dark .stock-group-caret { color: rgba(255,255,255,0.78); }

/* Small metal "chip" — a picture of the material next to its name. */
.mat-swatch {
    width: 26px; height: 26px; border-radius: 7px; flex-shrink: 0;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.14), 0 1px 3px rgba(11,39,64,0.22);
}

/* −/+ quantity stepper for fast stock entry */
.qty-stepper { display: inline-flex; align-items: stretch; }
.qty-btn {
    width: 30px; display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--line); background: #fff; color: var(--accent);
    font-size: 1.05rem; font-weight: 700; line-height: 1; cursor: pointer; user-select: none;
    transition: background 0.12s ease;
}
.qty-btn:hover  { background: #e8f4fc; }
.qty-btn:active { background: #d6ecfb; }
.qty-btn:first-child { border-radius: 9px 0 0 9px; }
.qty-btn:last-child  { border-radius: 0 9px 9px 0; border-left: none; }
.qty-stepper .qty-inp {
    width: 3.3rem; text-align: center; border-radius: 0; border-left: none; border-right: none;
}
@media (max-width: 640px) { .qty-btn { min-width: 40px; } }

/* ============================================================================
   Shop-floor: Station Terminal (station.html) + Manager Floor Board (floor.html)
   Big, touch-friendly, wall-tablet-legible.
   ============================================================================ */

/* ---- Station Terminal ---- */
.stn-topline { display:flex; flex-wrap:wrap; align-items:center; gap:10px 14px; }
.stn-badge {
    display:inline-flex; align-items:center; gap:8px; font-weight:700; letter-spacing:.01em;
    background:linear-gradient(135deg,#0090d4,#0067b3); color:#fff;
    padding:8px 16px; border-radius:999px; font-size:16px; box-shadow:0 3px 10px rgba(0,103,179,.28);
}
.stn-badge .dot { width:9px; height:9px; border-radius:50%; background:#8ff0b0; box-shadow:0 0 0 3px rgba(143,240,176,.3); }
.stn-count-pill {
    font-size:13px; font-weight:700; color:var(--ink); background:var(--surface-2);
    border:1px solid var(--line); border-radius:999px; padding:5px 12px;
}
.stn-picker { font-size:14px; padding:8px 12px; }

.stn-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(300px,1fr)); gap:14px; }
.stn-card {
    background:var(--surface); border:1px solid var(--line); border-left:6px solid var(--accent);
    border-radius:16px; padding:16px 16px 14px; box-shadow:0 1px 2px rgba(11,39,64,.05),0 10px 26px rgba(11,39,64,.06);
    display:flex; flex-direction:column; gap:10px; transition:opacity .25s ease, transform .1s ease;
}
.stn-card.busy { opacity:.5; pointer-events:none; }
.stn-card-top { display:flex; align-items:flex-start; justify-content:space-between; gap:10px; }
.stn-sor { font-size:12px; font-weight:700; color:var(--ink-3); letter-spacing:.02em; }
.stn-part { font-size:20px; font-weight:750; letter-spacing:-.01em; line-height:1.15; }
.stn-part small { display:block; font-size:13px; font-weight:500; color:var(--ink-2); margin-top:2px; }
.stn-batch { font-size:12px; font-weight:700; padding:4px 10px; border-radius:999px; white-space:nowrap; }
.stn-facts { display:flex; flex-wrap:wrap; gap:6px 8px; font-size:12.5px; color:var(--ink-2); }
.stn-fact { background:var(--surface-2); border-radius:8px; padding:3px 9px; font-weight:600; }
.stn-fact.wait-old { background:#fdeee2; color:#b1400a; }
.stn-done {
    margin-top:2px; width:100%; border:0; border-radius:12px; cursor:pointer;
    background:linear-gradient(135deg,#1f9d55,#178045); color:#fff;
    font-size:18px; font-weight:750; padding:15px 12px; letter-spacing:.01em;
    box-shadow:0 4px 12px rgba(23,128,69,.28); transition:filter .12s ease, transform .06s ease;
}
.stn-done:hover { filter:brightness(1.05); }
.stn-done:active { transform:translateY(1px); }
.stn-unitdone {
    width:100%; border:1px dashed var(--line); background:var(--surface-2); color:var(--ink);
    border-radius:10px; padding:9px; font-size:13px; font-weight:700; cursor:pointer; margin-top:-2px;
}
.stn-unitdone:hover { background:#e3edf6; }
.stn-empty { text-align:center; padding:64px 20px; color:var(--ink-3); }
.stn-empty .big { font-size:52px; margin-bottom:10px; }

/* ---- Manager Floor Board ---- */
.floor-hero {
    background:linear-gradient(135deg,#0b2740,#123a5c); color:#eaf4fb; border-radius:16px;
    padding:18px 20px; box-shadow:0 10px 26px rgba(11,39,64,.14); display:flex;
    flex-wrap:wrap; align-items:center; justify-content:space-between; gap:12px; margin-bottom:16px;
}
.floor-hero .lbl { font-size:12px; letter-spacing:.12em; text-transform:uppercase; color:#7fb4d8; font-weight:700; }
.floor-hero .big { font-size:26px; font-weight:750; letter-spacing:-.01em; margin-top:2px; }
.floor-hero .big small { font-weight:600; color:#9fc0d8; font-size:15px; }
.floor-hero.calm .big { color:#9be7bb; }
.floor-hero.hot   .big { color:#ffcf9e; }
.floor-updated { font-size:12px; color:#7fb4d8; font-family:ui-monospace,monospace; }

.floor-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:12px; }
.floor-col {
    background:var(--surface); border:1px solid var(--line); border-top:5px solid var(--accent);
    border-radius:14px; padding:15px 15px 14px; box-shadow:0 1px 2px rgba(11,39,64,.05),0 8px 22px rgba(11,39,64,.06);
}
.floor-col.hot { border-top-color:#e8590c; box-shadow:0 0 0 2px rgba(232,89,12,.16),0 8px 22px rgba(232,89,12,.1); }
.floor-col .stage { font-size:14px; font-weight:750; letter-spacing:-.01em; display:flex; align-items:center; gap:7px; }
.floor-col .stage .tag {
    font-size:10px; font-weight:800; text-transform:uppercase; letter-spacing:.05em;
    background:#fdeee2; color:#c0410a; padding:2px 7px; border-radius:6px;
}
.floor-wip { font-size:40px; font-weight:800; letter-spacing:-.03em; line-height:1; margin:8px 0 2px; font-variant-numeric:tabular-nums; }
.floor-wip small { font-size:14px; font-weight:600; color:var(--ink-3); letter-spacing:0; }
.floor-sub { font-size:12.5px; color:var(--ink-2); display:flex; flex-direction:column; gap:3px; margin-top:8px; }
.floor-sub b { color:var(--ink); font-variant-numeric:tabular-nums; }
.floor-age { font-weight:700; }
.floor-age.old { color:#c0410a; }
.floor-empty-col { color:var(--ink-3); font-size:12.5px; font-style:italic; margin-top:8px; }

/* ---- Floor Board: today's output per operator ---- */
.op-row {
    display:flex; align-items:center; gap:12px; padding:11px 14px; background:var(--surface);
    border:1px solid var(--line); border-radius:12px; margin-bottom:8px; box-shadow:0 1px 2px rgba(11,39,64,.04);
}
.op-who { display:flex; align-items:center; gap:9px; min-width:130px; }
.op-avatar { width:30px; height:30px; border-radius:50%; background:linear-gradient(135deg,#0090d4,#0067b3);
    color:#fff; font-weight:700; font-size:14px; display:grid; place-items:center; flex:none; }
.op-name { font-weight:600; font-size:14px; text-transform:capitalize; }
.op-chips { display:flex; flex-wrap:wrap; gap:6px; flex-grow:1; }
.op-chip { font-size:12px; font-weight:600; color:var(--ink-2); background:var(--surface-2);
    border:1px solid var(--line); border-radius:999px; padding:3px 10px; }
.op-total { font-size:22px; font-weight:800; letter-spacing:-.02em; font-variant-numeric:tabular-nums; white-space:nowrap; }
.op-total small { font-size:12px; font-weight:600; color:var(--ink-3); letter-spacing:0; }
@media (max-width:560px){ .op-row{flex-wrap:wrap} .op-total{margin-left:auto} }

/* ---- Admin: collapsible SOR cards (SOR → units → parts) ---- */
.admin-sor-head {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.35rem 0.3rem; border-radius: 10px;
    cursor: pointer; user-select: none;
}
.admin-sor-head:hover { background: var(--surface-2); }
.admin-sor-body { display: none; }
.admin-sor-body.open { display: block; margin-top: 0.6rem; }

/* ============================================================================
   Admin: List / Grid view toggle for the unit list
   ============================================================================ */
.view-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.view-toggle-btn {
    background: var(--surface); color: var(--ink-2); border: none; font-size: 12px; font-weight: 600;
    padding: 6px 11px; cursor: pointer; transition: background 0.12s ease, color 0.12s ease;
}
.view-toggle-btn + .view-toggle-btn { border-left: 1px solid var(--line); }
.view-toggle-btn:hover { background: var(--surface-2); }
.view-toggle-btn.active { background: var(--accent); color: #fff; }

/* Grid container: units lay out as a wrapping grid of chips instead of a
   vertical stack. An expanded chip spans every column so its full controls +
   detail panel render at normal width instead of squeezed into chip width. */
.units-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; align-items: start; }
.units-grid > .admin-row.unit-expanded { grid-column: 1 / -1; }

/* Collapsed chip look — only applied while NOT expanded, so an expanded chip
   falls back to the normal full-width row styling used in List view. */
.unit-chip:not(.unit-expanded) { padding: 8px 10px; }
.unit-chip:not(.unit-expanded) .unit-head-row {
    gap: 6px; font-size: 12px;
}
.unit-chip:not(.unit-expanded) .unit-head-row .u-hide-in-chip { display: none; }
.unit-chip:not(.unit-expanded) .unit-head-row .u-label { font-size: 13px; }
.unit-chip:not(.unit-expanded) .unit-head-row input[type="number"] {
    width: 2.4rem; padding: 2px 4px; font-size: 11px;
}
.unit-chip:not(.unit-expanded) .unit-head-row .stage-pill { font-size: 9px; padding: 2px 6px; }
