/* Balance Sheep — app chrome & components
   Fonts loaded in layout.php (IBM Plex Sans / IBM Plex Mono). */

:root {
  --rail: #171921;
  --rail-2: #20232C;
  --rail-3: #262A34;
  --rail-line: #262A34;
  --rail-mut: #7E8494;
  --rail-txt: #A9AEBB;
  --bg: #F5F5F2;
  --panel: #FFFFFF;
  --line: #E5E4DF;
  --line-soft: #EFEEE9;
  --row-line: #F5F4F0;
  --ink: #1D1F26;
  --mut: #6D7180;
  --faint: #9A9DA8;
  --brand: #4F46E5;
  --brand-dark: #4338CA;
  --brand-soft: #EEEDFC;
  --brand-line: #C7C4F4;
  --green: #3FBF7A;
  --green-ink: #14713E;
  --green-soft: #E7F5EE;
  --green-line: #BCE3CD;
  --red: #C93F36;
  --red-soft: #FBECEA;
  --red-line: #F2D7D3;
  --red-panel: #FEF6F5;
  --amber: #D97706;
  --etsy: #F1641E;
  --qb: #2CA01C;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.5;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.main { padding: 22px 26px 34px; min-width: 0; max-width: 1180px; }
/* Data-table pages (Products) opt out of the reading-width cap — their
   columns have real content to fill, and titles need the room. */
.main.wide { max-width: 1760px; }

/* ---------- Sidebar ---------- */
.rail {
  background: var(--rail);
  display: flex; flex-direction: column;
  padding: 18px 14px 16px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.rail-brand { display: flex; align-items: center; gap: 10px; padding: 0 4px; }
.rail-logo-img { width: 138px; max-width: 100%; height: auto; display: block; filter: brightness(0) invert(1); }
.rail-logo {
  width: 30px; height: 30px; border-radius: 8px; background: var(--brand);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 15px;
}
.rail-name { color: #fff; font-weight: 600; font-size: 14.5px; letter-spacing: .1px; }
.rail-tag { color: #767C8B; font-size: 10.5px; margin-top: 1px; }

.rail-label {
  color: #5C6270; font-size: 9.5px; font-weight: 700;
  letter-spacing: 1.2px; text-transform: uppercase;
  padding: 0 4px; margin: 20px 0 6px;
}
.store-card {
  width: 100%; display: flex; align-items: center; gap: 9px;
  background: var(--rail-2); border: 1px solid #2E3340; border-radius: 8px;
  padding: 8px 10px; text-align: left;
}
.store-tile {
  width: 24px; height: 24px; border-radius: 6px; flex: none;
  color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.store-meta { min-width: 0; flex: 1; }
.store-name { display: block; color: #fff; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.store-sub { display: block; color: var(--rail-mut); font-size: 10.5px; margin-top: 1px; }

.rail-nav { display: flex; flex-direction: column; gap: 2px; }
.rail-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 7px;
  color: var(--rail-txt); font-size: 13px; font-weight: 500;
  text-decoration: none;
}
.rail-link:hover { background: var(--rail-2); color: #E6E8ED; text-decoration: none; }
.rail-link.active { background: var(--rail-3); color: #fff; }
.rail-link svg { flex: none; }
.rail-badge {
  margin-left: auto; background: var(--brand); color: #fff;
  font-size: 10.5px; font-weight: 600; padding: 1px 7px; border-radius: 999px;
}
.rail-dot { margin-left: auto; width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.rail-dot.off { background: var(--red); }
.rail-spacer { flex: 1; }
.rail-sep { border-top: 1px solid var(--rail-line); padding-top: 10px; margin-top: 12px; }

.auto-card { background: var(--rail-2); border-radius: 8px; padding: 10px 12px; margin-top: 10px; }
.auto-head { display: flex; align-items: center; gap: 6px; color: #E6E8ED; font-size: 12px; font-weight: 600; }
.auto-sub { color: var(--rail-mut); font-size: 11px; margin-top: 3px; }

.user-row { display: flex; align-items: center; gap: 9px; margin-top: 12px; padding: 12px 4px 0; border-top: 1px solid var(--rail-line); }
.user-ava {
  width: 26px; height: 26px; border-radius: 50%; background: #3A3F4D;
  color: #fff; font-size: 11px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.user-name { color: #C6CAD3; font-size: 12.5px; }
.user-out { margin-left: auto; color: var(--rail-mut); font-size: 11.5px; }
.user-out:hover { color: #E6E8ED; text-decoration: none; }

/* ---------- Page head ---------- */
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -.2px; }
.page-sub { color: var(--mut); font-size: 12.5px; margin-top: 3px; }
.head-actions { margin-left: auto; display: flex; align-items: center; gap: 9px; }
.back-link { color: var(--mut); font-size: 12px; font-weight: 500; }
.back-link:hover { color: var(--ink); text-decoration: none; }

/* ---------- Pills / chips / badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); background: var(--panel);
  border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 500;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.pill .dot.off { background: var(--red); }
.pill small { color: var(--faint); font-weight: 400; font-size: 12px; }

.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px; }
.chip.new { background: var(--brand-soft); color: var(--brand); }
.chip.posted { background: var(--green-soft); color: var(--green-ink); }
.chip.error { background: var(--red-soft); color: var(--red); }
.chip.ignored { background: #F0EFEA; color: var(--mut); }
.chip.waiting { background: #FDF3E3; color: #92610C; }
.srcchip {
  background: #F0EFEA; border-radius: 999px; padding: 1px 8px;
  font-size: 10px; font-weight: 700; letter-spacing: .5px; color: var(--mut);
  text-transform: uppercase;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--brand); color: #fff; border: none; border-radius: 8px;
  padding: 9px 16px; font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.ghost { background: var(--panel); color: var(--ink); border: 1px solid #D8D7D0; font-weight: 500; }
.btn.ghost:hover { background: var(--line-soft); }
.btn.small { padding: 5px 13px; font-size: 12px; border-radius: 7px; }
.btn.outline { background: var(--panel); color: var(--brand); border: 1px solid var(--brand-line); }
.btn.outline:hover { background: var(--brand-soft); }
.btn.danger-quiet { background: none; border: none; color: var(--faint); font-weight: 500; padding: 5px 8px; }
.btn.danger-quiet:hover { color: var(--red); background: none; }
.btn[disabled], .btn.is-busy { opacity: .75; cursor: default; pointer-events: none; }
.btn.full { width: 100%; }

.spin {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.85); border-top-color: transparent;
  animation: pbspin .7s linear infinite; vertical-align: -2px;
}
.btn.ghost .spin, .btn.outline .spin { border-color: var(--brand); border-top-color: transparent; }
@keyframes pbspin { to { transform: rotate(360deg); } }

/* ---------- Banners ---------- */
.banner { border-radius: 8px; padding: 10px 14px; font-size: 12.5px; font-weight: 600; margin-bottom: 16px; }
.banner.ok { background: var(--green-soft); border: 1px solid var(--green-line); color: var(--green-ink); }
.banner.err { background: var(--red-soft); border: 1px solid var(--red-line); color: var(--red); }
.banner.warn { background: #FDF3E3; border: 1px solid #F0DCB8; color: #92610C; }
.banner a { font-weight: 600; }

/* ---------- KPI cards ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 15px 17px 13px; display: block; color: inherit; }
a.kpi:hover { text-decoration: none; border-color: #D2D0C9; }
.kpi .label { color: var(--mut); font-size: 10.5px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; display: flex; align-items: center; gap: 5px; }
.kpi .value { font-size: 28px; font-weight: 700; margin-top: 6px; }
.kpi .value.bad { color: var(--red); }
.kpi .note { color: var(--mut); font-size: 11.5px; margin-top: 3px; }
.kpi .note.accent { color: var(--brand); font-weight: 500; }
.kpi .note.bad { color: var(--red); font-weight: 500; }

/* ---------- Panels ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 18px; }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 13px 17px; border-bottom: 1px solid var(--line-soft); }
.panel-head .t { font-size: 13.5px; font-weight: 650; }
.panel-head .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.panel-body { padding: 13px 17px; }
.count-chip { background: var(--red-soft); color: var(--red); font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
.count-chip.zero { background: var(--green-soft); color: var(--green-ink); }
.two-col { display: grid; grid-template-columns: 1.45fr 1fr; gap: 18px; align-items: start; }

/* ---------- Attention rows ---------- */
.attn { display: flex; gap: 10px; padding: 14px 17px 16px; border-bottom: 1px solid var(--row-line); }
.attn:last-child { border-bottom: none; }
.attn .adot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); margin-top: 5px; flex: none; }
.attn .meta { color: var(--mut); font-size: 12px; }
.attn .title { font-size: 13px; font-weight: 600; margin-top: 3px; }
.attn .hint { color: var(--mut); font-size: 12.5px; line-height: 1.55; margin-top: 3px; }
.attn .acts { display: flex; align-items: center; gap: 8px; margin-top: 11px; }
.empty-note { padding: 26px; text-align: center; color: var(--mut); font-size: 13px; }

/* ---------- Activity feed ---------- */
.feed-row { display: flex; gap: 10px; padding: 11px 17px; border-top: 1px solid var(--row-line); }
.feed-row:first-child { border-top: none; }
.fdot { width: 7px; height: 7px; border-radius: 50%; margin-top: 5px; flex: none; background: var(--faint); }
.fdot.post, .fdot.connect { background: var(--green); }
.fdot.download { background: var(--brand); }
.fdot.skip { background: #B9BCC6; }
.fdot.error { background: var(--red); }
.fdot.unpost { background: var(--amber); }
.feed-msg { font-size: 12.8px; min-width: 0; }
.feed-when { color: var(--faint); font-size: 11.5px; margin-top: 2px; display: flex; align-items: center; gap: 6px; }

/* ---------- Tabs ---------- */
.tabs { display: inline-flex; gap: 4px; background: #EBEAE5; border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
.tabs a {
  display: inline-flex; align-items: center; gap: 7px;
  border-radius: 7px; padding: 6px 13px;
  font-size: 12.5px; font-weight: 500; color: var(--mut); text-decoration: none;
}
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { background: var(--panel); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.tabs .n { background: #E0DFD9; color: var(--mut); font-size: 10.5px; font-weight: 700; padding: 0 7px; border-radius: 999px; }
.tabs a.active .n.hot { background: var(--brand); color: #fff; }
.tabs .n.bad { background: var(--red-soft); color: var(--red); }

/* ---------- Info strip ---------- */
.strip {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 9px 17px; background: #FAFAF8; border-bottom: 1px solid var(--line-soft);
  font-size: 11.5px; color: var(--mut);
}
.strip .s-t { font-weight: 600; color: #3A3D47; }
.strip .s-n { color: var(--brand); font-weight: 700; }
.strip .s-arrow { color: #C9CBD3; }
.strip .tip { margin-left: auto; }

/* Bulk "Post selected" toolbar (Orders → New / Errors). */
.bulkbar {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 17px; background: #FAFAF8; border-bottom: 1px solid var(--line-soft);
}
.bulkbar form { display: flex; align-items: center; gap: 12px; margin: 0; }
.bulkbar .bulk-count { font-size: 11.5px; color: var(--mut); }
table.grid th.chk, table.grid td.chk { width: 1%; white-space: nowrap; }
table.grid td.chk input, table.grid th.chk input { cursor: pointer; margin: 0; }

/* ---------- Tables ---------- */
table.grid { width: 100%; border-collapse: collapse; }
table.grid th {
  text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line-soft);
  font-size: 10.5px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase; color: var(--faint);
}
table.grid td { padding: 10px 12px; border-bottom: 1px solid var(--row-line); font-size: 12.5px; vertical-align: middle; }
table.grid tr:last-child td { border-bottom: none; }
table.grid th:first-child, table.grid td:first-child { padding-left: 17px; }
table.grid th:last-child, table.grid td:last-child { padding-right: 17px; }
table.grid .num { text-align: right; }
table.grid td.num { font-weight: 600; }
table.grid .muted { color: var(--mut); font-weight: 400; }
.order-link { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 12px; font-weight: 600; }
tr.has-err td { border-bottom: none; }
tr.errrow td { padding: 0 17px 12px; border-bottom: 1px solid var(--row-line); font-size: 12px; color: var(--red); }
.err-line { padding: 0 17px 12px; font-size: 12px; color: var(--red); }
.totals-row td { font-size: 12px; font-weight: 650; border-top: 1px solid var(--line-soft); }
.totals-row .lbl { letter-spacing: .5px; color: var(--mut); text-transform: uppercase; font-size: 11px; }
.sku-tag { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 11.5px; background: #F0EFEA; border-radius: 4px; padding: 2px 7px; display: inline-block; }
.sku-tag.bad { background: var(--red-soft); color: var(--red); border: 1px solid var(--red-line); }
.sku-note { font-size: 10.5px; color: var(--red); font-weight: 600; display: block; margin-top: 2px; }
.sku-match { font-size: 10.5px; color: var(--mut); display: block; margin-top: 2px; }

/* ---------- Totals block (order detail) ---------- */
.sumlines { width: 290px; margin-left: auto; display: flex; flex-direction: column; gap: 6px; padding: 13px 17px; }
.sumlines .row { display: flex; font-size: 12.5px; align-items: center; }
.sumlines .row span:first-child { color: var(--mut); display: inline-flex; align-items: center; gap: 5px; }
.sumlines .row span:last-child { margin-left: auto; }
.sumlines .row .strike { color: var(--faint); text-decoration: line-through; }
.sumlines .row.sep { border-top: 1px solid var(--line-soft); padding-top: 7px; }
.sumlines .row.grand { font-size: 13px; font-weight: 650; }
.sumlines .row.grand span:first-child { color: var(--ink); }

/* ---------- Fix-it card ---------- */
.fixcard { background: var(--red-panel); border: 1px solid var(--red-line); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; }
.fixcard .f-title { font-size: 14px; font-weight: 650; }
.fixcard .f-sub { color: var(--mut); font-size: 12.5px; line-height: 1.55; margin-top: 4px; }
.fixcard .kbd { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 11.5px; background: #fff; border: 1px solid #E8C9C4; border-radius: 4px; padding: 0 5px; }
.fixcard .acts { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.fixcard .acts .acts-lead { font-size: 12px; }

/* Missing-SKU fix: two side-by-side options with an "or" divider. */
.fix-options { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: stretch; margin-top: 14px; }
.fix-opt { background: #fff; border: 1px solid var(--red-line); border-radius: 8px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.fix-opt .fo-head { font-size: 13px; font-weight: 650; }
.fix-opt .fo-sub { color: var(--mut); font-size: 12px; line-height: 1.5; margin-top: 0; }
.fix-opt .fo-form { margin-top: auto; padding-top: 4px; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.fix-opt .fo-form input[type=text] {
  flex: 1; min-width: 170px; padding: 8px 11px; border: 1px solid #D8D7D0; border-radius: 8px;
  font-family: inherit; font-size: 12.5px; color: var(--ink); background: #FAFAF8; outline: none;
}
.fix-opt .fo-form input[name=qbo_sku] { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 12px; }
.fix-opt .fo-form input[type=text]:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(79,70,229,.15); }
.fix-opt .kbd { border-color: var(--line); }
.fix-or { align-self: center; color: var(--faint); font-size: 11px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; }
@media (max-width: 900px) {
  .fix-options { grid-template-columns: 1fr; }
  .fix-or { justify-self: center; }
}

/* ---------- Key/value cards ---------- */
.kv { display: flex; flex-direction: column; gap: 9px; padding: 13px 17px; }
.kv .row { display: flex; font-size: 12.5px; align-items: center; }
.kv .row span:first-child { color: var(--mut); display: inline-flex; align-items: center; gap: 5px; }
.kv .row span:last-child { margin-left: auto; text-align: right; }

/* ---------- Connections ---------- */
.conn-group { color: var(--faint); font-size: 10.5px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase; margin: 0 0 8px; }
.conn-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 8px; }
.conn-head .conn-group { margin: 0; }
.conn-add { display: inline-flex; align-items: center; gap: 6px; }
.conn-add .plus { color: var(--brand); font-size: 13px; line-height: 1; }
.conn-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 16px 18px; margin-bottom: 18px;
  display: grid; grid-template-columns: auto 1fr auto auto auto; gap: 14px; align-items: center;
}
.conn-card.nc { grid-template-columns: auto 1fr auto auto; }
.conn-card.has-prefs { grid-template-columns: auto 1fr auto auto auto auto; }
.conn-tile.qb { background: #fff; border: 1px solid var(--line); }
.conn-tile.muted { background: var(--line); color: var(--faint); }
.conn-tile .etsy-wm { font-family: Georgia, 'Times New Roman', serif; font-size: 15px; font-weight: 600; color: #fff; letter-spacing: .2px; }
.conn-remove {
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  background: #fff; border: 1px solid #D8D7D0; border-radius: 8px; color: var(--faint); cursor: pointer;
}
.conn-remove:hover { color: var(--red); border-color: var(--red-line); background: var(--red-panel); }
.confirm-row {
  grid-column: 1 / -1; display: none; align-items: center; gap: 14px;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--red-line);
}
.confirm-row.open { display: flex; }
.confirm-row .msg { flex: 1; font-size: 12.5px; color: #3A3D47; }
.btn.danger { background: var(--red); color: #fff; }
.btn.danger:hover { background: #B23127; }
.conn-tile {
  width: 38px; height: 38px; border-radius: 9px; color: #fff;
  font-size: 15px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.conn-name { font-size: 13.5px; font-weight: 650; }
.conn-sub { color: var(--mut); font-size: 12px; margin-top: 2px; }
.conn-status { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.conn-token { display: inline-flex; align-items: center; gap: 5px; color: var(--mut); font-size: 11.5px; }
.foot-note { color: var(--faint); font-size: 11.5px; line-height: 1.6; max-width: 640px; }

/* ---------- Log page ---------- */
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.filters a {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--panel); color: var(--mut); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 13px; font-size: 12px; font-weight: 500; text-decoration: none;
}
.filters a:hover { border-color: #C9C7C0; color: var(--ink); text-decoration: none; }
.filters a.active { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 600; }
.filters .n { background: #F0EFEA; border-radius: 999px; padding: 0 7px; font-size: 10.5px; font-weight: 700; }
.filters a.active .n { background: rgba(255,255,255,.18); }
.loghead {
  padding: 8px 17px; background: #FAFAF8;
  border-bottom: 1px solid var(--line-soft); border-top: 1px solid var(--line-soft);
  font-size: 10.5px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: var(--faint);
}
.panel > .loghead:first-child { border-top: none; }
.log-row { display: grid; grid-template-columns: 10px 1fr auto 76px; gap: 12px; align-items: center; padding: 10px 17px; border-bottom: 1px solid var(--row-line); }
.log-row:last-child { border-bottom: none; }
.log-row .ldot { width: 8px; height: 8px; border-radius: 50%; }
.log-row .lmsg { font-size: 12.8px; min-width: 0; }
.log-row .ltime { color: var(--faint); font-size: 11.5px; text-align: right; }

/* ---------- Forms / settings ---------- */
.fgroup { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 18px; }
.fgroup .fg-head { display: flex; align-items: center; gap: 6px; padding: 13px 17px; border-bottom: 1px solid var(--line-soft); }
.fgroup .fg-head .t { font-size: 13.5px; font-weight: 650; }
.frow { display: grid; grid-template-columns: 1fr 240px; gap: 16px; align-items: center; padding: 12px 17px; border-bottom: 1px solid var(--row-line); }
.frow:last-child { border-bottom: none; }
.frow .flabel { font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.frow .fsub { color: var(--mut); font-size: 11.5px; margin-top: 2px; font-weight: 400; }
.frow input[type=text], .frow input[type=password], .frow select {
  width: 100%; padding: 8px 11px; border: 1px solid #D8D7D0; border-radius: 8px;
  font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 12.5px; color: var(--ink);
  background: #FAFAF8; outline: none;
}
.frow select { font-family: 'IBM Plex Sans', system-ui, sans-serif; }
.frow input:focus, .frow select:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(79,70,229,.15); }
.savebar { display: flex; align-items: center; gap: 12px; }
.savebar .note { color: var(--faint); font-size: 11.5px; }

/* ---------- Tooltip ---------- */
.tip { position: relative; display: inline-flex; align-items: center; cursor: help; color: var(--faint); }
.tip:hover, .tip:focus { color: var(--brand); outline: none; }
.tipbox {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: #16181F; color: #E6E8ED;
  font-size: 11.5px; font-weight: 400; line-height: 1.55; letter-spacing: 0; text-transform: none;
  padding: 9px 12px; border-radius: 8px; width: 236px;
  opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 60;
  box-shadow: 0 10px 26px rgba(0,0,0,.35); text-align: left; white-space: normal;
}
.tip:hover .tipbox, .tip:focus .tipbox { opacity: 1; }
.tipbox.right { left: auto; right: -4px; transform: none; }
.tipbox.left { left: -8px; transform: none; }
/* Placement fixes: 'down' opens below (for icons near the top of the page);
   'side' is a narrower box kept inboard so the sidebar can't clip it. */
.tipbox.down { bottom: auto; top: calc(100% + 8px); }
.tipbox.side { left: -95px; right: auto; transform: none; width: 190px; }
.rail .tip { color: var(--rail-mut); }
.rail .tip:hover { color: #E6E8ED; }

/* ---------- Settings (tabbed) ---------- */
.stabs { display: flex; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.stabs a { padding: 0 20px 11px 0; margin-bottom: -1px; font-size: 13px; font-weight: 500; color: var(--mut); border-bottom: 2px solid transparent; white-space: nowrap; }
.stabs a:hover { color: var(--ink); text-decoration: none; }
.stabs a.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

.spanel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 20px 22px 8px; margin-bottom: 18px; }
.spanel .shead { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
.spanel h2 { margin: 0; font-size: 15px; font-weight: 650; }
.sdesc { font-size: 12.5px; color: var(--mut); margin: 4px 0 0; max-width: 560px; line-height: 1.5; }
.refresh { display: flex; align-items: center; gap: 10px; white-space: nowrap; flex-shrink: 0; }
.refresh .when { font-size: 12px; color: var(--faint); }

.sgroup { border-top: 1px solid var(--line-soft); }
.sgroup.reset-zone { margin-top: 36px; border-top: 2px solid var(--line-soft); }
.sgroup.reset-zone .srow { border-bottom: none; }
.sgroup.reset-zone .confirm-row { margin-top: 0; padding-bottom: 14px; }
.srow { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 14px 0; border-bottom: 1px solid var(--line-soft); }
.sgroup .srow:last-child { border-bottom: none; }
.srow .info { flex: 1 1 auto; min-width: 0; }
.srow .info .name { font-size: 13.5px; font-weight: 600; }
.srow .info .desc { font-size: 12px; color: var(--mut); margin-top: 2px; line-height: 1.5; max-width: 460px; }
.srow .ctrl { flex: 0 0 300px; max-width: 300px; text-align: right; }
.srow .ctrl select, .srow .ctrl input[type=text], .srow .ctrl input[type=time], .srow .ctrl input[type=date] {
  width: 100%; padding: 9px 12px; border: 1px solid #D8D7D0; border-radius: 8px;
  font-family: inherit; font-size: 13px; color: var(--ink); background: #fff; outline: none;
}
.srow .ctrl select:focus, .srow .ctrl input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.13); }
.srow.sub { border-left: 3px solid var(--brand-soft); background: #FAFAF9; margin: 0 -22px; padding-left: 38px; padding-right: 22px; }
.srow .static { font-size: 13px; font-weight: 600; }
.srow .static.muted { color: var(--faint); font-weight: 400; }
.ssec { font-size: 10.5px; font-weight: 700; letter-spacing: .9px; text-transform: uppercase; color: var(--faint); margin: 18px 0 0; }
.sactions { margin-top: 16px; padding: 14px 0; border-top: 1px solid var(--line-soft); }

/* ---------- Orders filter bar ---------- */
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.filter-bar .fb-search {
  flex: 1 1 200px; min-width: 160px; max-width: 300px;
  padding: 8px 11px; border: 1px solid #D8D7D0; border-radius: 8px;
  font-family: inherit; font-size: 13px; color: var(--ink); background: #fff; outline: none;
}
.filter-bar .fb-select {
  padding: 8px 11px; border: 1px solid #D8D7D0; border-radius: 8px;
  font-family: inherit; font-size: 13px; color: var(--ink); background: #fff; outline: none;
}
.filter-bar .fb-custom { display: none; align-items: center; gap: 6px; }
.filter-bar .fb-custom.open { display: inline-flex; }
.filter-bar .fb-custom input[type=date] {
  padding: 7px 9px; border: 1px solid #D8D7D0; border-radius: 8px;
  font-family: inherit; font-size: 13px; color: var(--ink); background: #fff; outline: none;
}
.filter-bar .fb-search:focus, .filter-bar .fb-select:focus, .filter-bar .fb-custom input:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.13);
}
.filter-bar .fb-to { color: var(--mut); font-size: 12px; }
.filter-bar .fb-reset { color: var(--mut); font-size: 12.5px; margin-left: 2px; }

/* ---------- Confirmation modal ---------- */
.pbmodal-overlay {
  position: fixed; inset: 0; background: rgba(23,25,33,.45);
  display: none; align-items: center; justify-content: center; z-index: 100;
}
.pbmodal-overlay.open { display: flex; }
.pbmodal {
  background: #fff; border-radius: 12px; width: 440px; max-width: calc(100vw - 40px);
  padding: 24px 26px 20px; position: relative;
  box-shadow: 0 24px 60px rgba(0,0,0,.28);
}
.pbmodal-x {
  position: absolute; top: 12px; right: 14px; border: none; background: none;
  color: var(--faint); font-size: 13px; cursor: pointer; padding: 4px; line-height: 1;
}
.pbmodal-x:hover { color: var(--ink); }
.pbmodal-title { text-align: center; font-weight: 700; font-size: 15.5px; margin-bottom: 12px; }
.pbmodal-msg { color: var(--mut); font-size: 13px; line-height: 1.6; }
.pbmodal-acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.switch { position: relative; display: inline-block; width: 38px; height: 21px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; cursor: pointer; background: #C9CBD3; border-radius: 999px; transition: background .2s; }
.switch .slider::before { content: ""; position: absolute; width: 17px; height: 17px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider::before { transform: translateX(17px); }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 3px rgba(79,70,229,.25); }
.switch.disabled .slider { cursor: default; opacity: .55; }

/* ---------- Connect wizard & channel picker ---------- */
.wiz { max-width: 720px; margin: 0 auto; }
.wiz-title { text-align: center; font-size: 20px; font-weight: 650; letter-spacing: -.2px; margin: 8px 0 20px; }
.wsteps { display: flex; margin-bottom: 18px; }
.wsteps .ws { flex: 1; text-align: center; padding-bottom: 10px; border-bottom: 3px solid var(--line); color: var(--faint); font-size: 12.5px; font-weight: 600; }
.wsteps .ws.done { color: var(--green-ink); border-bottom-color: var(--green); }
.wsteps .ws.active { color: var(--brand); border-bottom-color: var(--brand); }
.wiz-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 20px 22px; }
.wiz-card h2 { margin: 0 0 6px; font-size: 14.5px; font-weight: 650; }
.wiz-card .wtext { color: var(--mut); font-size: 12.8px; line-height: 1.65; margin: 0; max-width: 560px; }
.wiz-card .srow { padding: 4px 0; }
.wiz-actions { display: flex; align-items: center; margin-top: 18px; }
.wiz-actions .right { margin-left: auto; display: flex; gap: 10px; }
.wiz-ok { text-align: center; padding: 16px 0 8px; }
.wiz-ok .okmark {
  width: 52px; height: 52px; border-radius: 50%; font-size: 24px;
  background: var(--green-soft); border: 1px solid var(--green-line); color: var(--green-ink);
  display: inline-flex; align-items: center; justify-content: center;
}
.wiz-ok h2 { font-size: 16px; margin: 12px 0 4px; }
.wiz-ok p { color: var(--mut); font-size: 12.8px; line-height: 1.6; margin: 0 0 18px; }
.wiz-ok .btn { margin: 0 4px; }

.chan-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.chan { position: relative; }
.chan input { position: absolute; opacity: 0; pointer-events: none; }
.chan label {
  display: flex; align-items: center; gap: 11px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; cursor: pointer; font-size: 13px; font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.chan label:hover { border-color: #C9C7C0; }
.chan input:checked + label { border-color: var(--brand); box-shadow: 0 0 0 2.5px rgba(79,70,229,.16); }
.chan input:focus-visible + label { box-shadow: 0 0 0 3px rgba(79,70,229,.3); }
.chan.off label { opacity: .55; cursor: not-allowed; box-shadow: none; }
.chan.off label:hover { border-color: var(--line); }
.chan .conn-tile { width: 30px; height: 30px; border-radius: 7px; font-size: 13px; flex: none; }
.chan .etsy-wm { font-size: 11.5px; }
.chan .soon {
  margin-left: auto; font-size: 9px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase;
  color: var(--amber); background: #FDF3E3; border: 1px solid #F0DCB8; border-radius: 4px; padding: 1px 5px;
}
.pick-actions { display: flex; margin-top: 20px; }
.pick-actions .btn { margin-left: auto; }

/* ---------- Channel preferences ---------- */
.pref-name { display: flex; align-items: center; gap: 12px; padding-bottom: 16px; border-bottom: 1px solid var(--line-soft); margin-bottom: 16px; }
.pref-name-label { font-size: 13.5px; font-weight: 600; flex: 1; }
.pref-name input {
  width: 320px; padding: 9px 12px; border: 1px solid #D8D7D0; border-radius: 8px;
  font-family: inherit; font-size: 13px; color: var(--ink); background: #fff; outline: none;
}
.pref-name input[readonly] { background: #FAFAF8; color: var(--mut); }
.pref-name input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.13); }
.pref-static { display: inline-block; padding: 9px 12px; font-size: 13px; font-weight: 600; color: var(--ink); }

/* ---------- Login ---------- */
body.login-page {
  background: var(--rail); min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.login-card {
  width: 340px; background: #fff; border-radius: 14px;
  padding: 30px 28px 26px; box-shadow: 0 24px 60px rgba(0,0,0,.45);
}
.login-brand { display: flex; align-items: center; justify-content: center; gap: 11px; }
.login-logo {
  width: 36px; height: 36px; border-radius: 9px; background: var(--brand);
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 17px;
}
.login-logo-img { width: 190px; max-width: 100%; height: auto; display: block; }
.login-name { font-size: 16.5px; font-weight: 650; letter-spacing: -.2px; }
.login-tag { color: var(--mut); font-size: 11.5px; margin-top: 1px; }
.login-tag-c { text-align: center; color: var(--mut); font-size: 11.5px; margin-top: 9px; }
.login-fields { display: flex; flex-direction: column; gap: 14px; margin-top: 24px; }
.login-fields .flabel { font-size: 10.5px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; color: var(--mut); margin-bottom: 6px; }
.login-fields input {
  width: 100%; padding: 10px 12px; border: 1px solid #D8D7D0; border-radius: 8px;
  font-family: inherit; font-size: 13.5px; color: var(--ink); background: #FAFAF8; outline: none;
}
.login-fields input:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(79,70,229,.15); }
.login-note { text-align: center; color: var(--faint); font-size: 11px; margin-top: 16px; }
.login-note a { color: var(--brand); text-decoration: none; font-weight: 500; }
.login-note a:hover { text-decoration: underline; }

/* Password peek (login & reset pages). */
.pwd-wrap { position: relative; }
.pwd-wrap input { padding-right: 40px; }
.pwd-toggle {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; padding: 5px 7px;
  background: none; border: 0; border-radius: 6px; cursor: pointer; color: var(--mut);
}
.pwd-toggle:hover { color: var(--ink); }
.pwd-toggle .icon-hide { display: none; }
.pwd-toggle.showing .icon-show { display: none; }
.pwd-toggle.showing .icon-hide { display: block; }
.login-host { color: #5C6270; font-size: 11px; margin-top: 22px; font-family: 'IBM Plex Mono', ui-monospace, monospace; }
.login-card .banner { margin: 16px 0 0; }

/* Greyed-out settings group (features not shipped yet). */
.sgroup.ghosted { opacity: .55; }
.sgroup.ghosted .ctrl select, .sgroup.ghosted .ctrl input { cursor: not-allowed; }

/* ---------- Misc ---------- */
.muted { color: var(--mut); }
.right { text-align: right; }
.hint-inline { color: var(--faint); font-size: 11px; max-width: 280px; text-align: right; line-height: 1.45; }
.head-stack { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
}

/* Products page: pagination footer + the row-level QuickBooks pick box. */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 17px; border-top: 1px solid var(--line-soft); font-size: 12.5px; }
.pager-btns { display: inline-flex; align-items: center; gap: 10px; }

/* ---------- Products table ---------- */
/* Eight columns have to fit inside the panel, so the SKU / status / action
   columns shrink-wrap and the two product-name columns split the rest.
   The name columns carry no min-width: their content wraps, and anything
   with a hard minimum (the match control, nowrap cells) is kept narrow
   enough that the row total never exceeds the panel. */
.products-grid { table-layout: auto; }
.products-grid th, .products-grid td { padding-left: 8px; padding-right: 8px; }
.products-grid .c-name { width: 30%; line-height: 1.45; }
/* Compact tags/chips inside this table — every pixel saved on the fixed
   columns goes straight to the two product-name columns. */
.products-grid .sku-tag { font-size: 11px; padding: 2px 6px; }
.products-grid .chip { font-size: 10.5px; padding: 2px 8px; gap: 4px; }
.products-grid .c-sku,
.products-grid .c-status,
.products-grid .c-match,
.products-grid .c-acts { width: 1%; white-space: nowrap; }
/* Two-word column labels may wrap; without this the header text — not the
   cell content — is what dictates these columns' width. */
.products-grid th.c-sku, .products-grid th.c-status { white-space: normal; }
.products-grid .c-acts { text-align: right; font-size: 12px; }
.products-grid td.c-status .sku-note { display: block; margin-top: 3px; white-space: normal; max-width: 190px; }
.products-grid td { vertical-align: middle; }
/* Last-ditch guard: on a narrow window the table scrolls inside its panel
   instead of spilling out over the page. */
.tablewrap { overflow-x: auto; }

/* Match control: the SKU box and its button read as ONE segmented control,
   visually separate from the neighbouring action button. */
.matchgrp { display: inline-flex; align-items: stretch; border: 1px solid #D8D7D0; border-radius: 9px; background: #fff; overflow: hidden; transition: border-color .12s, box-shadow .12s; }
.matchgrp:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.13); }
.matchgrp input[type=text] {
  width: 98px; padding: 7px 9px; border: none; outline: none; background: transparent;
  font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 12px; color: var(--ink);
}
.matchgrp input::placeholder { font-family: 'IBM Plex Sans', system-ui, sans-serif; color: var(--faint); }
.matchgrp button {
  border: none; border-left: 1px solid var(--line-soft); background: #FAFAF8;
  padding: 0 12px; font-family: inherit; font-size: 12px; font-weight: 600; color: var(--brand);
  cursor: pointer; white-space: nowrap; transition: background .12s;
}
.matchgrp button:hover { background: var(--brand-soft); }
.matchgrp:focus-within button { background: var(--brand); color: #fff; border-left-color: var(--brand); }

/* Inline "name it in QuickBooks" editor, shown in place of the row's actions. */
.createform { display: flex; align-items: center; justify-content: flex-end; gap: 9px; flex-wrap: wrap; }
.createform .cf-lbl { font-size: 11px; font-weight: 600; letter-spacing: .3px; text-transform: uppercase; color: var(--faint); }
.createform .cf-input {
  flex: 1 1 320px; min-width: 240px; max-width: 460px;
  padding: 7px 11px; border: 1px solid var(--brand); border-radius: 8px;
  box-shadow: 0 0 0 3px rgba(79,70,229,.13);
  font-family: inherit; font-size: 12.5px; color: var(--ink); background: #fff; outline: none;
}

@media (max-width: 1240px) {
  .matchgrp input[type=text] { width: 104px; }
  .products-grid th, .products-grid td { padding-left: 8px; padding-right: 8px; }
}
