:root {
  color-scheme: light;
  --page-bg: #f4f8fb;
  --text: #15313b;
  --sheet-bg: #ffffff;
  --grid: #bfe3ea;
  --head-bg: #dff5f6;
  --label-bg: #f7fcfd;
  --sum-bg: #d9f0f2;
  --accent: #136275;
  --label-text: #1f5260;
  --muted: #6c8a92;
  --focus: #1189a4;
  --ink: #0b3f9e;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: var(--page-bg);
  color: var(--text);
}

:root[data-theme="greenish"] {
  --page-bg: #f3faf5;
  --text: #153624;
  --grid: #b9dfc6;
  --head-bg: #def4e5;
  --label-bg: #f6fcf8;
  --sum-bg: #d8f0df;
  --accent: #1d6b3c;
  --label-text: #255337;
  --muted: #668774;
  --focus: #23894a;
}

:root[data-theme="reddish"] {
  --page-bg: #fff6f6;
  --text: #3d1c1c;
  --grid: #efc3c3;
  --head-bg: #fde3e3;
  --label-bg: #fff9f9;
  --sum-bg: #f8dada;
  --accent: #9b2f32;
  --label-text: #6f3133;
  --muted: #9a7071;
  --focus: #bf3f43;
}

:root[data-theme="black"] {
  --page-bg: #f4f4f4;
  --text: #111111;
  --grid: #7d7d7d;
  --head-bg: #e1e1e1;
  --label-bg: #fafafa;
  --sum-bg: #d7d7d7;
  --accent: #111111;
  --label-text: #111111;
  --muted: #555555;
  --focus: #111111;
}

* {
  box-sizing: border-box;
  user-select: none;
}

body {
  margin: 0;
  min-height: 100vh;
  -webkit-user-select: none;
}

.page {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 0;
}

input {
  font: inherit;
}

input:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent);
  outline: none;
}

.sheet-wrap {
  background: var(--sheet-bg);
  overflow: hidden;
}

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

table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  height: 38px;
  border: 1px solid var(--grid);
  padding: 0;
  position: relative;
  text-align: center;
}

th {
  background: var(--head-bg);
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

thead th:first-child,
tbody th {
  width: 74px;
}

thead th:last-child,
tbody td:last-child {
  width: 96px;
}

tbody th {
  background: var(--label-bg);
  color: var(--label-text);
  font-size: 14px;
  padding: 0 5px;
  text-align: left;
}

tbody tr.section-total th,
tbody tr.section-total td {
  background: var(--sum-bg);
  font-weight: 900;
}

td input {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 37px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-family: "Comic Sans MS", "Comic Sans", cursive;
  font-size: 22px;
  text-align: center;
  font-weight: 700;
}

td.zero-score::after {
  position: absolute;
  inset: 4px;
  z-index: 0;
  background: linear-gradient(
    to bottom right,
    transparent calc(50% - 1px),
    var(--ink) 50%,
    transparent calc(50% + 1px)
  );
  content: "";
  pointer-events: none;
}

td input::-webkit-outer-spin-button,
td input::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

td input[type="number"] {
  appearance: textfield;
}

td input:focus {
  position: relative;
  z-index: 1;
  box-shadow: inset 0 0 0 2px var(--focus);
}

.total-cell {
  display: grid;
  min-height: 37px;
  color: var(--ink);
  font-family: "Comic Sans MS", "Comic Sans", cursive;
  font-size: 22px;
  place-items: center;
}

.row-total {
  color: var(--ink);
  font-family: "Comic Sans MS", "Comic Sans", cursive;
  font-size: 22px;
  font-weight: 900;
}

.sum-cell,
.clickable-total {
  cursor: pointer;
}

.sum-cell:focus-visible,
.clickable-total:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.logo-space {
  background: var(--sheet-bg);
}

.hint {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
  text-transform: none;
}

.footer-row td {
  height: 38px;
  border-top: 10px solid var(--sheet-bg);
}

.brand-cell {
  background: var(--sheet-bg);
  text-align: left;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 38px;
  padding: 4px 8px;
}

.brand-logo {
  display: grid;
  min-width: 104px;
  justify-items: center;
  color: var(--accent);
  line-height: 1;
  cursor: pointer;
}

.brand-logo:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.brand-logo strong {
  font-family: "Brush Script MT", "Segoe Script", cursive;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-logo span {
  width: 100%;
  border-top: 2px solid var(--accent);
  padding-top: 3px;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 5px;
  text-align: center;
}

.brand-caption {
  color: var(--accent);
  font-size: 14px;
  font-weight: 400;
  margin-inline: auto;
  white-space: nowrap;
  cursor: pointer;
}

.brand-caption:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.barcode {
  display: flex;
  align-items: stretch;
  gap: 1px;
  margin-left: 0;
  margin-right: 18px;
  width: 160px;
  height: 36px;
  padding: 3px 5px;
  background: var(--sheet-bg);
  cursor: pointer;
}

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

.barcode span {
  background: var(--accent);
}

.grand-total-cell {
  background: var(--sheet-bg);
  padding: 0;
  vertical-align: top;
}

.grand-total-box {
  display: grid;
  width: 100%;
  height: 38px;
  place-items: center;
  background: var(--sum-bg);
  color: var(--ink);
  font-family: "Comic Sans MS", "Comic Sans", cursive;
  font-size: 22px;
  font-weight: 900;
}

.toast {
  position: fixed;
  right: 12px;
  bottom: 12px;
  left: 12px;
  z-index: 10;
  max-width: 520px;
  margin-inline: auto;
  border: 2px solid #b42318;
  border-radius: 8px;
  background: #fff1a8;
  color: #8a1f11;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
  font-size: 14px;
  font-weight: 800;
  opacity: 0;
  padding: 10px 12px;
  pointer-events: none;
  text-align: center;
  transform: translateY(12px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 760px) {
  .page {
    padding: 0;
  }

  th,
  td {
    height: 34px;
  }

  th {
    font-size: 11px;
  }

  thead th:first-child,
  tbody th {
    width: 54px;
  }

  thead th:last-child,
  tbody td:last-child {
    width: 64px;
  }

  tbody th {
    padding: 0 3px;
    font-size: 12px;
  }

  td input {
    min-height: 33px;
  }

  .total-cell {
    min-height: 33px;
  }

  .footer-row td {
    height: 34px;
    border-top-width: 8px;
  }

  .grand-total-box {
    height: 34px;
  }

  .brand-block {
    gap: 6px;
    padding: 3px 4px;
  }

  .brand-logo {
    min-width: 76px;
  }

  .brand-logo strong {
    font-size: 18px;
  }

  .brand-logo span {
    border-top-width: 1px;
    font-size: 6px;
    letter-spacing: 3px;
  }

  .brand-caption {
    font-size: 11px;
  }

  .barcode {
    width: 112px;
    height: 30px;
    padding: 3px;
  }

}

@media print {
  body {
    background: var(--sheet-bg);
  }

  .page {
    width: 100%;
    padding: 0;
  }

  table {
    min-width: 0;
  }
}
