/* ngs_repricer_ui — minimal, dense, no framework */

:root {
  --bg: #0f1419;
  --bg-card: #1a2129;
  --bg-row: #151b22;
  --bg-row-alt: #1a2129;
  --fg: #d4d4d4;
  --fg-muted: #888;
  --accent: #7fc0ff;
  --border: #2a3540;
  --hot: #e85a4f;
  --warm: #e6b800;
  --cold: #888;
  --alert: #ff5252;
  --good: #4caf50;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  /* Sticky top nav — stays visible site-wide while scrolling */
  position: sticky;
  top: 0;
  z-index: 8;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

nav { display: flex; gap: 16px; align-items: baseline; }
nav .brand { font-weight: 700; color: var(--accent); font-size: 16px; }
nav a {
  color: var(--fg);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 4px;
}
nav a:hover { background: rgba(255,255,255,0.05); }
.who { color: var(--fg-muted); font-size: 12px; }

main { padding: 16px; max-width: 100%; }

footer {
  border-top: 1px solid var(--border);
  padding: 8px 16px;
  color: var(--fg-muted);
  text-align: center;
}

/* ---------- summary tiles ---------- */
.tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}
.tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 8px;
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  white-space: nowrap;
}
.tile.hot { border-color: var(--hot); }
.tile.warm { border-color: var(--warm); }
.tile.cold { border-color: var(--cold); }
.tile.realcold { border-color: var(--accent); }
.tile.alert { border-color: var(--alert); background: rgba(255, 82, 82, 0.1); }
/* Clickable summary tiles — behave like buttons, highlight the active filter. */
a.tile-link { text-decoration: none; color: var(--fg); cursor: pointer; }
a.tile-link:hover { filter: brightness(1.25); }
.tile.tile-active { box-shadow: inset 0 0 0 1px currentColor; background: rgba(127, 192, 255, 0.12); }
.tile .t-num { font-size: 14px; font-weight: 700; }
.tile .t-lbl { font-size: 10px; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.3px; }

/* Pause-all form rendered inline at the end of the tile strip */
.tile-pauseall {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;   /* push to the right end of the flex strip */
}
.tile-pauseall input[type="text"] {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 3px 8px;
  font-size: 12px;
  border-radius: 4px;
  width: 200px;
}

/* ---------- filters ---------- */
.filters {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  /* Sticky filter/search bar across every page that uses .filters.
     Sits BELOW the top nav header (~44px tall). */
  position: sticky;
  top: 44px;
  z-index: 7;
  /* White search/filter bar (Mustafa) — stands out from the dark theme. Text,
     borders and placeholder are darkened below so they stay readable on white. */
  background: #ffffff;
  padding: 6px 8px;
  border-radius: 4px;
}
.filters input, .filters select, .filters button {
  background: #ffffff;
  border: 1px solid #ccd2d8;
  color: #1a2129;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 13px;
}
.filters input::placeholder { color: #8a929b; }
.filters button {
  background: var(--accent);
  color: white;
  cursor: pointer;
  border-color: var(--accent);
}
.filters button:hover { filter: brightness(1.1); }
.filters .reset { color: var(--fg-muted); text-decoration: none; font-size: 13px; }
.filters .count { color: var(--fg-muted); font-size: 12px; margin-left: auto; }

/* ---------- grid tables ---------- */
table.grid {
  width: 100%;
  /* border-collapse:collapse BREAKS position:sticky on <th> in Chrome.
     Use separate + border-spacing:0 to mimic collapse visually while
     keeping the sticky header working. */
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-card);
  font-size: 13px;
}
table.grid.small { font-size: 12px; }
table.grid th, table.grid td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
table.grid th {
  background: var(--bg-row);
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
  /* Sticky column header — applies to every .grid table site-wide.
     Sits BELOW the top nav (44px) + .filters bar (~48px) = ~92px.
     !important because some downstream rules (e.g. cursor: grab on overview)
     were silently overriding `position` via the cascade. */
  position: -webkit-sticky !important;
  position: sticky !important;
  top: 92px;
  z-index: 4;
  background-clip: padding-box;
  box-shadow: inset 0 -1px 0 var(--border);
}
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid tbody tr:nth-child(even) { background: var(--bg-row-alt); }
table.grid tbody tr:hover { background: rgba(127, 192, 255, 0.08); }
table.grid a { color: var(--accent); text-decoration: none; }
table.grid a:hover { text-decoration: underline; }
table.grid .empty { text-align: center; color: var(--fg-muted); padding: 24px; }

/* tier-color row accents */
tr.row-hot td:first-child { border-left: 3px solid var(--hot); }
tr.row-warm td:first-child { border-left: 3px solid var(--warm); }
tr.row-cold td:first-child { border-left: 3px solid var(--cold); }
tr.stuck { background: rgba(255, 82, 82, 0.08) !important; }

/* flag chips */
/* `display: flex` on a <td> breaks border-collapse continuity (row border
   becomes broken). Keep the cell as a normal table-cell and space chips with
   margin instead of gap. */
td.flags { white-space: nowrap; }
.flag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  margin-right: 4px;
}
.flag:last-child { margin-right: 0; }
.flag.stuck { background: var(--alert); color: white; }
.flag.mc { background: #4a3a8a; color: white; }
.flag.bundle { background: #2a5a3a; color: white; }
.flag.oos { background: #b04020; color: white; font-weight: 700; }
.flag.ended { background: #555; color: white; font-weight: 700; }
/* OOS-only toggle pill in the filter bar */
.oos-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 14px;
  border: 1px solid #6a4030;
  background: #2a1c18;
  color: #d8a090;
  font-size: 0.85em;
  font-weight: 600;
  text-decoration: none;
  margin-left: 6px;
}
.oos-pill:hover { filter: brightness(1.25); }
.oos-pill.active {
  background: #b04020;
  border-color: #ff8060;
  color: white;
  box-shadow: 0 0 0 2px rgba(255,128,96,0.35);
}

/* diff column for change log */
.diff .old { color: var(--fg-muted); }
.diff .arr { color: var(--fg-muted); margin: 0 6px; }
.diff .new { color: var(--good); font-weight: 600; }
.reason { color: var(--fg-muted); font-style: italic; white-space: normal; max-width: 400px; }

/* ---------- detail page ---------- */
.back-link { margin-bottom: 12px; }
.back-link a { color: var(--accent); text-decoration: none; }
.back-link a:hover { text-decoration: underline; }
h1 { margin: 8px 0 12px; font-size: 22px; }
.tier-tag { font-size: 13px; padding: 2px 8px; border-radius: 3px; vertical-align: middle; margin-left: 6px; }
.tier-tag.tier-hot { background: rgba(232, 90, 79, 0.2); }
.tier-tag.tier-warm { background: rgba(230, 184, 0, 0.2); }
.tier-tag.tier-cold { background: rgba(136, 136, 136, 0.2); }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
}
.card.span2 { grid-column: span 2; }
/* Full-row span — for wide tables (competitor tables) that shouldn't share
   the grid row with anything else. Use on sections that contain tables with
   8+ columns or that need every pixel of width. */
.card.span-full { grid-column: 1 / -1; }
.card h2 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.card dl { display: grid; grid-template-columns: 140px 1fr; gap: 4px 12px; margin: 0; font-size: 13px; }
.card dt { color: var(--fg-muted); }
.card dd { margin: 0; font-variant-numeric: tabular-nums; }
.card dd.reason { font-style: italic; color: var(--fg-muted); }

.comp-list { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.comp-list li { padding: 2px 0; }
.comp-list a { color: var(--accent); text-decoration: none; font-weight: 600; }
.comp-list a:hover { text-decoration: underline; filter: brightness(1.15); }
/* Catch-all: any anchor inside a card section (bundle components, etc.) gets
   the same readable accent treatment unless it's already styled elsewhere. */
.card a:not([class]) { color: var(--accent); text-decoration: none; }
.card a:not([class]):hover { text-decoration: underline; }
.muted { color: var(--fg-muted); font-size: 12px; }

/* ---------- Phase 2 controls ---------- */
.flash-stack { margin: 10px 0; display: grid; gap: 6px; }
.flash {
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
  border: 1px solid var(--border);
}
.flash-ok   { background: rgba(46, 160, 67, 0.12); border-color: #2ea043; color: #7ddc8a; }
.flash-warn { background: rgba(245, 158, 11, 0.12); border-color: #b08000; color: #f5c34c; }
.flash-error{ background: rgba(220, 53, 69, 0.12); border-color: #d44; color: #ff8888; }

.banner {
  margin: 8px 0 12px;
  padding: 10px 14px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}
.banner-pause {
  background: rgba(245, 158, 11, 0.16);
  border: 1px solid #b08000;
  color: #f5c34c;
}
.banner form.inline { margin-left: auto; }

.global-controls {
  display: flex;
  gap: 8px;
  margin: 8px 0 12px;
  align-items: center;
}
.global-controls input[type=text] {
  flex: 1;
  max-width: 360px;
  padding: 6px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--fg);
  border-radius: 4px;
  font-size: 13px;
}

button, .btn-pause, .btn-resume, .btn-force, .btn-ack, .btn-pauseall, .btn-mini {
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 13px;
  background: var(--bg-card);
  color: var(--fg);
  font-family: inherit;
}
button:hover { filter: brightness(1.15); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-pause     { background: #4a3a0c; color: #f5c34c; border-color: #8a6a1c; }
.btn-pauseall  { background: #6a2020; color: #ff9d9d; border-color: #b34040; font-weight: 600; }
.btn-resume    { background: #1d4d2a; color: #7ddc8a; border-color: #2ea043; }
.btn-force     { background: #2a3d6a; color: #9ec4ff; border-color: #3a6ab0; }
.btn-ack       { background: #5a3a2a; color: #ffcc99; border-color: #b06a40; }
.btn-mini      { padding: 3px 8px; font-size: 11px; }
.btn-retire    { background: #3a1a14; color: #ff8c70; border-color: #6a3020; margin-left: 4px; }
.btn-retire:hover { background: #5a2418; }

form.inline { display: inline-block; margin: 0; }
.sku-controls {
  margin: 10px 0 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.sku-controls input[type=text] {
  padding: 4px 8px; background: var(--bg-card); border: 1px solid var(--border);
  color: var(--fg); border-radius: 4px; font-size: 12px; min-width: 180px;
}
.sku-controls .muted { margin-left: 4px; }

.actions { white-space: nowrap; }
.row-paused-row, tr.paused-row { opacity: 0.55; }
.tile.paused      { background: rgba(245, 158, 11, 0.10); border-color: #8a6a1c; }
.flag.paused      { background: rgba(245, 158, 11, 0.20); color: #f5c34c; }
.flag.pending     { background: rgba(110, 160, 255, 0.18); color: #9ec4ff; }
.tier-tag.tier-paused  { background: rgba(245, 158, 11, 0.25); color: #f5c34c; }
.tier-tag.tier-pending { background: rgba(110, 160, 255, 0.25); color: #9ec4ff; }

/* ---------- eBay link icons ---------- */
.ebay-icons { white-space: nowrap; display: flex; gap: 4px; }
.ebay-icon {
  display: inline-block;
  width: 22px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--border);
}
.ebay-icon.ebay-sdffs { background: #5a2020; color: #ff8888; border-color: #9a3030; }  /* red */
.ebay-icon.ebay-tn    { background: #5a3a0c; color: #ffa040; border-color: #a8651c; }  /* UT orange */
.ebay-icon.ebay-dg    { background: #1c3a5a; color: #7eb2ff; border-color: #3a6ab0; }  /* blue */
/* GB: renders the actual GunBroker favicon as an <img>, so styling stays minimal —
   just box-sizing to match the S/T/D letter badges. The img child holds the visual.
   Inline-flex centers the 20x20 favicon in the 22x22 .ebay-icon box on both axes,
   keeping it vertically aligned with the eBay favicon prefix on other rows. */
.ebay-icon.ebay-gb { background: transparent; border-color: #444; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.ebay-icon.ebay-gb img { display: block; }
/* Marketplace prefix favicon (eBay) sits before the S/T/D letter badges on
   eBay rows, mirroring the GB favicon role on GB rows. 20x20 to match the
   GB img dimensions so both rows have the same vertical line-up. */
.marketplace-favicon { vertical-align: middle; margin-right: 2px; border-radius: 2px; }
.ebay-icons { line-height: 22px; }
.ebay-icons img { vertical-align: middle; }

/* Top bar: tiles + bulk action + pause-all on a single horizontal row.
   Each section keeps its own styling; flex-wrap lets it gracefully wrap to a
   second row on narrow screens. */
.topbar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.topbar-row .tiles { margin-bottom: 0; }
.topbar-row .bulk-inline { margin: 0; flex: 1 1 auto; }
.topbar-row .bulk-toolbar { margin: 0; padding: 4px 8px; }
.topbar-row .tile-pauseall { margin: 0; }
.ebay-icon.ebay-sdffs:hover, .ebay-icon.ebay-tn:hover, .ebay-icon.ebay-dg:hover, .ebay-icon.ebay-gb:hover {
  filter: brightness(1.3);
}
.ebay-icon.ebay-off {
  background: transparent; color: #555; border-color: #333; cursor: not-allowed;
}
/* OUT_OF_STOCK: strikethrough + amber outline glow. Composed on top of the
   .ebay-sdffs / .ebay-tn / .ebay-dg base colors so the store stays identifiable.
   Tooltip on the <a> spells out OUT_OF_STOCK. */
.ebay-icon.ebay-oos {
  text-decoration: line-through;
  border-color: #f0c040 !important;
  box-shadow: 0 0 0 2px rgba(240,192,64,0.45);
}
a.upc-search {
  font-size: 10px;
  color: var(--accent);
  text-decoration: none;
  margin-left: 4px;
  padding: 1px 4px;
  border-radius: 3px;
  border: 1px solid var(--accent);
}
a.upc-search:hover { filter: brightness(1.25); border-color: var(--accent); }

/* ---------- Copy-to-clipboard icon (SKU / UPC) ---------- */
.copy-btn {
  font-size: 11px;
  line-height: 1;
  color: var(--fg-muted);
  background: none;
  border: none;
  margin-left: 3px;
  padding: 1px 3px;
  border-radius: 3px;
  cursor: pointer;
  opacity: 0.55;
  vertical-align: baseline;
}
.copy-btn:hover { opacity: 1; color: var(--accent); background: rgba(127,192,255,0.12); }
.copy-btn.copied { opacity: 1; color: #4caf50; }
.copy-btn.copy-failed { opacity: 1; color: #c44444; }

/* ---------- Tier change buttons (Phase 2) ---------- */
.tier-divider { color: var(--border); padding: 0 8px; }
.tier-label { color: var(--fg-muted); font-size: 12px; }
.btn-tier {
  cursor: pointer;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--fg);
}
.btn-tier:hover { filter: brightness(1.2); }
.btn-tier-current {
  background: rgba(110, 160, 255, 0.18);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
  cursor: default;
}
.btn-tier-hot:hover  { border-color: #d44; color: #ff8888; }
.btn-tier-warm:hover { border-color: #b08000; color: #f5c34c; }
.btn-tier-cold:hover { border-color: #888; color: #ccc; }
.btn-tier-real-cold:hover { border-color: #4080ff; color: #7fb0ff; }

/* ---------- Active nav indicator ---------- */
nav a.nav-active {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
  padding-bottom: 2px;
  font-weight: 600;
}

/* ---------- Phase 3 edit-rule form ---------- */
form.edit-rule { margin: 0; }
.edit-rule-dl input[type=number] {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 3px 6px;
  border-radius: 3px;
  font-family: inherit;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  width: 100px;
}
.edit-rule-dl input[type=number]:focus { border-color: var(--accent); outline: none; }
.edit-rule-dl .prefix {
  color: var(--fg-muted);
  margin-right: 2px;
}
.big-change-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.big-change-row input[type=text] {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 5px 8px;
  border-radius: 3px;
  font-family: inherit;
  font-size: 12px;
  font-family: monospace;
}
.big-change-row input[type=text]:focus { border-color: var(--accent); outline: none; }
.btn-save {
  background: #1d4d2a;
  color: #7ddc8a;
  border-color: #2ea043;
  padding: 6px 16px;
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- Phase 3 competitor blocklist ---------- */
tr.row-blocked { opacity: 0.45; }
tr.row-blocked td:first-child::before { content: "⛔ "; }

/* ---------- Phase 4 bulk action toolbar ---------- */
.bulk-toolbar {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 0 0 8px;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  flex-wrap: wrap;
  font-size: 12px;
}
.bulk-toolbar .bulk-lbl  { color: var(--fg-muted); margin-right: 4px; }
.bulk-toolbar .bulk-sep  { color: var(--border); padding: 0 4px; }
.bulk-toolbar .bulk-reason {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 4px 6px;
  border-radius: 3px;
  font-size: 12px;
  width: 180px;
}
input[type=checkbox] { accent-color: var(--accent); }

/* ---------- login page + logout ---------- */
.logout-link { color: var(--accent); text-decoration: none; }
.logout-link:hover { text-decoration: underline; }
.login-wrap {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px 26px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-title { margin: 0; font-size: 20px; color: var(--accent); }
.login-sub { margin: 0 0 6px; color: var(--fg-muted); font-size: 13px; }
.login-label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--fg-muted); }
.login-label input {
  background: #ffffff;
  border: 1px solid #ccd2d8;
  color: #1a2129;
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 14px;
}
.login-btn {
  background: var(--accent);
  color: #06223b;
  border: none;
  border-radius: 4px;
  padding: 9px 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
}
.login-btn:hover { filter: brightness(1.08); }
.login-note { margin: 4px 0 0; color: var(--fg-muted); font-size: 11px; text-align: center; }

/* ---------- Rich tooltip (table-style hover popup) ----------
   Cells with a data-tip attribute get this instead of the browser's
   plain-text title bubble. Format of data-tip (one item per line):
     "# Heading"   → bold header line
     "Label|Value" → one aligned table row
     "> note"      → small muted note under the table
   Rendered by the delegated handler in base.html into #rich-tip.
   pointer-events:none so it never blocks clicks on the cell under it. */
#rich-tip {
  position: fixed;
  z-index: 999;
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.45;
  max-width: 360px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.55);
  pointer-events: none;
}
#rich-tip .rt-head {
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 5px;
  white-space: nowrap;
}
#rich-tip table { border-collapse: collapse; width: 100%; }
#rich-tip td { padding: 1px 0; border: 0; }
#rich-tip td.rt-label { color: var(--fg-muted); padding-right: 14px; white-space: nowrap; }
#rich-tip td.rt-val {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
  white-space: nowrap;
}
#rich-tip td.rt-val.rt-bad { color: var(--alert); }
#rich-tip .rt-note {
  margin-top: 5px;
  color: var(--fg-muted);
  font-size: 11px;
}
