@font-face {
  font-family: "DM Sans";
  src: url("assets/dm-sans.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

@font-face {
  font-family: Manrope;
  src: url("assets/manrope.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}

/* HTS Systems brand palette, based on the public htssystems.co.uk theme. */
:root {
  color-scheme: light;
  --ink: #172b25;
  --paper: #f2f5f1;
  --lime: #c9ee9e;
  --line: #d9e2da;
  --panel: #ffffff;
  --soft: #e9f1e8;
  --muted: #52675c;
  --focus: #286544;
  --warning: #80502c;
  --display: Manrope, "DM Sans", system-ui, sans-serif;
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; line-height: 1.5; }
[hidden] { display: none !important; }

.skip-link {
  position: fixed;
  top: .75rem;
  left: .75rem;
  z-index: 2;
  padding: .65rem 1rem;
  background: var(--lime);
  color: var(--ink);
  transform: translateY(-200%);
}

.skip-link:focus { transform: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  min-height: 76px;
  padding: .5rem clamp(1rem, 3vw, 2.5rem);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.brand { display: flex; align-items: center; gap: .85rem; min-width: 0; }
.brand-logo {
  display: block;
  width: 190px;
  height: 62px;
  flex: 0 0 auto;
}

.brand-logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: left center;
}

.site-header .brand-logo {
  width: 145px;
  height: 48px;
}

.brand-label {
  border-left: 1px solid var(--line);
  padding-left: .85rem;
  color: var(--muted);
  font-size: .69rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

main { max-width: 1580px; margin: auto; padding: 0 clamp(1rem, 3vw, 2.5rem) 3rem; }
#status { margin: .8rem 0; color: var(--ink); font-weight: 600; }
#status:empty { margin: 0; }
#status:not(:empty) { border-left: 4px solid var(--lime); padding: .45rem .75rem; background: var(--panel); }

.gate {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  max-width: 1060px;
  margin: clamp(1.25rem, 8vw, 6rem) auto;
  border: 1px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
  background: var(--panel);
  box-shadow: 0 18px 55px #1c332517;
}

.gate-intro,
.gate-form,
.gate-compact { padding: clamp(1.25rem, 4vw, 3.5rem); }

.gate-intro {
  border-right: 1px solid var(--line);
  color: #f6faf5;
  background: radial-gradient(ellipse at 90% 100%, #386143, transparent 68%), #1a3028;
}

.gate-form { align-self: center; }
.gate-compact { display: block; max-width: 590px; }
.gate-intro h1 { font-size: clamp(2.25rem, 6vw, 5rem); overflow-wrap: anywhere; }
.gate-intro p { max-width: 34ch; margin-bottom: 0; color: #d8e9df; }
.brand-dot { color: #637b13; }

.tag {
  display: inline-block;
  padding: .35rem .55rem;
  background: var(--lime);
  color: var(--ink);
  font-size: .69rem;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
}

h1, h2, h3 { font-family: var(--display); }
h1 {
  margin: .55rem 0;
  font-size: clamp(2rem, 6vw, 4rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.065em;
}
h2 { margin: .2rem 0 .85rem; font-size: 1.35rem; font-weight: 750; line-height: 1.2; letter-spacing: -.035em; }
p, small { color: var(--muted); }
label { display: block; margin: .75rem 0; font-size: .92rem; font-weight: 650; }

input, textarea, select {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: .35rem;
  padding: .65rem .7rem;
  background: #fff;
  border: 1px solid #889b8d;
  border-radius: 10px;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  font-weight: 400;
}

input[type="checkbox"] { display: inline-block; width: auto; min-height: auto; accent-color: var(--focus); }
textarea { min-height: 6rem; }

button {
  min-height: 44px;
  padding: .55rem .85rem;
  border: 1px solid var(--ink);
  border-radius: 10px;
  background: var(--lime);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:hover:not(:disabled) { background: #d8f5b6; }
button.secondary { background: transparent; color: var(--ink); }
button.secondary:hover:not(:disabled) { background: var(--soft); }
button[aria-current="true"] { border-color: var(--ink); background: var(--lime); color: var(--ink); }
button:disabled { opacity: .55; cursor: default; }

.heading, .row { display: flex; align-items: center; justify-content: space-between; gap: .7rem; flex-wrap: wrap; }
.workspace-heading { padding: clamp(1.25rem, 4vw, 2.5rem) 0 .7rem; }
.workspace-heading h1 { margin-bottom: .25rem; }
.card, .metric { min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: clamp(.95rem, 2vw, 1.4rem); }
.card { background: var(--panel); }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 205px), 1fr)); gap: .65rem; margin: .7rem 0; }
.metrics:empty { display: none; }
.metric { background: var(--soft); }
.metric strong { display: block; font: 750 clamp(1.35rem, 3vw, 2rem)/1.2 var(--display); letter-spacing: -.055em; overflow-wrap: anywhere; }
.metric small { display: block; margin-top: .25rem; }

.actions { display: flex; flex-wrap: wrap; gap: .45rem; margin: .75rem 0; }
#workspace {
  display: grid;
  grid-template-columns: clamp(11rem, 17vw, 15.5rem) minmax(0, 1fr);
  gap: clamp(1rem, 2.8vw, 2.25rem);
  align-items: start;
  padding-top: 1.35rem;
}
.workspace-content { min-width: 0; }
.workspace-sidebar {
  position: sticky;
  top: 1.2rem;
  max-height: calc(100dvh - 2.4rem);
  overflow-y: auto;
  padding: .9rem;
  border-radius: 18px;
  background: #1a3028;
  color: #ecf4ee;
}
.workspace-heading {
  padding: .2rem 0 .95rem;
  min-height: 3.75rem;
}
.workspace-heading h1 { font-size: clamp(1.85rem, 4vw, 2.85rem); letter-spacing: -.05em; }
.nav-group + .nav-group { margin-top: .9rem; padding-top: .75rem; border-top: 1px solid #355146; }
.nav-label { display: block; padding: .15rem .7rem .35rem; color: #adccba; font-size: .72rem; font-weight: 700; }
#nav button {
  display: block;
  width: 100%;
  min-height: 40px;
  padding: .53rem .7rem;
  text-align: left;
  border-color: transparent;
  background: transparent;
  color: #e8f2e9;
  font-size: .9rem;
  border-radius: 8px;
}
#nav button:hover:not(:disabled) { background: #2b493d; }
#nav button[aria-current="true"],
#nav button[aria-current="true"]:hover:not(:disabled) { background: var(--lime); color: var(--ink); }
#nav button:focus-visible { outline-color: var(--lime); }
.card { border-radius: 16px; box-shadow: 0 2px 8px #1a302805; }
.metric { background: var(--panel); border-radius: 14px; }
.dashboard-context {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .65rem;
  padding: .95rem 1.05rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #e6ede4;
}
.dashboard-context strong { display: block; overflow-wrap: anywhere; }
.dashboard-context small { display: block; }
.dashboard-controls { display: flex; align-items: flex-end; flex-wrap: wrap; gap: .5rem; }
.dashboard-controls label { margin: 0; font-size: .75rem; color: var(--muted); }
.dashboard-controls select { margin-top: .2rem; font-size: .85rem; }
.dashboard-context button, #refresh { background: #fff; border-color: #9cac9d; }
.dashboard-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .75rem;
  margin: .85rem 0;
}
.dashboard-tile { border-top: 3px solid #b3c7b3; }
.dashboard-tile:nth-child(-n+3) { border-top-color: #4c8767; }
.dashboard-tile strong { font-size: clamp(1.3rem, 2.45vw, 2.15rem); margin: .2rem 0; }
.dashboard-tile small:first-child { font-weight: 700; }
.dashboard-detail {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr);
  align-items: start;
  gap: .85rem;
}
.dashboard-side { display: grid; gap: .85rem; min-width: 0; }
.dashboard-list { padding-left: 0; margin: 0; list-style: none; }
.dashboard-list li {
  display: flex;
  justify-content: space-between;
  gap: .65rem;
  padding: .65rem 0;
  border-bottom: 1px solid var(--line);
  font-size: .89rem;
  overflow-wrap: anywhere;
}
.dashboard-list li:last-child { border: 0; }
.dashboard-list small { display: block; }
.trend-card h2 { margin-bottom: .3rem; }
.trend-legend { display: flex; flex-wrap: wrap; gap: .35rem 1.1rem; margin: .65rem 0; color: var(--muted); font-size: .8rem; }
.trend-legend span::before { content: ""; display: inline-block; width: .65rem; height: .65rem; margin-right: .4rem; border-radius: 3px; background: #397654; }
.trend-legend span + span::before { background: #bc7649; }
.trend-chart { max-height: 27rem; overflow: auto; }
.trend-day {
  display: grid;
  grid-template-columns: 3.6rem minmax(0, 1fr);
  align-items: center;
  gap: .65rem;
  padding: .5rem 0;
  border-top: 1px solid var(--line);
}
.trend-day time, .trend-line { font-size: .8rem; }
.trend-line {
  display: grid;
  grid-template-columns: minmax(1.75rem, 1fr) max-content;
  gap: .5rem;
  align-items: center;
  font-variant-numeric: tabular-nums;
}
.trend-line meter { width: 100%; height: .55rem; appearance: none; }
.trend-line meter::-webkit-meter-bar { background: #eaf0e9; border: 0; border-radius: 4px; }
.trend-sales meter::-webkit-meter-optimum-value { background: #397654; border-radius: 4px; }
.trend-cost meter::-webkit-meter-optimum-value { background: #bc7649; border-radius: 4px; }
.trend-sales meter::-moz-meter-bar { background: #397654; }
.trend-cost meter::-moz-meter-bar { background: #bc7649; }
.dashboard-empty { padding: .75rem 0; }

.grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: .85rem; }
.list { max-height: 24rem; overflow: auto; }
.entry { padding: .7rem 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.entry:last-child { border-bottom: 0; }
.entry p { white-space: pre-wrap; margin: .35rem 0; }
.list button { width: 100%; text-align: left; margin: .2rem 0; }
.bubble { margin: .55rem 0; padding: .75rem; border-radius: 10px; background: var(--soft); white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.out { border-left: 3px solid var(--focus); }
.notice { color: var(--warning); }
#books_image { display: block; max-width: min(100%, 620px); max-height: 65vh; margin: .8rem 0; border-radius: 10px; }

.op-stack { display: grid; gap: .85rem; }
.op-toolbar { margin: .7rem 0; }
.op-toolbar:empty { display: none; }
.op-toolbar label { max-width: 440px; }
.op-fields, .op-products { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); }
.op-fields { gap: 0 1rem; }
.op-products { gap: .55rem; margin: .7rem 0; }
.op-products button { text-align: left; }
.op-stack summary, dialog summary { cursor: pointer; padding: .65rem 0; }
.op-stack pre { font-size: .8rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.op-stack details > summary { overflow-wrap: anywhere; }

dialog {
  width: min(94vw, 700px);
  max-height: 85vh;
  padding: 1.25rem;
  overflow: auto;
  border: 1px solid var(--ink);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
}
dialog::backdrop { background: #111310a6; }
dialog a { color: var(--focus); text-underline-offset: .15em; }
.vault-preview { display: block; max-width: 100%; max-height: 52vh; margin: .75rem auto; object-fit: contain; }

#print { display: none; }
#print table { width: 100%; border-collapse: collapse; }
#print th, #print td { padding: .4rem; border-bottom: 1px solid var(--line); text-align: left; }

@media (max-width: 700px) {
  .site-header { min-height: 68px; }
  .brand-logo { width: 145px; height: 48px; }
  .brand, .brand-label { gap: .65rem; }
  .brand-label { padding-left: .65rem; font-size: .62rem; }
  .gate, .grid { grid-template-columns: minmax(0, 1fr); }
  .gate-intro { border-right: 0; border-bottom: 1px solid var(--line); }
  .gate-break { display: none; }
  .list { max-height: 15rem; }
}

@media (max-width: 480px) {
  main { padding-inline: .8rem; }
  .site-header { padding-inline: .8rem; }
  .brand-logo { width: 91px; height: 36px; }
  .site-header .brand-logo { width: 102px; height: 36px; }
  .brand-label { position: absolute; height: 1px; width: 1px; overflow: hidden; clip-path: inset(50%); }
  .workspace-heading h1 { font-size: clamp(1.45rem, 6vw, 1.7rem); }
  .header-actions { gap: .35rem; font-size: .82rem; }
  .header-actions button { padding-inline: .5rem; }
  .op-fields { grid-template-columns: minmax(0, 1fr); }
  .dashboard-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media print {
  body { background: white; color: var(--ink); }
  body > .site-header, body > .skip-link, main > * { display: none !important; }
  main { padding: 0; }
  main > #print { display: block !important; max-width: 740px; margin: 1rem auto; }
  #print .print-header { border-bottom: 1px solid var(--line); margin-bottom: 1.2rem; padding-bottom: .45rem; }
  #print h1 { font-size: 2rem; }
  #print p { color: var(--ink); }
}

.header-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }
.header-actions a { color: var(--focus); text-underline-offset: .18em; }
#mobileNavigation { display: none; }
#offlineNotice { padding: .65rem .85rem; border-left: 4px solid var(--warning); background: var(--panel); }
body { padding-bottom: env(safe-area-inset-bottom, 0px); }
.site-header { padding-top: max(.4rem, env(safe-area-inset-top)); }
@media (max-width: 700px) {
  #mobileNavigation { display: block; margin: .75rem 0; }
  #workspace { grid-template-columns: minmax(0, 1fr); padding-top: .8rem; gap: 0; }
  .workspace-sidebar { display: none; }
  .workspace-heading { padding-bottom: .25rem; }
  .dashboard-detail { grid-template-columns: minmax(0, 1fr); }
  .header-actions button { padding-inline: .65rem; }
  button, input, select, textarea { min-height: 44px; }
  input, select, textarea { font-size: 1rem; }
  input[type="checkbox"] { min-height: auto; }
}

@media (max-width: 360px) {
  .dashboard-metrics { grid-template-columns: minmax(0, 1fr); }
  .trend-day { gap: .35rem; grid-template-columns: 2.9rem minmax(0, 1fr); }
}

.wa-grid { margin-top: 1rem; }
.wa-grid .card { min-width: 0; overflow-wrap: anywhere; }
.wa-grid .bubble form { margin-top: .75rem; }
.wa-grid details { margin: 1rem 0; }
.wa-grid details summary { cursor: pointer; }

.verification-actions { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: 1rem; }
.new-customer { margin-top: 1.5rem; padding-top: 1.1rem; border-top: 1px solid var(--line); }
.new-customer p { margin: 0 0 .65rem; }
.account-note { font-size: .875rem; color: var(--muted); line-height: 1.6; }
.new-customer .account-note { margin-top: .7rem; }
.account-consent { display: flex; gap: .65rem; align-items: flex-start; }
.account-consent input { width: 1.1rem; height: 1.1rem; min-height: 0; margin: .2rem 0 0; flex-shrink: 0; }
#signup .gate-intro h1 { font-size: clamp(2.25rem, 4.6vw, 4rem); }
#verifyEmail h1 { font-size: clamp(2rem, 4vw, 3rem); }
#verificationEmail { overflow-wrap: anywhere; }

/* Application review and platform administration */
.application-status { max-width: 46rem; }
.application-details { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,11rem),1fr)); gap: .7rem 1rem; margin: 1rem 0; }
.application-details dt { font-weight: 650; font-size: .9rem; }
.application-details dd { margin: .2rem 0 0; overflow-wrap: anywhere; }
.platform-business { margin-top: 1rem; padding: 1rem; }
.platform-business-heading { display: flex; gap: .5rem 1rem; flex-wrap: wrap; align-items: baseline; justify-content: space-between; }
.platform-business-heading h3 { margin: 0; overflow-wrap: anywhere; }
.platform-form { display: flex; flex-wrap: wrap; align-items: end; gap: .65rem; margin-block: .85rem; }
.platform-form label { flex: 1 1 13rem; margin: 0; }
.platform-form textarea { width: 100%; }
.review-message { white-space: pre-wrap; overflow-wrap: anywhere; padding: .7rem; border-inline-start: 3px solid currentColor; }
.platform-audit small { display: block; overflow-wrap: anywhere; }
@media (max-width: 40rem) {
  .platform-form { display: grid; }
  .platform-business { padding: .75rem; }
  .platform-form .actions { display: flex; flex-wrap: wrap; }
}
