:root {
  --green: #174b3d;
  --green-dark: #103a2f;
  --green-soft: #eaf2ef;
  --ink: #17241f;
  --muted: #6b7973;
  --line: #dfe6e2;
  --bg: #f4f6f4;
  --white: #fff;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family:
    Inter, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

input {
  font-size: 16px;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(960px, 100%);
  margin: 0 auto;
  padding: 0 20px 36px;
}

.app-header {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--green);
}

.brand-mark svg {
  width: 24px;
  fill: none;
  stroke: #dceab8;
  stroke-width: 2.2;
  stroke-linecap: round;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  overflow: hidden;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.version {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 10px;
  text-align: right;
}

.version span {
  display: block;
}

.version span:first-child {
  color: var(--green);
  font-weight: 750;
}

main {
  display: grid;
  gap: 12px;
}

.panel {
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--white);
}

.panel {
  padding: 20px;
}

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

.section-title h2 {
  margin: 0;
  font-size: 16px;
}

.section-title > span {
  color: var(--muted);
  font-size: 10px;
  text-align: right;
}

.mobile-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.table-row input:focus {
  border-color: #6e9a8c;
  box-shadow: 0 0 0 3px rgba(23, 75, 61, 0.09);
}

.material-table {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.table-row {
  display: grid;
  grid-template-columns: minmax(145px, 1.2fr) minmax(110px, 0.85fr) minmax(160px, 1.1fr) minmax(90px, 0.7fr);
  gap: 12px;
  align-items: center;
  min-height: 58px;
  padding: 10px 14px;
  border-top: 1px solid #e8edeb;
}

.table-row:first-child {
  border-top: 0;
}

.table-head {
  min-height: 38px;
  color: var(--muted);
  background: #f6f8f7;
  font-size: 9px;
  font-weight: 700;
}

.material-name {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
}

.material-name > span {
  min-width: 0;
}

.material-name b,
.material-name small {
  display: block;
}

.material-name b {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.material-name small {
  margin-top: 2px;
  color: #89968f;
  font-size: 9px;
}

.material-dot {
  width: 7px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 4px;
  background: #9db1aa;
}

.material-dot.pvc {
  background: var(--green);
}

.material-dot.labor {
  background: #6b7973;
}

.ingredient-row:nth-child(2n) .material-dot {
  background: #d88c51;
}

.ingredient-row:nth-child(3n) .material-dot {
  background: #a4be62;
}

.table-row label {
  min-width: 0;
}

.table-row input {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 8px 10px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: 0;
  background: white;
}

.mobile-label {
  display: none;
}

.fixed-ratio {
  color: #8c9993;
  font-size: 10px;
}

.table-row > strong {
  color: #42534c;
  font-size: 11px;
  text-align: right;
  white-space: nowrap;
}

.simple-result {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.simple-result > span {
  color: var(--muted);
  font-size: 12px;
}

.simple-result strong {
  font-size: 24px;
  font-weight: 750;
}

.simple-result small {
  margin-left: 5px;
  color: var(--muted);
  font-size: 10px;
}

.simple-result[data-status="error"] strong {
  color: #aa4b42;
}

.privacy-note {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 10px;
}

.privacy-note svg {
  width: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--green);
  stroke-width: 1.8;
}

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

.server-config-head h2 {
  margin: 0;
  font-size: 15px;
}

.server-config-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.server-config-head p[data-status="success"] {
  color: var(--green);
}

.server-config-head p[data-status="error"] {
  color: #aa4b42;
}

.server-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.button {
  min-height: 44px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
}

.button.primary {
  color: white;
  border: 1px solid var(--green);
  background: var(--green);
}

.button.secondary {
  color: var(--green);
  border: 1px solid #bacac4;
  background: white;
}

.button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.utility-actions {
  display: flex;
  justify-content: center;
  gap: 20px;
}

.utility-actions button {
  padding: 4px;
  color: var(--muted);
  border: 0;
  background: transparent;
  font-size: 10px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

@media (max-width: 720px) {
  .app-shell {
    padding: 0 12px 20px;
  }

  .app-header {
    min-height: 60px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .brand strong {
    font-size: 15px;
  }

  .brand small,
  .version #updatedAt {
    display: none;
  }

  main {
    gap: 10px;
  }

  .panel {
    border-radius: 13px;
  }

  .panel {
    padding: 14px;
  }

  .section-title {
    margin-bottom: 12px;
  }

  .section-title h2 {
    font-size: 15px;
  }

  .section-title > span {
    max-width: 150px;
    line-height: 1.4;
  }

  .material-table {
    overflow: visible;
    border: 0;
  }

  .table-head {
    display: none;
  }

  .table-row,
  #ingredientRows .table-row:first-child {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
    min-height: 0;
    margin-top: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 11px;
  }

  .pvc-row {
    margin-top: 0;
  }

  .material-name {
    grid-column: 1;
    grid-row: 1;
  }

  .table-row > strong {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
  }

  .table-row label {
    grid-row: 2;
  }

  .table-row input {
    min-height: 44px;
  }

  .mobile-label {
    display: block;
  }

  .fixed-ratio {
    grid-column: 2;
    grid-row: 2;
    align-self: end;
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 0 10px;
    border-radius: 9px;
    background: #f5f7f6;
  }

  .server-actions {
    gap: 8px;
  }

  .simple-result {
    padding: 14px 2px 0;
  }

  .simple-result strong {
    font-size: 22px;
  }
}

@media print {
  body {
    padding: 0;
    background: white;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .server-actions,
  .utility-actions,
  .privacy-note {
    display: none;
  }
}
