:root {
    --bg: #0f1419;
    --panel: #1a1f2b;
    --border: #2a3142;
    --text: #d8dde6;
    --muted: #7a8599;
    --accent: #4dabf7;
    --green: #51cf66;
    --yellow: #ffd43b;
    --red: #ff6b6b;
    --orange: #ff922b;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.topbar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 10px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--panel);
    gap: 16px;
}
.brand { font-weight: 600; font-size: 16px; justify-self: start; }

/* Page navigation — centered, prominent */
.page-nav {
    justify-self: center;
    display: flex;
    gap: 6px;
    background: rgba(0,0,0,0.25);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--border);
}
.page-nav a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    font-size: 15px;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
    border-radius: 7px;
    transition: all 0.15s ease;
    letter-spacing: 0.2px;
}
.page-nav a:hover {
    color: var(--text);
    background: rgba(255,255,255,0.04);
}
.page-nav a.active {
    color: white;
    background: linear-gradient(180deg, rgba(77,171,247,0.25) 0%, rgba(77,171,247,0.15) 100%);
    box-shadow: 0 1px 0 rgba(77,171,247,0.4) inset, 0 0 0 1px rgba(77,171,247,0.3);
}
.page-nav .nav-icon { font-size: 16px; line-height: 1; }

/* User info & logout */
.user-nav {
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 16px;
}
.user-nav .user {
    color: var(--muted);
    font-size: 13px;
}
.user-nav .logout-link {
    color: var(--muted);
    text-decoration: none;
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    transition: all 0.15s ease;
}
.user-nav .logout-link:hover {
    color: var(--red);
    border-color: var(--red);
    background: rgba(255,107,107,0.05);
}

@media (max-width: 700px) {
    .topbar { grid-template-columns: 1fr; row-gap: 8px; padding: 10px 16px; }
    .brand, .page-nav, .user-nav { justify-self: center; }
}

main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 14px; margin: 0 0 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 16px;
}
.card-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.card-value { font-size: 28px; font-weight: 600; margin-top: 4px; }
.card-sub { font-size: 11px; color: var(--muted); margin-top: 4px; }
.card.pending { border-color: var(--orange); }
.card.pending .card-value { color: var(--orange); }
.card.below-be-card { border-color: var(--red); }

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 16px;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--border); }
th { font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; }
td code { background: rgba(255,255,255,0.05); padding: 1px 5px; border-radius: 3px; font-size: 12px; }

.muted { color: var(--muted); }
.pos { color: var(--green); }
.neg { color: var(--red); }

.status { font-size: 11px; padding: 2px 6px; border-radius: 3px; text-transform: uppercase; letter-spacing: 0.5px; }
.status-success { background: rgba(81,207,102,0.15); color: var(--green); }
.status-error   { background: rgba(255,107,107,0.15); color: var(--red); }
.status-running { background: rgba(255,212,59,0.15); color: var(--yellow); }

.tier { font-size: 11px; padding: 2px 8px; border-radius: 3px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.tier-hot  { background: rgba(255,107,107,0.15); color: var(--red); }
.tier-warm { background: rgba(255,146,43,0.15); color: var(--orange); }
.tier-cold { background: rgba(77,171,247,0.15); color: var(--accent); }

.action { font-size: 11px; padding: 2px 6px; border-radius: 3px; font-family: monospace; }
.action-increase { background: rgba(81,207,102,0.15); color: var(--green); }
.action-decrease { background: rgba(255,107,107,0.15); color: var(--red); }
.action-rejected { background: rgba(255,212,59,0.15); color: var(--yellow); }
.action-no_change { background: rgba(122,133,153,0.15); color: var(--muted); }
.action-skip_already_winning_no_competitor,
.action-skip_no_buybox,
.action-skip_no_breakeven,
.action-skip_we_not_in_buybox,
.action-skip_cannot_beat_buybox_without_loss,
.action-skip_free_shipping_without_delivery_tag_needs_manual_review {
    background: rgba(77,171,247,0.10); color: var(--accent);
}

.login-card {
    max-width: 360px;
    margin: 80px auto;
    padding: 32px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.login-card h1 { font-size: 22px; margin: 0 0 24px; }
.login-card label { display: block; margin-bottom: 16px; }
.login-card span { display: block; margin-bottom: 4px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.login-card input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-size: 14px;
}
.login-card input:focus { border-color: var(--accent); outline: none; }
.login-card button {
    width: 100%;
    padding: 10px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
}
.login-card button:hover { opacity: 0.9; }
.error {
    background: rgba(255,107,107,0.15);
    color: var(--red);
    padding: 8px 12px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 13px;
}

/* Apply preview page */
.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
/* Filter pills — segmented "action area" buttons. Warm amber tone, NOT blue
   (blue = navigation; this page is for actions on prices).
   Filters block spans the whole row to align column-by-column with the cards
   row above it; apply-btn wraps to its own row via flex-wrap on .action-bar. */
.filters {
    display: flex;
    gap: 8px;
    flex: 1 1 100%;
    background: rgba(0,0,0,0.25);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--border);
}
.filter-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    flex: 1 1 0;
    min-width: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 7px;
    color: var(--muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
    cursor: pointer;
}
.filter-pill:hover {
    color: var(--text);
    background: rgba(255,255,255,0.04);
}
.filter-pill.active {
    color: #1a1209;
    background: linear-gradient(180deg, #ffb84d 0%, #ff922b 100%);
    box-shadow: 0 1px 0 rgba(255,255,255,0.25) inset, 0 2px 6px rgba(255,146,43,0.35);
    font-weight: 600;
}
.filter-pill .filter-icon {
    font-size: 16px;
    line-height: 1;
    width: 18px;
    text-align: center;
}
.filter-pill .filter-count {
    background: rgba(0,0,0,0.18);
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    min-width: 24px;
    text-align: center;
}
.filter-pill.active .filter-count {
    background: rgba(0,0,0,0.22);
    color: #1a1209;
}

/* Apply button — the real action. Distinct red-orange so nobody confuses it
   with filters or navigation. Disabled state stays clear. */
.apply-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 28px;
    background: linear-gradient(180deg, #ff6b6b 0%, #e03131 100%);
    color: white;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(224,49,49,0.35), 0 1px 0 rgba(255,255,255,0.15) inset;
    transition: all 0.15s ease;
    min-width: 220px;
}
.apply-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(224,49,49,0.45), 0 1px 0 rgba(255,255,255,0.2) inset;
}
.apply-btn:disabled {
    background: linear-gradient(180deg, #2a3142 0%, #1f2530 100%);
    color: var(--muted);
    box-shadow: none;
    cursor: not-allowed;
    border-color: var(--border);
    opacity: 0.7;
}
.apply-btn-icon { font-size: 18px; line-height: 1; margin-bottom: 2px; }
.apply-btn-text { font-size: 15px; }
.apply-btn-sub { font-size: 11px; font-weight: 400; opacity: 0.75; margin-top: 3px; }

.panel-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.panel-header h2 { margin: 0; }

.table-scroll { overflow-x: auto; max-height: 70vh; }
.table-scroll table { font-size: 12px; }
.apply-table thead { position: sticky; top: 0; background: var(--panel); z-index: 1; }
.apply-table th { white-space: nowrap; }
.apply-table td { white-space: nowrap; }
.apply-table strong { color: var(--text); }
.apply-table tbody tr:hover { background: rgba(255,255,255,0.02); }
.row-select-col { width: 32px; text-align: center; }
.row-select-col input[type="checkbox"] { cursor: pointer; transform: scale(1.1); accent-color: var(--orange); }

/* Floating bulk-action bar */
.bulk-bar {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    background: linear-gradient(180deg, #232a3a 0%, #1a1f2b 100%);
    border: 1px solid rgba(255,107,107,0.4);
    box-shadow: 0 8px 24px rgba(0,0,0,0.5), 0 1px 0 rgba(255,255,255,0.08) inset;
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 100;
    min-width: 380px;
}
.bulk-bar-left { display: flex; align-items: center; gap: 12px; flex: 1; }
.bulk-bar-count { font-size: 14px; }
.bulk-bar-count strong { color: var(--orange); font-size: 16px; }
.bulk-clear {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
}
.bulk-clear:hover { color: var(--text); border-color: var(--muted); }

.bulk-apply {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    background: linear-gradient(180deg, #ff6b6b 0%, #e03131 100%);
    color: white;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(224,49,49,0.4), 0 1px 0 rgba(255,255,255,0.15) inset;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.bulk-apply:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(224,49,49,0.55);
}
.bulk-apply:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.bulk-apply.working {
    background: linear-gradient(180deg, #4dabf7 0%, #339af0 100%);
    box-shadow: 0 2px 8px rgba(77,171,247,0.4);
}
.bulk-apply-icon { font-size: 16px; }

.apply-result {
    margin: 16px 0;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
}
.apply-result.success { background: rgba(81,207,102,0.10); color: var(--green); border: 1px solid rgba(81,207,102,0.3); }
.apply-result.error   { background: rgba(255,107,107,0.10); color: var(--red); border: 1px solid rgba(255,107,107,0.3); }

/* Sortable headers */
.sortable-col {
    cursor: pointer;
    user-select: none;
    transition: color 0.15s ease, background 0.15s ease;
    position: relative;
}
.sortable-col:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.sortable-col.sorted-asc, .sortable-col.sorted-desc { color: var(--orange); }
.sort-ind { font-size: 11px; opacity: 0.9; }
