/* style.css - Diamond Origins Tracker style sheet styled similarly to utropia.net */
/* Fonts and header.css are linked from each page's <head> instead of being
 * @imported here. An @import cannot start downloading until this file has
 * been fetched and parsed, which serialised three round trips (style.css ->
 * font CSS -> font files) before text could paint. */

:root {
    --bg-dark: #07090e;
    --bg-page-mid: #0d121d;
    --bg-surface: rgba(13, 20, 32, 0.55);
    --bg-surface-hover: rgba(22, 33, 51, 0.7);
    --bg-card: rgba(18, 27, 44, 0.5);
    --bg-control: rgba(0, 0, 0, 0.35);
    --bg-control-solid: #0d121d;
    --bg-option: #0d121d;
    --bg-option-checked: #0b3a46;
    --bg-overlay: rgba(10, 15, 26, 0.85);
    --bg-modal: #090c12;
    --bg-modal-mid: #121927;
    --bg-footer: rgba(13, 20, 32, 0.75);
    --bg-dropdown: rgba(18, 25, 41, 0.96);
    --bg-toast: rgba(18, 27, 44, 0.95);
    --bg-table-head: #0d121a;
    --bg-table-head-price: #16140d;
    --fill-faint: rgba(255, 255, 255, 0.03);
    --fill-soft: rgba(255, 255, 255, 0.06);
    --fill-medium: rgba(255, 255, 255, 0.1);
    --fill-inset: rgba(0, 0, 0, 0.2);
    --bg-well: #64748b;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-highlight: rgba(0, 240, 255, 0.4);
    
    /* Neon Colors */
    --neon-cyan: #00f0ff;
    --neon-green: #00ff88;
    --neon-pink: #ff2a85;
    --neon-yellow: #ffc700;
    --neon-purple: #b46bff;
    --text-primary: #f0f4f9;
    --text-secondary: #8e9bb0;
    --text-muted: #5f6b7d;
    --logo-from: #ffffff;
    
    --shadow-glow: 0 0 12px rgba(0, 240, 255, 0.35);
    --shadow-panel: 0 8px 32px 0 rgba(0, 0, 0, 0.25);
    --font-main: 'Google Sans', sans-serif;

    /* Native widgets (dropdown lists, date pickers, datalist, autofill) follow
     * this scheme so their chrome matches the skin's text colour. */
    color-scheme: dark;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-family: var(--font-main);
}

body, button, input, select, textarea, optgroup, option,
code, kbd, samp, pre, tt {
    font-family: var(--font-main);
}

body {
    background: radial-gradient(circle at 50% 50%, var(--bg-page-mid) 0%, var(--bg-dark) 100%) no-repeat fixed;
    background-size: cover;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* Custom Scrollbar styled in cyberpunk theme */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
    background: rgba(0, 240, 255, 0.2);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--neon-cyan);
}

/* Main Container */
/* Content width is user-selectable from the user menu (see header.js). */
html[data-width="compact"] { --app-max-width: 1100px; }
html[data-width="default"] { --app-max-width: 1400px; }
html[data-width="wide"] { --app-max-width: 1760px; }
html[data-width="full"] { --app-max-width: none; }

.app-container {
    max-width: var(--app-max-width, none);
    margin: 0 auto;
    padding: 20px 20px 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-container > main {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
}

app-footer {
    display: block;
    flex-shrink: 0;
    margin-top: auto;
}



/* Cards & Glassmorphism Panels */
.glass-panel {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: var(--shadow-panel);
}

.panel-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: 3px solid var(--neon-cyan);
    padding-left: 10px;
}

/* Action Controls Header */
.action-controls {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
}

.left-actions, .right-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Styled Premium Buttons with Glows */
.btn {
    font-family: var(--font-main);
    font-size: 14px;
    font-weight: 500;
    padding: 10px 20px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-icon {
    padding: 10px;
    width: 40px;
    height: 40px;
    justify-content: center;
    box-sizing: border-box;
}

.btn-cyan {
    background: rgba(0, 240, 255, 0.1);
    border-color: var(--neon-cyan);
    color: var(--neon-cyan);
}
.btn-cyan:hover {
    background: var(--neon-cyan);
    color: #000;
    box-shadow: 0 0 15px var(--neon-cyan);
}

.btn-green {
    background: rgba(0, 255, 136, 0.1);
    border-color: var(--neon-green);
    color: var(--neon-green);
}
.btn-green:hover {
    background: var(--neon-green);
    color: #000;
    box-shadow: 0 0 15px var(--neon-green);
}

.btn-pink {
    background: rgba(255, 42, 133, 0.1);
    border-color: var(--neon-pink);
    color: var(--neon-pink);
}
.btn-pink:hover {
    background: var(--neon-pink);
    color: #fff;
    box-shadow: 0 0 15px var(--neon-pink);
}

.btn-yellow {
    background: rgba(255, 199, 0, 0.1);
    border-color: var(--neon-yellow);
    color: var(--neon-yellow);
}
.btn-yellow:hover {
    background: var(--neon-yellow);
    color: #000;
    box-shadow: 0 0 15px var(--neon-yellow);
}

.btn-purple {
    background: rgba(180, 107, 255, 0.1);
    border-color: var(--neon-purple);
    color: var(--neon-purple);
}
.btn-purple:hover {
    background: var(--neon-purple);
    color: #000;
    box-shadow: 0 0 15px var(--neon-purple);
}

.btn-muted {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--text-muted);
    color: var(--text-secondary);
}
.btn-muted:hover {
    background: var(--fill-medium);
    color: var(--text-primary);
}

/* Stock Lists & Grid Layouts */
.stock-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.parcel-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 20px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.parcel-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-highlight);
    box-shadow: 0 6px 20px rgba(0, 240, 255, 0.1);
}

/* 10 Seconds Highlight Completion Animation */
.highlight-completed {
    animation: neon-pulse-animation 2s ease-in-out infinite;
    z-index: 2;
}

@keyframes neon-pulse-animation {
    0% {
        border-color: var(--neon-green);
        box-shadow: 0 0 8px rgba(0, 255, 136, 0.3);
    }
    50% {
        border-color: var(--neon-green);
        box-shadow: 0 0 25px rgba(0, 255, 136, 0.8), inset 0 0 12px rgba(0, 255, 136, 0.3);
    }
    100% {
        border-color: var(--neon-green);
        box-shadow: 0 0 8px rgba(0, 255, 136, 0.3);
    }
}

.parcel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.parcel-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.parcel-id {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-main);
    margin-top: 2px;
}

/* Badges for status */
.badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    white-space: nowrap;
    display: inline-block;
}

.badge-stock {
    background: rgba(0, 255, 136, 0.15);
    color: var(--neon-green);
    border: 1px solid var(--neon-green);
}

.badge-stockm {
    background: rgba(255, 199, 0, 0.18);
    color: var(--neon-yellow);
    border: 1px solid var(--neon-yellow);
}

.badge-memoin {
    background: rgba(255, 199, 0, 0.18);
    color: var(--neon-yellow);
    border: 1px solid var(--neon-yellow);
}

.badge-memo {
    background: rgba(255, 199, 0, 0.15);
    color: var(--neon-yellow);
    border: 1px solid var(--neon-yellow);
}

.badge-sold {
    background: rgba(255, 42, 133, 0.15);
    color: var(--neon-pink);
    border: 1px solid var(--neon-pink);
}

.badge-returnmemoout,
.badge-returnsale {
    background: rgba(0, 243, 255, 0.15);
    color: var(--neon-cyan);
    border: 1px solid var(--neon-cyan);
}

.badge-purchase {
    background: rgba(0, 255, 136, 0.15);
    color: var(--neon-green);
    border: 1px solid var(--neon-green);
}

.badge-sale {
    background: rgba(255, 42, 133, 0.15);
    color: var(--neon-pink);
    border: 1px solid var(--neon-pink);
}

.badge-memoout {
    background: rgba(255, 199, 0, 0.15);
    color: var(--neon-yellow);
    border: 1px solid var(--neon-yellow);
}

.badge-mix,
.badge-mixin,
.badge-mixout,
.badge-mixout\+ {
    background: rgba(0, 240, 255, 0.1);
    color: var(--neon-cyan);
    border: 1px solid var(--neon-cyan);
}

.badge-splitin,
.badge-splitout {
    background: rgba(0, 240, 255, 0.1);
    color: var(--neon-cyan);
    border: 1px solid var(--neon-cyan);
}

.tx-impact-card {
    background: var(--fill-inset);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 12px;
}

.tx-impact-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.tx-impact-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    min-width: 0;
}

.tx-impact-role {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--neon-cyan);
    font-weight: 600;
    margin-bottom: 0;
}

.tx-impact-parcel-id {
    font-family: var(--font-main);
    font-weight: 700;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tx-impact-parcel-name {
    margin-top: 0;
    font-size: 12px;
    color: var(--text-secondary);
}

.tx-impact-weight-block {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    flex-shrink: 0;
}

.tx-impact-weight {
    font-family: var(--font-main);
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
}

.tx-impact-weight-now {
    font-family: var(--font-main);
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.tx-impact-origins-block {
    border-top: 1px dashed rgba(255, 255, 255, 0.08);
    padding-top: 10px;
}

.tx-impact-origins-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.tx-impact-chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-secondary);
}

.tx-impact-chip-copy,
.tx-impact-chip-set {
    background: rgba(0, 240, 255, 0.1);
    border-color: rgba(0, 240, 255, 0.35);
    color: var(--neon-cyan);
}

.tx-impact-origins-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
}

.tx-impact-tracing-bars {
    margin-top: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tx-impact-tracing-bars .tracing-bar-container {
    margin-bottom: 0;
}

.tx-impact-tracing-bars .tracing-bar-labels {
    margin-bottom: 3px;
}

.tx-impact-origin-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: var(--text-primary);
}

.tx-impact-origin-row .pct {
    font-family: var(--font-main);
    color: var(--text-secondary);
}

.tx-impact-formula-card {
    margin-top: 16px;
    padding: 12px 14px;
    border: 1px dashed rgba(0, 240, 255, 0.28);
    border-radius: 10px;
    background: rgba(0, 240, 255, 0.04);
}

.tx-impact-formula-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--neon-cyan);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 10px;
}

.tx-impact-formula-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px 12px;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-family: var(--font-main);
}

.tx-impact-formula-line:last-child {
    margin-bottom: 0;
}

.tx-impact-formula-origin {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 88px;
    color: var(--text-primary);
    font-weight: 600;
}

.tx-impact-formula-eq strong {
    color: var(--neon-cyan);
    font-weight: 700;
}


.parcel-weight-display {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 10px 0;
    font-family: var(--font-main);
}

.parcel-weight-label {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Mix UI Overlay styles */
.mix-checkbox-wrapper {
    position: absolute;
    top: 15px;
    right: 15px;
    display: none;
    z-index: 5;
}

.mix-active .mix-checkbox-wrapper {
    display: block;
}

.mix-weight-input-wrapper {
    margin-top: 15px;
    background: var(--fill-inset);
    padding: 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    display: none;
}

.mix-active .mix-weight-input-wrapper {
    display: block;
}

/* Tracing Fields visual bar/meter */
.tracing-bars-section {
    margin-top: 15px;
    border-top: 1px dashed var(--border-color);
    padding-top: 15px;
}

.tracing-category-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tracing-bar-container {
    margin-bottom: 10px;
}

.tracing-bar-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-primary);
    margin-bottom: 3px;
}

.tracing-bar-track {
    background: rgba(255, 255, 255, 0.05);
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.tracing-bar-fill {
    background: linear-gradient(90deg, var(--neon-cyan), #00a2ff);
    height: 100%;
    border-radius: 3px;
}

.parcel-actions-row {
    display: flex;
    gap: 8px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.parcel-btn-small {
    font-family: var(--font-main);
    font-size: 11px;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
}

.parcel-btn-small:hover {
    color: var(--text-primary);
    background: var(--fill-medium);
}

.parcel-btn-cyan:hover {
    border-color: var(--neon-cyan);
    color: var(--neon-cyan);
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.25);
}

.parcel-btn-yellow:hover {
    border-color: var(--neon-yellow);
    color: var(--neon-yellow);
    box-shadow: 0 0 8px rgba(255, 199, 0, 0.25);
}

.parcel-btn-pink:hover {
    border-color: var(--neon-pink);
    color: var(--neon-pink);
    box-shadow: 0 0 8px rgba(255, 42, 133, 0.25);
}

.parcel-btn-green:hover {
    border-color: var(--neon-green);
    color: var(--neon-green);
    box-shadow: 0 0 8px rgba(0, 255, 136, 0.25);
}

/* Modals styled in Glassmorphism */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-overlay);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: radial-gradient(circle at 50% 50%, var(--bg-modal-mid) 0%, var(--bg-modal) 100%);
    border: 1px solid var(--border-highlight);
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 30px;
    box-shadow: 0 0 30px rgba(0, 240, 255, 0.25);
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--neon-cyan);
    text-shadow: 0 0 8px rgba(0, 240, 255, 0.4);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    transition: color 0.2s ease;
}
.modal-close:hover {
    color: var(--neon-pink);
}

/* In-page confirm and alert (header.js), above every other layer. */
.modal-overlay.tracex-prompt {
    z-index: 5000;
}

.tracex-prompt-box {
    max-width: 440px;
    padding: 24px;
}

.tracex-prompt-message {
    margin: 0 0 20px;
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.5;
    white-space: pre-line;
}

.tracex-prompt-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-zap {
    background: rgba(255, 199, 0, 0.1);
    border: 1px solid rgba(255, 199, 0, 0.35);
    color: var(--neon-yellow);
    border-radius: 8px;
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.btn-zap:hover {
    background: var(--neon-yellow);
    color: #000;
    box-shadow: 0 0 12px rgba(255, 199, 0, 0.45);
}

.btn-zap i,
.btn-zap svg {
    width: 15px;
    height: 15px;
}

/* Forms controls */
.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

input[type="text"], input[type="number"], input[type="password"], input[type="email"], input[type="url"], input[type="tel"], select {
    width: 100%;
    background: var(--bg-control);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 14px;
    transition: all 0.3s ease;
}

/* ---------------------------------------------------------------------------
 * Dropdown list readability.
 *
 * The closed control above is deliberately translucent so it sits on the glass
 * panels, but the OPEN dropdown is drawn by the operating system, which cannot
 * render transparency: rgba(0,0,0,0.35) composited over the OS default came out
 * light grey while the text stayed #fff, leaving every dropdown in the app
 * white-on-grey and unreadable. Options therefore need an explicitly OPAQUE
 * background. This applies to every <select> in traceX, not one component.
 * ------------------------------------------------------------------------ */
option,
optgroup,
select option,
select optgroup {
    background-color: var(--bg-option);
    color: var(--text-primary);
}

/* Headings in a tree-shaped picker (group accounts) are disabled options. The
 * browser greys them further, so start from a colour that survives that. */
option:disabled,
select option:disabled {
    color: var(--text-secondary);
}

/* Opaque too, for the same reason - a translucent highlight would composite
 * against the OS popup's own background rather than ours. */
option:checked,
select option:checked {
    background-color: var(--bg-option-checked);
    color: var(--text-primary);
}

input[type="text"]:focus, input[type="number"]:focus, input[type="password"]:focus, input[type="email"]:focus, input[type="tel"]:focus, select:focus {
    outline: none;
    border-color: var(--neon-cyan);
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.2);
}

/* Dynamic rows for tracing fields */
.tracing-field-builder {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.01);
    margin-bottom: 20px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tracing-field-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.tracing-field-header label {
    margin-bottom: 0 !important;
    cursor: pointer;
}

.collapse-icon {
    color: var(--neon-cyan);
    font-size: 10px;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.tracing-field-builder.collapsed {
    background: rgba(255, 255, 255, 0.002);
    border-color: rgba(255, 255, 255, 0.05);
    margin-bottom: 12px;
    padding: 12px 15px;
}

.tracing-field-builder.collapsed .tracing-field-content {
    display: none;
}

.tracing-field-builder.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.tracing-rows-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

.tracing-row {
    display: grid;
    grid-template-columns: 1fr 80px 40px;
    gap: 10px;
    align-items: center;
}

.btn-remove-row {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    transition: color 0.2s ease;
}
.btn-remove-row:hover {
    color: var(--neon-pink);
}

.tracing-summary-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-secondary);
}

.sum-indicator {
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}
.sum-ok {
    background: rgba(0, 255, 136, 0.1);
    color: var(--neon-green);
}
.sum-error {
    background: rgba(255, 42, 133, 0.1);
    color: var(--neon-pink);
}

/* Tables Styles (Transactions, etc) */
/* Cap the scroll box to the viewport so the horizontal scrollbar stays in
   view instead of sitting at the very bottom of a long list. */
.table-responsive {
    overflow: auto;
    width: 100%;
    max-height: min(75vh, 820px);
}

.table-responsive > table > thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg-table-head, #121b2c);
}

.premium-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}

.premium-table th {
    background: var(--bg-table-head);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.premium-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    white-space: nowrap;
}

.premium-table td svg {
    display: inline-block !important;
    vertical-align: middle !important;
    flex-shrink: 0;
}

.premium-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Details popovers / items inside tables */
.details-subtext {
    font-size: 11px;
    color: var(--text-muted);
    white-space: normal;
    word-break: break-word;
    max-width: min(420px, 36vw);
    line-height: 1.45;
}

#origins-transactions-table th#th-tx-impact,
#origins-transactions-table td.tx-impact-cell {
    width: 72px;
    min-width: 72px;
    max-width: 72px;
    text-align: center;
    position: sticky;
    right: 0;
    z-index: 2;
    background: var(--bg-surface);
    box-shadow: -8px 0 12px rgba(0, 0, 0, 0.25);
}

#origins-transactions-table thead th#th-tx-impact {
    z-index: 3;
    background: var(--bg-table-head, rgba(18, 27, 44, 0.98));
}

#origins-transactions-table tbody tr:hover td.tx-impact-cell {
    background: var(--bg-surface-hover);
}

/* Footer Section */
.app-footer {
    text-align: center;
    padding: 40px 0;
    color: var(--text-muted);
    font-size: 12px;
}

/* Panels that set display explicitly would otherwise win over the user-agent
 * rule for [hidden]. Pages gate whole sections with that attribute, so it has
 * to keep the last word. */
[hidden] {
    display: none !important;
}

/* ---------------------------------------------------------------------------
 * Loading state
 *
 * Shown while the Supabase session is still resolving. Pages used to fall
 * through to their "sign in" panel during that window, which flashed a wrong
 * message at users who were in fact signed in.
 * ------------------------------------------------------------------------ */
.app-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
    padding: 60px 30px;
    text-align: center;
}

.app-loader {
    position: relative;
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
}

/* A cyan arc sweeping around the traceX diamond. The mask punches the centre
 * out of the conic gradient, which gives a smooth ring no border can match. */
.app-loader::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: conic-gradient(
        from 0turn,
        rgba(0, 240, 255, 0) 0deg,
        rgba(0, 240, 255, 0.12) 150deg,
        var(--neon-cyan) 330deg,
        rgba(0, 240, 255, 0) 360deg
    );
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3.5px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3.5px));
    animation: app-loader-spin 1.1s linear infinite;
}

.app-loader::after {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 240, 255, 0.16) 0%, transparent 68%);
    animation: app-loader-halo 2s ease-in-out infinite;
}

.app-loader-mark {
    position: relative;
    z-index: 1;
    font-size: 17px;
    line-height: 1;
    color: var(--neon-cyan);
    text-shadow: 0 0 12px rgba(0, 240, 255, 0.7);
    animation: app-loader-pulse 2s ease-in-out infinite;
}

.app-loading-text {
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.3px;
    color: var(--text-primary);
    margin: 0;
}

.app-loading-text::after {
    content: '';
    animation: app-loader-dots 1.6s steps(4, end) infinite;
}

.app-loading-hint {
    font-size: 12px;
    letter-spacing: 2.4px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: -14px 0 0;
}

/* Skeleton rows standing in for the table that is about to arrive. */
.app-skeleton {
    width: 100%;
    max-width: 620px;
    display: flex;
    flex-direction: column;
    gap: 11px;
    margin-top: 4px;
}

.app-skeleton-row {
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.04) 25%,
        rgba(0, 240, 255, 0.11) 37%,
        rgba(255, 255, 255, 0.04) 63%
    );
    background-size: 400% 100%;
    animation: app-skeleton-shimmer 1.5s ease-in-out infinite;
}

.app-skeleton-row:nth-child(2) { width: 88%; animation-delay: 0.1s; }
.app-skeleton-row:nth-child(3) { width: 94%; animation-delay: 0.2s; }
.app-skeleton-row:nth-child(4) { width: 76%; animation-delay: 0.3s; }

@keyframes app-loader-spin {
    to { transform: rotate(1turn); }
}

@keyframes app-loader-halo {
    0%, 100% { opacity: 0.45; transform: scale(0.94); }
    50% { opacity: 1; transform: scale(1.06); }
}

@keyframes app-loader-pulse {
    0%, 100% { opacity: 0.65; transform: scale(0.9); }
    50% { opacity: 1; transform: scale(1.1); }
}

@keyframes app-loader-dots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

@keyframes app-skeleton-shimmer {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

/* Motion here is decorative: the text alone still says "loading". */
@media (prefers-reduced-motion: reduce) {
    .app-loader::before,
    .app-loader::after,
    .app-loader-mark,
    .app-loading-text::after,
    .app-skeleton-row {
        animation: none;
    }
    .app-loading-text::after { content: '…'; }
}

/* Alert Notification System */
.notification-container {
    position: fixed;
    bottom: 25px;
    right: 25px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.toast {
    background: var(--bg-toast);
    border: 1px solid var(--neon-cyan);
    border-radius: 8px;
    padding: 12px 20px;
    color: var(--text-primary);
    font-size: 13px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    min-width: 250px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slide-in 0.3s ease-out;
}

@keyframes slide-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Stock View Controls Container */
.stock-view-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--fill-faint);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 10px 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.view-toggle-buttons {
    display: flex;
    gap: 8px;
}

.view-toggle-buttons .btn-muted {
    padding: 6px 12px;
    font-size: 12px;
    margin-bottom: 0;
}

.view-toggle-buttons .btn-muted.active {
    background: rgba(0, 240, 255, 0.15);
    border-color: var(--neon-cyan);
    color: var(--neon-cyan);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.25);
}

/* Search Filter Box */
.search-filter-box {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-width: 280px;
    max-width: 380px;
    flex: 1;
}

.search-filter-box i,
.search-filter-box svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    pointer-events: none;
    transition: color 0.2s ease;
    z-index: 2;
}

.search-filter-box input {
    width: 100%;
    padding: 7px 30px 7px 32px;
    font-size: 12px;
    background: var(--bg-control-solid);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-main);
    transition: all 0.25s ease;
    outline: none;
}

.search-filter-box input::placeholder {
    color: var(--text-muted);
    font-size: 12px;
}

.search-filter-box input:focus {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
    background: var(--bg-control-solid);
}

.search-filter-box:focus-within i,
.search-filter-box:focus-within svg {
    color: var(--neon-cyan);
}

.search-filter-box button {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
}

/* Glassmorphic Column Chooser Dropdown */
.column-chooser-dropdown {
    display: block;
    position: absolute;
    top: 45px;
    right: 0;
    z-index: 100;
    padding: 15px;
    width: 200px;
    border-radius: 10px;
    border: 1px solid var(--border-highlight) !important;
    background: var(--bg-dropdown) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 15px rgba(0, 240, 255, 0.1);
    
    /* Elegant Micro-animations */
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px) scale(0.96);
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.column-chooser-dropdown.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

/* Beautiful Switch Style for Tracing Fields Toggle */
.tracing-toggle-wrapper {
    display: flex;
    align-items: center;
}

.switch-label {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    user-select: none;
    gap: 10px;
    margin-bottom: 0;
}

.switch-label input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 36px;
    height: 18px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 9px;
    position: relative;
    outline: none;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.3s ease;
}

.switch-label input[type="checkbox"]:checked {
    background: rgba(0, 240, 255, 0.2);
    border-color: var(--neon-cyan);
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.25);
}

.switch-label input[type="checkbox"]::before {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-secondary);
    top: 2px;
    left: 2px;
    transition: all 0.3s ease;
}

.switch-label input[type="checkbox"]:checked::before {
    background: var(--neon-cyan);
    left: 20px;
    box-shadow: 0 0 5px var(--neon-cyan);
}

/* Tracing Bars styling for Row-view inline rendering */
.row-tracing-compact {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px 35px;
    padding: 12px 18px;
    background: var(--fill-inset, rgba(0, 0, 0, 0.2));
    border-radius: 6px;
    margin-top: 5px;
    border: 1px solid var(--border-color);
}

@media (max-width: 768px) {
    .row-tracing-compact {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }
}

.row-tracing-cat-block {
    min-width: 0;
}

/* Single tracing field: one line of values instead of a stacked block */
.row-tracing-compact.row-tracing-flat {
    display: block;
    padding: 8px 14px;
}

.row-tracing-flat .row-tracing-cat-block {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 22px;
}

.row-tracing-flat .row-tracing-item {
    margin-bottom: 0;
    justify-content: flex-start;
    gap: 6px;
    white-space: nowrap;
}

.row-tracing-cat-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--neon-cyan);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.row-tracing-item {
    font-size: 11px;
    color: var(--text-primary);
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.row-tracing-item span.pct {
    color: var(--text-secondary);
    font-family: var(--font-main);
}

/* Action button style inside row view */
.row-actions-cell {
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: stretch;
    width: 100%;
}

.row-actions-cell .parcel-btn-small {
    margin-top: 0;
    width: 100%;
    box-sizing: border-box;
    padding: 6px 8px;
    font-size: 11px;
    white-space: nowrap !important;
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 5px;
    line-height: 1;
}

.row-actions-cell .parcel-btn-small svg,
.row-actions-cell .parcel-btn-small i[data-lucide] {
    flex-shrink: 0;
    margin-right: 0 !important;
}

/* Zero weight grayed out styling */
.zero-weight {
    opacity: 0.58 !important;
    filter: grayscale(0.35) brightness(95%);
    transition: all 0.2s ease;
}

.zero-weight:hover {
    opacity: 0.9 !important;
    filter: none;
}

/* Premium SVG Icon style override for Lucide */
svg.lucide, i[data-lucide] {
    width: 16px;
    height: 16px;
    stroke-width: 2px;
    display: inline-block;
    vertical-align: middle;
}
.btn svg.lucide, .btn i[data-lucide] {
    margin-right: 4px;
}

/* Action control desk light font weight */
#demo-controls-action-row .btn {
    font-weight: 300 !important;
}

/* Sleek Premium Timeline Link Icon */
.timeline-link-icon {
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.timeline-link-icon:hover {
    color: var(--neon-cyan);
    background: rgba(0, 240, 255, 0.08);
    border-color: rgba(0, 240, 255, 0.3);
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.25);
    transform: translateY(-1px);
}

/* Calculation Tree CSS Styles */
.calc-parents-row {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 24px;
    margin-bottom: 15px;
    width: 100%;
    flex-wrap: nowrap;
}
.calc-arrow-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 15px;
    width: 100%;
}
.calc-connector-line {
    width: 2px;
    height: 20px;
    background: linear-gradient(180deg, var(--border-color), var(--neon-cyan));
}
.calc-arrow-delta {
    font-family: var(--font-main);
    font-size: 11px;
    font-weight: 700;
    color: var(--neon-cyan);
    background: rgba(0, 240, 255, 0.08);
    border: 1px solid rgba(0, 240, 255, 0.25);
    border-radius: 4px;
    padding: 2px 8px;
    margin: 4px 0;
    white-space: nowrap;
}
.calc-arrow-contribs {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    margin-bottom: 2px;
}
.calc-arrow-contrib {
    font-family: var(--font-main);
    font-size: 10px;
    color: var(--neon-pink);
    opacity: 0.9;
    white-space: nowrap;
}
.calc-arrow {
    color: var(--neon-cyan);
    font-size: 12px;
    margin-top: -2px;
}
.calc-branch {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: fit-content;
}
.calc-node-card {
    background: var(--bg-card, rgba(18, 27, 44, 0.85));
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    min-width: 220px;
    max-width: 280px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    margin: 5px;
}
.calc-node-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 240, 255, 0.25);
}
.calc-node-card.status-stock {
    border-color: var(--neon-green);
    box-shadow: inset 0 0 8px rgba(0, 255, 136, 0.15);
}
.calc-node-card.status-memo {
    border-color: var(--neon-yellow);
    box-shadow: inset 0 0 8px rgba(255, 199, 0, 0.15);
}
.calc-node-card.status-sold {
    border-color: var(--neon-pink);
    box-shadow: inset 0 0 8px rgba(255, 42, 133, 0.15);
}
.calc-node-card.status-purchased {
    border-color: var(--neon-green);
    box-shadow: inset 0 0 8px rgba(0, 255, 136, 0.15);
}
.calc-node-card.status-mixout,
.calc-node-card.status-mixout\+ {
    border-color: var(--neon-cyan);
    box-shadow: inset 0 0 8px rgba(0, 240, 255, 0.15);
}
.calc-node-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    gap: 8px;
}
.calc-node-id {
    font-family: var(--font-main);
    font-weight: bold;
    font-size: 12px;
    color: var(--neon-cyan);
}
.calc-node-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.calc-node-weight {
    font-size: 12px;
    font-family: var(--font-main);
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Premium Dropdown Style */
.premium-select {
    width: 80px;
    padding: 6px 10px;
    font-size: 12px;
    background: var(--bg-control-solid) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    font-family: var(--font-main);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}

.premium-select:hover {
    border-color: var(--neon-cyan) !important;
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

.premium-select:focus {
    border-color: var(--neon-cyan) !important;
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.35);
}

.premium-select option {
    background: var(--bg-option);
    color: var(--text-primary);
}

/* Premium Search Input Style */
.premium-search-input:hover {
    border-color: var(--neon-cyan) !important;
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.15);
}

.premium-search-input:focus {
    border-color: var(--neon-cyan) !important;
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
}

/* Origins Summary Views & Cake Chart Styles */
.origins-summary-panel-container {
    background: var(--fill-inset, rgba(0, 0, 0, 0.2));
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.origins-summary-panel-header {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--neon-cyan);
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    flex-wrap: wrap;
    gap: 10px;
}

.origins-summary-view-toggle {
    display: inline-flex;
    background: var(--fill-inset, rgba(0, 0, 0, 0.3));
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px;
}

.origins-summary-origin-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.origins-summary-origin-card:hover,
.origins-summary-origin-card.is-filtered {
    background: rgba(0, 240, 255, 0.05);
    border-color: rgba(0, 240, 255, 0.3);
}

.origins-summary-origin-card.is-filtered {
    background: rgba(0, 240, 255, 0.08);
    border-color: var(--neon-cyan);
}

.origins-summary-origin-weight {
    font-size: 14px;
    font-family: var(--font-main);
    font-weight: 700;
    color: var(--text-primary);
}

.origins-summary-origin-track {
    background: var(--fill-soft);
    height: 4px;
    border-radius: 2px;
    overflow: hidden;
}

.origins-summary-origin-fill {
    background: linear-gradient(90deg, var(--neon-cyan), #00a2ff);
    height: 100%;
}

.origins-summary-view-toggle button.active {
    background: var(--neon-cyan) !important;
    color: var(--bg-dark) !important;
}

.origins-summary-view-toggle button:hover:not(.active) {
    color: var(--text-primary) !important;
    background: var(--fill-soft) !important;
}

.origins-summary-chart-container {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 40px;
    padding: 15px 20px;
    flex-wrap: wrap;
    width: 100%;
}

@media (max-width: 768px) {
    .origins-summary-chart-container {
        flex-direction: column;
        gap: 24px;
    }
}

.donut-chart-svg {
    display: block;
    max-width: 280px;
    max-height: 280px;
    width: 100%;
    height: auto;
    flex-shrink: 0;
}

.donut-slice {
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), filter 0.25s ease, opacity 0.25s ease;
    cursor: pointer;
    transform-origin: 110px 110px;
}

.donut-slice:hover {
    transform: scale(1.03);
    filter: brightness(1.1) drop-shadow(0 0 5px var(--hover-color, rgba(0, 240, 255, 0.5)));
    opacity: 1 !important;
}

.donut-slice.dimmed {
    opacity: 0.35;
}

.donut-slice.highlighted {
    transform: scale(1.03);
    filter: brightness(1.1) drop-shadow(0 0 5px var(--hover-color, rgba(0, 240, 255, 0.5)));
    opacity: 1 !important;
}

.origins-chart-legend {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 240px;
    width: fit-content;
}

.legend-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.legend-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.15);
}

.legend-item.active-filter {
    background: rgba(0, 240, 255, 0.08);
    border-color: var(--neon-cyan);
}

.legend-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-item-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.legend-item-values {
    margin-left: auto;
    text-align: right;
    display: flex;
    flex-direction: column;
    font-family: var(--font-main);
}

.legend-item-pct {
    font-size: 12px;
    font-weight: 700;
    color: var(--neon-cyan);
}

.legend-item-weight {
    font-size: 10px;
    color: var(--text-secondary);
}

/* Spinner & Company Page Loading Utility */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Multi-Sale Mode Styles */
.multi-sale-checkbox-wrapper {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 10;
    display: none;
}

.multi-sale-active .multi-sale-checkbox-wrapper {
    display: block;
}

.multi-sale-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--neon-pink);
}

.multi-sale-item-row {
    background: var(--bg-card, rgba(18, 26, 43, 0.7));
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.multi-sale-item-row:hover {
    border-color: rgba(255, 42, 133, 0.3);
    background: var(--bg-surface-hover);
}

.multi-sale-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.multi-sale-item-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.multi-sale-item-meta {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-main);
}







/* Purchase supplier defaults */
.purchase-supplier-panel {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 12px;
    margin-bottom: 18px;
    border: 1px solid rgba(0, 240, 255, 0.16);
    border-radius: 8px;
    background: rgba(0, 240, 255, 0.035);
}
.purchase-supplier-panel .form-group {
    flex: 1;
    margin: 0;
}
.purchase-supplier-panel select {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    color: var(--text-primary);
    background: var(--bg-control);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: var(--font-main);
    font-size: 14px;
    outline: none;
}
.purchase-supplier-panel select:focus {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.2);
}
.purchase-supplier-panel .btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin: 0;
    white-space: nowrap;
}
.purchase-supplier-panel .btn[hidden] {
    display: none;
}
@media (max-width: 680px) {
    .purchase-supplier-panel {
        align-items: stretch;
        flex-direction: column;
    }
    .purchase-supplier-panel .btn {
        justify-content: center;
    }
}
/* ---------------------------------------------------------------------------
 * Trace loading feedback (trace-loading.js)
 *
 * One shared vocabulary for "busy": a progress bar pinned under the header, a
 * dimmed panel with a spinner for lists, an in-field spinner for search boxes,
 * and a spinner for buttons. Every Trace page used to go silent while it read
 * from Supabase; these are the states that say otherwise.
 * ------------------------------------------------------------------------ */
:root {
    /* Loading scrims. Redefined for the bright skin in skins.css so the busy
     * states read on a light page too. */
    --trace-scrim-strong: rgba(8, 13, 24, 0.88);
    --trace-scrim-soft: rgba(8, 13, 24, 0.45);
    --trace-busy-card-bg: rgba(6, 12, 22, 0.95);
    --trace-skeleton-base: rgba(255, 255, 255, 0.045);
    --trace-skeleton-sheen: rgba(0, 240, 255, 0.12);
}

.trace-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 4000;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.trace-topbar.is-active {
    opacity: 1;
    transform: translateY(0);
}

.trace-topbar-track {
    position: relative;
    height: 3px;
    overflow: hidden;
    background: rgba(0, 240, 255, 0.1);
}

.trace-topbar-fill {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 34%;
    border-radius: 0 3px 3px 0;
    background: linear-gradient(90deg, transparent, var(--neon-cyan), transparent);
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.55);
    animation: trace-topbar-sweep 1.15s ease-in-out infinite;
}

.trace-topbar-label {
    position: absolute;
    top: 9px;
    right: 18px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 11px;
    border-radius: 20px;
    font-family: var(--font-main);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: var(--neon-cyan);
    background: var(--trace-busy-card-bg);
    border: 1px solid rgba(0, 240, 255, 0.35);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    white-space: nowrap;
}

.trace-dot-spinner {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 2px solid rgba(0, 240, 255, 0.25);
    border-top-color: var(--neon-cyan);
    animation: trace-spin 0.75s linear infinite;
}

/* Busy regions ------------------------------------------------------------ */
.trace-busy {
    /* The stale content stays readable underneath, which is the point: the
     * panel is refreshing, not empty. An empty region would collapse to no
     * height at all and hide the overlay, so hold a floor while it is busy. */
    pointer-events: none;
    min-height: 140px;
}

.trace-busy > .trace-busy-overlay {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 26px 18px 18px;
    border-radius: inherit;
    background: linear-gradient(180deg, var(--trace-scrim-strong) 0%, var(--trace-scrim-strong) 45%, var(--trace-scrim-soft) 100%);
    backdrop-filter: blur(1.5px);
    -webkit-backdrop-filter: blur(1.5px);
    overflow: hidden;
}

.trace-busy-card {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    border-radius: 24px;
    background: var(--trace-busy-card-bg);
    border: 1px solid rgba(0, 240, 255, 0.3);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.28);
}

.trace-ring {
    position: relative;
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    flex: none;
}

.trace-ring::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: conic-gradient(
        from 0turn,
        rgba(0, 240, 255, 0) 0deg,
        rgba(0, 240, 255, 0.14) 150deg,
        var(--neon-cyan) 330deg,
        rgba(0, 240, 255, 0) 360deg
    );
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
    animation: trace-spin 1.05s linear infinite;
}

.trace-ring-mark {
    position: relative;
    font-size: 9px;
    line-height: 1;
    color: var(--neon-cyan);
    text-shadow: 0 0 10px rgba(0, 240, 255, 0.7);
    animation: trace-pulse 1.9s ease-in-out infinite;
}

.trace-busy-text {
    font-family: var(--font-main);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.trace-busy-hint {
    font-family: var(--font-main);
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.trace-busy-skeleton {
    width: 100%;
    max-width: 720px;
    display: flex;
    flex-direction: column;
    gap: 11px;
}

.trace-skeleton-row {
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(
        90deg,
        var(--trace-skeleton-base) 25%,
        var(--trace-skeleton-sheen) 37%,
        var(--trace-skeleton-base) 63%
    );
    background-size: 400% 100%;
    animation: trace-skeleton-shimmer 1.4s ease-in-out infinite;
}

.trace-skeleton-row:nth-child(2) { width: 90%; animation-delay: 0.1s; }
.trace-skeleton-row:nth-child(3) { width: 96%; animation-delay: 0.2s; }
.trace-skeleton-row:nth-child(4) { width: 78%; animation-delay: 0.3s; }

/* Busy search fields ------------------------------------------------------ */
input.trace-input-busy {
    /* The magnifier is an inline background image, so it has to be overruled
     * to make room for the spinner that replaces it. */
    background-image: none !important;
    border-color: rgba(0, 240, 255, 0.55) !important;
    box-shadow: 0 0 0 2px rgba(0, 240, 255, 0.1);
}

.trace-input-spinner {
    position: absolute;
    left: 9px;
    top: 50%;
    width: 13px;
    height: 13px;
    margin-top: -7px;
    border-radius: 50%;
    border: 2px solid rgba(0, 240, 255, 0.22);
    border-top-color: var(--neon-cyan);
    animation: trace-spin 0.7s linear infinite;
    pointer-events: none;
    z-index: 3;
}

/* The chip sits inside the field's right edge: the toolbars around these
 * search boxes are packed, and anything hung outside would land on the control
 * next to it. */
.trace-input-chip {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: 20px;
    font-family: var(--font-main);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--neon-cyan);
    background: rgba(0, 240, 255, 0.12);
    border: 1px solid rgba(0, 240, 255, 0.3);
    white-space: nowrap;
    pointer-events: none;
    z-index: 3;
}

/* Narrow fields have no room for the word next to the text being typed; the
 * in-field spinner carries the state there. */
@media (max-width: 700px) {
    .trace-input-chip { display: none; }
}

/* Busy buttons ------------------------------------------------------------ */
.trace-btn-busy {
    display: inline-flex !important;
    align-items: center;
    gap: 7px;
    opacity: 0.85;
    cursor: progress !important;
}

.trace-btn-spinner {
    width: 12px;
    height: 12px;
    flex: none;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.22);
    border-top-color: currentColor;
    animation: trace-spin 0.7s linear infinite;
}

/* Diamond Save Animation */
.trace-diamond-icon {
    width: 16px;
    height: 16px;
    display: inline-block;
    vertical-align: -2px;
    flex: none;
    filter: drop-shadow(0 0 5px rgba(0, 240, 255, 0.6));
}

.trace-diamond-fill {
    animation: trace-diamond-fill 1.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes trace-diamond-fill {
    0% {
        clip-path: polygon(0% 100%, 100% 100%, 100% 100%, 0% 100%);
        opacity: 0.35;
    }
    50% {
        clip-path: polygon(0% 45%, 100% 40%, 100% 100%, 0% 100%);
        opacity: 0.85;
    }
    85%, 100% {
        clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%);
        opacity: 1;
    }
}

/* Inline "still working" line used inside empty tables and dropdowns. */
.trace-inline-loading {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-family: var(--font-main);
    font-size: 13px;
    color: var(--text-secondary);
}

@keyframes trace-spin {
    to { transform: rotate(1turn); }
}

@keyframes trace-pulse {
    0%, 100% { opacity: 0.6; transform: scale(0.9); }
    50% { opacity: 1; transform: scale(1.1); }
}

@keyframes trace-topbar-sweep {
    0% { left: -35%; }
    100% { left: 100%; }
}

@keyframes trace-skeleton-shimmer {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

/* The words carry the state on their own; the motion is decoration. */
@media (prefers-reduced-motion: reduce) {
    .trace-topbar-fill,
    .trace-dot-spinner,
    .trace-ring::before,
    .trace-ring-mark,
    .trace-input-spinner,
    .trace-btn-spinner,
    .trace-skeleton-row {
        animation: none;
    }
    .trace-topbar-fill { left: 0; width: 100%; opacity: 0.5; }
}

/* ---------------------------------------------------------------------------
 * Inline origin lists ("Origins: [flag] Angola (55%), [flag] Australia (45%)")
 *
 * The flag reads as part of the country name it precedes, so it sits tight
 * against that name and keeps its distance from the text running before it.
 * ------------------------------------------------------------------------ */
.origin-inline {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.origin-inline img,
.origin-inline .origin-special-icon {
    margin-right: 3px !important;
    margin-left: 7px;
}

/* ---------------------------------------------------------------------------
 * Table pager
 *
 * The stock grid and the ledger hold one page of rows at a time - the rest is
 * still in the database - so each carries the controls for reaching the rest.
 * ------------------------------------------------------------------------ */
.trace-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
}

.trace-pager-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 6px;
    font-family: var(--font-main);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-control);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.trace-pager-btn:hover:not(:disabled) {
    color: var(--neon-cyan);
    border-color: rgba(0, 240, 255, 0.45);
    background: var(--bg-surface-hover);
}

.trace-pager-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.trace-pager-range {
    margin: 0 6px;
    font-family: var(--font-main);
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.trace-pager-range strong {
    color: var(--text-primary);
    font-weight: 600;
}

.trace-pager-page {
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    color: var(--neon-cyan);
    background: rgba(0, 240, 255, 0.1);
    border: 1px solid rgba(0, 240, 255, 0.25);
}
