/* ==========================================================================
   Supplier Dashboard
   ========================================================================== */

.dash { display: grid; grid-template-columns: 248px 1fr; min-height: calc(100vh - 106px); }
@media (max-width: 960px) { .dash { grid-template-columns: 1fr; } }

/* ---------- Side nav ---------- */
.dash-nav { background: var(--charcoal); color: var(--cream-2); padding: 1.5rem 1rem; display: flex; flex-direction: column; gap: 1.5rem; }
.dash-who { display: flex; gap: .75rem; align-items: center; padding: 0 .5rem; }
.dash-who__logo { flex-shrink: 0; box-shadow: 0 0 0 2px var(--wheat); width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; font-style: italic; color: #fff; }
.dash-who b { display: block; color: #fff; font-family: var(--font-display); line-height: 1.2; }
.dash-who span { font-size: .8rem; color: var(--wheat); }
.dash-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .2rem; }
.dash-nav button {
  width: 100%; display: flex; align-items: center; gap: .7rem; border: 0; background: transparent; color: inherit; cursor: pointer;
  padding: .7rem .75rem; border-radius: var(--radius-sm); font-family: var(--font-display); font-weight: 600; font-size: .95rem; text-align: left;
}
.dash-nav button:hover { background: rgba(255,255,255,.06); color: #fff; }
.dash-nav button[aria-current="page"] { background: var(--orange); color: #fff; }
.dash-nav .count { margin-left: auto; background: var(--wheat); color: var(--charcoal); font-size: .72rem; font-weight: 800; border-radius: 999px; padding: .05rem .5rem; }
.dash-nav button[aria-current="page"] .count { background: #fff; }
.dash-nav__foot { margin-top: auto; font-size: .8rem; color: rgba(239,230,210,.6); padding: 0 .5rem; }
@media (max-width: 960px) {
  .dash-nav { padding: 1rem; gap: 1rem; }
  .dash-nav ul { display: flex; overflow-x: auto; gap: .35rem; }
  .dash-nav button { white-space: nowrap; padding: .55rem .8rem; }
  .dash-nav__foot { display: none; }
}

/* ---------- Main ---------- */
.dash-main { padding: 1.75rem clamp(1rem, 3vw, 2.5rem) 3rem; min-width: 0; }
.dash-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.75rem; }
.dash-top h1 { font-size: clamp(1.7rem, 3vw, 2.3rem); margin: 0; }
.dash-top p { margin: .2rem 0 0; color: var(--muted); }

.demo-switch { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; background: var(--paper); border: 1px dashed var(--line); border-radius: var(--radius); padding: .6rem .8rem; margin-bottom: 1.5rem; font-size: .88rem; color: var(--muted); }
.seg { display: inline-flex; background: var(--cream-2); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: .4rem .9rem; border-radius: 999px; font-weight: 600; font-size: .85rem; cursor: pointer; color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--charcoal); color: var(--cream); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; }
.stat span { font-size: .82rem; color: var(--muted); font-weight: 600; }
.stat b { display: block; font-family: var(--font-display); font-size: 2rem; font-weight: 800; color: var(--charcoal); line-height: 1.15; margin-top: .2rem; }
.stat small { color: var(--green); font-weight: 600; }

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; min-width: 0; }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.panel__head h2 { font-size: 1.25rem; margin: 0; }
.cols { display: grid; grid-template-columns: 1.3fr 1fr; gap: 1.25rem; margin-bottom: 1.25rem; }
@media (max-width: 1100px) { .cols { grid-template-columns: 1fr; } }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; margin: 0 -1.25rem; padding: 0 1.25rem; }
table.dt { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 760px; }
.dt th { text-align: left; font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: .6rem .6rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.dt td { padding: .8rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.dt tr:last-child td { border-bottom: 0; }
.dt .prod { display: flex; align-items: center; gap: .7rem; }
.dt .prod b { display: block; color: var(--charcoal); font-weight: 600; }
.dt .prod small { color: var(--muted); }
.thumb { flex-shrink: 0; width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; }
.thumb svg { width: 32px; height: 32px; }
.stock { display: inline-flex; align-items: center; gap: .3rem; }
.stock input { width: 84px; padding: .35rem .5rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.stock span { color: var(--muted); font-size: .82rem; }
.row-actions { display: flex; gap: .35rem; justify-content: end; }
.mini-btn { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: .35rem .65rem; font-size: .82rem; font-weight: 600; cursor: pointer; color: var(--ink); }
.mini-btn:hover { border-color: var(--charcoal); }

.status { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .6rem; border-radius: 999px; font-size: .76rem; font-weight: 700; white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status--open { background: var(--green-soft); color: var(--green); }
.status--group { background: var(--orange-soft); color: var(--orange-dark); }
.status--draft { background: var(--cream-2); color: var(--muted); }
.status--low { background: #fbe9c9; color: #94620b; }
.status--out { background: #f3d6cf; color: #a13a22; }

.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.toolbar input[type="search"], .toolbar select { padding: .5rem .75rem; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: .88rem; }

/* ---------- Group purchase tracking ---------- */
.gp-list { display: grid; gap: 1rem; }
.gp-row { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; background: #fff; display: grid; gap: .6rem; }
.gp-row__top { display: flex; justify-content: space-between; gap: 1rem; align-items: start; flex-wrap: wrap; }
.gp-row h3 { margin: 0; font-size: 1.05rem; }
.gp-row small { color: var(--muted); }
.gp-row .progress { height: 10px; }
.gp-row .progress__bar { transition: none; }
.gp-meta { display: flex; gap: 1.25rem; flex-wrap: wrap; font-size: .85rem; color: var(--muted); }
.gp-meta b { color: var(--charcoal); }
.buyers { display: none; border-top: 1px solid var(--line); padding-top: .6rem; }
.gp-row.is-open .buyers { display: block; }
.buyers table { width: 100%; font-size: .86rem; border-collapse: collapse; }
.buyers td { padding: .35rem 0; border-bottom: 1px dashed var(--line); }
.buyers td:last-child { text-align: right; font-weight: 600; }

/* ---------- Inquiries ---------- */
.inq { display: flex; gap: .85rem; padding: .9rem 0; border-top: 1px solid var(--line); }
.inq:first-child { border-top: 0; padding-top: 0; }
.inq__avatar { flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%; background: var(--cream-2); display: grid; place-items: center; font-weight: 700; font-size: .85rem; color: var(--charcoal); }
.inq__body { flex: 1; min-width: 0; }
.inq__body b { color: var(--charcoal); }
.inq__body p { margin: .15rem 0 .35rem; font-size: .9rem; }
.inq__body small { color: var(--muted); }
.inq.is-unread .inq__avatar { background: var(--orange); color: #fff; }
.inq.is-unread b::after { content: " • New"; color: var(--orange-dark); font-size: .78rem; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 620px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: grid; gap: .35rem; }
.field > span { font-size: .84rem; font-weight: 600; color: var(--charcoal); }
.field > span em { font-style: normal; color: var(--muted); font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%; padding: .65rem .8rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--orange); outline-offset: 1px; border-color: transparent; }
.field textarea { min-height: 90px; resize: vertical; }
.field .hint { font-size: .78rem; color: var(--muted); }
.checks { display: flex; flex-wrap: wrap; gap: .5rem; }
.check { display: inline-flex; align-items: center; gap: .45rem; padding: .45rem .8rem; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: .88rem; cursor: pointer; }
.check:has(input:checked) { border-color: var(--orange); background: var(--orange-soft); }
.check input { accent-color: var(--orange); }
.fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; display: grid; gap: .75rem; background: var(--cream); }
.fieldset legend { font-family: var(--font-display); font-weight: 700; color: var(--charcoal); padding: 0 .4rem; }
.tier-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: .5rem; align-items: end; }
.icon-x { border: 0; background: transparent; cursor: pointer; color: var(--muted); font-size: 1.3rem; line-height: 1; padding: .4rem .5rem; }

/* ---------- Drawer ---------- */
dialog.drawer {
  margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: min(640px, 100vw); max-width: 100vw;
  border: 0; padding: 0; background: var(--paper); box-shadow: var(--shadow-lg); color: var(--ink);
}
dialog.drawer::backdrop { background: rgba(34,32,28,.45); }
.drawer__inner { display: flex; flex-direction: column; height: 100%; }
.drawer__head { display: flex; justify-content: space-between; align-items: center; padding: 1.2rem 1.5rem; border-bottom: 1px solid var(--line); }
.drawer__head h2 { margin: 0; font-size: 1.4rem; }
.drawer__body { padding: 1.5rem; overflow-y: auto; flex: 1; display: grid; gap: 1.1rem; align-content: start; }
.drawer__foot { display: flex; gap: .6rem; justify-content: end; padding: 1rem 1.5rem; border-top: 1px solid var(--line); background: var(--cream); }

.type-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; }
@media (max-width: 760px) { .type-cards { grid-template-columns: 1fr; } }
.type-card { position: relative; display: block; border: 2px solid var(--line); border-radius: var(--radius); padding: 1rem; cursor: pointer; background: #fff; }
.type-card:has(input:checked) { border-color: var(--orange); background: var(--orange-soft); }
.type-card input { position: absolute; opacity: 0; }
.type-card b { display: block; font-family: var(--font-display); color: var(--charcoal); margin: .5rem 0 .2rem; }
.type-card small { color: var(--muted); }
.type-card .tile__icon { width: 42px; height: 42px; }

[hidden] { display: none !important; }

/* Fixes: compact checkboxes/radios inside fields, readable table columns */
.field input[type="checkbox"], .field input[type="radio"] { width: auto; padding: 0; }
.dt .prod { min-width: 230px; }
.dt td { white-space: nowrap; }
.dt td:first-child { white-space: normal; }
