/* Dealers page (dealers.js). Everything scoped under .dl; colors from app.css tokens so light/dark both work. */

/* ---- dealers.html page frame and the shared pieces of both screens (sections, cards, rows) ---- */
.dlpage main .wrap {
  padding-block: 16px 48px;
}

.dl {
  display: grid;
  gap: 16px;
}

.dl button {
  -webkit-tap-highlight-color: transparent;
}

.dl .bad {
  color: var(--bad);
}

.dl i.up {
  font-style: normal;
  color: var(--ok);
  font-weight: 700;
}

.dl i.down {
  font-style: normal;
  color: var(--bad);
  font-weight: 700;
}

.dl .sub {
  color: var(--muted);
  font-size: .9rem;
  margin: 0;
}

.dl .empty.sm {
  padding: 14px;
  font-size: .92rem;
}

.dl .sec {
  display: grid;
  gap: 10px;
}

.dl .sec h3 {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin: 0;
}

.dl .sec h4 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin: 6px 0 0;
  color: var(--muted);
}

.dl .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.dl .ln {
  display: grid;
  grid-template-columns: minmax(80px,auto) 1fr auto;
  gap: 4px 12px;
  align-items: center;
  padding: 9px 14px;
  border-top: 1px solid var(--line);
}

.dl .card>.ln:first-child {
  border-top: 0;
}

.dl .ln .nm {
  min-width: 0;
}

.dl .ln small {
  display: block;
  color: var(--muted);
  font-size: .85rem;
}

.dl .ln .q2 {
  font-family: var(--mono);
  font-weight: 600;
  white-space: nowrap;
}

.dl .sku {
  font-family: var(--mono);
  font-size: .82rem;
  color: var(--steel);
  font-weight: 600;
}

/* top tiles */
.dltiles {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 10px;
}

.dltile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dltile b {
  font-size: .82rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.dltile strong {
  font-family: var(--display);
  font-size: 2rem;
  line-height: 1.1;
}

.dltile span {
  font-size: .88rem;
  color: var(--muted);
}

.dltile.bad {
  border-color: var(--bad);
  background: var(--bad-bg);
}

.dltile.bad strong {
  color: var(--bad);
}

.dltile.warn {
  border-color: var(--warn);
  background: var(--warn-bg);
}

.dltile.warn strong {
  color: var(--warn);
}

/* ---- List screen: search box, filter chips + sort, and the Shopify sync line ---- */
.dlbar {
  display: flex;
  gap: 10px;
  align-items: center;
}

.dlbar .libq {
  flex: 1;
  min-width: 0;
  box-sizing: border-box;
  font: inherit;
  font-size: 1.05rem;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
}

.dlbar .libq:focus {
  outline: none;
  border-color: var(--steel);
}

.dlnav {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.dlnav .chip {
  font-size: .9rem;
  padding: 4px 12px;
}

.dlnav .chip span {
  font-family: var(--mono);
  font-size: .78rem;
  opacity: .7;
  margin-left: 2px;
}

.dlsort {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: .88rem;
  color: var(--muted);
}

.dlsort .ein {
  width: auto;
  padding: 6px 8px;
}

.dlsync {
  display: flex;
  gap: 8px 12px;
  align-items: center;
  flex-wrap: wrap;
  font-size: .88rem;
  color: var(--muted);
}

.dlsync>span:first-child {
  margin-right: auto;
}

/* paperwork chips */
.pw {
  display: inline-block;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .03em;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
}

.pw.ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.pw.warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.pw.bad {
  background: var(--bad-bg);
  color: var(--bad);
}

.pw.none {
  border: 1px solid var(--muted);
  color: var(--muted);
}

/* dealer list */
.dlist {
  display: grid;
}

.dlrow {
  display: grid;
  grid-template-columns: minmax(0,2.2fr) 70px minmax(0,1.3fr) minmax(0,1fr) minmax(0,2fr);
  gap: 6px 14px;
  align-items: center;
  text-align: left;
  font: inherit;
  color: var(--ink);
  background: none;
  border: 0;
  border-top: 1px solid var(--line);
  padding: 11px 14px;
  cursor: pointer;
  width: 100%;
}

.dlist>.dlrow:first-child {
  border-top: 0;
}

.dlrow:hover {
  background: var(--bg);
}

.dlrow:focus-visible {
  outline: 3px solid var(--straw);
  outline-offset: -3px;
}

.dlrow>span {
  min-width: 0;
}

.dlrow small {
  display: block;
  color: var(--muted);
  font-size: .84rem;
}

.dlname b {
  font-size: 1.02rem;
}

.dltier b,.dlsales b,.dllast b {
  font-family: var(--mono);
  font-weight: 600;
}

.dllast .pw {
  margin-top: 3px;
}

.dlpaper {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* one dealer */

/* ---- One-dealer screen: Info form ---- */
.dl .dhead h2 {
  margin: 0;
}

.dlgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill,minmax(220px,1fr));
  gap: 10px 14px;
}

.dlgrid label {
  display: grid;
  gap: 4px;
  font-weight: 700;
  font-size: .88rem;
  color: var(--muted);
}

.dlgrid label .ein {
  font-weight: 400;
  color: var(--ink);
}

.dlpair {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 10px;
}

.dlsave {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.dl .pmsg {
  font-weight: 600;
}

.dl .pmsg.bad {
  color: var(--bad);
}

/* ---- One-dealer screen: Paperwork slots, files, and the drop zones ---- */
.dlslots {
  display: grid;
  grid-template-columns: repeat(auto-fill,minmax(300px,1fr));
  gap: 12px;
}

.dlslot {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  display: grid;
  gap: 8px;
  align-content: start;
}

.dlslh {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.dlfile {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  align-items: center;
}

.dlfile a {
  color: var(--steel);
  text-decoration: underline;
  cursor: pointer;
  font-weight: 600;
  word-break: break-all;
}

.dlfile small {
  grid-column: 1;
  color: var(--muted);
  font-size: .84rem;
}

.dlfile .btn {
  grid-row: 1/span 2;
  grid-column: 2;
}

.dlfile.none small {
  grid-column: 1/-1;
}

.dlold summary {
  cursor: pointer;
  color: var(--muted);
  font-size: .85rem;
}

.dlold .dlfile {
  margin-top: 6px;
}

.dldrop {
  border: 2px dashed var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  display: grid;
  gap: 8px;
  cursor: pointer;
  color: var(--muted);
  font-size: .9rem;
}

.dldrop:focus-visible {
  outline: 3px solid var(--straw);
  outline-offset: 2px;
}

.dldrop.over {
  border-color: var(--straw);
  background: var(--bg);
}

.dldrop.busy {
  opacity: .6;
  pointer-events: none;
}

.dldrop u {
  color: var(--ink);
}

.dldates {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: end;
}

.dldates label {
  display: grid;
  gap: 3px;
  font-size: .8rem;
  font-weight: 700;
}

.dldates .ein {
  padding: 5px 8px;
  width: auto;
}

.dldates small {
  font-size: .8rem;
}

/* ---- One-dealer screen: Shopify (customer search and the checks list) ---- */
.dlfind {
  display: flex;
  gap: 8px;
}

.dlfind .ein {
  flex: 1;
  min-width: 0;
}

.dlchecks {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.dlchecks li {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: .92rem;
  border: 1px solid var(--line);
  background: var(--panel);
}

.dlchecks li.ok {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: transparent;
}

.dlchecks li.warn {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: transparent;
  font-weight: 600;
}

.dlchecks li.bad {
  background: var(--bad-bg);
  color: var(--bad);
  border-color: transparent;
  font-weight: 600;
}

/* ---- One-dealer screen: Sales (number tiles, chart legend, bar chart, by-year table) ---- */
.dlnums {
  display: grid;
  grid-template-columns: repeat(4,minmax(0,1fr));
  gap: 10px;
}

.dlnums>div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.dlnums b {
  display: block;
  font-family: var(--display);
  font-size: 1.5rem;
}

.dlnums small {
  color: var(--muted);
  font-size: .84rem;
}

.dlleg {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .84rem;
  color: var(--muted);
}

.dlleg .k {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  display: inline-block;
  margin-left: 8px;
}

.dlleg .k.prev,.dlchart .prev {
  background: var(--line);
  fill: var(--muted);
  opacity: .45;
}

.dlleg .k.cur,.dlchart .cur {
  background: var(--steel);
  fill: var(--steel);
}

.dlchart {
  width: 100%;
  height: auto;
  max-height: 180px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  box-sizing: border-box;
}

.dlchart text {
  font-size: 11px;
  fill: var(--muted);
  font-family: var(--body);
}

.dlyears {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  font-size: .94rem;
}

.dlyears th,.dlyears td {
  padding: 8px 12px;
  text-align: right;
  border-top: 1px solid var(--line);
}

.dlyears th {
  color: var(--muted);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-top: 0;
}

.dlyears th:first-child,.dlyears td:first-child {
  text-align: left;
}

.dlyears td small {
  color: var(--muted);
}

/* ---- One-dealer screen: Notes, and the Delete dealer bar ---- */
.dlnote {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
}

.dlnrow {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
}

.dl .card>.dlnrow:first-child {
  border-top: 0;
}

.dlnrow small {
  color: var(--muted);
  font-size: .82rem;
}

.dlnrow p {
  margin: 0;
  grid-column: 1;
}

.dlnrow .btn {
  grid-row: 1/span 2;
  grid-column: 2;
  align-self: start;
}

.dl .btn.del {
  color: var(--bad);
}

.dldanger {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.dldanger small {
  color: var(--muted);
}

/* ---- Phones: one tile per row; each dealer row becomes a 2-column card ---- */
@media (max-width:760px) {
  .dltiles {
    grid-template-columns: 1fr;
  }
  .dlrow {
    grid-template-columns: 1fr auto;
    grid-template-areas: "n s" "t l" "p p";
  }
  .dlname {
    grid-area: n;
  }
  .dlsales {
    grid-area: s;
    text-align: right;
  }
  .dltier {
    grid-area: t;
  }
  .dllast {
    grid-area: l;
    text-align: right;
  }
  .dlpaper {
    grid-area: p;
  }
  .dlnums {
    grid-template-columns: repeat(2,minmax(0,1fr));
  }
  .dlyears th:nth-child(4),.dlyears td:nth-child(4) {
    display: none;
  }
  .dlnote {
    grid-template-columns: 1fr;
  }
}

/* ---- Printing: hide the boxes and buttons ---- */
@media print {
  .dlbar,.dlnav,.dlsync,.dldrop,.dldanger,.dlnote,.dlfind {
    display: none!important;
  }
}

/* ---- Dealer program (app version 166, dealer-program.js) ---------------------------------------------------------- */

/* Collapsible list sections, like the CWA / Meyer boxes on Drop Ship. */
.dlsec {
  background: var(--panel);
  border: 1px solid var(--line);
}

.dlsec>summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.dlsec>summary::-webkit-details-marker {
  display: none;
}

/* The ▸ / ▾ arrow before each heading. */
.dlsec>summary::before {
  content: "▸";
  color: var(--muted);
  font-size: .9rem;
  width: 12px;
}

.dlsec[open]>summary::before {
  content: "▾";
}

.dlsec>summary:hover {
  background: var(--bg);
}

.dlcount {
  font-family: var(--mono);
  font-size: .8rem;
  letter-spacing: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 9px;
  color: var(--muted);
}

.dlcount.bad {
  background: var(--bad-bg);
  border-color: var(--bad);
  color: var(--bad);
}

.dlsecbody {
  border-top: 1px solid var(--line);
  padding: 12px 14px 14px;
  display: grid;
  gap: 10px;
}

/* Inside a section the card is already framed by the section. */
.dlsecbody>.card.dlist {
  border-radius: 0;
}

.dlsec.attn {
  border-left: 4px solid var(--warn);
}

.dlsecbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
}

.dlsecbar .sub {
  flex: 1 1 320px;
}

/* Needs attention: the dealer row with its flags under it. */
.dlattn {
  border-top: 1px solid var(--line);
}

.dlist>.dlattn:first-child {
  border-top: 0;
}

.dlattn .dlrow {
  border-top: 0;
}

.dlflags {
  display: grid;
  gap: 6px;
  padding: 0 14px 12px;
}

/* One flag: text on the left, buttons on the right. */
.dpflag {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  background: var(--bg);
}

.dpflag.lvl-act {
  border-left-color: var(--warn);
  background: var(--warn-bg);
}

.dpflag.up.lvl-act {
  border-left-color: var(--ok);
  background: var(--ok-bg);
}

.dpflag.graceOver.lvl-act,
.dpflag.paper.lvl-act {
  border-left-color: var(--bad);
  background: var(--bad-bg);
}

.dpflag.lvl-info {
  border-left-color: var(--steel);
}

.dpflagtext {
  display: grid;
  gap: 2px;
}

.dpflagtext small {
  color: var(--muted);
}

.dpflagbtns,
.dprowbtns,
.dpignore {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.dl .ein.sm {
  padding: 4px 6px;
  font-size: .85rem;
  width: auto;
}

/* Qualifies — not invited rows (not buttons: they hold their own buttons). */
.dprow {
  display: grid;
  grid-template-columns: minmax(0,2.2fr) minmax(0,1.2fr) minmax(0,1.6fr) auto;
  gap: 6px 14px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding: 11px 14px;
}

.dlist>.dprow:first-child {
  border-top: 0;
}

.dprow>span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.dprow small {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dprow .dlpaper {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.dpcheckbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .9rem;
  cursor: pointer;
}

/* The Dealer program panel on one dealer. */
.dpnums {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.dpnums>div {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 10px 12px;
  display: grid;
  gap: 2px;
}

.dpnums b {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}

.dpnums strong {
  font-family: var(--display);
  font-size: 1.35rem;
}

.dpnums small {
  color: var(--muted);
}

.dpnums .ok strong {
  color: var(--ok);
}

.dpnums .bad strong {
  color: var(--bad);
}

.dpsetup {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 12px 14px;
  display: grid;
  gap: 8px;
}

.dpsetup h4 {
  margin: 0;
}

.dpsetup>.btn {
  justify-self: start;
}

.dpcheck {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.dpcheck li b {
  display: inline-block;
  width: 18px;
}

.dpcheck li.done b {
  color: var(--ok);
}

.dpcheck li.todo b {
  color: var(--warn);
}

.dpcheck small {
  color: var(--muted);
}

.dpactivate {
  display: flex;
  justify-content: flex-end;
}

.dpshopify {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 10px 14px;
}

.dpshopify summary {
  cursor: pointer;
  font-weight: 700;
}

.dpshopify .sub {
  margin: 8px 0;
}

.dptable {
  border-collapse: collapse;
  width: 100%;
}

.dptable th,
.dptable td {
  text-align: left;
  border-top: 1px solid var(--line);
  padding: 6px 8px;
  vertical-align: top;
}

.dptable th {
  width: 190px;
  color: var(--muted);
  font-weight: 600;
}

/* The Program rules box. */
.dprules {
  display: grid;
  gap: 10px;
}

.dprules h4 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin: 8px 0 0;
}

.dprules h4 small {
  font-family: var(--body);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  color: var(--muted);
}

.dl .dlgrid label.dpcheckbox {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  align-self: end;
  padding-bottom: 10px;
  color: var(--ink);
  font-size: .92rem;
}

.dl .dlgrid label.dpcheckbox input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.dprules>.btn {
  justify-self: start;
}

.dpwide {
  grid-column: 1 / -1;
}

.dptiers {
  display: grid;
  gap: 8px;
}

.dptier {
  display: grid;
  grid-template-columns: minmax(0,1.4fr) minmax(0,.7fr) minmax(0,1fr) auto;
  gap: 8px;
  align-items: end;
}

.dptier label {
  display: grid;
  gap: 4px;
  font-size: .85rem;
  color: var(--muted);
}

@media (max-width: 760px) {
  .dprow {
    grid-template-columns: 1fr;
  }

  .dptier {
    grid-template-columns: 1fr 1fr;
  }

  .dpflag {
    flex-direction: column;
    align-items: flex-start;
  }
}
