/* Uses Nook's documented colours and the existing Studio panel/table controls. */
:root {
  --bg: #f4f1ed;
  --card: #fff;
  --ink: #1e1e1e;
  --sub: #6e635b;
  --line: #c8b8aa;
  --accent: #b0492a;
  --brass: #b08d57;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font:
    15px/1.5 Montserrat,
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  background: var(--bg);
  color: var(--ink);
}
.screen {
  max-width: 1280px;
  margin: auto;
  padding: 1rem 1.2rem 3rem;
}
header {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
header h1 {
  font-size: 1.05rem;
  margin: 0;
  font-weight: 600;
}
.env,
.pill {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
}
.tabs {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  width: 100%;
}
.tab {
  color: var(--sub);
  font-size: 0.86rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  text-decoration: none;
}
.tab.active {
  background: var(--accent);
  color: white;
}
[hidden] {
  display: none !important;
}
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.2rem;
  margin-bottom: 1rem;
}
h2 {
  font-size: 1.1rem;
  margin: 0.2rem 0 0.5rem;
}
h3 {
  font-size: 1rem;
  margin: 0.5rem 0;
}
p {
  margin: 0.5rem 0;
}
.muted {
  color: var(--sub);
  font-size: 0.85rem;
}
.warning {
  color: var(--accent);
}
.sales-tools .sales-export-option {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.35rem;
  align-self: flex-end;
  flex: 0 1 auto;
  min-height: 42px;
  font-size: 0.85rem;
}
.sales-tools .sales-export-option input { width: 1rem; height: 1rem; min-height: 1rem; padding: 0; margin: 0; }
.bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 0.65rem 0;
}
.spread {
  justify-content: space-between;
}
.sales-tools {
  align-items: flex-end;
}
.sales-tools label {
  flex: 0 1 16rem;
  margin: 0;
}
.sales-tools input,
.sales-tools select,
.sales-tools button {
  min-height: 2.65rem;
  font-size: 0.9rem;
}
.sales-maintenance {
  margin: 0.5rem 0;
  font-size: 0.85rem;
}
.sales-maintenance summary {
  cursor: pointer;
  color: var(--sub);
}
.sales-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-align: left;
}
.sales-toggle[aria-expanded="true"] > span {
  transform: rotate(90deg);
}
.sales-details > td {
  padding: 0;
}
.sales-drawer {
  contain: inline-size;
  background: var(--bg);
  padding: 0.8rem 1rem;
  overflow-wrap: anywhere;
}
.sales-drawer td {
  white-space: normal;
}
.sales-drawer .money {
  white-space: nowrap;
}
.product-rankings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 1rem;
}
.product-rankings li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
}
.product-rankings .money {
  display: block;
  font-weight: 600;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 0.6rem;
}
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.6rem;
}
.sales-metrics {
  /* Five wider cards per row at the Studio's full desktop width. */
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}
.metric {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.8rem;
}
.metric strong {
  display: block;
  font-size: 1.4rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.sales-basis-notes {
  margin: 0.7rem 0 0.4rem;
  padding-left: 1.1rem;
  font-size: 0.85rem;
}
.sales-kpi-group > h3 {
  margin: 0 0 0.5rem;
}
.sales-kpi-group + .sales-kpi-group {
  margin-top: 1.1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
}
.sales-metric {
  --metric-accent: var(--line);
  display: grid;
  grid-template-rows: subgrid;
  grid-row: span 4;
  row-gap: 0.45rem;
  min-width: 0;
  background: var(--bg);
  border-top: 3px solid var(--metric-accent);
}
.sales-metric--featured,
.sales-metric--attention { --metric-accent: var(--accent); }
.sales-metric--secondary { --metric-accent: var(--brass); }
.sales-metric-head {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  /* Reserve two title lines. Subgrid lets longer labels grow the shared
     title row on narrow screens without misaligning the figures. */
  min-height: 3em;
}
.sales-metric-head .muted { overflow-wrap: anywhere; }
.sales-metric-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 1.7rem;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 999px;
  background: var(--metric-accent);
  color: var(--ink);
}
.sales-metric-icon svg { width: 1.05rem; height: 1.05rem; }
.sales-metric-detail {
  display: block;
  font-size: 0.72rem;
  overflow-wrap: anywhere;
}
.sales-metric-detail + .sales-metric-detail { margin-top: 0.45rem; }
.sales-metric-foot {
  display: flex;
  align-items: flex-end;
}
.sales-metric--featured .sales-metric-icon,
.sales-metric--attention .sales-metric-icon { color: var(--card); }
.sales-metric-status {
  align-self: flex-start;
  margin-top: auto;
  font-size: 0.7rem;
}
label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--sub);
  margin: 0.3rem 0;
}
.check {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.check input {
  width: auto;
}
input,
select,
textarea,
button {
  font: inherit;
}
input,
select,
textarea {
  width: 100%;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--card);
  color: var(--ink);
}
textarea {
  min-height: 6rem;
  resize: vertical;
}
button {
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--card);
  padding: 0.45rem 0.8rem;
  color: var(--ink);
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
a {
  color: var(--accent);
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.tablewrap {
  overflow-x: auto;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.85rem;
}
th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 0.6rem 0.5rem;
  vertical-align: top;
}
th {
  font-size: 0.72rem;
  color: var(--sub);
  font-weight: 600;
  white-space: nowrap;
}
td input[type="checkbox"] {
  width: auto;
  min-width: 1rem;
}
td small {
  display: block;
  color: var(--sub);
}
ul {
  padding-left: 1.2rem;
}
li {
  margin: 0.2rem 0;
}
.sku {
  font-family: ui-monospace, monospace;
  overflow-wrap: anywhere;
}
.money {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.quote-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.5rem;
}
.quote-toggle[aria-expanded="true"] span {
  transform: rotate(90deg);
}
.quote-details > td {
  padding: 0;
}
.shipping-filter label { flex: 0 1 28rem; }
.shipping-profile-cell { min-width: 12rem; max-width: 16rem; overflow-wrap: anywhere; }
.shipping-profile-cell > a { display: block; }
.shipping-drawer {
  /* Keep its explanation and close control within the viewport even when the
     product table itself needs horizontal scrolling on a small screen. */
  position: sticky;
  left: 0;
  width: min(100%, calc(100vw - 6rem));
}
.shipping-drawer table { table-layout: fixed; min-width: 600px; }
.shipping-drawer th { white-space: normal; }
.audit-filters { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.audit-metrics { margin: 1rem 0 0.5rem; }
.audit-metrics .metric span { font-size: 0.8rem; color: var(--sub); }
.tablewrap table.audit-table { table-layout: fixed; min-width: 1000px; }
.audit-table th { white-space: normal; }
.audit-table th:nth-child(1) { width: 5%; }
.audit-table th:nth-child(2) { width: 22%; }
.audit-table th:nth-child(3) { width: 18%; }
.audit-table th:nth-child(4) { width: 22%; }
.audit-table th:nth-child(5) { width: 18%; }
.audit-table th:nth-child(6) { width: 15%; }
.audit-table td { overflow-wrap: anywhere; }
.audit-table .shipping-profile-cell { min-width: 0; max-width: none; }
.audit-options { list-style: none; padding: 0; margin: 0; }
.audit-options li { border-bottom: 1px solid var(--line); padding: 0 0 0.5rem; margin: 0 0 0.5rem; }
.audit-options li:last-child { border-bottom: none; margin-bottom: 0; }
.audit-options strong { display: block; font-size: 0.9rem; }
.audit-options .money { white-space: normal; }
.audit-options-cell small { font-size: 0.75rem; }
.audit-review-cell .pill { display: inline-block; }
.audit-review-cell details { font-size: 0.78rem; }
.audit-actions { font-size: 0.8rem; }
.audit-actions > a { display: block; margin-bottom: 0.5rem; }
.studio-page .audit-actions .studio-product-link { white-space: normal; max-width: 100%; }
.audit-actions button { width: 100%; margin: 0.2rem 0; padding: 0.35rem 0.45rem; font-size: 0.8rem; }
#planning-tools { border-top: 1px solid var(--line); margin-top: 0.8rem; padding-top: 0.3rem; }
#delivery-review-confirm { flex: 0 0 auto; }
.quote-drawer {
  /* Explanations must not participate in the table's column sizing. */
  contain: inline-size;
  white-space: normal;
  overflow-wrap: anywhere;
  background: var(--bg);
  padding: 0.8rem 1rem;
}
.quote-drawer .bar {
  margin-top: 0;
}
.quote-drawer ul {
  margin: 0.5rem 0;
}
details > summary {
  cursor: pointer;
  font-weight: 600;
  margin: 0.5rem 0;
}
dialog {
  width: min(900px, 94vw);
  max-height: 90vh;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.2rem;
  color: var(--ink);
  background: var(--card);
}
dialog::backdrop {
  background: var(--ink);
  opacity: 0.4;
}
.skip {
  position: absolute;
  left: 1rem;
  top: -10rem;
  background: var(--card);
  padding: 0.5rem;
  z-index: 100;
}
.skip:focus {
  top: 1rem;
}
.email {
  min-height: 18rem;
  font-size: 0.85rem;
}
.packrow {
  display: grid;
  grid-template-columns: repeat(4, minmax(70px, 1fr)) auto;
  gap: 0.5rem;
  align-items: end;
  margin: 0.5rem 0;
}
#notice:not(:empty) {
  border: 1px solid var(--line);
  padding: 0.8rem;
  margin-bottom: 1rem;
  background: var(--card);
}
@media (max-width: 600px) {
  .screen {
    padding: 0.8rem 0.7rem 2rem;
  }
  .panel {
    padding: 0.8rem;
  }
  .tab {
    font-size: 0.78rem;
    padding: 0.3rem 0.5rem;
  }
  .packrow {
    grid-template-columns: 1fr 1fr;
  }
  .tablewrap table {
    min-width: 700px;
  }
  .metric strong {
    font-size: 1.2rem;
  }
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media print {
  header,
  .bar,
  button,
  #tools,
  #notice {
    display: none;
  }
  .screen {
    padding: 0;
  }
  .panel {
    break-inside: avoid;
    border: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
