:root {
  color-scheme: light;
  --ink: #18202a;
  --muted: #677484;
  --line: #d9e0e8;
  --panel: #ffffff;
  --page: #eef3f6;
  --nav: #132236;
  --nav-soft: #20344f;
  --accent: #167d7f;
  --accent-strong: #0c6668;
  --target-curve-color: #263d5a;
  --amber: #c17b22;
  --red: #b94754;
  --blue: #376fa9;
  --shadow: 0 16px 44px rgba(31, 48, 71, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 28px 20px;
  color: #eef7fb;
  background:
    linear-gradient(rgba(19, 34, 54, 0.86), rgba(19, 34, 54, 0.92)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='360' height='720' viewBox='0 0 360 720'%3E%3Cpath d='M0 75 C72 48 110 118 182 92 C255 66 287 7 360 42 L360 0 L0 0 Z' fill='%232e6a73'/%3E%3Cpath d='M0 278 C82 230 130 336 212 289 C278 252 310 192 360 215 L360 132 C306 107 255 143 205 173 C121 224 84 146 0 189 Z' fill='%23704546' opacity='.72'/%3E%3Cpath d='M0 571 C55 518 122 618 198 565 C254 526 303 498 360 533 L360 720 L0 720 Z' fill='%23bf8a38' opacity='.78'/%3E%3C/svg%3E");
  background-size: cover;
}

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

.brand-mark {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.11);
  font-weight: 800;
  letter-spacing: 0;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.section-title h3,
.section-title span {
  margin: 0;
}

.brand h1 {
  font-size: 21px;
  line-height: 1.25;
}

.brand p {
  margin-top: 4px;
  color: rgba(238, 247, 251, 0.72);
  font-size: 13px;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: rgba(238, 247, 251, 0.82);
  background: transparent;
  text-align: left;
}

.nav-item span:first-child {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
}

.nav-item.is-active,
.nav-item:hover {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.12);
}

.side-panel {
  display: flex;
  gap: 12px;
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(9, 20, 34, 0.36);
}

.side-panel p {
  margin: 4px 0 0;
  color: rgba(238, 247, 251, 0.72);
  font-size: 13px;
  line-height: 1.5;
}

.account-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: rgba(238, 247, 251, 0.82);
  background: rgba(9, 20, 34, 0.24);
  font-size: 13px;
}

.account-panel button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 7px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
  font-weight: 700;
}

.account-panel button:hover {
  background: rgba(255, 255, 255, 0.18);
}

.status-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  margin-top: 5px;
  border-radius: 999px;
  background: #50d38a;
  box-shadow: 0 0 0 5px rgba(80, 211, 138, 0.16);
}

.login-page {
  min-height: 100vh;
  background:
    linear-gradient(rgba(19, 34, 54, 0.84), rgba(19, 34, 54, 0.9)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1440' height='900' viewBox='0 0 1440 900'%3E%3Cpath d='M0 124 C223 64 353 197 538 136 C736 71 914 5 1148 76 C1279 116 1360 113 1440 91 L1440 0 L0 0 Z' fill='%232e6a73'/%3E%3Cpath d='M0 550 C215 435 345 674 569 547 C773 431 902 365 1088 430 C1230 480 1338 481 1440 430 L1440 900 L0 900 Z' fill='%23bf8a38' opacity='.75'/%3E%3C/svg%3E");
  background-size: cover;
}

.login-shell {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 100vh;
  justify-items: center;
  padding: 28px;
}

.login-panel {
  align-self: center;
  width: min(480px, 100%);
  padding: 32px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  gap: 15px;
  align-items: center;
  margin-bottom: 26px;
}

.login-brand .brand-mark {
  color: #ffffff;
  background: var(--nav);
}

.login-brand h1 {
  margin: 5px 0 0;
  font-size: 26px;
}

.login-brand p:last-child {
  margin: 5px 0 0;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
}

.login-form input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid #ccd6e2;
  border-radius: 7px;
  color: var(--ink);
  background: #ffffff;
  font-weight: 700;
}

.login-button {
  min-height: 48px;
  margin-top: 6px;
}

.login-button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.login-status {
  min-height: 22px;
  margin: 0;
  color: var(--red);
  font-weight: 700;
}

.content {
  min-width: 0;
  padding: 28px;
}

.site-footer {
  margin-top: 32px;
  padding: 18px 12px 4px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.login-footer {
  width: min(480px, 100%);
  margin-top: 16px;
  border-color: rgba(255, 255, 255, 0.22);
  color: rgba(255, 255, 255, 0.78);
}

.login-footer a:hover {
  color: #ffffff;
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
}

.is-hidden {
  display: none !important;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.topbar-actions-only {
  justify-content: flex-end;
}

.eyebrow {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar h2 {
  margin-top: 5px;
  font-size: 28px;
  line-height: 1.2;
}

.top-actions {
  display: flex;
  gap: 10px;
}

.primary-button,
.ghost-button,
.small-button {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 7px;
  border: 1px solid transparent;
  font-weight: 700;
}

.primary-button {
  color: #ffffff;
  background: var(--accent);
}

.primary-button:hover {
  background: var(--accent-strong);
}

.ghost-button,
.small-button {
  color: var(--ink);
  border-color: var(--line);
  background: #ffffff;
}

.small-button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.danger-button {
  color: var(--red);
  border-color: rgba(185, 71, 84, 0.28);
  background: #fff7f8;
}

.danger-button:hover {
  border-color: rgba(185, 71, 84, 0.52);
  background: #fff0f2;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(420px, 1.05fr);
  gap: 18px;
  align-items: start;
}

.panel,
.results-area,
.table-wrap,
.record-list,
.device-step,
.library-workspace,
.dye-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

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

.section-title h3 {
  font-size: 18px;
}

.section-title span {
  color: var(--muted);
  font-size: 13px;
}

.fabric-selector-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fafb;
}

.target-condition-panel {
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fafb;
}

.fabric-picker {
  margin-bottom: 0;
}

.fabric-picker > span {
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  padding: 0 11px;
  border: 1px solid #cdd6df;
  border-radius: 7px;
  color: var(--ink);
  background: #fbfdff;
  outline: none;
}

input,
select {
  height: 40px;
}

textarea {
  min-height: 82px;
  padding: 11px;
  resize: vertical;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 125, 127, 0.12);
}

input[type="range"] {
  padding: 0;
  accent-color: var(--accent);
}

.range-field {
  grid-column: 1 / -1;
}

.range-field span {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.range-field output {
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.spectral-input {
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto auto;
  gap: 10px;
  margin-top: 14px;
  height: 390px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fafb;
}

.compact-title {
  margin-bottom: 0;
}

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

.reflectance-point {
  display: grid;
  gap: 6px;
}

.reflectance-grid span,
.reflectance-point span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.reflectance-grid input,
.reflectance-point input {
  height: 38px;
  padding: 0 6px;
  text-align: center;
}

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

.reflectance-grid input[type="number"] {
  appearance: textfield;
}

.reflectance-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.reflectance-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
  flex-wrap: nowrap;
}

.reflectance-calculate-button {
  min-width: 156px;
  min-height: 48px;
  font-size: 16px;
}

.reflectance-tools span {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}

.correction-actions {
  align-items: flex-end;
}

.correction-secondary-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.correction-secondary-actions span {
  color: var(--muted);
  font-size: 12px;
}

.correction-calculate-button {
  min-width: 156px;
  min-height: 48px;
  font-size: 16px;
}

.clipboard-fallback {
  position: absolute;
  right: 14px;
  bottom: 14px;
  left: 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid rgba(22, 125, 127, 0.24);
  border-radius: 8px;
  background: #eef7f7;
  box-shadow: 0 10px 28px rgba(31, 48, 71, 0.14);
}

.clipboard-fallback textarea {
  min-height: 44px;
}

.swatch-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  padding: 14px;
  border-radius: 8px;
  background: #f4f7f9;
}

.target-summary-row {
  margin-top: 0;
  margin-bottom: 0;
}

.theory-sample-panel {
  display: grid;
  grid-template-rows: auto auto auto auto;
  gap: 10px;
  margin-top: 14px;
  height: 390px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fafb;
}

.theory-sample-panel .swatch-row {
  margin-top: 0;
}

.theory-sample-panel .compact-empty {
  grid-row: 1 / -1;
  align-self: stretch;
  min-height: 0;
}

.lab-direction-panel {
  padding: 10px 14px;
  border: 1px solid rgba(22, 125, 127, 0.2);
  border-radius: 8px;
  background: #eef7f7;
}

.lab-direction-panel strong {
  display: block;
  color: var(--accent-strong);
  font-size: 15px;
}

.lab-direction-panel p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.swatch-row p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.color-chip {
  width: 74px;
  height: 58px;
  flex: 0 0 auto;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 7px;
}

.spectrum-panel {
  display: flex;
  flex-direction: column;
}

canvas {
  display: block;
  width: 100%;
  height: 300px;
  border: 1px solid #dbe3ea;
  border-radius: 8px;
  background: #fbfdff;
}

.spectrum-panel canvas {
  height: 423px;
}

.legend {
  display: flex;
  gap: 18px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend i {
  display: inline-block;
  width: 28px;
  height: 3px;
  border-radius: 99px;
}

.target-line {
  background: var(--target-curve-color);
}

.predict-line {
  background: var(--accent);
}

.results-area {
  margin-top: 18px;
  padding: 18px;
}

.correction-area {
  margin-top: 18px;
  padding: 18px;
}

.correction-grid {
  display: grid;
  grid-template-columns: minmax(420px, 0.9fr) minmax(420px, 1.1fr);
  gap: 18px;
}

.correction-panel,
.correction-result {
  min-height: 260px;
}

.compact-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.correction-reflectance-grid {
  margin-top: 12px;
}

.correction-limit-row {
  margin-top: 14px;
}

.compact-empty {
  min-height: 220px;
}

.correction-list {
  display: grid;
  gap: 12px;
}

.correction-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.recipe-card {
  display: grid;
  gap: 13px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.recipe-card:hover {
  border-color: rgba(22, 125, 127, 0.45);
  box-shadow: 0 10px 28px rgba(31, 48, 71, 0.11);
}

.recipe-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(22, 125, 127, 0.16);
}

.recipe-card.is-selected .recipe-head h4::after {
  content: "当前显示";
  margin-left: 10px;
  padding: 3px 7px;
  border-radius: 999px;
  color: var(--accent-strong);
  background: rgba(22, 125, 127, 0.12);
  font-size: 12px;
  vertical-align: middle;
}

.recipe-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.recipe-title {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.recipe-head h4 {
  margin: 0;
  font-size: 16px;
}

.recipe-cost {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.badge {
  align-self: start;
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  color: #ffffff;
  background: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.metric {
  padding: 9px;
  border-radius: 7px;
  background: #eef3f6;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 3px;
  font-size: 17px;
}

.formula-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.formula-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid #e6ecf1;
  font-size: 14px;
}

.formula-list li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.recipe-note {
  min-height: 42px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.table-wrap {
  overflow: auto;
}

.library-workspace .table-wrap {
  overflow-x: hidden;
}

.library-layout {
  display: grid;
  grid-template-columns: minmax(620px, 1fr) minmax(420px, 0.82fr);
  gap: 18px;
  align-items: start;
}

.library-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fbfdff;
  text-align: left;
}

.library-item strong {
  font-size: 14px;
}

.library-item span {
  color: var(--muted);
  font-size: 12px;
}

.library-item.is-active {
  border-color: var(--accent);
  background: #eef7f7;
  box-shadow: inset 4px 0 0 var(--accent);
}

.library-list-card {
  width: min(820px, calc(100vw - 36px));
}

.library-search-head {
  display: grid;
  grid-template-columns: auto minmax(220px, 320px);
  gap: 10px;
  align-items: center;
}

.library-search-head input {
  height: 36px;
}

.library-modal-list {
  display: grid;
  gap: 10px;
  max-height: min(62vh, 620px);
  overflow: auto;
  margin-top: 16px;
}

.library-modal-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fbfdff;
  text-align: left;
}

.library-modal-item:hover,
.library-modal-item.is-active {
  border-color: var(--accent);
  background: #eef7f7;
}

.library-modal-item.is-active {
  box-shadow: inset 4px 0 0 var(--accent);
}

.library-modal-item strong,
.library-modal-item span {
  display: block;
}

.library-modal-item strong {
  font-size: 15px;
}

.library-modal-item span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.library-modal-item .delete-library-button {
  display: inline-flex;
  min-width: 54px;
  height: 34px;
  align-items: center;
  justify-content: center;
  justify-self: center;
  border: 1px solid rgba(185, 71, 84, 0.34);
  border-radius: 7px;
  color: var(--red);
  background: #fff6f7;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
}

.library-modal-item .delete-library-button:hover,
.library-modal-item .delete-library-button:focus {
  border-color: var(--red);
  outline: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 28, 42, 0.42);
}

.modal-backdrop.is-hidden {
  display: none;
}

.modal-card {
  width: min(640px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(19, 34, 54, 0.26);
}

.library-editor h3 {
  margin: 0;
  font-size: 16px;
}

.lab-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.lab-preview-value {
  display: flex;
  align-items: center;
  width: 100%;
  height: 40px;
  padding: 0 11px;
  border: 1px solid #cdd6df;
  border-radius: 7px;
  color: var(--ink);
  background: #f3f7f9;
  font-size: 14px;
}

.field-group-title {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.library-name-field,
.fiber-field,
.reflectance-field {
  margin-top: 12px;
}

.reflectance-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.reflectance-label-row .small-button {
  width: auto;
  white-space: nowrap;
}

.library-workspace {
  overflow: hidden;
}

.table-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.table-head h3,
.table-head p {
  margin: 0;
}

.table-head h3 {
  margin-top: 4px;
  font-size: 20px;
}

.library-dye-count {
  margin-top: 4px !important;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.table-head span {
  color: var(--muted);
  font-size: 13px;
}

.table-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 12px;
}

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

.dye-table {
  table-layout: fixed;
  min-width: 0;
}

.dye-table th:nth-child(1),
.dye-table td:nth-child(1) {
  width: 28%;
}

.dye-table th:nth-child(2),
.dye-table td:nth-child(2) {
  width: 10%;
}

.dye-table th:nth-child(3),
.dye-table td:nth-child(3),
.dye-table th:nth-child(4),
.dye-table td:nth-child(4) {
  width: 11%;
}

.dye-table th:nth-child(5),
.dye-table td:nth-child(5) {
  width: 28%;
}

.dye-table th:nth-child(6),
.dye-table td:nth-child(6) {
  width: 12%;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--muted);
  background: #f5f8fa;
  font-size: 13px;
}

td {
  font-size: 14px;
}

.dye-table th,
.dye-table td {
  padding: 13px 14px;
  overflow-wrap: anywhere;
  white-space: normal;
}

.dye-row {
  cursor: pointer;
}

.dye-row:hover,
.dye-row.is-selected {
  background: #eef7f7;
}

.dye-row.is-selected td:first-child {
  box-shadow: inset 4px 0 0 var(--accent);
}

.dye-row:focus {
  outline: 3px solid rgba(22, 125, 127, 0.2);
  outline-offset: -3px;
}

.delete-dye-button {
  min-width: 54px;
  height: 32px;
  border: 1px solid rgba(185, 71, 84, 0.34);
  border-radius: 7px;
  color: var(--red);
  background: #fff6f7;
  font-size: 13px;
  font-weight: 800;
}

.delete-dye-button:hover,
.delete-dye-button:focus {
  border-color: var(--red);
  outline: none;
}

.fiber-pill {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  color: #ffffff;
  background: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.fiber-pill.nylon {
  background: var(--red);
}

.record-list {
  display: grid;
  gap: 0;
  min-height: 240px;
  overflow: hidden;
}

.dye-detail {
  position: sticky;
  top: 18px;
  min-height: 420px;
  padding: 18px;
}

.empty-detail {
  display: grid;
  min-height: 360px;
  place-content: center;
  color: var(--muted);
  text-align: center;
}

.empty-detail strong {
  color: var(--ink);
  font-size: 18px;
}

.empty-detail p {
  max-width: 320px;
  margin: 8px auto 0;
  line-height: 1.6;
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.detail-head h3 {
  margin: 4px 0 0;
  font-size: 22px;
  line-height: 1.25;
}

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

.detail-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 16px 0;
}

.detail-metrics div {
  min-height: 74px;
  padding: 10px;
  border-radius: 7px;
  background: #f3f7fa;
}

.detail-metrics span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.detail-metrics strong {
  display: block;
  margin-top: 7px;
  font-size: 18px;
}

.detail-block {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.detail-block h4 {
  margin: 0;
  font-size: 15px;
}

.detail-block p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

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

.mini-table {
  min-width: 660px;
}

.mini-table th,
.mini-table td {
  padding: 10px 11px;
  font-size: 12px;
}

.sample-color-chip {
  display: block;
  width: 48px;
  height: 30px;
  border: 1px solid rgba(24, 32, 42, 0.16);
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.reflectance-bars {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  align-items: end;
  gap: 8px;
  height: 130px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.reflectance-bars div {
  display: grid;
  gap: 6px;
  justify-items: center;
  align-items: end;
  height: 100%;
}

.reflectance-bars span {
  display: block;
  width: 100%;
  max-width: 20px;
  border-radius: 5px 5px 2px 2px;
  background: var(--accent);
}

.reflectance-bars small {
  color: var(--muted);
  font-size: 10px;
}

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

.editor-wide,
.editor-help,
.editor-actions,
.editor-error {
  grid-column: 1 / -1;
}

.editor-help {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.editor-subtitle {
  grid-column: 1 / -1;
  margin: 8px 0 -2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.sample-editor {
  display: grid;
  gap: 10px;
}

.sample-editor-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.sample-editor-head span {
  color: var(--ink);
  font-weight: 800;
}

.sample-editor-head small {
  color: var(--muted);
  font-size: 12px;
}

.sample-editor-row {
  display: grid;
  grid-template-columns: minmax(170px, 0.8fr) minmax(260px, 1.4fr) auto;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fafb;
}

.sample-editor-meta {
  display: grid;
  gap: 5px;
  align-self: center;
}

.sample-editor-meta strong {
  color: var(--ink);
  font-size: 16px;
}

.sample-editor-meta span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.sample-editor-row textarea {
  min-height: 48px;
}

.sample-editor-row .small-button {
  width: auto;
  white-space: nowrap;
}

.editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.editor-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 13px;
  font-weight: 700;
}

.empty-state {
  display: grid;
  min-height: 240px;
  place-items: center;
  color: var(--muted);
}

.record-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.record-item:last-child {
  border-bottom: 0;
}

.account-admin-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.42fr) minmax(520px, 1fr);
  gap: 18px;
  align-items: start;
}

.account-form {
  display: grid;
  gap: 14px;
}

.account-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
}

.account-form input,
.account-form select,
.account-role-select {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid #ccd6e2;
  border-radius: 7px;
  color: var(--ink);
  background: #ffffff;
  font-weight: 700;
}

.account-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

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

.account-table th {
  color: var(--muted);
  background: #f6f8fa;
  font-size: 13px;
}

.account-table td:nth-child(1) {
  width: 28%;
}

.account-table td:nth-child(2) {
  width: 20%;
}

.account-table td:nth-child(3) {
  width: 15%;
}

.account-table td:nth-child(4) {
  width: 37%;
}

.account-badge,
.account-state {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-left: 8px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.account-badge {
  color: var(--blue);
  background: rgba(55, 111, 169, 0.1);
}

.account-state {
  margin-left: 0;
}

.account-state.is-on {
  color: var(--accent-strong);
  background: rgba(22, 125, 127, 0.1);
}

.account-state.is-off {
  color: var(--red);
  background: rgba(185, 71, 84, 0.1);
}

.account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.account-actions .small-button {
  min-width: 64px;
  white-space: nowrap;
}

.account-actions .small-button:disabled,
.account-role-select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.record-item h3 {
  margin: 0;
  font-size: 16px;
}

.record-item p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.import-layout {
  display: grid;
  grid-template-columns: minmax(520px, 0.95fr) minmax(420px, 1.05fr);
  gap: 18px;
  align-items: start;
}

.import-panel,
.import-result {
  min-height: 430px;
}

.import-textarea {
  margin-top: 14px;
}

.device-step {
  padding: 20px;
}

.device-step span {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 900;
}

.device-step h3 {
  margin: 18px 0 8px;
}

.device-step p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    padding: 18px;
  }

  .nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .side-panel {
    display: none;
  }

  .workbench,
  .recipe-grid,
  .correction-grid,
  .device-grid,
  .import-layout,
  .library-layout {
    grid-template-columns: 1fr;
  }

  .dye-detail {
    position: static;
  }
}

@media (max-width: 720px) {
  .content {
    padding: 18px;
  }

  .topbar,
  .top-actions,
  .nav {
    align-items: stretch;
    grid-template-columns: 1fr 1fr;
  }

  .topbar {
    flex-direction: column;
  }

  .top-actions {
    display: grid;
    width: 100%;
  }

  .form-grid,
  .compact-form,
  .library-modal-item,
  .lab-row,
  .metrics,
  .detail-metrics {
    grid-template-columns: 1fr;
  }

  .reflectance-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .correction-actions,
  .correction-secondary-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .correction-calculate-button {
    width: 100%;
  }

  .nav-item {
    justify-content: center;
    font-size: 14px;
  }

}

@media (max-width: 520px) {
  .fabric-selector-panel {
    grid-template-columns: 1fr;
  }

  .spectrum-panel canvas {
    min-height: 300px;
  }
}
