/* Etsy Profit Tracker — shared visual system (sidebar workspace).
   Presentation only: no data, permission or API behaviour lives here. Legacy --clr-* variables stay defined because
   tracking-ui.js / production-ui.js inject their own styles that read them. */
:root {
  --clr-primary: #0b6b63; --clr-primary-strong: #08544e; --clr-primary-soft: #e3f2f0;
  --clr-red: #b42318; --clr-red-soft: #fdecea; --clr-green: #1b6b34; --clr-green-soft: #e2f4e8;
  --clr-amber: #8a5a00; --clr-amber-soft: #fff4d6; --clr-blue-soft: #e8f1fb;
  --clr-border: #dde3e8; --clr-border-strong: #c3ccd4; --clr-bg: #f3f5f7; --clr-surface: #fff; --clr-bg-soft: #eef1f4;
  --clr-ink: #16202a; --clr-ink-soft: #55626e; --clr-brand: #c2561b;
  --nav-bg: #14202b; --nav-ink: #c5d1db; --nav-ink-strong: #fff; --nav-hover: rgba(255,255,255,.07); --nav-active: rgba(255,255,255,.12);
  --radius: 8px; --radius-sm: 6px; --shadow-1: 0 1px 2px rgba(16,24,32,.06); --shadow-2: 0 8px 24px rgba(16,24,32,.16);
  --sidebar-w: 248px; --topbar-h: 60px; --focus: 0 0 0 3px rgba(11,107,99,.35);
  --font: Inter, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); background: var(--clr-bg); margin: 0; color: var(--clr-ink); font-size: 14px; line-height: 1.45; }
a { color: var(--clr-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--clr-primary); outline-offset: 2px; box-shadow: var(--focus); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -48px; background: #fff; color: var(--clr-ink); padding: 8px 14px; border-radius: var(--radius-sm); z-index: 400; border: 2px solid var(--clr-primary); }
.skip-link:focus { top: 8px; }

/* ---------- Shell ---------- */
.app { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--nav-bg); color: var(--nav-ink); display: flex; flex-direction: column; z-index: 120; overflow-y: auto; transition: transform .2s ease; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px; color: var(--nav-ink-strong); font-weight: 700; font-size: 15px; letter-spacing: .01em; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--clr-brand); display: grid; place-items: center; flex: none; }
.brand-mark svg { width: 18px; height: 18px; }
.brand small { display: block; font-weight: 500; font-size: 11px; color: #8fa1b0; letter-spacing: .04em; text-transform: uppercase; }
.nav { padding: 4px 10px 24px; display: flex; flex-direction: column; gap: 14px; }
.nav-group-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #8fa1b0; padding: 8px 10px 4px; margin: 0; font-weight: 700; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.page-tab { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; background: transparent; color: var(--nav-ink); font: inherit; font-size: 14px; font-weight: 500; text-align: left; border-radius: var(--radius-sm); cursor: pointer; position: relative; }
.page-tab svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.page-tab:hover { background: var(--nav-hover); color: var(--nav-ink-strong); }
.page-tab.active { background: var(--nav-active); color: var(--nav-ink-strong); }
.page-tab.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #3cc2b4; }
.page-tab:focus-visible { outline-color: #fff; box-shadow: none; }
.tab-badge { display: none; margin-left: auto; background: var(--clr-red); color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 11px; font-weight: 700; }
.nav-foot { margin-top: auto; padding: 14px 18px; font-size: 11px; color: #8fa1b0; border-top: 1px solid rgba(255,255,255,.08); }

.workspace { margin-left: var(--sidebar-w); min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 90; height: var(--topbar-h); background: var(--clr-surface); border-bottom: 1px solid var(--clr-border); display: flex; align-items: center; gap: 12px; padding: 0 24px; }
.topbar .spacer { flex: 1; }
.icon-btn { display: none; width: 40px; height: 40px; align-items: center; justify-content: center; border: 1px solid var(--clr-border); background: #fff; border-radius: var(--radius-sm); cursor: pointer; color: var(--clr-ink); padding: 0; }
.icon-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
.shop-switch, .account { position: relative; }
.shop-trigger, .account-btn { display: flex; align-items: center; gap: 10px; border: 1px solid var(--clr-border); background: #fff; border-radius: var(--radius); padding: 6px 12px; font: inherit; color: var(--clr-ink); cursor: pointer; min-height: 40px; max-width: 320px; }
.shop-trigger:hover, .account-btn:hover { border-color: var(--clr-border-strong); }
.shop-trigger-text { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; line-height: 1.2; text-align: left; }
.shop-trigger-name { font-weight: 600; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shop-trigger-sub { font-size: 12px; color: var(--clr-ink-soft); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { width: 14px; height: 14px; stroke: var(--clr-ink-soft); fill: none; stroke-width: 2; flex: none; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #98a4ae; flex: none; box-shadow: 0 0 0 3px rgba(152,164,174,.25); }
.status-dot[data-tone="ok"] { background: #1f9d55; box-shadow: 0 0 0 3px rgba(31,157,85,.2); }
.status-dot[data-tone="warn"] { background: #d99a00; box-shadow: 0 0 0 3px rgba(217,154,0,.22); }
.status-dot[data-tone="bad"] { background: #d4382c; box-shadow: 0 0 0 3px rgba(212,56,44,.2); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--clr-primary); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.menu { position: absolute; top: calc(100% + 6px); min-width: 260px; max-width: 92vw; background: #fff; border: 1px solid var(--clr-border); border-radius: var(--radius); box-shadow: var(--shadow-2); padding: 6px; z-index: 130; }
.shop-switch .menu { left: 0; }
.account .menu { right: 0; min-width: 220px; }
.menu[hidden] { display: none; }
.menu-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--clr-ink-soft); padding: 8px 10px 4px; font-weight: 700; }
.menu-item, .menu .shop-tab { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 9px 10px; border: 0; background: transparent; font: inherit; color: var(--clr-ink); border-radius: var(--radius-sm); cursor: pointer; text-align: left; text-decoration: none; }
.menu-item:hover, .menu .shop-tab:hover { background: var(--clr-bg-soft); text-decoration: none; }
.menu .shop-tab.active { background: var(--clr-primary-soft); color: var(--clr-primary-strong); font-weight: 600; }
.menu .shop-tab.active::after { content: "Selected"; font-size: 11px; font-weight: 600; }
.menu .shop-tab-add { border-top: 1px solid var(--clr-border); border-radius: 0 0 var(--radius-sm) var(--radius-sm); margin-top: 4px; color: var(--clr-primary); font-weight: 600; justify-content: flex-start; }
.menu .shop-tab-add::after { content: none !important; }
.shop-tab-del { margin-left: auto; padding: 0 6px; font-weight: 700; color: var(--clr-ink-soft); border-radius: 4px; }
.shop-tab-del:hover { color: var(--clr-red); background: var(--clr-red-soft); }
.menu-sep { height: 1px; background: var(--clr-border); margin: 6px 0; }
.menu-who { padding: 8px 10px; font-size: 12px; color: var(--clr-ink-soft); }
.menu-danger { color: var(--clr-red); }
#headerShopRating { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.pill { display: inline-flex; align-items: center; gap: 6px; background: var(--clr-bg-soft); border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600; color: var(--clr-ink-soft); white-space: nowrap; }
.pill .status-dot { width: 7px; height: 7px; box-shadow: none; }
#presenceBar { display: inline-flex; align-items: center; gap: 4px; }

.main { padding: 24px; max-width: 1480px; margin: 0 auto; }
.main[data-page="orders"] { max-width: none; } /* the Orders table uses the full width of the window; every other page keeps the 1480px column */
.main:focus { outline: none; }
.busy-bar { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: #3cc2b4; z-index: 300; transition: width .25s ease, opacity .3s ease; opacity: 0; }
.busy-bar.on { opacity: 1; width: 70%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 0 0 14px; }
.page-head h1 { font-size: 24px; line-height: 1.2; margin: 0; letter-spacing: -.01em; }
.page-sub { color: var(--clr-ink-soft); font-size: 13px; margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Status banner (connection / setup / reconnect). Always readable text, tone shown by border + label. */
.etsy-status-bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: #fff; border: 1px solid var(--clr-border); border-left: 4px solid #98a4ae; border-radius: var(--radius); font-size: 13px; margin: 0 0 16px; flex-wrap: wrap; }
.etsy-status-bar[data-state="ok"] { border-left-color: #1f9d55; }
.etsy-status-bar[data-state="syncing"] { border-left-color: #2563eb; }
.etsy-status-bar[data-state="setup"], .etsy-status-bar[data-state="disconnected"] { border-left-color: #d99a00; background: #fffaf0; }
.etsy-status-bar[data-state="reconnect"], .etsy-status-bar.error { border-left-color: #d4382c; background: #fff6f5; }
.etsy-status-bar .etsy-status-text { color: var(--clr-ink-soft); flex: 1 1 260px; }
.etsy-status-bar .etsy-status-text strong { color: var(--clr-ink); }
.etsy-status-bar.error .etsy-status-text { color: var(--clr-red); }
.status-label { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--clr-ink); }
.note-box { background: var(--clr-amber-soft); border: 1px solid #f0d98c; border-radius: var(--radius); padding: 10px 14px; font-size: 13px; color: #5c4300; margin-bottom: 16px; }
.empty-state { padding: 36px 20px; text-align: center; color: var(--clr-ink-soft); }
.empty-state strong { display: block; color: var(--clr-ink); margin-bottom: 4px; font-size: 15px; }
.error-state { background: var(--clr-red-soft); color: var(--clr-red); border: 1px solid #f4b8b2; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* ---------- Controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; min-height: 36px; border: 1px solid var(--clr-border-strong); background: #fff; border-radius: var(--radius-sm); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; color: var(--clr-ink); text-decoration: none; }
.btn:hover { border-color: #8b98a4; background: #fafbfc; text-decoration: none; }
.btn:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--clr-primary); color: #fff; border-color: var(--clr-primary); font-weight: 600; }
.btn-primary:hover { background: var(--clr-primary-strong); border-color: var(--clr-primary-strong); }
.btn-danger { color: var(--clr-red); border-color: var(--clr-red); background: #fff; }
.btn-small { padding: 4px 10px; min-height: 30px; font-size: 12px; }
.form-field label, .field-label { display: block; font-size: 12px; font-weight: 600; color: var(--clr-ink-soft); margin-bottom: 4px; }
input[type=text], input[type=number], input[type=date], input[type=url], input[type=password], input[type=email], select, textarea,
.form-field input, .form-field select { padding: 7px 10px; min-height: 36px; border: 1px solid var(--clr-border-strong); border-radius: var(--radius-sm); font: inherit; font-size: 13px; background: #fff; color: var(--clr-ink); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--clr-primary); box-shadow: var(--focus); }
.inline-field { width: 130px; min-height: 30px; padding: 3px 6px; }
.inline-cost { width: 92px; min-height: 30px; padding: 3px 6px; text-align: right; }
.inline-field.saving, .inline-cost.saving { opacity: .5; }
.checkbox-field { display: flex; align-items: center; gap: 6px; font-size: 13px; min-height: 36px; }

.toolbar { display: flex; gap: 10px 14px; align-items: flex-end; flex-wrap: wrap; background: #fff; border: 1px solid var(--clr-border); border-radius: var(--radius); padding: 12px 14px; margin: 0 0 16px; }
.filter-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .filter-row { margin: 0; }
.date-toolbar { gap: 10px 14px; }
.date-toolbar[hidden] { display: none; }
.preset-group { display: inline-flex; border: 1px solid var(--clr-border-strong); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.preset-group .btn { border: 0; border-radius: 0; border-right: 1px solid var(--clr-border); min-height: 36px; }
.preset-group .btn:last-child { border-right: 0; }
.preset-group .btn.is-active { background: var(--clr-primary-soft); color: var(--clr-primary-strong); font-weight: 700; }
.applied-range { margin-left: auto; font-size: 12.5px; color: var(--clr-ink-soft); text-align: right; align-self: center; }
.applied-range strong { color: var(--clr-ink); font-variant-numeric: tabular-nums; }
.panel-toolbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }

/* ---------- Cards, stats ---------- */
.card, .vat-card { background: #fff; border: 1px solid var(--clr-border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; box-shadow: var(--shadow-1); }
.card h2, .card h3, .vat-card h3 { margin: 0 0 12px; font-size: 15px; }
.vat-notice { background: var(--clr-amber-soft); border: 1px solid #f0d78c; color: #5c4300; border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; font-size: 13px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card { background: #fff; border: 1px solid var(--clr-border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow-1); }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--clr-ink-soft); margin-bottom: 4px; font-weight: 600; }
.stat-value { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat-value.positive, .profit-pos { color: var(--clr-green); }
.stat-value.negative, .profit-neg { color: var(--clr-red); }
.kpi-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: #fff; border: 1px solid var(--clr-border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-1); min-width: 0; }
.kpi.primary { border-top: 3px solid var(--clr-primary); }
.kpi-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--clr-ink-soft); font-weight: 700; }
.kpi-value { font-size: 30px; font-weight: 700; line-height: 1.15; margin: 6px 0 2px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi-value.positive { color: var(--clr-green); } .kpi-value.negative { color: var(--clr-red); }
.kpi-sub { font-size: 12.5px; color: var(--clr-ink-soft); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; align-items: start; }
.metric-list { list-style: none; margin: 0; padding: 0; }
.metric-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--clr-border); font-size: 13.5px; }
.metric-list li:last-child { border-bottom: 0; }
.metric-list .v { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.metric-list .link { font-size: 12px; margin-left: 8px; }
.bridge-row { display: grid; grid-template-columns: 150px minmax(0,1fr) 96px; gap: 10px; align-items: center; padding: 5px 0; font-size: 13px; }
.bridge-bar { height: 10px; background: var(--clr-bg-soft); border-radius: 5px; overflow: hidden; }
.bridge-bar span { display: block; height: 100%; border-radius: 5px; background: var(--clr-primary); }
.bridge-bar span.neg { background: #c2561b; }
.bridge-row .v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.chart-wrap { width: 100%; overflow: hidden; }
.chart-wrap svg { width: 100%; height: 190px; display: block; }
.chart-note { font-size: 12px; color: var(--clr-ink-soft); margin-top: 6px; }

/* ---------- Tables ---------- */
table { border-collapse: collapse; background: #fff; font-size: 13px; }
table.table-wide { width: 100%; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--clr-border); white-space: nowrap; vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--clr-ink-soft); font-weight: 700; background: #f8fafb; }
tbody tr:hover { background: #f6f9fa; }
td.truncate { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.table-scroll { overflow: auto; border: 1px solid var(--clr-border); border-radius: var(--radius); background: #fff; max-width: 100%; box-shadow: var(--shadow-1); }
.table-scroll thead th { position: sticky; top: 0; z-index: 4; box-shadow: inset 0 -1px 0 var(--clr-border); }
#ordersTableScroll { max-height: calc(100vh - 230px); min-height: 280px; }
#ordersTableScroll table th:nth-child(1), #ordersTableScroll table td:nth-child(1) { width: 100px; min-width: 100px; left: 0; }
#ordersTableScroll table th:nth-child(2), #ordersTableScroll table td:nth-child(2) { width: 120px; min-width: 120px; left: 100px; box-shadow: 2px 0 4px rgba(16,24,32,.07); }
#ordersTableScroll table th:nth-child(1), #ordersTableScroll table td:nth-child(1), #ordersTableScroll table th:nth-child(2), #ordersTableScroll table td:nth-child(2) { position: sticky; background: #fff; z-index: 2; }
#ordersTableScroll table th:nth-child(1), #ordersTableScroll table th:nth-child(2) { z-index: 6; background: #f8fafb; }
#ordersTableScroll tbody tr:hover td:nth-child(1), #ordersTableScroll tbody tr:hover td:nth-child(2) { background: #f6f9fa; }
#ordersTableScroll th:nth-child(n+10):nth-child(-n+15), #ordersTableScroll td:nth-child(n+10):nth-child(-n+15) { text-align: right; font-variant-numeric: tabular-nums; }
#ordersTableScroll td:nth-child(15) { font-weight: 650; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack > div { min-height: 22px; display: flex; align-items: center; }
.sticky-hscroll { display: none !important; } /* replaced by the table's own scrollbar so nothing floats over the last row */
.narrow-tab { max-width: 1100px; }
#pnlScroll { max-width: 760px; }
#pnlTable { width: 100%; }
#pnlTable td:last-child { width: 160px; text-align: right; font-variant-numeric: tabular-nums; }
.pnl-section-row td { font-weight: 700; padding-top: 18px; background: #f8fafb; }
.pnl-indent td:first-child { padding-left: 28px; color: var(--clr-ink-soft); }
.pnl-total-row td { font-weight: 700; border-top: 2px solid var(--clr-border-strong); }
.status-pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--clr-bg-soft); color: #33414d; }
.status-pill.ok { background: var(--clr-green-soft); color: var(--clr-green); }
.status-pill.warn { background: var(--clr-amber-soft); color: var(--clr-amber); }
.status-pill.bad { background: var(--clr-red-soft); color: var(--clr-red); }
.score-pill { display: inline-block; min-width: 28px; text-align: center; padding: 2px 9px; border-radius: 10px; font-size: 12px; font-weight: 700; }
.score-pill.needs-work { background: var(--clr-red-soft); color: var(--clr-red); }
.score-pill.could-improve { background: var(--clr-amber-soft); color: var(--clr-amber); }
.score-pill.healthy { background: var(--clr-green-soft); color: var(--clr-green); }

/* ---------- Dialogs ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(16,24,32,.5); display: none; align-items: center; justify-content: center; z-index: 200; padding: 16px; }
.modal-backdrop.open { display: flex; }
.modal { background: #fff; border-radius: 10px; padding: 22px; max-width: 420px; width: 100%; box-shadow: var(--shadow-2); max-height: calc(100vh - 32px); overflow: auto; }
.modal h2 { margin: 0 0 14px; font-size: 18px; }
.modal-actions { display: flex; gap: 8px; margin-top: 18px; justify-content: flex-end; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 40px; }
.pw-toggle { position: absolute; right: 0; top: 0; bottom: 0; width: 38px; display: flex; align-items: center; justify-content: center; background: none; border: none; cursor: pointer; color: var(--clr-ink-soft); padding: 0; }
.pw-toggle:hover { color: var(--clr-primary); }
.pw-toggle svg { width: 18px; height: 18px; }
.toast-host { position: fixed; right: 16px; bottom: 16px; z-index: 350; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: #16202a; color: #fff; padding: 10px 14px; border-radius: var(--radius); box-shadow: var(--shadow-2); font-size: 13px; display: flex; gap: 12px; align-items: center; }
.toast button { background: transparent; color: #8fe0d6; border: 0; font: inherit; font-weight: 700; cursor: pointer; text-decoration: underline; }
.scrim { display: none; position: fixed; inset: 0; background: rgba(16,24,32,.5); z-index: 110; }

/* ---------- Embedded Tracking / Production / order-detail UI (their own injected styles read the tokens above) ---------- */
body .trk-chip, body .prd-chip { border-radius: 999px; min-height: 32px; }
body .trk-panel, body .prd-panel { border-radius: var(--radius); box-shadow: var(--shadow-1); }
body .trk-badge { border-radius: 999px; }
body .trk-panel input[type=text], body .trk-panel select, body .trk-panel textarea { min-height: 36px; border-color: var(--clr-border-strong); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) { .kpi-row { grid-template-columns: repeat(2, minmax(0,1fr)); } .grid-2 { grid-template-columns: minmax(0,1fr); } }
@media (max-width: 1023px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-2); width: min(86vw, 300px); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; }
  body.nav-open { overflow: hidden; }
  .workspace { margin-left: 0; }
  .icon-btn { display: inline-flex; }
  .topbar { padding: 0 12px; gap: 8px; }
  .main { padding: 16px 12px 28px; }
  #headerShopRating, .account-name, #topAction span.long { display: none; }
}
@media (max-width: 640px) {
  .kpi-row { grid-template-columns: 1fr; }
  .kpi-value { font-size: 26px; }
  .topbar > * { min-width: 0; }
  .topbar #topAction { display: none; }   /* the same Add credentials / Reconnect action is in the status banner right below */
  .shop-switch { flex: 0 1 auto; }
  .account-btn { padding: 6px 8px; gap: 6px; }
  .shop-trigger { max-width: 52vw; padding: 6px 10px; }
  .shop-trigger-name { max-width: 34vw; }
  .shop-trigger-sub { max-width: 34vw; }
  .shop-switch .menu { position: fixed; left: 8px; right: 8px; top: calc(var(--topbar-h) + 4px); min-width: 0; }
  .account .menu { position: fixed; right: 8px; top: calc(var(--topbar-h) + 4px); }
  .toolbar { padding: 10px; }
  .toolbar .form-field, .toolbar .form-field input, .toolbar .form-field select { width: 100%; }
  .toolbar .form-field { flex: 1 1 130px; }
  .preset-group { flex-wrap: wrap; width: 100%; }
  .preset-group .btn { flex: 1 1 45%; }
  .applied-range { margin-left: 0; text-align: left; width: 100%; }
  .page-head h1 { font-size: 21px; }
  .bridge-row { grid-template-columns: 110px minmax(0,1fr) 84px; }
  .modal { padding: 18px; }
  #ordersTableScroll { max-height: calc(100vh - 200px); }
  .filter-row .form-field { flex: 1 1 130px; } .filter-row .form-field select, .filter-row .form-field input { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
@media print {
  .sidebar, .topbar, .scrim, .toast-host, .busy-bar, .toolbar, .skip-link, .etsy-status-bar { display: none !important; }
  .workspace { margin: 0; } .main { padding: 0; max-width: none; } body { background: #fff; }
}
@media (max-width: 1023px) {
  .sidebar { visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s; }
  body.nav-open .sidebar { visibility: visible; transition: transform .2s ease, visibility 0s; }
}
[hidden] { display: none !important; }
#ordersStats, #reviewsStats, #listingDoctorStats, #taxStats { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
#ordersStats .stat-card { padding: 9px 12px; } #ordersStats .stat-value { font-size: 17px; } #ordersStats .stat-label { font-size: 10.5px; }
/* embedded Tracking / Production controls adopt the shared look */
body .trk-chip, body .prd-chip { padding: 6px 14px; font-size: 13px; min-height: 34px; border-color: var(--clr-border-strong); font-family: inherit; }
body .trk-chip.active, body .prd-chip.active { background: var(--clr-primary); border-color: var(--clr-primary); color: #fff; font-weight: 600; }
body .trk-chip:hover:not(.active), body .prd-chip:hover:not(.active) { border-color: #8b98a4; }
body .trk-small, body .prd-small { color: var(--clr-ink-soft); }
body .trk-table, body .prd-table { width: 100%; }
body .trk-flash, body .prd-flash { border-radius: var(--radius-sm); }
.date-custom { display: contents; }
.date-custom-toggle { display: none; }
@media (max-width: 640px) {
  .date-custom-toggle { display: inline-flex; }
  .date-custom { display: none; }
  .date-toolbar.show-custom .date-custom { display: flex; flex-wrap: wrap; gap: 10px; width: 100%; align-items: flex-end; }
}
@media (max-width: 760px) {
  /* wide embedded tables scroll inside themselves, never the page */
  #tab-tracking table, #tab-production table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
