:root {
  --ink: #102033;
  --muted: #526174;
  --line: #d9e2ec;
  --bg: #f6f8fb;
  --white: #ffffff;
  --blue: #1e5a8a;
  --green: #0f6b73;
  --navy: #0b2341;
  --soft-blue: #eaf3fb;
  --soft-green: #e8f6f7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "BIZ UDGothic", "BIZ UDPGothic", sans-serif;
  font-size: 13px;
  color: var(--ink);
  background: var(--bg);
}

.app {
  display: grid;
  grid-template-columns: 172px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--navy);
  color: white;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: white;
  color: var(--navy);
  font-weight: 700;
}

.brand-name {
  font-weight: 700;
  font-size: 15px;
}

.view-head p,
label,
.paper-row span,
.export-flow span,
.field-caption,
.project-meta,
.manifest-option small,
.linked-records p {
  color: var(--muted);
}

.nav {
  display: grid;
  gap: 2px;
}

.nav-item,
.nav-toggle {
  border: 0;
  background: transparent;
  color: #dbe7f2;
  text-align: left;
  padding: 9px 10px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  border-left: 4px solid transparent;
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  border-left-color: #7fc2f3;
  color: white;
  font-weight: 700;
}

.nav-toggle {
  grid-template-columns: 18px 1fr 12px;
}

.nav-toggle[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
}

.nav-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-chevron {
  color: #9fb7cf;
  font-size: 18px;
  line-height: 1;
  transform: rotate(0deg);
  transition: transform 120ms ease;
}

.nav-toggle[aria-expanded="true"] .nav-chevron {
  transform: rotate(90deg);
}

.subnav {
  display: grid;
  gap: 1px;
  margin: 2px 0 2px 30px;
}

.subnav[hidden] {
  display: none;
}

.subnav-item {
  border: 0;
  border-left: 3px solid transparent;
  background: transparent;
  color: #c8d8e8;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  text-align: left;
  padding: 7px 8px;
}

.subnav-item.active {
  background: rgba(255, 255, 255, 0.1);
  border-left-color: #7fc2f3;
  color: white;
  font-weight: 700;
}

.main {
  padding: 6px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  letter-spacing: 0;
}

.workspace {
  background: var(--white);
  border: 1px solid var(--line);
  height: calc(100vh - 12px);
  min-height: 0;
  overflow: hidden;
  padding: 6px 8px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

#view-project.active,
#view-masters.active {
  display: grid;
  grid-template-rows: auto auto 1fr;
  height: 100%;
  min-height: 0;
}

.view-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
  margin-bottom: 6px;
}

h2 {
  font-size: 19px;
  margin-bottom: 2px;
}

.view-head p {
  font-size: 13px;
}

.primary {
  border: 0;
  background: var(--blue);
  color: white;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 12px;
  cursor: pointer;
}

.secondary {
  border: 1px solid var(--blue);
  background: white;
  color: var(--blue);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
}

.project-board {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 6px;
  height: 142px;
  margin-bottom: 5px;
}

.project-list-pane,
.project-detail-pane {
  border: 1px solid var(--line);
  background: #fbfdff;
  min-height: 0;
  padding: 0;
}

.project-list-pane {
  padding: 0;
  background: white;
  overflow-y: scroll;
}

.section-title {
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 3px;
}

.project-list {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.project-list th,
.project-list td {
  border-bottom: 1px solid var(--line);
  padding: 6px 7px;
  text-align: left;
  white-space: nowrap;
}

.project-list thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #dfeef9;
  color: var(--ink);
  font-size: 11px;
  border-bottom: 1px solid #a9c4dc;
}

.project-list tbody th {
  color: var(--blue);
  font-weight: 700;
}

.project-list td:nth-child(2) {
  max-width: 154px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-list tr {
  cursor: pointer;
}

.project-list tr.active {
  background: #eaf3fb;
  box-shadow: inset 4px 0 0 var(--blue);
}

.project-fields {
  display: grid;
  grid-template-columns: 1fr 1.6fr 1fr;
  gap: 3px 8px;
  height: 100%;
  background: white;
  padding: 4px 8px;
  align-content: start;
}

.project-fields label {
  border: 0;
  padding: 0;
  gap: 3px;
  color: var(--muted);
  font-size: 12px;
}

.project-fields input {
  min-height: 22px;
  padding: 4px 6px;
  font-size: 13px;
  font-weight: 700;
  border-color: #c9d8e7;
}

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

.input-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px;
  min-width: 0;
}

.input-action input {
  min-width: 0;
  width: 100%;
}

.ref-button {
  border: 1px solid #7daed7;
  background: #f4f9fd;
  color: var(--blue);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  min-height: 18px;
  padding: 1px 6px;
}

.ref-button:hover {
  background: #e3f0fa;
}

.tab-shell {
  border: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  overflow: hidden;
  background: white;
}

.manifest-tabs {
  display: flex;
  gap: 3px;
  border-bottom: 2px solid var(--blue);
  background: white;
  padding: 0;
  overflow-x: auto;
}

.manifest-tab {
  border: 1px solid #b8ccdf;
  border-bottom: 0;
  border-radius: 5px 5px 0 0;
  background: #f4f7fa;
  color: #3c5268;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 5px 12px 6px;
  min-width: 136px;
  cursor: pointer;
  position: relative;
  top: 1px;
}

.manifest-tab.active {
  background: white;
  color: var(--ink);
  border-color: var(--blue);
  border-top: 3px solid var(--blue);
  padding-top: 3px;
  top: 2px;
}

.add-tab {
  color: var(--blue);
}

.manifest-panel {
  display: none;
  padding: 0 0 4px;
  min-height: 0;
  overflow: hidden;
}

.manifest-panel.active {
  display: block;
}

.manifest-scroll {
  overflow: visible;
  padding-bottom: 0;
}

.manifest-sheet {
  width: 100%;
  border: 1px solid var(--blue);
  background: white;
  color: #0051b0;
  padding: 4px;
  font-size: 10px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 3px;
}

.manifest-sheet label {
  color: #0051b0;
  font-size: 11px;
  gap: 2px;
  line-height: 1.05;
}

.manifest-sheet input,
.manifest-sheet select,
.manifest-sheet textarea {
  min-height: 17px;
  border: 1px solid #8dbbe8;
  color: var(--ink);
  background: #fbfdff;
  padding: 2px 3px;
  font-weight: 700;
  font-size: 11px;
}

.manifest-sheet textarea {
  width: 100%;
  min-height: 22px;
  resize: vertical;
  font: inherit;
}

.sheet-top {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr 1.5fr 1fr 1.4fr;
  gap: 3px;
  margin-bottom: 3px;
}

.sheet-section {
  display: grid;
  gap: 3px;
  margin-bottom: 3px;
}

.two-cols {
  grid-column: 1;
  grid-template-columns: 1fr 1fr;
}

.three-cols {
  grid-column: 1 / -1;
  grid-row: auto;
  grid-template-columns: 1fr 1fr 1.15fr;
}

.bottom-cols {
  grid-column: 1 / -1;
  grid-template-columns: 1fr 1.15fr;
}

.paper-block {
  border: 1px solid #3e8dd6;
  padding: 4px;
  background: #fff;
}

.paper-block h3,
.table-title {
  background: var(--blue);
  color: white;
  font-size: 10px;
  padding: 2px 4px;
  margin: -4px -4px 3px;
  text-align: center;
}

.paper-block label + label {
  margin-top: 2px;
}

.paper-block label {
  grid-template-columns: 74px 1fr;
  align-items: center;
}

.paper-block .input-action {
  grid-template-columns: minmax(0, 1fr) 38px;
}

.waste-area {
  grid-column: 1;
  display: grid;
  grid-template-columns: 1fr 72px 72px;
  gap: 3px;
  margin-bottom: 3px;
}

.waste-area.compact {
  grid-template-columns: 1fr 120px;
}

.waste-table,
.side-table {
  border: 1px solid #3e8dd6;
  padding: 4px;
}

.waste-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0;
  border-top: 1px solid #b8d8f2;
  border-left: 1px solid #b8d8f2;
}

.waste-grid label,
.side-table label {
  border-right: 1px solid #b8d8f2;
  border-bottom: 1px solid #b8d8f2;
  padding: 1px 2px;
}

.waste-grid label {
  grid-template-columns: minmax(44px, 1fr) 30px;
  align-items: center;
  gap: 2px;
}

.waste-grid span,
.side-table span {
  color: #0051b0;
  font-weight: 700;
  font-size: 9px;
}

.side-table {
  display: grid;
  align-content: start;
}

.side-table label {
  grid-template-columns: 1fr 18px;
  align-items: center;
}

.side-table input[type="checkbox"] {
  width: 14px;
  height: 14px;
  min-height: 14px;
  margin: 0;
  accent-color: var(--blue);
  justify-self: center;
}

.sheet-line {
  grid-column: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  margin-bottom: 3px;
}

.sheet-line label {
  border: 1px solid #3e8dd6;
  padding: 3px;
}

.stamp-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
}

.stamp-row label {
  border: 1px solid #3e8dd6;
  min-height: 26px;
  padding: 3px;
  background: #eaf6ff;
  align-content: start;
}

.empty-sheet-message {
  border: 1px solid #8dbbe8;
  border-left: 6px solid var(--blue);
  padding: 14px;
  margin-bottom: 8px;
  color: var(--ink);
  font-weight: 700;
}

.linked-strip {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--green);
  background: var(--soft-green);
  color: var(--ink);
  padding: 5px 6px;
  margin-top: 5px;
  font-size: 11px;
}

.linked-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

.linked-table th,
.linked-table td {
  border: 1px solid #c8d8e8;
  padding: 3px 6px;
  text-align: left;
  white-space: nowrap;
}

.linked-table th {
  color: var(--blue);
  width: 56px;
}

.linked-records {
  border: 1px solid var(--line);
  background: var(--soft-blue);
  padding: 22px;
  display: grid;
  align-content: start;
  gap: 16px;
}

.mini-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

.mini-table th,
.mini-table td {
  border-bottom: 1px solid var(--line);
  padding: 13px;
  text-align: left;
}

.mini-table th {
  width: 96px;
  color: var(--blue);
}

.device-switch {
  display: flex;
  border: 1px solid var(--line);
  background: white;
}

.device-button {
  border: 0;
  border-right: 1px solid var(--line);
  background: white;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  min-width: 94px;
  padding: 12px 16px;
  cursor: pointer;
}

.device-button:last-child {
  border-right: 0;
}

.device-button.active {
  background: var(--blue);
  color: white;
}

.reception-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 24px;
}

.select-panel,
.weighing-panel {
  border: 1px solid var(--line);
  background: white;
  padding: 22px;
}

.select-panel h3 {
  margin-bottom: 16px;
}

.manifest-options {
  display: grid;
  gap: 12px;
}

.manifest-option {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  font: inherit;
  text-align: left;
  padding: 16px;
  cursor: pointer;
  display: grid;
  gap: 6px;
}

.manifest-option span,
.manifest-option small {
  display: block;
}

.manifest-option span {
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
}

.manifest-option strong {
  font-size: 18px;
}

.manifest-option.active {
  border-color: var(--blue);
  box-shadow: inset 5px 0 0 var(--blue);
  background: #f7fbff;
}

.temp-option.active {
  border-color: var(--green);
  box-shadow: inset 5px 0 0 var(--green);
  background: var(--soft-green);
}

.temp-note {
  border-left: 4px solid var(--green);
  background: var(--soft-green);
  margin-top: 16px;
  padding: 12px;
  font-size: 13px;
  font-weight: 700;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.master-layout {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 6px;
  min-height: 0;
  overflow: hidden;
}

.master-edit {
  border: 1px solid var(--line);
  background: white;
  padding: 8px;
  display: grid;
  grid-template-columns: 150px 1fr 180px;
  gap: 6px 8px;
}

.master-edit label {
  display: grid;
  gap: 3px;
  font-size: 12px;
  font-weight: 700;
}

.master-edit input {
  min-height: 27px;
  border: 1px solid #c9d8e7;
  padding: 4px 6px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
}

.master-list {
  border: 1px solid var(--line);
  background: white;
  min-height: 0;
  overflow: auto;
}

.master-table,
.master-choice-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

.master-table thead th,
.master-choice-table thead th {
  background: #dfeef9;
  color: var(--ink);
  font-size: 12px;
}

.master-table tbody tr {
  cursor: pointer;
}

.master-table tbody tr:hover,
.master-choice-table tbody tr:hover {
  background: #f4f9fd;
}

.master-dialog {
  width: min(900px, calc(100vw - 40px));
  border: 1px solid var(--line);
  padding: 0;
}

.master-dialog::backdrop {
  background: rgba(6, 23, 40, 0.35);
}

.master-dialog form {
  margin: 0;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--navy);
  color: white;
  padding: 10px 12px;
}

.dialog-head h2 {
  font-size: 16px;
  margin: 0;
}

.icon-button {
  border: 0;
  background: transparent;
  color: white;
  cursor: pointer;
  font: inherit;
  font-size: 20px;
  line-height: 1;
}

.choice-button {
  border: 1px solid var(--blue);
  background: var(--blue);
  color: white;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
}

.panel-title-row h3 {
  font-size: 24px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.weighing-grid {
  grid-template-columns: repeat(3, 1fr);
}

.tablet-mode .reception-layout {
  max-width: 760px;
  grid-template-columns: 1fr;
  margin: 0 auto;
}

.tablet-mode .manifest-options {
  grid-template-columns: repeat(3, 1fr);
}

.tablet-mode .weighing-grid {
  grid-template-columns: repeat(2, 1fr);
}

.tablet-mode .select-panel,
.tablet-mode .weighing-panel {
  padding: 26px;
}

.tablet-mode .manifest-option {
  min-height: 118px;
}

.tablet-mode input,
.tablet-mode select {
  min-height: 54px;
  font-size: 18px;
}

.tablet-mode .primary {
  min-height: 54px;
  min-width: 150px;
}

label {
  display: grid;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  padding: 12px;
  font: inherit;
  background: #fff;
}

.split {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 28px;
}

.paper-preview {
  border: 1px solid var(--line);
  background: #fbfdff;
  padding: 22px;
}

.paper-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--blue);
  margin-bottom: 18px;
}

.paper-row {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

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

.data-table th {
  background: var(--navy);
  color: white;
  text-align: left;
  padding: 14px;
}

.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 16px 14px;
}

.export-flow {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.export-flow div {
  background: var(--white);
  border: 1px solid var(--line);
  border-left: 6px solid var(--blue);
  padding: 18px;
}

.export-flow b,
.export-flow span {
  display: block;
}

.export-flow b {
  margin-bottom: 8px;
}

@media (max-width: 900px) {
  .app,
  .form-grid,
  .split,
  .export-flow,
  .project-panel,
  .reception-layout,
  .tablet-mode .manifest-options,
  .tablet-mode .weighing-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .app {
    display: block;
  }

  .main {
    padding: 18px;
  }

  .view-head,
  .panel-title-row {
    flex-direction: column;
  }

  .project-panel {
    display: grid;
  }

  .project-meta {
    min-width: 0;
  }
}
