:root {
  --ink: #17202a;
  --muted: #5d6d7e;
  --line: #d7dee8;
  --panel: #ffffff;
  --wash: #f2f6f8;
  --night: #243447;
  --accent: #0b7fab;
  --accent-dark: #075f81;
  --ok: #138a52;
  --danger: #c0392b;
  --warning: #f4b942;
  --touch: 68px;
}

html {
  height: 100%;
  overflow: hidden;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  color: var(--ink);
  font-family: "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  background: var(--wash);
}

button {
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.app-shell {
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 6px 24px;
  background: var(--night);
  color: white;
}

.eyebrow {
  margin: 0 0 2px;
  color: #c8d8e4;
  font-size: 14px;
  font-weight: 700;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 26px;
}

.scale-panel {
  display: grid;
  grid-template-columns: auto auto auto;
  gap: 8px;
  align-items: baseline;
  min-width: 330px;
  justify-content: end;
}

.scale-label {
  color: #c8d8e4;
  font-weight: 700;
}

#currentWeight {
  font-size: 40px;
  line-height: 1;
}

.unit {
  font-size: 24px;
  font-weight: 800;
}

main {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 8px 16px 20px;
}

.mode-tabs {
  display: flex;
  gap: 8px;
  margin: 0 auto 6px;
  max-width: 1220px;
}

.mode-tabs button {
  min-height: 42px;
  padding: 0 28px;
  color: var(--night);
  background: #dde7ef;
}

.mode-tabs .active {
  color: white;
  background: var(--accent);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

#tabletView {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 8px;
  height: calc(100vh - 138px);
  max-width: 1220px;
  margin: 0 auto;
}

#tabletView.active {
  display: grid;
}

.progress-panel {
  grid-row: 1;
  min-height: 34px;
  padding: 0;
  overflow: hidden;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.progress-panel ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 0;
}

.progress-panel li {
  position: relative;
  min-width: 120px;
  color: #6d7f88;
  background: #d4dde4;
  font-size: 17px;
  font-weight: 800;
  clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 50%, calc(100% - 18px) 100%, 0 100%, 18px 50%);
  margin-left: -12px;
  opacity: 0.72;
}

.progress-panel li:first-child {
  margin-left: 0;
  clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 50%, calc(100% - 18px) 100%, 0 100%);
}

.progress-panel li button {
  width: 100%;
  min-height: 32px;
  padding: 0 24px 0 28px;
  color: inherit;
  background: transparent;
  text-align: center;
}

.progress-panel li:not(.reachable) button {
  cursor: default;
}

.progress-panel li.done {
  color: #12313b;
  background: #a8d7dc;
  opacity: 1;
}

.progress-panel li.reachable:not(.active):not(.done) {
  color: #24434d;
  background: #c8e2e5;
  opacity: 0.95;
}

.progress-panel li.active {
  color: #102d36;
  background: #8fd2d9;
  opacity: 1;
  box-shadow: inset 0 -3px rgba(0, 0, 0, 0.14);
}

.tablet-screen {
  grid-column: 1;
  grid-row: 2;
  position: relative;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  padding: 16px 28px;
  border-radius: 8px;
  background: #314052;
  color: white;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.tablet-footer {
  grid-column: 1;
  grid-row: 3;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 0 2px;
}

.tablet-footer button {
  min-height: 44px;
  color: #eaf4f8;
  background: #415164;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  box-shadow: inset 0 -3px rgba(0, 0, 0, 0.16);
  font-size: 20px;
  font-weight: 900;
}

.tablet-footer button:hover,
.tablet-footer button:focus-visible {
  background: #4e6175;
  outline: 2px solid #78d7e8;
  outline-offset: 1px;
}

#cancelButton {
  color: #ffffff;
  background: #6a5360;
}

#backButton {
  background: #2f6679;
}

.step {
  display: none;
  height: 100%;
}

.step.active {
  display: block;
}

#confirmStep.step.active {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100%;
  min-height: 0;
}

#confirmStep .large-prompt {
  margin-bottom: 12px;
  font-size: clamp(30px, 3.4vw, 42px);
}

.center-stage {
  min-height: 610px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 28px;
  text-align: center;
}

.large-prompt {
  margin: 0 0 12px;
  font-size: clamp(30px, 3.7vw, 44px);
  line-height: 1.2;
  font-weight: 900;
}

.start-button {
  width: min(360px, 80vw);
  aspect-ratio: 1;
  border-radius: 50%;
  color: white;
  background: radial-gradient(circle at 35% 28%, #78d7e8, #008bb5 72%);
  font-size: 58px;
  box-shadow: 0 16px 0 rgba(0, 0, 0, 0.2);
}

.start-button.small {
  width: 230px;
  font-size: 34px;
}

.done-actions {
  display: grid;
  align-items: center;
  justify-content: center;
  justify-items: center;
  gap: 24px;
}

.large-action {
  min-width: 230px;
  min-height: 104px;
  font-size: 34px;
}

.status-text {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  color: #dce9ef;
}

.assist-text {
  margin: 16px 0 0;
  color: #dce9ef;
  font-size: 24px;
  font-weight: 800;
}

.input-layout {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(340px, 430px);
  gap: 28px;
  align-items: start;
}

.big-output {
  display: block;
  width: 100%;
  min-height: 88px;
  margin-bottom: 12px;
  padding: 12px 22px;
  border: 3px solid #5fb7db;
  border-radius: 8px;
  color: #10202d;
  background: white;
  font-size: clamp(46px, 7vw, 80px);
  line-height: 1;
  font-weight: 900;
  text-align: right;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.keypad button,
.selection-grid button,
.quick-grid button,
.weight-actions button {
  min-height: var(--touch);
  color: #1d2b36;
  background: linear-gradient(#ffffff, #dce5ec);
  border: 1px solid #aeb9c4;
  box-shadow: inset 0 -4px rgba(0, 0, 0, 0.1);
  font-size: 30px;
}

.keypad .wide {
  grid-column: span 2;
}

.keypad .action-key {
  margin-top: 12px;
}

.keypad .enter-wide {
  grid-column: span 2;
}

.keypad .danger {
  color: white;
  background: var(--danger);
}

.keypad .enter {
  color: white;
  background: var(--ok);
}

.quick-grid,
.weight-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.quick-grid button,
.weight-actions button {
  min-height: 86px;
  font-size: 24px;
}

.selection-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.selection-grid button {
  min-height: 94px;
  padding: 12px;
  text-align: left;
  font-size: clamp(22px, 2.8vw, 32px);
}

.selection-grid small {
  display: block;
  margin-top: 6px;
  color: #53626e;
  font-size: 18px;
}

.chooser-layout {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(340px, 430px);
  gap: 28px;
  height: calc(100% - 64px);
  min-height: 0;
}

.chooser-main,
.chooser-side {
  min-height: 0;
}

.chooser-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: #dce9ef;
  font-size: 22px;
  font-weight: 900;
}

.chooser-reset {
  min-height: 46px;
  padding: 0 18px;
  color: var(--night);
  background: #dce5ec;
  font-size: 18px;
}

.code-panel,
.kana-panel {
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
}

.kana-panel {
  margin-top: 12px;
}

.code-panel {
  padding: 0;
  background: transparent;
}

.kana-panel > span {
  display: block;
  margin-bottom: 8px;
  color: #dce9ef;
  font-size: 20px;
  font-weight: 900;
}

.code-output {
  display: block;
  min-height: 88px;
  margin-bottom: 12px;
  padding: 12px 22px;
  border: 3px solid #5fb7db;
  border-radius: 8px;
  color: var(--ink);
  background: white;
  font-size: clamp(46px, 7vw, 80px);
  line-height: 1;
  font-weight: 900;
  text-align: right;
}

.mini-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.mini-keypad button {
  min-height: var(--touch);
  color: #1d2b36;
  background: linear-gradient(#ffffff, #dce5ec);
  border: 1px solid #aeb9c4;
  box-shadow: inset 0 -4px rgba(0, 0, 0, 0.1);
  font-size: 30px;
}

.kana-grid button {
  min-height: 42px;
  color: #1d2b36;
  background: linear-gradient(#ffffff, #dce5ec);
  border: 1px solid #aeb9c4;
  box-shadow: inset 0 -3px rgba(0, 0, 0, 0.1);
  font-size: 20px;
}

.mini-keypad .danger {
  color: white;
  background: var(--danger);
}

.mini-keypad .enter {
  color: white;
  background: var(--ok);
}

.mini-keypad .wide {
  grid-column: span 2;
}

.mini-keypad .action-key {
  margin-top: 12px;
}

.mini-keypad .enter-wide {
  grid-column: span 2;
}

.kana-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.kana-grid button.active {
  color: white;
  background: var(--accent);
}

.empty-choice {
  display: grid;
  place-items: center;
  min-height: 94px;
  border-radius: 8px;
  color: #dce9ef;
  background: rgba(255, 255, 255, 0.12);
  font-size: 24px;
  font-weight: 900;
}

.confirm-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.1fr);
  gap: 16px;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-content: start;
  min-height: 0;
}

.summary-card {
  min-height: 76px;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--ink);
  background: white;
}

.summary-card span {
  color: var(--muted);
  font-weight: 800;
}

.summary-card strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
  line-height: 1.15;
}

.delivery-note {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  padding: 12px 22px;
  border-radius: 2px;
  color: #263b43;
  background: #d6f4ef;
  border: 2px solid #4f777a;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.12);
}

.delivery-note h2 {
  width: 190px;
  margin: 0 auto 6px;
  padding-bottom: 2px;
  border-bottom: 3px double #4f777a;
  text-align: center;
  font-size: 24px;
  letter-spacing: 10px;
  color: #142d34;
}

.note-date-line {
  display: flex;
  justify-content: flex-end;
  align-items: end;
  gap: 7px;
  min-height: 28px;
  padding: 0 10px;
  border: 2px solid #6b9292;
  border-bottom: 0;
  font-weight: 800;
}

.note-date-line strong {
  min-width: 32px;
  min-height: 20px;
  padding: 0 4px;
  border-bottom: 1px solid #4f777a;
  text-align: center;
  font-size: 16px;
}

.note-job-line {
  display: grid;
  grid-template-columns: 110px 1fr;
  min-height: 32px;
  align-items: center;
  padding: 0 12px;
  border: 2px solid #6b9292;
}

.note-job-line span,
.note-party-grid span,
.note-vehicle-grid span,
.note-remarks span {
  color: #405f65;
  font-weight: 800;
}

.note-party-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.95fr;
  min-height: 62px;
  border-left: 2px solid #6b9292;
  border-right: 2px solid #6b9292;
  border-bottom: 2px solid #6b9292;
}

.note-customer {
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 14px;
  padding: 8px 12px 10px;
  border-right: 2px solid #6b9292;
}

.note-customer strong {
  max-width: 100%;
  border-bottom: 1px solid #4f777a;
  font-size: 21px;
  line-height: 1.25;
}

.note-customer span {
  font-size: 19px;
}

.note-site {
  display: grid;
  grid-template-rows: 24px 1fr;
}

.note-site span {
  display: grid;
  place-items: center;
  border-bottom: 1px solid #6b9292;
}

.note-site strong {
  padding: 6px;
  font-size: 16px;
}

.note-vehicle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 46px;
  border-left: 2px solid #6b9292;
  border-right: 2px solid #6b9292;
  border-bottom: 2px solid #6b9292;
}

.note-vehicle-grid > div {
  display: grid;
  grid-template-rows: 22px 1fr;
  text-align: center;
}

.note-vehicle-grid > div:first-child {
  border-right: 2px solid #6b9292;
}

.note-vehicle-grid span {
  display: grid;
  place-items: center;
  border-bottom: 1px solid #6b9292;
}

.note-vehicle-grid strong {
  display: grid;
  place-items: center;
  font-size: 19px;
}

.note-items {
  width: 100%;
  border-collapse: collapse;
}

.note-items th,
.note-items td {
  height: 32px;
  border: 2px solid #6b9292;
  padding: 5px;
  text-align: center;
}

.note-items th {
  color: #263b43;
  font-size: 15px;
}

.note-items td:first-child {
  width: 46%;
}

.note-items td:nth-child(2),
.note-items td:nth-child(3) {
  width: 27%;
}

.note-remarks {
  display: grid;
  grid-template-rows: 24px 1fr;
  min-height: 48px;
  border-left: 2px solid #6b9292;
  border-right: 2px solid #6b9292;
  border-bottom: 2px solid #6b9292;
}

.note-remarks span {
  display: flex;
  align-items: center;
  padding-left: 10px;
  border-bottom: 1px solid #6b9292;
  font-size: 15px;
}

.note-remarks strong {
  padding: 4px 8px;
  font-size: 15px;
}

.note-footer {
  min-height: 68px;
  border-left: 2px solid #6b9292;
  border-right: 2px solid #6b9292;
  border-bottom: 2px solid #6b9292;
}

.note-company {
  display: grid;
  align-content: end;
  gap: 2px;
  padding: 6px 10px 7px;
}

.note-company p {
  margin: 0;
  padding-bottom: 2px;
  border-bottom: 2px solid #4f777a;
  color: #17202a;
  font-size: 21px;
  font-weight: 900;
}

.note-company span {
  font-size: 9px;
  font-weight: 700;
}

.action-row {
  display: flex;
  justify-content: flex-end;
  gap: 14px;
  margin-top: 12px;
}

.primary,
.secondary {
  min-height: 58px;
  padding: 0 34px;
  font-size: 24px;
}

.primary {
  color: white;
  background: var(--ok);
}

.secondary {
  color: var(--night);
  background: #dce5ec;
}

.office-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 16px;
  height: calc(100vh - 154px);
  max-width: 1220px;
  margin: 0 auto;
}

.office-main,
.office-side > * {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.office-main {
  min-height: 0;
  overflow: hidden;
  padding: 18px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-heading .eyebrow {
  color: var(--accent-dark);
}

#exportCsv {
  min-width: 240px;
  font-size: 22px;
}

.table-wrap {
  min-height: 0;
  max-height: calc(100vh - 338px);
  overflow: auto;
}

.office-tabs,
.master-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.csv-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.office-tabs button,
.master-tabs button {
  min-height: 36px;
  padding: 0 14px;
  color: var(--night);
  background: #dde7ef;
  font-size: 16px;
}

.office-tabs button.active,
.master-tabs button.active {
  color: white;
  background: var(--accent);
}

.office-panel {
  display: none;
}

.office-panel.active {
  display: grid;
  min-height: 0;
}

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

.delivery-records-table {
  table-layout: fixed;
  font-size: 13px;
}

.records-table th,
.records-table td {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.records-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: #f7fafc;
}

.delivery-records-table th,
.delivery-records-table td {
  overflow: hidden;
  padding: 9px 5px;
  text-overflow: ellipsis;
}

.delivery-records-table th:nth-child(1),
.delivery-records-table td:nth-child(1) {
  width: 14%;
}

.delivery-records-table th:nth-child(2),
.delivery-records-table td:nth-child(2) {
  width: 7%;
}

.delivery-records-table th:nth-child(3),
.delivery-records-table td:nth-child(3),
.delivery-records-table th:nth-child(4),
.delivery-records-table td:nth-child(4) {
  width: 13%;
}

.delivery-records-table th:nth-child(5),
.delivery-records-table td:nth-child(5) {
  width: 11%;
}

.delivery-records-table th:nth-child(6),
.delivery-records-table td:nth-child(6),
.delivery-records-table th:nth-child(7),
.delivery-records-table td:nth-child(7) {
  width: 9%;
}

.delivery-records-table th:nth-child(8),
.delivery-records-table td:nth-child(8) {
  width: 10%;
}

.delivery-records-table th:nth-child(9),
.delivery-records-table td:nth-child(9) {
  width: 11%;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 900;
}

.status-pill.done {
  color: #11613a;
  background: #dff4e9;
}

.status-pill.pending {
  color: #8a4c00;
  background: #fff0cf;
}

.compact-table th,
.compact-table td {
  padding: 10px;
}

.table-action {
  min-height: 30px;
  padding: 0 8px;
  color: white;
  background: var(--accent);
  border-radius: 6px;
  font-size: 14px;
}

.danger-link {
  background: var(--danger);
}

.master-editor {
  display: grid;
  gap: 14px;
}

.master-csv-actions {
  display: grid;
  grid-template-columns: 84px 84px;
  gap: 8px;
  align-items: center;
}

.master-csv-actions button {
  min-height: 30px;
  padding: 0 8px;
  font-size: 14px;
}

.master-form {
  display: grid;
  grid-template-columns: 82px minmax(150px, 1fr) 56px 62px 82px 90px 104px;
  gap: 8px;
  align-items: center;
}

.master-form input {
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

.master-form .ghost-field {
  visibility: hidden;
  pointer-events: none;
}

.master-form .primary {
  width: 104px;
  min-height: 36px;
  padding: 0 12px;
  font-size: 16px;
}

.office-side {
  display: grid;
  gap: 16px;
  align-content: start;
}

.master-box {
  padding: 18px;
}

.master-box h3 {
  margin-bottom: 12px;
}

.master-box dl,
.master-box ul {
  margin: 0;
}

.master-box dt {
  margin-top: 12px;
  color: var(--muted);
  font-weight: 800;
}

.master-box dd {
  margin: 3px 0 0;
  font-weight: 800;
}

.master-box li {
  margin-bottom: 8px;
}

#printArea {
  display: none;
}

.print-note {
  color: #000;
  font-family: "Yu Gothic", "Meiryo", sans-serif;
}

.print-note h1 {
  text-align: center;
  letter-spacing: 12px;
}

.print-note table {
  width: 100%;
  border-collapse: collapse;
}

.print-note th,
.print-note td {
  border: 1px solid #000;
  padding: 10px;
  text-align: center;
}

@media print {
  body > .app-shell {
    display: none;
  }

  #printArea {
    display: block;
  }
}

@media (max-width: 880px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .scale-panel {
    min-width: 0;
    justify-content: start;
  }

  #tabletView.active,
  .input-layout,
  .confirm-layout,
  .office-grid {
    grid-template-columns: 1fr;
  }

  .progress-panel li {
    min-width: 92px;
    font-size: 14px;
    text-align: center;
  }

  .tablet-screen {
    min-height: 620px;
    padding: 18px;
  }

  .selection-grid,
  .quick-grid,
  .weight-actions {
    grid-template-columns: 1fr;
  }

  .action-row {
    flex-direction: column;
  }
}
