:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #13201d;
  --muted: #5b6864;
  --line: #d9e1de;
  --accent: #0f766e;
  --accent-2: #b42318;
  --soft: #e7f4f1;
  --warn: #fff3cd;
  --bad: #fde7e7;
  --good: #e6f6ea;
  --shadow: 0 8px 24px rgba(19, 32, 29, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

button,
input,
select {
  font: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(245, 247, 248, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
  padding: 14px clamp(14px, 4vw, 32px) 10px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.76rem;
}

h1 {
  margin: 0;
  font-size: clamp(1.5rem, 5vw, 2.3rem);
  letter-spacing: 0;
}

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

h2 {
  font-size: 1.1rem;
}

h3 {
  font-size: 0.95rem;
  margin-bottom: 10px;
}

.anchor-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-top: 12px;
  scrollbar-width: thin;
}

.anchor-nav a,
.tool-btn,
.icon-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
  border-radius: 8px;
  padding: 9px 12px;
  white-space: nowrap;
  cursor: pointer;
}

.anchor-nav a {
  font-size: 0.86rem;
}

#app {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 16px clamp(10px, 3vw, 24px) 48px;
}

.section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(14px, 3vw, 20px);
  margin: 0 0 16px;
}

.section.hidden {
  display: none;
}

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

.toolbar,
.preset-row,
.switch-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}

.tool-btn {
  background: var(--soft);
  border-color: #b7dcd5;
  color: #0b4d47;
}

.tool-btn.danger {
  background: var(--bad);
  border-color: #f0b8b8;
  color: #7a1810;
}

.icon-btn {
  min-width: 66px;
  font-weight: 700;
}

.preset-row input,
.preset-row select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}

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

.grid.compact {
  max-width: 520px;
  margin-bottom: 12px;
}

.mini-grid {
  grid-template-columns: repeat(5, minmax(84px, 1fr));
}

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

.note-list {
  display: grid;
  gap: 4px;
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px solid #b7dcd5;
  border-radius: 8px;
  background: var(--soft);
  color: #0b4d47;
  font-size: 0.84rem;
}

.note-list p {
  margin: 0;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
}

.input-wrap,
.pickup-table td {
  display: flex;
  align-items: center;
  gap: 5px;
}

input[type="number"],
input[type="text"],
select {
  width: 100%;
  min-width: 0;
}

.field input,
.pickup-table input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
  min-height: 42px;
}

.input-wrap em,
.pickup-table span {
  color: var(--muted);
  font-style: normal;
  font-size: 0.82rem;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.toggle input {
  width: 20px;
  height: 20px;
}

.kpi-grid,
.check-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.kpi,
.check {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfc;
  min-height: 74px;
}

.kpi span,
.check span,
.check small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.kpi strong,
.check strong {
  display: block;
  margin-top: 4px;
  font-size: 1.08rem;
}

.check.ok {
  background: var(--good);
  border-color: #b8dfc2;
}

.check.bad {
  background: var(--bad);
  border-color: #f0b8b8;
}

.positive {
  color: #087443;
}

.negative {
  color: var(--accent-2);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 660px;
}

.pickup-table table {
  min-width: 560px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: right;
  vertical-align: middle;
}

th:first-child,
td:first-child {
  text-align: left;
}

thead th {
  position: sticky;
  top: 0;
  background: #eef5f3;
  color: #243c37;
  font-size: 0.82rem;
  z-index: 1;
}

tbody tr:last-child th,
tbody tr:last-child td {
  border-bottom: 0;
}

.pickup-table input {
  width: 78px;
  text-align: right;
}

.formula-list {
  display: grid;
  gap: 8px;
}

code {
  display: block;
  padding: 10px;
  background: #17211f;
  color: #e7f4f1;
  border-radius: 8px;
  overflow-x: auto;
  white-space: nowrap;
}

.warning,
.error {
  border-radius: 8px;
  padding: 12px;
  margin-top: 12px;
}

.warning {
  background: var(--warn);
  border: 1px solid #eed588;
}

.error {
  background: var(--bad);
  border: 1px solid #f0b8b8;
  color: #7a1810;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: #17211f;
  color: #fff;
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  z-index: 30;
}

@media (max-width: 820px) {
  .grid,
  .mini-grid,
  .two-columns,
  .kpi-grid,
  .check-grid {
    grid-template-columns: 1fr;
  }

  .section {
    box-shadow: none;
  }

  .site-header {
    padding-left: 10px;
    padding-right: 10px;
  }

  .preset-row {
    display: grid;
    grid-template-columns: 1fr 86px;
  }

  .preset-row select {
    grid-column: 1 / -1;
  }

  .preset-row button:last-child {
    grid-column: 2;
  }
}

@media (max-width: 520px) {
  #app {
    padding-left: 8px;
    padding-right: 8px;
  }

  .section {
    padding: 12px;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .tool-btn,
  .icon-btn {
    min-height: 42px;
  }

  th,
  td {
    padding: 8px;
  }
}
