/* GeoPad: one hand-written stylesheet, built for outdoor use on a phone.
   Dark text on white, strong borders, and every control at least 48px tall. */

:root {
  --ink: #111;
  --muted: #3d3d3d;
  --paper: #fff;
  --line: #222;
  --soft: #eef2f7;
  --brand: #0b3a6e;
  --brand-ink: #fff;
  --active: #ffe14d;
  --danger: #a10f0f;
  --ok: #0b6b2c;
  --tap: 48px;
  /* The one space between neighbouring controls. */
  --gap: 0.75rem;
  font-size: 18px;
}

* {
  box-sizing: border-box;
}

/* Keep `hidden` meaning hidden on elements we give a display, e.g. .link. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.45;
}

main {
  max-width: 44rem;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
}

h1 {
  font-size: 1.6rem;
  margin: 0.5rem 0;
}

h2 {
  font-size: 1.25rem;
  margin: 1.5rem 0 0.5rem;
}

a {
  color: var(--brand);
  text-underline-offset: 0.15em;
}

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

.lead {
  font-size: 1.1rem;
}

.meta,
.hint {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0.25rem 0;
}

/* --- top bar ------------------------------------------------------------ */

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1rem;
  padding: 0.25rem 1rem;
  border-bottom: 2px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: var(--tap);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--ink);
  text-decoration: none;
}

.topbar nav {
  display: flex;
  gap: 0.25rem;
}

/* Phones: brand and "Sign out" on one line, the section links below.
   A company logo stands in for the company name there. */
@media (max-width: 40rem) {
  .topbar nav {
    order: 3;
    flex-basis: 100%;
    margin-left: -0.6rem;
  }

  .brand-logo + .brand-name {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

.topbar nav a,
.link {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 0.6rem;
  font-weight: 600;
}

.signout {
  margin: 0 0 0 auto;
}

/* A company logo can be any shape: fit it to the bar's height. */
.brand-logo {
  height: 40px;
  width: auto;
  max-width: 10rem;
  object-fit: contain;
}

/* --- company page ------------------------------------------------------- */

.company-logo {
  display: block;
  max-width: 100%;
  max-height: 8rem;
  margin-bottom: var(--gap);
}

.company-details {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1rem;
}

.company-details dt {
  font-weight: 600;
}

.company-details dd {
  margin: 0;
}

.company-details .address {
  white-space: pre-line;
}

.form + .form {
  margin-top: var(--gap);
}

/* --- buttons and fields ------------------------------------------------- */

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0.5rem 1.1rem;
  border: 2px solid var(--brand);
  border-radius: 6px;
  background: var(--brand);
  color: var(--brand-ink);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

button.secondary,
.button.secondary {
  background: var(--paper);
  color: var(--brand);
}

button.danger {
  background: var(--paper);
  border-color: var(--danger);
  color: var(--danger);
}

button.link {
  background: none;
  border: 0;
  color: var(--brand);
  text-decoration: underline;
}

/* A text link with a full-size tap target, for gloved fingers on site. */
.tap-link {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
}

button:disabled {
  opacity: 0.55;
  cursor: progress;
}

.big {
  min-height: 64px;
  font-size: 1.15rem;
  width: 100%;
}

.stack,
.big-actions,
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
}

/* Phones: toolbar buttons share each row evenly instead of leaving ragged gaps. */
@media (max-width: 40rem) {
  .toolbar > * {
    flex: 1 1 9rem;
  }
}

.big-actions > * {
  flex: 1 1 14rem;
}

.form {
  display: grid;
  gap: 0.9rem;
}

.field {
  display: grid;
  gap: 0.3rem;
}

label,
legend {
  font-weight: 600;
}

input,
textarea,
select {
  width: 100%;
  min-height: var(--tap);
  padding: 0.5rem 0.7rem;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}

.invalid input,
.invalid textarea,
.invalid fieldset {
  border-color: var(--danger);
}

fieldset {
  border: 2px solid var(--line);
  border-radius: 6px;
  margin: 0;
  padding: 0.5rem 0.75rem;
}

.choice {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: var(--tap);
  font-weight: 500;
}

.choice input {
  flex: none;
  width: 1.5rem;
  min-height: 1.5rem;
  margin: 0;
}

.with-button {
  display: flex;
  gap: var(--gap);
}

.search {
  margin-bottom: var(--gap);
}

.with-button input {
  flex: 1;
  min-width: 0;
}

.error {
  color: var(--danger);
  font-weight: 700;
  margin: 0.2rem 0;
}

.ok {
  color: var(--ok);
  font-weight: 700;
}

div.ok {
  margin-bottom: 1rem;
}

.readings .table-wrap {
  margin-bottom: 1rem;
}

.toolbar + .hint {
  margin-top: var(--gap);
}

#results > .meta {
  margin: var(--gap) 0 0.5rem;
}

.net-status {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 0.75rem 1rem;
  background: var(--danger);
  color: #fff;
  font-weight: 700;
  text-align: center;
}

.tag {
  display: inline-block;
  padding: 0 0.45rem;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  vertical-align: middle;
}

/* --- landing ------------------------------------------------------------ */
/* The signed-out page at / (welcome.html): an engineering log sheet, with
   graph paper, serif headings and monospace labels. Scoped to .landing and
   .landing-nav so app pages are untouched. */

.landing,
.topbar:has(.landing-nav) {
  --sheet: #f6f3ea;
  --card: #fffdf7;
  --ink-navy: #1d2a36;
  --accent: #c2410c;
  --serif: "Iowan Old Style", Georgia, serif;
  --mono: ui-monospace, Menlo, Consolas, monospace;
}

.landing {
  background: var(--sheet);
  color: var(--ink-navy);
  font-family: var(--serif);
}

.landing main {
  max-width: none;
  padding: 0;
}

.topbar:has(.landing-nav) {
  background: var(--sheet);
  border-bottom-color: var(--ink-navy);
}

.landing-nav {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.85rem;
}

.landing-nav a {
  color: var(--ink-navy);
}

.landing-wrap {
  max-width: 70rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.landing section {
  padding: 3.5rem 0;
  border-bottom: 1.5px solid var(--ink-navy);
}

.landing h1 {
  font-size: 2.6rem;
  line-height: 1.1;
  font-weight: 600;
  margin: 0 0 1rem;
}

.landing h2 {
  font-size: 1.9rem;
  font-weight: 600;
  margin: 0 0 1.5rem;
}

.landing h3 {
  font-family: var(--mono);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 0.6rem;
}

.landing-sub {
  font-size: 1.1rem;
  color: #3e4c59;
  max-width: 34em;
}

.landing-kicker,
.landing-badge {
  margin: 0 0 0.4rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.landing-cta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  margin: 1.5rem 0 0;
}

.landing-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0.5rem 1.1rem;
  border: 1.5px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
}

.landing-button.ghost {
  background: transparent;
  border-color: var(--ink-navy);
  color: var(--ink-navy);
}

/* hero: graph paper behind the headline and the phone */

.landing-hero {
  background-image:
    linear-gradient(#0b3a6e14 1px, transparent 1px),
    linear-gradient(90deg, #0b3a6e14 1px, transparent 1px);
  background-size: 24px 24px;
}

.landing-hero-grid {
  display: flex;
  align-items: center;
  gap: 3rem;
}

.phone {
  flex: none;
  width: 260px;
  padding: 12px;
  border-radius: 34px;
  background: var(--ink-navy);
}

/* Mirrors the real testing page: readings list, then the 4-column keypad. */
.phone-screen {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 14px;
  border-radius: 24px;
  background: #fff;
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 0.75rem;
}

.phone-site {
  margin: 0;
  font-weight: 700;
}

.phone-rows {
  list-style: none;
  margin: 0;
  padding: 0;
}

.phone-rows li {
  display: flex;
  justify-content: space-between;
  padding: 0.2rem 0.4rem;
  border-bottom: 1px solid #ccc;
}

.phone-rows .active {
  background: var(--active);
  outline: 2px solid var(--line);
}

.phone-label {
  margin: 0.3rem 0 0;
}

.phone-keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.phone-keys span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  border-radius: 5px;
  background: var(--brand);
  color: var(--brand-ink);
  font-size: 1rem;
  font-weight: 700;
}

.phone-keys .zero {
  grid-column: span 4;
}

/* how it works */

.landing-steps {
  list-style: none;
  counter-reset: step;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.landing-steps li {
  counter-increment: step;
}

.landing-steps li::before {
  content: "STEP 0" counter(step);
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--accent);
}

.landing-steps h3 {
  margin-top: 0.6rem;
}

/* report preview: the sample PDF page, laid on the desk */

.landing-report {
  background: var(--card);
}

.landing-sheet {
  margin: 2rem 0 0;
  padding: 14px;
  background: #fff;
  border: 1.5px solid var(--ink-navy);
  box-shadow: 10px 10px 0 #0b3a6e22;
  transform: rotate(-0.6deg);
}

.landing-sheet img {
  display: block;
  width: 100%;
  height: auto;
}

.landing-sheet figcaption {
  margin-top: 0.6rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* features and pricing: cells of a dashed log-sheet grid */

.landing-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1.5px solid var(--ink-navy);
}

.landing-grid li {
  padding: 1.25rem;
  border-right: 1px dashed var(--ink-navy);
  border-bottom: 1px dashed var(--ink-navy);
  background: var(--card);
}

.landing-grid p {
  margin: 0;
}

.landing-tiers li {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.landing-tiers .landing-button {
  margin-top: auto;
}

.landing-tiers .popular {
  box-shadow: inset 0 4px 0 var(--accent);
}

.landing-tiers h3 {
  margin: 0;
}

.landing-price {
  font-size: 2.2rem;
  font-weight: 600;
  line-height: 1.1;
}

.landing-price small {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 400;
}

.landing-note {
  margin: 1rem 0 0;
  font-size: 0.95rem;
}

/* closing call to action and footer */

.landing .landing-end {
  background: var(--brand);
  color: var(--sheet);
  border-bottom: 0;
}

.landing-footer {
  padding: 1.5rem 0;
  font-family: var(--mono);
  font-size: 0.8rem;
}

@media (max-width: 720px) {
  .landing section {
    padding: 2.5rem 0;
  }

  .landing h1 {
    font-size: 2rem;
  }

  .landing-hero-grid {
    flex-direction: column;
    align-items: stretch;
  }

  .phone {
    margin: 0 auto;
  }

  .landing-steps,
  .landing-grid {
    grid-template-columns: 1fr;
  }
}

/* --- lists, tables ------------------------------------------------------ */

.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}

.card {
  display: flex;
  align-items: stretch;
  border: 2px solid var(--line);
  border-radius: 8px;
}

.card-link {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem 0.5rem;
  padding: 0.6rem 0.8rem;
  min-height: var(--tap);
  color: var(--ink);
  text-decoration: none;
}

.card-link .meta {
  flex-basis: 100%;
}

/* A button beside a card's text; on a phone it drops below rather than squeezing. */
.card:has(.card-action) {
  flex-wrap: wrap;
}

.card-action {
  display: flex;
  align-items: center;
  padding: 0.4rem 0.6rem;
}

.card-action button {
  white-space: nowrap;
}

.select-box {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 3.25rem;
  border-right: 2px solid var(--line);
}

.select-box input {
  width: 1.6rem;
  min-height: 1.6rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
}

th,
td {
  border: 1.5px solid var(--line);
  padding: 0.5rem 0.6rem;
  text-align: left;
}

th {
  background: var(--soft);
}

.details {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.3rem 1rem;
}

.details dt {
  font-weight: 700;
}

.details dd {
  margin: 0;
}

/* --- Scala entry -------------------------------------------------------- */

.test-header details {
  margin: 0.5rem 0;
}

.test-header summary {
  min-height: var(--tap);
  display: flex;
  align-items: center;
  font-weight: 700;
  color: var(--brand);
  cursor: pointer;
}

.scala-rows ol {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
}

.rows-head {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 0.5rem;
  font-weight: 700;
  padding: 0.25rem 0;
}

.row {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 0.5rem;
  padding: 0.2rem;
  border-radius: 8px;
  /* scrollIntoView keeps the active row clear of the sticky keypad */
  scroll-margin-bottom: 22rem;
}

.row form {
  margin: 0;
}

.row.active {
  background: var(--active);
  outline: 3px solid var(--ink);
}

.label-form input {
  text-align: center;
  font-weight: 600;
}

.row-button {
  width: 100%;
  justify-content: flex-start;
  gap: 0.75rem;
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line);
}

.row-button .blows {
  min-width: 1.6rem;
  text-align: right;
  font-size: 1.15rem;
}

.row-button .bar {
  flex: 1;
  height: 1.1rem;
  background: var(--soft);
  border-radius: 3px;
}

.row-button .bar span {
  display: block;
  height: 100%;
  background: var(--brand);
  border-radius: 3px;
}

.keypad {
  position: sticky;
  bottom: 0;
  z-index: 5;
  margin: 1rem -1rem 0;
  padding: 0.5rem 1rem 0.75rem;
  background: var(--paper);
  border-top: 3px solid var(--line);
}

.keypad-label {
  margin: 0 0 0.4rem;
}

.keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.45rem;
}

.key {
  min-height: 56px;
  font-size: 1.4rem;
}

.key.zero {
  grid-column: span 4;
}

.finish,
.readings {
  margin-top: 1.5rem;
}

.danger-zone {
  margin-top: 2rem;
}

/* --- Scala results: bar log chart and CBR view -------------------------- */

.scala-chart {
  margin: 0 0 1rem;
}

/* Narrow viewBox: ~16px text on a phone; capped so it doesn't balloon on desktop. */
.scala-chart svg {
  display: block;
  width: 100%;
  max-width: 30rem;
  height: auto;
  font-size: 17px;
}

.scala-chart .grid line {
  stroke: #e3e7ec;
  stroke-width: 1.5;
}

.scala-chart .axis {
  stroke: var(--line);
  stroke-width: 2;
}

.scala-chart .tick {
  fill: var(--muted);
}

.scala-chart .title {
  font-size: 15px;
}

.scala-chart .title,
.scala-chart .value {
  fill: var(--ink);
  font-weight: 600;
}

.scala-chart .bar {
  fill: var(--brand);
}

.scala-chart .limits line {
  stroke: var(--danger);
  stroke-width: 2.5;
  stroke-dasharray: 8 6;
}

.scala-chart .limits text {
  fill: var(--danger);
  font-size: 14px;
  font-weight: 600;
}

/* Reference lines only while the checkbox above the chart is ticked. */
.scala-chart:not(:has(.limits-toggle input:checked)) .limits {
  display: none;
}

.cbr-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 1rem;
  margin-bottom: 0.5rem;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  min-height: var(--tap);
  cursor: pointer;
}

.switch input {
  appearance: none;
  flex: none;
  position: relative;
  width: 3.2rem;
  min-height: 0;
  height: 1.8rem;
  margin: 0;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  cursor: pointer;
}

.switch input::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1.8rem - 8px);
  height: calc(1.8rem - 8px);
  border-radius: 50%;
  background: var(--ink);
  transition: transform 0.15s;
}

.switch input:checked {
  background: var(--brand);
  border-color: var(--brand);
}

.switch input:checked::before {
  background: var(--brand-ink);
  transform: translateX(1.4rem);
}

dialog {
  width: min(32rem, calc(100% - 2rem));
  padding: 1rem;
  border: 2px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
}

dialog::backdrop {
  background: rgb(0 0 0 / 0.45);
}

/* --- platform admin ---------------------------------------------------- */

.warning {
  border: 2px solid var(--danger);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.settings-group + .settings-group {
  margin-top: 1.5rem;
}

.copyable {
  overflow-wrap: anywhere;
  user-select: all;
}

/* Not an error: the page is a copy saved on the device. */
.net-status.notice {
  background: var(--ink);
}

.saved-list {
  padding-left: 1.2rem;
}

.saved-list li {
  margin: 0.5rem 0;
}
