/*
 * SellKit Seller Dashboard. Served as a static asset and loaded by the shell
 * at GET /seller (src/routes/seller.page.ts), whose CSP is style-src 'self':
 * every rule the page needs lives here, never in a style attribute.
 *
 * Same warm palette as buyer.html, lib/email.ts and the Reader, so the seller
 * and the buyer see one product. Light only, for the reason buyer.html gives:
 * cream and gold have no readable dark twin.
 */
:root {
  color-scheme: light;
  --paper: #f5f2ed;
  --card: #ffffff;
  --hairline: #e8e3dc;
  --hairline-strong: #d9d1c6;
  --ink: #1a1715;
  --ink-soft: #332e29;
  --muted: #6f6862;
  --accent: #a9713f;
  --accent-soft: #fbf3ea;
  --accent-line: #ecdcc9;
  --ok: #2f7a4b;
  --ok-soft: #e9f4ed;
  --warn: #9a5b12;
  --warn-soft: #fbf0e1;
  --danger: #b3261e;
  --danger-soft: #fbeceb;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(26, 23, 21, .04), 0 6px 20px rgba(26, 23, 21, .05);
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--accent); }
code { font: 13px/1.4 var(--mono); background: #f3eee7; padding: 1px 5px; border-radius: 4px; }
h1, h2, h3, h4 { font-weight: 400; margin: 0; }
h1 { font: 400 27px/1.25 var(--serif); margin: .5rem 0 1.2rem; }
h2 { font: 400 23px/1.25 var(--serif); }
h3 { font: 400 18px/1.3 var(--serif); margin-bottom: .75rem; }
h4 { font: 600 13px/1.3 var(--sans); letter-spacing: .02em; margin: 0 0 .5rem; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); }
.muted { color: var(--muted); }
.hint { display: block; margin: .35rem 0 0; font-size: 12.5px; color: var(--muted); font-weight: 400; letter-spacing: 0; }
.note { margin: 0 0 1rem; font-size: 13.5px; color: var(--muted); }
.noscript { margin: 3rem auto; max-width: 30rem; text-align: center; }
.mono { font-family: var(--mono); font-size: 12.5px; }

/* ---- Buttons and fields ------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  background: var(--ink); color: #fff; border: 1px solid var(--ink); border-radius: 7px;
  font: 600 14px/1.2 var(--sans); padding: 10px 16px;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
}
.btn:hover { background: var(--ink-soft); border-color: var(--ink-soft); }
.btn:active { transform: translateY(1px); }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn.xs { padding: 4px 9px; font-size: 12px; font-weight: 600; }
.btn.block { width: 100%; padding: 12px 18px; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--hairline-strong); }
.btn.ghost:hover { background: var(--card); border-color: #c9bfb2; }
.btn.danger { background: transparent; color: var(--danger); border-color: #e7c3bf; }
.btn.danger:hover { background: var(--danger-soft); }
.btn[disabled] { opacity: .45; cursor: default; transform: none; }
.btn:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

label { display: block; font-size: 12.5px; font-weight: 600; letter-spacing: .02em; color: var(--ink); }
label.inline { display: inline-flex; align-items: center; gap: .5rem; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number],
input[type=search], input[type=date], select, textarea {
  display: block; width: 100%; margin-top: .3rem; padding: 9px 11px;
  border: 1px solid var(--hairline-strong); border-radius: 7px; background: var(--card); color: var(--ink);
  font: 400 14.5px/1.4 var(--sans);
}
label.inline select, label.inline input { width: auto; margin-top: 0; }
textarea { resize: vertical; min-height: 4.5rem; }
textarea[readonly], input[readonly] { background: #faf8f5; font-family: var(--mono); font-size: 13px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-line); border-color: var(--accent); }
input[type=file] { display: block; font-size: 13px; max-width: 100%; margin-top: .3rem; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--ink); vertical-align: -3px; }
fieldset { border: 1px solid var(--hairline); border-radius: 8px; padding: .5rem .8rem .7rem; margin: 0; }
legend { font-size: 12.5px; font-weight: 600; padding: 0 .3rem; }
.checks { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; }
.check { display: inline-flex; align-items: center; gap: .45rem; font-weight: 500; font-size: 13.5px; }
.field-prefix { display: flex; align-items: stretch; margin-top: .3rem; }
.field-prefix > span { display: flex; align-items: center; padding: 0 .6rem; border: 1px solid var(--hairline-strong);
  border-right: 0; border-radius: 7px 0 0 7px; background: #faf8f5; color: var(--muted); font-weight: 400; font-size: 13px; }
.field-prefix input { margin-top: 0; border-radius: 0 7px 7px 0; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem 1rem; margin-top: .9rem; }
.form-grid .span2 { grid-column: 1 / -1; }
.form-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .7rem 1rem; margin: .4rem 0 .9rem; }
.form-row > label { flex: 1 1 10rem; min-width: 8.5rem; }
.form-row > label.grow, .toolbar > label.grow { flex: 3 1 16rem; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-top: .6rem; }
.copy-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.copy-row input { flex: 1 1 16rem; margin-top: 0; }

/* ---- Auth gate -------------------------------------------------------- */
.gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem 1rem; }
.gate-card { width: 100%; max-width: 26rem; background: var(--card); border: 1px solid var(--hairline);
  border-radius: 16px; padding: 2rem 1.75rem; box-shadow: var(--shadow); }
.gate-card form label { margin-bottom: .95rem; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 1.2rem;
  background: #f3eee7; border-radius: 9px; }
.seg button { cursor: pointer; border: 0; border-radius: 6px; padding: 8px; background: transparent;
  font: 600 13.5px/1.2 var(--sans); color: var(--muted); }
.seg button[aria-selected=true] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(26, 23, 21, .1); }
.notice { margin: 0 0 1rem; padding: .65rem .8rem; border-radius: 8px; font-size: 13.5px;
  background: var(--warn-soft); color: var(--warn); border: 1px solid #f0dcc0; }
.gate-alt { margin-top: .6rem; }
.gate-card form h2 { margin-bottom: .5rem; font-size: 20px; }
.gate-card form > .muted { font-size: 14px; margin: 0 0 1.1rem; }
.closed { text-align: center; padding: .5rem 0; }
.closed h2 { margin-bottom: .5rem; font-size: 20px; }
.closed p { font-size: 14px; margin: 0 0 1.1rem; }

/* ---- App shell -------------------------------------------------------- */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .8rem 1.5rem; background: rgba(245, 242, 237, .92); border-bottom: 1px solid var(--hairline);
  backdrop-filter: saturate(1.4) blur(8px); -webkit-backdrop-filter: saturate(1.4) blur(8px); }
.brand { display: flex; align-items: baseline; gap: .7rem; min-width: 0; }
.brand-title { font: 400 19px/1.2 var(--serif); white-space: nowrap; }
.who { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.who-name { font-size: 13.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 16rem; }

.tabs { display: flex; gap: .25rem; padding: .6rem 1.5rem 0; border-bottom: 1px solid var(--hairline);
  overflow-x: auto; scrollbar-width: none; max-width: 76rem; margin: 0 auto; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { cursor: pointer; border: 0; background: transparent; padding: .65rem .9rem; margin-bottom: -1px;
  font: 600 14px/1.2 var(--sans); color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected=true] { color: var(--ink); border-bottom-color: var(--accent); }

.content { max-width: 76rem; margin: 0 auto; padding: 1.5rem 1.5rem 4rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .8rem; margin-bottom: 1.1rem; }
.panel-tools { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--hairline); border-radius: var(--radius);
  padding: 1.15rem 1.25rem; margin: 0 0 1rem; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; margin-bottom: .6rem; }
.card-head h3, .card-head h4 { margin: 0; }
.sub-head { margin-top: 1.4rem; }
details.card > summary, details.sub > summary { cursor: pointer; font: 400 17px/1.3 var(--serif); list-style: none; }
details.card > summary::-webkit-details-marker, details.sub > summary::-webkit-details-marker { display: none; }
details.card > summary::before, details.sub > summary::before { content: '+'; display: inline-block; width: 1.1rem;
  color: var(--accent); font-family: var(--sans); font-weight: 700; }
details[open] > summary::before { content: '\2212'; }
details.sub { margin-top: 1rem; padding-top: .8rem; border-top: 1px solid var(--hairline); }
details.sub > summary { font: 600 13.5px/1.3 var(--sans); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.grid2 > .card { margin-bottom: 1rem; }
.images { margin-top: 1.2rem; }

/* ---- KPIs and chart --------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.kpis > .loading, .kpis > .error-box { grid-column: 1 / -1; }
.kpi { background: var(--card); border: 1px solid var(--hairline); border-radius: var(--radius); padding: .95rem 1.05rem; box-shadow: var(--shadow); }
.kpi .kpi-label { font-size: 12px; font-weight: 600; letter-spacing: .03em; color: var(--muted); }
.kpi .kpi-value { margin-top: .3rem; font: 400 26px/1.15 var(--serif); font-variant-numeric: tabular-nums; }
.kpi .kpi-sub { margin-top: .2rem; font-size: 12px; color: var(--muted); }
.chart { display: flex; align-items: flex-end; gap: 3px; height: 11rem; padding: .4rem 0 0; border-bottom: 1px solid var(--hairline); }
.chart .bar { flex: 1 1 0; min-width: 3px; background: linear-gradient(180deg, #c48d5a, var(--accent)); border-radius: 3px 3px 0 0;
  min-height: 2px; transition: height .35s ease, opacity .15s ease; }
.chart .bar:hover { opacity: .75; }
.chart > .empty, .chart > .loading, .chart > .error-box { align-self: center; margin: 0 auto; }
.chart-axis { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-top: .35rem; }
.chart-axis:empty { display: none; }

/* ---- Tables, pills, lists -------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -.25rem; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  padding: .5rem .55rem; border-bottom: 1px solid var(--hairline); white-space: nowrap; }
td { padding: .6rem .55rem; border-bottom: 1px solid #f1ece6; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn + .btn { margin-left: .35rem; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #fbf9f6; }
tr.selected td { background: var(--accent-soft); }
.empty { padding: 1rem 0 .4rem; font-size: 13.5px; color: var(--muted); }
.error-box { padding: .7rem .85rem; border-radius: 8px; font-size: 13.5px; background: var(--danger-soft); color: var(--danger); border: 1px solid #f0cfcc; }
.loading { padding: .9rem 0; font-size: 13.5px; color: var(--muted); }
.loading::before { content: ''; display: inline-block; width: 12px; height: 12px; margin-right: .5rem; vertical-align: -2px;
  border: 2px solid var(--hairline-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.list-foot { display: flex; justify-content: center; margin-top: .6rem; }
.list-foot:empty { display: none; }

.pill { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px; border: 1px solid var(--hairline); background: #faf7f3; color: var(--muted); white-space: nowrap; }
.pill.ok { color: var(--ok); background: var(--ok-soft); border-color: #cfe6d7; }
.pill.warn { color: var(--warn); background: var(--warn-soft); border-color: #f0dcc0; }
.pill.bad { color: var(--danger); background: var(--danger-soft); border-color: #f0cfcc; }
.pill.accent { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }
.pills { display: flex; flex-wrap: wrap; gap: .35rem; }

.status-line { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: .2rem 0 .8rem; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .3rem 1rem; font-size: 13.5px; margin: .4rem 0 .8rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ---- Products --------------------------------------------------------- */
.product { padding: 0; overflow: hidden; }
.product-head { display: flex; align-items: center; gap: .9rem; padding: .95rem 1.15rem; flex-wrap: wrap; }
.product-head .meta { flex: 1 1 14rem; min-width: 0; }
.product-name { font: 400 18px/1.3 var(--serif); overflow-wrap: anywhere; }
.product-sub { font-size: 12.5px; color: var(--muted); margin-top: .15rem; }
.product-thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: #f3eee7; border: 1px solid var(--hairline); flex: none; }
.product-body { border-top: 1px solid var(--hairline); padding: 1rem 1.15rem 1.15rem; background: #fdfcfa; }
.section-title { font: 700 11.5px/1.3 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 1.3rem 0 .6rem; }
.section-title:first-child { margin-top: 0; }
.variant { border: 1px solid var(--hairline); border-radius: 10px; padding: .85rem .95rem; margin-bottom: .75rem; background: var(--card); }
.variant-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.variant-name { font-weight: 600; }
.variant-price { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }
.file-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .55rem 0; border-top: 1px solid #f1ece6; font-size: 13.5px; }
.file-row:first-of-type { border-top: 0; }
.file-name { flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere; }
.file-actions { display: flex; gap: .35rem; flex-wrap: wrap; }
.inset { margin-top: .6rem; padding: .8rem .9rem; border-radius: 9px; background: #faf8f5; border: 1px solid var(--hairline); }
.inset label:not(.check) { margin-top: .7rem; }
.progress { margin: .5rem 0; font-size: 13px; color: var(--accent); font-weight: 600; }
.img-preview { height: 84px; display: flex; align-items: center; justify-content: flex-start; margin-bottom: .4rem; }
.img-preview img { max-height: 84px; max-width: 100%; border-radius: 8px; border: 1px solid var(--hairline); }
.img-preview.wide img { width: 100%; object-fit: cover; }
.once { margin: .4rem 0 1rem; padding: .85rem .95rem; border-radius: 10px; background: var(--accent-soft); border: 1px solid var(--accent-line); }
.once p { margin: 0 0 .5rem; font-size: 13.5px; }
.toolbar { display: flex; flex-wrap: wrap; gap: .7rem 1rem; align-items: flex-end; margin-bottom: .6rem; }
.toolbar > label { flex: 1 1 9rem; }
.detail { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--hairline); }

/* ---- Toast ------------------------------------------------------------ */
.toast { position: fixed; left: 50%; bottom: 1.4rem; transform: translateX(-50%); z-index: 20; max-width: calc(100vw - 2rem);
  background: var(--ink); color: #fdfbf8; font-size: 14px; padding: .7rem 1.1rem; border-radius: 9px;
  box-shadow: 0 8px 28px rgba(26, 23, 21, .22); animation: rise .2s ease; }
.toast.bad { background: var(--danger); }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---- Small screens ---------------------------------------------------- */
@media (max-width: 64rem) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 52rem) {
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .topbar { padding: .7rem 1rem; }
  .tabs { padding: .4rem 1rem 0; }
  .content { padding: 1.1rem 1rem 3rem; }
  .who-name { display: none; }
}
@media (max-width: 36rem) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .brand .eyebrow { display: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .kpi-value { font-size: 22px; }
  .card { padding: 1rem; }
  .gate-card { padding: 1.6rem 1.25rem; }
  .form-row > label { flex-basis: 100%; }
  .form-row > .btn { width: 100%; }
  /* Tables scroll sideways inside their card instead of squeezing every cell. */
  .table-wrap table { min-width: 34rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
