/* ===========================================================================
   Sourcing Desk — Modern Design System
   High-end Arbitrage & Sourcing Analytics Dashboard
   =========================================================================== */

:root,
[data-theme="light"] {
    --bg: #F8FAFC;
    --surface: #FFFFFF;
    --surface-2: #F1F5F9;
    --surface-3: #E2E8F0;
    --ink: #0F172A;
    --muted: #64748B;
    --line: #E2E8F0;
    --line-soft: #F1F5F9;

    --accent: #4F46E5;
    --accent-hover: #4338CA;
    --accent-ink: #FFFFFF;
    --accent-soft: #EEF2FF;
    --accent-border: #C7D2FE;

    --go: #059669;
    --go-bg: #ECFDF5;
    --go-line: #A7F3D0;
    --go-ink: #065F46;

    --stop: #E11D48;
    --stop-bg: #FFF1F2;
    --stop-line: #FECDD3;
    --stop-ink: #9F1239;

    --warn: #D97706;
    --warn-bg: #FFFBEB;
    --warn-line: #FDE68A;
    --warn-ink: #92400E;

    --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
    --shadow-sm: 0 2px 4px 0 rgba(15, 23, 42, 0.06);
    --shadow-md: 0 6px 16px -2px rgba(15, 23, 42, 0.08), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 16px 32px -4px rgba(15, 23, 42, 0.1), 0 4px 12px -2px rgba(15, 23, 42, 0.06);
}

[data-theme="dark"] {
    --bg: #090D16;
    --surface: #111827;
    --surface-2: #182234;
    --surface-3: #1F2D44;
    --ink: #F8FAFC;
    --muted: #94A3B8;
    --line: #243044;
    --line-soft: #182234;

    --accent: #6366F1;
    --accent-hover: #818CF8;
    --accent-ink: #FFFFFF;
    --accent-soft: rgba(99, 102, 241, 0.16);
    --accent-border: rgba(99, 102, 241, 0.35);

    --go: #10B981;
    --go-bg: rgba(16, 185, 129, 0.12);
    --go-line: rgba(16, 185, 129, 0.28);
    --go-ink: #34D399;

    --stop: #F43F5E;
    --stop-bg: rgba(244, 63, 94, 0.12);
    --stop-line: rgba(244, 63, 94, 0.28);
    --stop-ink: #FB7185;

    --warn: #F59E0B;
    --warn-bg: rgba(245, 158, 11, 0.12);
    --warn-line: rgba(245, 158, 11, 0.28);
    --warn-ink: #FCD34D;

    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 5px 0 rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 20px 0 rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 16px 36px 0 rgba(0, 0, 0, 0.65);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: 'Plus Jakarta Sans', ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.12s ease;
}

a:hover {
    color: var(--accent-hover);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.mono {
    font-family: 'JetBrains Mono', ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
    font-feature-settings: "tnum" 1;
}

/* ---------------------------------------------------------------------
   Masthead
   --------------------------------------------------------------------- */

.masthead {
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.masthead-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand {
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    color: var(--ink);
}

.brand .dot {
    color: var(--accent);
}

.masthead-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.masthead-nav a {
    text-decoration: none;
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 600;
    padding: 7px 14px;
    border-radius: 8px;
    transition: all 0.15s ease;
}

.masthead-nav a:hover {
    color: var(--ink);
    background: var(--surface-2);
}

.masthead-nav a.current {
    color: var(--accent);
    background: var(--accent-soft);
    font-weight: 700;
}

.masthead-user {
    font-size: 0.82rem;
    color: var(--muted);
    padding-left: 14px;
    margin-left: 6px;
    border-left: 1px solid var(--line);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
}

.masthead-user .role-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--accent-soft);
    color: var(--accent);
}

.icon-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 9px;
    cursor: pointer;
    color: var(--muted);
    font-size: 1.05rem;
    padding: 0;
    transition: all 0.15s ease;
    box-shadow: var(--shadow-xs);
}

.icon-btn:hover {
    color: var(--ink);
    border-color: var(--muted);
    background: var(--surface-2);
    transform: translateY(-1px);
}

.text-btn {
    background: none;
    border: 1px solid transparent;
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    padding: 7px 12px;
    border-radius: 8px;
    transition: all 0.15s ease;
}

.text-btn:hover {
    color: var(--ink);
    background: var(--surface-2);
    border-color: var(--line);
}

/* ---------------------------------------------------------------------
   Buttons & Form Controls
   --------------------------------------------------------------------- */

button.primary {
    padding: 12px 22px;
    font-family: inherit;
    font-size: 0.94rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--accent-ink);
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25), var(--shadow-xs);
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

button.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35), var(--shadow-sm);
    filter: brightness(1.05);
}

button.primary:active {
    transform: translateY(1px);
    box-shadow: 0 1px 3px rgba(79, 70, 229, 0.2);
}

button.primary:disabled {
    background: var(--muted);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
    opacity: 0.7;
}

button.secondary {
    padding: 10px 18px;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 650;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 9px;
    cursor: pointer;
    box-shadow: var(--shadow-xs);
    transition: all 0.15s ease;
}

button.secondary:hover {
    border-color: var(--muted);
    background: var(--surface-2);
    transform: translateY(-1px);
}

label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select {
    width: 100%;
    padding: 10px 13px;
    font-size: 0.94rem;
    font-family: 'JetBrains Mono', ui-monospace, "SF Mono", monospace;
    color: var(--ink);
    background: var(--surface);
    border: 1.5px solid var(--line);
    border-radius: 9px;
    transition: all 0.15s ease;
    box-shadow: var(--shadow-xs);
}

input:focus,
select:focus {
    background: var(--surface);
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-soft);
}

input::placeholder {
    color: var(--muted);
    opacity: 0.6;
}

.field {
    margin-bottom: 16px;
}

.row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.hint {
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.45;
    margin-top: 6px;
}

.error-box {
    background: var(--stop-bg);
    border: 1px solid var(--stop-line);
    border-left: 4px solid var(--stop);
    color: var(--stop-ink);
    padding: 12px 16px;
    font-size: 0.88rem;
    font-weight: 500;
    border-radius: 10px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-xs);
}

.success-box {
    background: var(--go-bg);
    border: 1px solid var(--go-line);
    border-left: 4px solid var(--go);
    color: var(--go-ink);
    padding: 12px 16px;
    font-size: 0.88rem;
    font-weight: 500;
    border-radius: 10px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-xs);
}

.hidden {
    display: none !important;
}

/* ---------------------------------------------------------------------
   Panels & Cards
   --------------------------------------------------------------------- */

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    padding: 22px 24px;
}

.block {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow-xs);
    padding: 18px 20px;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.block:hover {
    border-color: var(--line-soft);
    box-shadow: var(--shadow-sm);
}

.block h3 {
    margin: 0 0 12px;
    font-size: 0.85rem;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line-soft);
    display: flex;
    align-items: center;
    gap: 8px;
}

dl {
    margin: 0;
}

.line {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 14px;
    padding: 7px 0;
    border-bottom: 1px solid var(--line-soft);
}

.line:last-child {
    border-bottom: none;
}

.line dt {
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 500;
}

.line dd {
    margin: 0;
    font-family: 'JetBrains Mono', ui-monospace, "SF Mono", monospace;
    font-feature-settings: "tnum" 1;
    font-size: 0.88rem;
    font-weight: 600;
    text-align: right;
    color: var(--ink);
}

.line dd.good {
    color: var(--go);
    font-weight: 700;
}

.line dd.bad {
    color: var(--stop);
    font-weight: 700;
}

.line.total {
    border-top: 2px solid var(--line);
    border-bottom: none;
    margin-top: 8px;
    padding-top: 10px;
}

.line.total dt {
    color: var(--ink);
    font-weight: 750;
    font-size: 0.9rem;
}

.line.total dd {
    font-weight: 750;
    font-size: 0.95rem;
}

/* ---------------------------------------------------------------------
   Product Image Showcase Frame
   --------------------------------------------------------------------- */

.product-image-frame {
    width: 144px;
    height: 144px;
    flex-shrink: 0;
    background: #FFFFFF;
    border: 1.5px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06), var(--shadow-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    padding: 8px;
    transition: all 0.2s ease;
}

.product-image-frame:hover {
    border-color: var(--accent);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.15), var(--shadow-sm);
}

.product-image-frame img {
    max-width: 92%;
    max-height: 92%;
    object-fit: contain;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.06));
}

.product-image-frame:hover img {
    transform: scale(1.08);
}

.product-image-frame .no-image-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
    text-align: center;
}

.product-image-frame .img-badge {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(4px);
    color: #FFFFFF;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.03em;
}

/* ---------------------------------------------------------------------
   Structured Metadata Pill Chips
   --------------------------------------------------------------------- */

.meta-chips-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 12px 0 16px;
}

.meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink);
    box-shadow: var(--shadow-xs);
    transition: all 0.15s ease;
}

.meta-chip:hover {
    background: var(--surface);
    border-color: var(--muted);
}

.meta-chip .chip-label {
    font-size: 0.68rem;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.meta-chip.asin-chip {
    font-family: 'JetBrains Mono', monospace;
    background: var(--accent-soft);
    border-color: var(--accent-border);
    color: var(--accent);
}

.meta-chip.asin-chip .chip-label {
    color: var(--accent);
}

.chip-copy-btn {
    background: none;
    border: none;
    padding: 2px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.12s ease;
}

.chip-copy-btn:hover {
    background: rgba(99, 102, 241, 0.2);
    transform: scale(1.1);
}

/* ---------------------------------------------------------------------
   Criteria / Verdict Status Pill
   --------------------------------------------------------------------- */

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 750;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    box-shadow: var(--shadow-xs);
}

.status-pill.status-pass {
    background: var(--go-bg);
    color: var(--go-ink);
    border: 1px solid var(--go-line);
}

.status-pill.status-fail {
    background: var(--stop-bg);
    color: var(--stop-ink);
    border: 1px solid var(--stop-line);
}

.status-pill.status-estimate {
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--accent-border);
}

/* ---------------------------------------------------------------------
   Modern Action Buttons: Amazon, Keepa, etc.
   --------------------------------------------------------------------- */

.action-toolbar,
.jump {
    display: flex !important;
    align-items: center !important;
    gap: 14px !important;
    flex-wrap: wrap !important;
    margin: 18px 0 24px !important;
}

.btn-action,
.jump a {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px !important;
    padding: 12px 24px !important;
    border-radius: 10px !important;
    font-size: 0.92rem !important;
    font-weight: 800 !important;
    text-decoration: none !important;
    cursor: pointer !important;
    transition: all 0.15s ease !important;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15) !important;
    letter-spacing: -0.01em !important;
}

.btn-action:hover,
.jump a:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.22) !important;
}

.btn-action:active,
.jump a:active {
    transform: translateY(0) !important;
}

.btn-action.btn-amazon,
.jump a:first-child {
    background: linear-gradient(180deg, #FFA724 0%, #FF9900 100%) !important;
    color: #111111 !important;
    border: 1.5px solid #D97706 !important;
    box-shadow: 0 3px 8px rgba(217, 119, 6, 0.35) !important;
}

.btn-action.btn-amazon:hover,
.jump a:first-child:hover {
    background: linear-gradient(180deg, #FFB84D 0%, #FFA724 100%) !important;
    box-shadow: 0 6px 18px rgba(217, 119, 6, 0.45) !important;
    color: #000000 !important;
}

.btn-action.btn-keepa,
.jump a:nth-child(2) {
    background: linear-gradient(180deg, #0284C7 0%, #0369A1 100%) !important;
    color: #FFFFFF !important;
    border: 1.5px solid #075985 !important;
    box-shadow: 0 3px 8px rgba(2, 132, 199, 0.35) !important;
}

.btn-action.btn-keepa:hover,
.jump a:nth-child(2):hover {
    background: linear-gradient(180deg, #0EA5E9 0%, #0284C7 100%) !important;
    box-shadow: 0 6px 18px rgba(2, 132, 199, 0.45) !important;
    color: #FFFFFF !important;
}

/* ---------------------------------------------------------------------
   Verdict Hero Card
   --------------------------------------------------------------------- */

.verdict {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 24px 26px;
    border: 1px solid var(--line);
    border-left: 6px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow-md);
    flex-wrap: wrap;
    margin-bottom: 20px;
    position: relative;
}

.verdict.go {
    border-left-color: var(--go);
}

.verdict.stop {
    border-left-color: var(--stop);
}

.verdict.estimate {
    border-left-color: var(--accent);
}

.verdict .info {
    flex: 1 1 300px;
    min-width: 0;
}

.verdict h2 {
    margin: 0 0 6px;
    font-size: 1.15rem;
    font-weight: 750;
    line-height: 1.35;
    letter-spacing: -0.01em;
    color: var(--ink);
}

.verdict .figure {
    text-align: right;
    flex-shrink: 0;
    background: var(--surface-2);
    border: 1px solid var(--line);
    padding: 16px 22px;
    border-radius: 14px;
    min-width: 190px;
}

.figure .figure-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 2px;
}

.figure .amount {
    font-family: 'JetBrains Mono', monospace;
    font-feature-settings: "tnum" 1;
    font-size: 2.2rem;
    font-weight: 750;
    line-height: 1.1;
    letter-spacing: -0.03em;
    display: block;
}

.verdict.go .figure .amount {
    color: var(--go);
}

.verdict.stop .figure .amount {
    color: var(--stop);
}

.verdict.estimate .figure .amount {
    color: var(--accent);
}

.figure .stats-pills {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

.figure .mini-stat {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--line);
    padding: 2px 7px;
    border-radius: 6px;
}

.figure .mini-stat strong {
    color: var(--ink);
    font-weight: 700;
}

@media (max-width: 640px) {
    .verdict .figure {
        text-align: left;
        width: 100%;
    }
    .figure .stats-pills {
        justify-content: flex-start;
    }
}

/* ---------------------------------------------------------------------
   Rejection & Warning Alert Cards
   --------------------------------------------------------------------- */

.flags {
    display: flex;
    flex-direction: column;
    gap: 9px;
    margin: 0 0 22px;
}

.flag-banner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 13px 16px;
    font-size: 0.88rem;
    border-radius: 12px;
    box-shadow: var(--shadow-xs);
    border: 1px solid;
}

.flag-banner.stop {
    background: var(--stop-bg);
    border-color: var(--stop-line);
    color: var(--stop-ink);
}

.flag-banner.warn {
    background: var(--warn-bg);
    border-color: var(--warn-line);
    color: var(--warn-ink);
}

.flag-banner .flag-icon {
    flex-shrink: 0;
    margin-top: 2px;
}

.flag-banner .flag-content {
    flex: 1;
    font-weight: 600;
}

/* ---------------------------------------------------------------------
   Data Blocks Grid
   --------------------------------------------------------------------- */

.blocks {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
}

.approval {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 14px;
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-soft);
    padding: 7px 14px;
    border-radius: 8px;
    transition: all 0.15s ease;
}

.approval:hover {
    background: var(--accent);
    color: var(--accent-ink);
}

/* ---------------------------------------------------------------------
   Empty / Loading states
   --------------------------------------------------------------------- */

.placeholder {
    background: var(--surface);
    border: 1.5px dashed var(--line);
    border-radius: 16px;
    padding: 48px 32px;
    color: var(--muted);
    text-align: center;
    max-width: 500px;
    margin: 0 auto;
}

.placeholder strong {
    display: block;
    color: var(--ink);
    font-size: 1.15rem;
    font-weight: 750;
    margin-bottom: 8px;
}

.placeholder p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

.spinner {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    padding: 36px 24px;
    color: var(--ink);
    font-size: 0.92rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.spinner-icon {
    width: 22px;
    height: 22px;
    border: 2.5px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---------------------------------------------------------------------
   Settings block
   --------------------------------------------------------------------- */

.settings-block {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--line-soft);
}

.settings-label {
    font-size: 0.75rem;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 14px;
}