:root {
  --lab-font: 'Bai Jamjuree', sans-serif;
  --lab-primary: #009a73;
  --lab-primary-light: #00c896;
  --lab-primary-dark: #007a5c;
  --lab-primary-soft: #ecfdf6;
  --lab-primary-glow: rgba(0, 154, 115, .18);
  --lab-accent-border: #c5ead9;
  --lab-danger: #ef4444;
  --lab-danger-dark: #dc2626;
  --lab-danger-soft: #fef2f2;
  --lab-text: #111111;
  --lab-text-muted: #4a4a4a;
  --lab-empty: #737373;
  --lab-surface: #ffffff;
  --lab-shadow: 0 4px 24px rgba(0, 60, 45, .07);
  --lab-shadow-lg: 0 12px 40px rgba(0, 60, 45, .1);
  --radius: 16px;
  --radius-sm: 12px;
}

*, *::before, *::after {
  box-sizing: border-box;
  font-family: var(--lab-font);
}

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

html {
  font-family: var(--lab-font);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--lab-font);
  color: var(--lab-text);
  background: linear-gradient(160deg, #e4faf2 0%, #f4fdf8 40%, #eef9f3 100%);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis: none;
}

button,
input,
select,
textarea,
optgroup,
option {
  font-family: var(--lab-font);
}

table,
th,
td,
caption {
  font-family: var(--lab-font);
}

/* Background decoration */
.bg-blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
}
.bg-blob-1 {
  width: 420px; height: 420px;
  background: rgba(0, 200, 150, .15);
  top: -120px; right: -80px;
}
.bg-blob-2 {
  width: 360px; height: 360px;
  background: rgba(0, 154, 115, .1);
  bottom: -100px; left: -60px;
}

.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: none;
  margin: 0 auto;
  padding: 20px 16px 40px;
  min-height: 100vh;
}

/* ── Header ── */
.hero {
  background: var(--lab-surface);
  border-radius: var(--radius);
  box-shadow: var(--lab-shadow);
  border: 1px solid rgba(197, 234, 217, .6);
  padding: 20px 22px;
  margin-bottom: 16px;
}
.hero-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand-icon {
  width: 52px; height: 52px;
  background: var(--lab-primary-soft);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
h1 {
  margin: 0;
  font-size: clamp(22px, 5vw, 28px);
  font-weight: 700;
  color: var(--lab-primary);
  letter-spacing: -.02em;
  line-height: 1.2;
}
.hero p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--lab-text-muted);
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--lab-primary-soft);
  border: 1px solid var(--lab-accent-border);
  border-radius: 999px;
  padding: 8px 16px 8px 12px;
  color: var(--lab-primary);
  font-weight: 600;
}
.stat-num { font-size: 20px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 13px; opacity: .85; }
.stat-icon { display: flex; opacity: .7; }

/* ── Workspace (sidebar + content on desktop) ── */
.workspace {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Navigation ── */
.nav-wrap { margin-bottom: 4px; }
.nav-toolbar {
  display: none;
}
.nav-collapse-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1.5px solid var(--lab-accent-border);
  border-radius: 10px;
  background: #fff;
  color: var(--lab-text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background .15s ease, box-shadow .15s ease;
}
.nav-collapse-btn:hover {
  border-color: var(--lab-primary);
  color: var(--lab-primary);
  background: var(--lab-primary-soft);
  box-shadow: 0 0 0 3px var(--lab-primary-glow);
}
.nav-collapse-text { line-height: 1; }
.nav-expand-btn {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 64px;
  padding: 12px 8px;
  border: 1px solid rgba(197, 234, 217, .8);
  border-radius: var(--radius);
  background: var(--lab-surface);
  color: var(--lab-primary);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  cursor: pointer;
  box-shadow: var(--lab-shadow);
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease, transform .15s ease;
}
.nav-expand-btn:hover {
  border-color: var(--lab-primary);
  background: var(--lab-primary-soft);
  box-shadow: var(--lab-shadow-lg);
  transform: translateX(2px);
}
.nav-expand-btn span {
  display: block;
  line-height: 1.2;
  white-space: nowrap;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--lab-surface);
  border-radius: var(--radius);
  padding: 8px;
  box-shadow: var(--lab-shadow);
  border: 1px solid rgba(197, 234, 217, .6);
}

.nav-group {
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-group.active-group .nav-menu-toggle:not(.active) {
  color: var(--lab-primary);
  background: var(--lab-primary-soft);
}
.nav-menu-toggle {
  position: relative;
}
.menu-chevron {
  margin-left: auto;
  display: flex;
  transition: transform .2s ease;
  opacity: .7;
}
.nav-group.expanded .menu-chevron { transform: rotate(180deg); }
.nav-menu-toggle.active .menu-chevron { opacity: 1; }

.nav-sub {
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 0 0 4px 12px;
  border-left: 2px solid var(--lab-accent-border);
  margin-left: 14px;
}
.nav-group.expanded .nav-sub { display: flex; }
.nav-sub-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 11px 12px 11px 14px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--lab-text-muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s ease;
  text-align: left;
}
.nav-sub-item:hover:not(.active) {
  background: var(--lab-primary-soft);
  color: var(--lab-primary);
}
.nav-sub-item.active {
  background: linear-gradient(135deg, var(--lab-primary-light), var(--lab-primary));
  color: #fff;
  box-shadow: 0 3px 12px var(--lab-primary-glow);
}
.sub-icon { display: flex; flex-shrink: 0; opacity: .85; }
.nav-sub-item.active .sub-icon { opacity: 1; }
.sub-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--lab-primary-soft);
  color: var(--lab-primary);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-sub-item.active .sub-badge {
  background: rgba(255,255,255,.25);
  color: #fff;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 13px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--lab-text-muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s ease;
  position: relative;
}
.nav-tab:hover:not(.active) {
  background: var(--lab-primary-soft);
  color: var(--lab-primary);
}
.nav-tab.active {
  background: linear-gradient(135deg, var(--lab-primary-light), var(--lab-primary));
  color: #fff;
  box-shadow: 0 4px 16px var(--lab-primary-glow);
}
.tab-badge {
  margin-left: auto;
  min-width: 18px; height: 18px;
  background: var(--lab-primary-soft);
  color: var(--lab-primary);
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
}
.nav-tab.active .tab-badge {
  background: rgba(255,255,255,.25);
  color: #fff;
}
.tab-icon, .btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.main { flex: 1; min-width: 0; }

.panel-content-narrow {
  max-width: 520px;
}

.inline-count {
  font-weight: 700;
  color: var(--lab-primary);
}

/* ── Panels ── */
.panel { display: none; animation: fadeUp .3s ease; }
.panel.active { display: block; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.panel-head-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.panel-head-icon.add {
  background: linear-gradient(135deg, #d4f5ea, #b8efd8);
  color: var(--lab-primary);
}
.panel-head-icon.list {
  background: linear-gradient(135deg, #d4f5ea, #b8efd8);
  color: var(--lab-primary);
}
.panel-head-icon.record {
  background: linear-gradient(135deg, #d0eef8, #b8e0f5);
  color: #1a7ab0;
}
.panel-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--lab-text);
}
.panel-head p {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--lab-text-muted);
}

/* ── Card & Form ── */
.card {
  background: var(--lab-surface);
  border-radius: var(--radius);
  box-shadow: var(--lab-shadow);
  border: 1px solid rgba(197, 234, 217, .5);
  padding: 22px;
}
.card-form {
  border-top: 3px solid var(--lab-primary);
}

.field { margin-bottom: 16px; }
.field label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--lab-text-muted);
}
.optional {
  font-weight: 400;
  font-size: 12px;
  color: var(--lab-empty);
}
.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.field-icon {
  position: absolute;
  left: 14px;
  color: var(--lab-empty);
  display: flex;
  pointer-events: none;
  transition: color .2s;
}
.input-wrap input {
  width: 100%;
  padding: 13px 14px 13px 44px;
  border: 1.5px solid #dce8e2;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 15px;
  color: var(--lab-text);
  background: #fafcfb;
  outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.input-wrap input::placeholder { color: #9ca3af; }
.input-wrap input:focus {
  border-color: var(--lab-primary);
  background: #fff;
  box-shadow: 0 0 0 4px var(--lab-primary-glow);
}
.input-wrap input.input-readonly {
  background: #f0f7f4;
  color: var(--lab-primary);
  font-weight: 600;
  letter-spacing: .02em;
  cursor: default;
}
.input-wrap input.input-readonly:focus {
  box-shadow: none;
  border-color: var(--lab-accent-border);
}
.input-wrap:focus-within .field-icon { color: var(--lab-primary); }
.field-hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--lab-empty);
}

textarea {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid #dce8e2;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 15px;
  color: var(--lab-text);
  background: #fafcfb;
  outline: none;
  resize: vertical;
  min-height: 80px;
  margin-bottom: 12px;
  transition: border-color .2s, box-shadow .2s;
}
textarea:focus {
  border-color: var(--lab-primary);
  background: #fff;
  box-shadow: 0 0 0 4px var(--lab-primary-glow);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, background .15s;
}
.btn:active { transform: scale(.98); }
.btn-primary {
  width: 100%;
  padding: 14px 20px;
  background: linear-gradient(135deg, var(--lab-primary-light), var(--lab-primary));
  color: #fff;
  box-shadow: 0 4px 16px var(--lab-primary-glow);
}
.btn-primary:hover {
  box-shadow: 0 6px 22px rgba(0, 154, 115, .3);
  background: linear-gradient(135deg, #00d4a0, var(--lab-primary-dark));
}
.btn-icon { display: flex; }

.link-btn {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  font-weight: 600;
  color: var(--lab-primary);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-btn:hover { color: var(--lab-primary-dark); }

/* ── Section label ── */
.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 24px 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--lab-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.section-count {
  background: var(--lab-primary-soft);
  color: var(--lab-primary);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  margin-top: 8px;
}
.empty-visual { margin-bottom: 16px; opacity: .85; }
.empty-state h3 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 600;
  color: var(--lab-text-muted);
}
.empty-state p {
  margin: 0;
  font-size: 14px;
  color: var(--lab-empty);
}

.list { display: grid; gap: 12px; }
.list-record { grid-template-columns: 1fr; }
.list-summary { grid-template-columns: 1fr; }

/* ── Summary cards ── */
.summary-card {
  display: flex;
  gap: 0;
  background: var(--lab-surface);
  border-radius: var(--radius);
  border: 1px solid rgba(197, 234, 217, .5);
  box-shadow: var(--lab-shadow);
  overflow: hidden;
  transition: box-shadow .2s;
}
.summary-card:hover { box-shadow: var(--lab-shadow-lg); }

.summary-round {
  width: 100px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px 12px;
  background: linear-gradient(180deg, #e8f6fc, #d0eef8);
  color: #1a7ab0;
  text-align: center;
}
.summary-card.no-result .summary-round {
  background: linear-gradient(180deg, #f0fdf8, #e4faf2);
  color: var(--lab-empty);
}
.round-shape {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(26, 122, 176, .15);
}
.summary-card.no-result .round-shape {
  box-shadow: 0 4px 14px rgba(0, 154, 115, .1);
  color: var(--lab-empty);
}
.round-num {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  color: #1a7ab0;
}
.round-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
}

.summary-round-btn {
  border: none;
  cursor: pointer;
  font: inherit;
  transition: filter .15s ease, transform .15s ease;
}
.summary-round-btn:hover {
  filter: brightness(0.97);
}
.summary-round-btn:hover .round-shape {
  transform: scale(1.04);
  box-shadow: 0 6px 18px rgba(26, 122, 176, .22);
}
.summary-round-btn:active {
  transform: scale(0.98);
}
.summary-round-btn .round-shape {
  transition: transform .15s ease, box-shadow .15s ease;
}
.round-hint {
  font-size: 10px;
  font-weight: 600;
  color: #3d8eb8;
  opacity: .9;
}

.summary-body {
  flex: 1;
  padding: 18px 20px;
  min-width: 0;
}
.summary-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.summary-head h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--lab-text);
}
.summary-latest {
  background: #f8fcfa;
  border-radius: var(--radius-sm);
  border-left: 4px solid #1a7ab0;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.summary-card.no-result .summary-latest {
  border-left-color: var(--lab-accent-border);
  background: #fafcfb;
}
.summary-latest-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #1a7ab0;
  margin-bottom: 10px;
}

.summary-latest-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}

.summary-topic-block {
  background: #f8fcfa;
  border-radius: var(--radius-sm);
  border-left: 4px solid #1a7ab0;
  overflow: hidden;
}

.summary-topic-block.summary-topic-empty {
  padding: 12px 14px;
}

.summary-topic-block.row-status-fail {
  border-left-color: #ef4444;
  background: #fffbfb;
}
.summary-topic-block.row-status-pass {
  border-left-color: var(--lab-primary);
  background: #f8fffc;
}
.summary-topic-block.row-status-keep {
  border-left-color: #eab308;
  background: #fffdf8;
}

.summary-topic-block.summary-topic-empty {
  border-left-color: var(--lab-accent-border);
  background: #fafcfb;
}

.summary-topic-toggle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  width: 100%;
  padding: 12px 14px;
  border: none;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: inherit;
  transition: background .15s ease;
}

.summary-topic-toggle:hover {
  background: rgba(0, 0, 0, .03);
}

.summary-topic-toggle-static {
  cursor: default;
  padding: 0;
  margin-bottom: 6px;
}

.summary-topic-chevron {
  display: flex;
  flex-shrink: 0;
  color: var(--lab-text-muted);
  transition: transform .2s ease;
}

.summary-topic-block.is-expanded .summary-topic-chevron {
  transform: rotate(90deg);
}

.summary-topic-toggle-main {
  flex: 1 1 140px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.summary-topic-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--lab-text);
  line-height: 1.3;
}

.summary-topic-subject,
.summary-topic-round {
  font-size: 13px;
  font-weight: 700;
  color: var(--lab-text-muted);
}

.summary-topic-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.summary-topic-action {
  font-size: 12px;
  font-weight: 600;
  color: var(--lab-primary);
  margin-left: auto;
}

.summary-topic-block.is-expanded .summary-topic-action {
  color: var(--lab-text-muted);
}

.summary-topic-details {
  padding: 0 14px 14px;
  border-top: 1px solid rgba(0, 0, 0, .06);
}

.summary-topic-time {
  margin: 10px 0 8px;
  font-size: 12px;
  color: var(--lab-text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.summary-topic-empty-text {
  margin: 0;
  font-size: 13px;
  color: var(--lab-text-muted);
  padding: 0 14px 12px;
}

.summary-topic-block.summary-topic-empty .summary-topic-empty-text {
  padding: 0;
}

.summary-topic-fields .result-field {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(0, 0, 0, .04);
  font-size: 13px;
}
.summary-topic-fields .result-field:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.badge.results-total {
  background: #eef6f2;
  color: var(--lab-text-muted);
}

.summary-latest-text {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--lab-text);
  line-height: 1.5;
}
.summary-latest-note {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--lab-text-muted);
}
.empty-latest p {
  margin: 0;
  font-size: 14px;
  color: var(--lab-empty);
}
.summary-form { margin-top: 12px; }

.badge.pending {
  background: var(--lab-primary-soft);
  color: var(--lab-primary);
}
.badge.code-badge {
  background: #eef6f2;
  color: var(--lab-text);
  font-family: var(--lab-font);
  font-size: 12px;
  letter-spacing: .03em;
}
.badge.col-count {
  background: #eef8f4;
  color: var(--lab-primary);
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  padding: 8px 14px;
  border: none;
  border-radius: 10px;
  background: var(--lab-primary-soft);
  color: var(--lab-primary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-back:hover { background: #d4f5ea; }
.detail-sub {
  font-family: var(--lab-font);
  font-size: 13px;
  color: var(--lab-primary);
}

.card-columns { padding: 22px; }
.card-topics { padding: 22px; }

.topic-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.topic-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #f8fcfa;
  border: 1px solid #e4f0ea;
  border-radius: 12px;
  cursor: pointer;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.topic-item:hover {
  border-color: var(--lab-accent-border);
  box-shadow: 0 2px 8px rgba(0, 154, 115, .08);
}
.topic-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--lab-primary-soft);
  color: var(--lab-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.topic-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.topic-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.topic-add-form {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}
.topic-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--lab-text);
}
.topic-remove {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 9px;
  background: var(--lab-danger-soft);
  color: var(--lab-danger);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.topic-remove:hover { background: var(--lab-danger); color: #fff; }

.topic-form-section {
  margin-bottom: 14px;
  padding: 12px 14px;
  background: #f8fcfa;
  border: 1px solid #e4f0ea;
  border-radius: 10px;
}
.topic-form-section.topic-form-empty { background: #fff8e8; border-color: #f0e0b8; }
.topic-form-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--lab-primary-dark);
  margin-bottom: 10px;
  text-transform: none;
}
.summary-setup-warn { margin: 0; }

/* ── Record entry ── */
.record-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 18px;
  padding: 10px 20px;
}
.record-progress-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--lab-empty);
  transition: color .25s ease;
}
.record-progress-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d4ebe2;
  transition: all .25s ease;
  flex-shrink: 0;
}
.record-progress-item.active { color: var(--lab-primary); }
.record-progress-item.active .record-progress-dot {
  width: 12px;
  height: 12px;
  background: var(--lab-primary);
  box-shadow: 0 0 0 4px var(--lab-primary-glow);
}
.record-progress-item.done { color: var(--lab-primary-dark); }
.record-progress-item.done .record-progress-dot { background: var(--lab-primary); }
.record-progress-line {
  width: 40px;
  height: 2px;
  background: #dcebe4;
  margin: 0 10px;
  border-radius: 1px;
  transition: background .25s ease;
}
.record-progress-line.done { background: var(--lab-primary); }

.card-record-entry {
  padding: 0;
  overflow: hidden;
  box-shadow: none;
}

.record-picker-collapsed {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 18px;
  background: linear-gradient(180deg, #f8fcfa 0%, #fff 100%);
  border-bottom: 1px solid #e8f2ed;
}
.record-picker-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  padding: 6px 4px;
  border-radius: 10px;
  transition: background .15s ease;
}
.record-picker-summary:hover {
  background: var(--lab-primary-soft);
}
.record-summary-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.record-summary-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--lab-text-muted);
  letter-spacing: .03em;
}
.record-summary-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--lab-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
.record-summary-sep {
  display: flex;
  color: var(--lab-empty);
  flex-shrink: 0;
}
.record-picker-change-btn {
  flex-shrink: 0;
  padding: 8px 14px;
  border: 1.5px solid var(--lab-accent-border);
  border-radius: 10px;
  background: #fff;
  color: var(--lab-primary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.record-picker-change-btn:hover {
  border-color: var(--lab-primary);
  background: var(--lab-primary-soft);
  box-shadow: 0 0 0 3px var(--lab-primary-glow);
}

.record-picker-grid {
  display: grid;
  gap: 0;
  border-bottom: 1px solid #e8f2ed;
}
@media (min-width: 720px) {
  .record-picker-grid { grid-template-columns: 1fr 1fr; }
}
.record-picker-panel {
  padding: 20px 22px;
  min-height: 200px;
}
.record-picker-panel-topic {
  background: #f8fcfa;
  border-top: 1px solid #e8f2ed;
}
@media (min-width: 720px) {
  .record-picker-panel-topic {
    border-top: none;
    border-left: 1px solid #e8f2ed;
  }
}
.record-picker-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.record-picker-title h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--lab-text);
}
.record-picker-badge {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--lab-primary-light), var(--lab-primary));
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.record-choice-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}
.record-choice-list::-webkit-scrollbar { width: 5px; }
.record-choice-list::-webkit-scrollbar-thumb {
  background: #c5ead9;
  border-radius: 4px;
}
.record-choice {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #e4f0ea;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.record-choice:hover {
  border-color: var(--lab-accent-border);
  box-shadow: 0 2px 10px rgba(0, 154, 115, .08);
}
.record-choice.selected {
  border-color: var(--lab-primary);
  background: var(--lab-primary-soft);
  box-shadow: 0 0 0 3px var(--lab-primary-glow);
}
.record-choice-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--lab-primary-soft);
  color: var(--lab-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.record-choice.selected .record-choice-icon {
  background: var(--lab-primary);
  color: #fff;
}
.record-choice-text { min-width: 0; flex: 1; }
.record-choice-name {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--lab-text);
  line-height: 1.3;
}
.record-choice-meta {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--lab-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.record-choice-empty {
  padding: 28px 16px;
  text-align: center;
  font-size: 14px;
  color: var(--lab-text-muted);
  background: #fff;
  border: 1px dashed #dcebe4;
  border-radius: 12px;
}

.record-content-area {
  padding: 22px;
  background: linear-gradient(180deg, #fafdfc 0%, #fff 100%);
  min-height: 180px;
}
.record-empty-state {
  text-align: center;
  padding: 28px 16px;
}
.record-empty-icon {
  margin: 0 auto 14px;
  opacity: .9;
}
.record-empty-state h3 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 700;
  color: var(--lab-text);
}
.record-empty-state p {
  margin: 0;
  font-size: 14px;
  color: var(--lab-text-muted);
  line-height: 1.5;
}

.record-setup-warn {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 12px;
  color: #92400e;
  font-size: 14px;
  line-height: 1.5;
}
.record-warn-icon {
  flex-shrink: 0;
  color: #d97706;
  display: flex;
  margin-top: 1px;
}

.record-context-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  margin-bottom: 12px;
  background: #f8fcfa;
  border: 1px solid #e4f0ea;
  border-radius: 10px;
  box-shadow: none;
}

.record-context-card.record-context-editing {
  background: #fffdf5;
  border-color: #f0d58a;
  border-left: 4px solid #eab308;
}
.record-round-pill {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--lab-primary);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: none;
}
.record-context-kicker {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  color: var(--lab-primary);
}
.record-context-body h3 {
  margin: 0 0 4px;
  font-size: 19px;
  font-weight: 700;
  color: var(--lab-text);
}
.record-context-sub {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--lab-text-muted);
}

.record-table-section {
  background: #fff;
  border: 1px solid #e4f0ea;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: none;
}
.record-table-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--lab-primary-soft);
  border-bottom: 1px solid var(--lab-accent-border);
}
.record-table-step {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--lab-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.record-table-head h4 {
  margin: 0 0 1px;
  font-size: 14px;
  font-weight: 700;
  color: var(--lab-text);
}
.record-table-head p {
  margin: 0;
  font-size: 12px;
  color: var(--lab-text-muted);
}
#recordEntryForm { padding: 16px 18px 18px; }

.record-table-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  margin-bottom: 16px;
  border: 1px solid #e8f2ed;
  border-radius: 8px;
  -webkit-overflow-scrolling: touch;
  box-shadow: none;
  scrollbar-width: thin;
  scrollbar-color: var(--lab-accent-border) #f4faf7;
}
.record-table-wrap::-webkit-scrollbar {
  height: 10px;
}
.record-table-wrap::-webkit-scrollbar-track {
  background: #f4faf7;
  border-radius: 0 0 8px 8px;
}
.record-table-wrap::-webkit-scrollbar-thumb {
  background: var(--lab-accent-border);
  border-radius: 999px;
  border: 2px solid #f4faf7;
}
.record-table-wrap::-webkit-scrollbar-thumb:hover {
  background: var(--lab-primary);
}
.record-table {
  width: max-content;
  min-width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}
.record-table th,
.record-table td {
  min-width: 140px;
  width: 140px;
}
.record-table th.th-col-round,
.record-table td.td-col-round {
  min-width: 72px;
  width: 72px;
}
.record-table th.th-col-usage,
.record-table td.td-col-usage {
  min-width: 168px;
  width: 168px;
}
.record-table thead th.th-col-usage {
  background: #eef6ff;
}
.record-table td.td-col-usage {
  background: #f8fcff;
}
.table-input-usage {
  font-weight: 600;
}
.record-table th.th-col-effective,
.record-table td.td-col-effective {
  min-width: 168px;
  width: 168px;
}
.record-table thead th.th-col-effective {
  background: #f3f4f6;
  color: var(--lab-text-muted);
}
.record-table td.td-col-effective {
  background: #f8f9fa;
}
.record-table thead th.th-col-effective-active,
.record-table thead th.th-col-effective.th-col-effective-active {
  background: #eef6ff;
  color: var(--lab-primary-dark);
}
.record-table td.td-col-effective-active {
  background: #f8fcff;
}
.record-table td.td-col-effective input:disabled {
  opacity: .55;
  cursor: not-allowed;
  background: #eef1f3;
}
.record-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 12px 8px;
  border-bottom: 2px solid var(--lab-accent-border);
  border-right: 1px solid rgba(197, 234, 217, .45);
  vertical-align: middle;
}
.record-table thead th:last-child { border-right: none; }
.record-table thead th.th-fixed {
  color: var(--lab-text-muted);
  background: #f0f5f3;
}
.record-table thead th.th-input {
  color: var(--lab-primary-dark);
  background: #ecf9f3;
}
.th-inner {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 6px;
  min-height: 0;
  padding: 0;
  height: 100%;
}
.th-inner-fixed,
.th-inner-ingredient {
  background: none;
}
.th-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -.01em;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.th-amount {
  display: inline-flex;
  align-items: center;
  align-self: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--lab-text-muted);
  background: rgba(255, 255, 255, .82);
  border: 1px solid #d1d5db;
  white-space: nowrap;
}
.th-amount-muted {
  font-weight: 600;
  background: transparent;
  border-style: dashed;
}
.th-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  align-self: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  line-height: 1.4;
}
.th-badge-auto {
  color: #5f736c;
  background: rgba(255, 255, 255, .75);
  border: 1px solid #dde5e1;
}
.th-badge-required {
  color: var(--lab-primary-dark);
  background: rgba(255, 255, 255, .7);
  border: 1px solid var(--lab-accent-border);
}
.th-lock {
  display: inline-flex;
  vertical-align: middle;
  opacity: .7;
}
.record-table td {
  padding: 12px 10px;
  vertical-align: middle;
}
.record-table td.td-fixed { background: #f8fbfa; }
.record-table td.td-input { background: #fff; }

/* Modern table inputs */
.record-table .table-input,
.record-table .table-input:hover,
.record-table .table-input:focus,
.record-table .table-input:focus-visible,
.record-table .table-input:active {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 1.5px solid #dcebe4;
  border-radius: 10px;
  padding: 11px 12px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--lab-text);
  background: linear-gradient(180deg, #ffffff 0%, #f9fcfb 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9);
  -webkit-appearance: none;
  appearance: none;
  filter: none;
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}
.record-table .table-input::placeholder {
  color: #9ca3af;
  font-weight: 400;
  opacity: 1;
}
.record-table .table-input:hover:not(:focus):not(:read-only) {
  border-color: #b8dfd0;
  background: #fff;
}
.record-table .table-input:focus {
  outline: none;
  border-color: var(--lab-primary);
  background: #fff;
  box-shadow: 0 0 0 3px var(--lab-primary-glow);
}
.record-table .table-input-fixed {
  background: #eef5f1;
  color: var(--lab-primary-dark);
  border-color: #d4e8df;
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  cursor: default;
  box-shadow: none;
}
.record-table .table-input-combo {
  min-width: 160px;
}
.record-table .table-input-date {
  min-height: 42px;
  color-scheme: light;
  padding-right: 10px;
}
.record-table .table-input-date::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: .75;
  padding: 4px;
  border-radius: 6px;
  transition: background .15s ease;
}
.record-table .table-input-date::-webkit-calendar-picker-indicator:hover {
  background: var(--lab-primary-soft);
}
.record-table .table-input-select {
  cursor: pointer;
  padding-right: 34px;
  font-weight: 600;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23009a73' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
}
.record-table .table-input-select:invalid,
.record-table .table-input-select option[value=""] {
  color: #9ca3af;
}

.record-table tbody tr.row-status-fail {
  box-shadow: inset 4px 0 0 #ef4444;
}
.record-table tbody tr.row-status-pass {
  box-shadow: inset 4px 0 0 var(--lab-primary);
}
.record-table tbody tr.row-status-keep {
  box-shadow: inset 4px 0 0 #eab308;
}
.record-table tbody tr.row-status-fail td { background: #fef2f2; }
.record-table tbody tr.row-status-pass td { background: #ecfdf6; }
.record-table tbody tr.row-status-keep td { background: #fffbeb; }
.record-table tbody tr[class*='row-status-'] .table-input:not(.table-input-fixed) {
  background: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .95);
}
.record-table tbody tr[class*='row-status-'] .table-input:focus {
  box-shadow: 0 0 0 3px var(--lab-primary-glow);
}

/* Legacy / summary forms outside record-table */
.table-input {
  width: 100%;
  min-width: 100px;
  border: 1.5px solid #dcebe4;
  border-radius: 9px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--lab-text);
  background: #fff;
  box-shadow: none;
  transition: border-color .15s ease;
}
.table-input-fixed {
  background: #f3f6f5;
  color: var(--lab-text-muted);
  border-color: #e4ebe8;
  font-weight: 600;
  font-size: 13px;
  box-shadow: none;
}
.table-input:focus {
  outline: none;
  border-color: var(--lab-primary);
  box-shadow: none;
}
.table-input-date {
  min-height: 42px;
  color-scheme: light;
}
.table-input-date::-webkit-datetime-edit,
.table-input-date::-webkit-datetime-edit-fields-wrapper,
.table-input-date::-webkit-datetime-edit-text,
.table-input-date::-webkit-datetime-edit-month-field,
.table-input-date::-webkit-datetime-edit-day-field,
.table-input-date::-webkit-datetime-edit-year-field {
  font-family: var(--lab-font);
}
.table-input-date::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: .65;
}
.btn-record-submit {
  width: 100%;
  padding: 14px 24px;
  font-size: 15px;
}
@media (min-width: 480px) {
  .btn-record-submit { width: auto; min-width: 220px; }
}

@media (max-width: 520px) {
  .record-progress-item span:not(.record-progress-dot) { font-size: 12px; }
  .record-progress-line { width: 20px; margin: 0 6px; }
}
.result-topic-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--lab-primary-dark);
  margin-bottom: 6px;
}
.columns-intro {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e8f2ed;
}
.columns-intro-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--lab-primary-soft);
  color: var(--lab-primary);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.columns-intro h3 { margin: 0 0 4px; font-size: 16px; color: var(--lab-text); }
.columns-intro p { margin: 0; font-size: 13px; color: var(--lab-text-muted); }

.column-add-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.column-input-wrap { flex: 1; min-width: 200px; }
.column-input-wrap input {
  width: 100%;
  padding: 12px 14px 12px 44px;
  border: 1.5px solid #dce8e2;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 15px;
  outline: none;
}
.column-input-wrap input:focus {
  border-color: var(--lab-primary);
  box-shadow: 0 0 0 4px var(--lab-primary-glow);
}
.btn-add-column {
  width: auto;
  padding: 12px 20px;
  white-space: nowrap;
}

.empty-columns {
  text-align: center;
  padding: 24px;
  color: var(--lab-empty);
  font-size: 14px;
  border: 1.5px dashed var(--lab-accent-border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}
.empty-columns p { margin: 0; }

.column-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.column-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: #f8fcfa;
  border: 1px solid #e4f0ea;
  border-radius: 10px;
}
.column-order {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--lab-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.column-name {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  color: var(--lab-text);
}
.column-remove {
  width: 36px; height: 36px;
  border: none;
  border-radius: 9px;
  background: var(--lab-danger-soft);
  color: var(--lab-danger);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.column-remove:hover { background: var(--lab-danger); color: #fff; }

.column-item-fixed {
  border-color: var(--lab-accent-border);
  background: var(--lab-primary-soft);
}
.column-fixed-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--lab-primary-dark);
  background: #fff;
  border: 1px solid var(--lab-accent-border);
  border-radius: 999px;
  padding: 4px 10px;
  flex-shrink: 0;
}
.input-readonly {
  background: #f0f5f3;
  color: var(--lab-text-muted);
  cursor: default;
}

.form-warn {
  margin: 0 0 12px;
  padding: 10px 12px;
  background: #fff8e8;
  border-radius: 8px;
  font-size: 13px;
  color: #8a6d00;
}
.result-field {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid #eef2ef;
  font-size: 14px;
}
.result-field:last-child { border-bottom: none; }
.result-key { color: var(--lab-text-muted); font-weight: 600; }
.result-val { color: var(--lab-text); text-align: right; }

.item-clickable { cursor: pointer; }
.item-clickable:hover { transform: translateY(-1px); }
.item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.item-go { color: var(--lab-empty); display: flex; }

.btn-outline {
  width: 100%;
  padding: 11px 16px;
  background: #fff;
  color: #1a7ab0;
  border: 2px solid #b8e0f5;
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background .15s, border-color .15s;
}
.btn-outline:hover {
  background: #e8f6fc;
  border-color: #1a7ab0;
}

.item {
  background: var(--lab-surface);
  border-radius: var(--radius);
  border: 1px solid rgba(197, 234, 217, .5);
  box-shadow: var(--lab-shadow);
  overflow: hidden;
  transition: box-shadow .2s, transform .2s;
}
.item:hover { box-shadow: var(--lab-shadow-lg); }

.item-top {
  display: flex;
  gap: 0;
}
.item-stripe {
  width: 4px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--lab-primary-light), var(--lab-primary));
}
.item-stripe.record {
  background: linear-gradient(180deg, #38bdf8, #1a7ab0);
}
.item-body { flex: 1; padding: 16px 18px; min-width: 0; }

.item-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.item-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.item-icon {
  width: 40px; height: 40px;
  border-radius: 11px;
  background: var(--lab-primary-soft);
  display: flex; align-items: center; justify-content: center;
  color: var(--lab-primary);
  flex-shrink: 0;
}
.item-icon.record {
  background: #e8f6fc;
  color: #1a7ab0;
}
.item h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--lab-text);
  line-height: 1.3;
}
.item-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.meta {
  font-size: 12px;
  color: var(--lab-text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--lab-primary-soft);
  color: var(--lab-primary);
}
.badge.results {
  background: #e8f6fc;
  color: #1a7ab0;
}
.hypothesis {
  margin-top: 10px;
  padding: 10px 12px;
  background: #f8fcfa;
  border-radius: 10px;
  border-left: 3px solid var(--lab-accent-border);
  font-size: 13px;
  color: var(--lab-text-muted);
  line-height: 1.5;
}
.hypothesis::before {
  content: '💡';
  margin-right: 6px;
}

.delete {
  width: 40px; height: 40px;
  padding: 0;
  border: none;
  border-radius: 11px;
  background: var(--lab-danger-soft);
  color: var(--lab-danger);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s, color .15s, transform .15s;
}
.delete:hover {
  background: var(--lab-danger);
  color: #fff;
}
.delete:active { transform: scale(.95); }

/* ── Result form & history ── */
.result-form {
  margin-top: 16px;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #f0fdf8, #e8faf3);
  border: 1.5px dashed var(--lab-accent-border);
}
.summary-latest.row-status-fail { border-left: 4px solid #ef4444; background: #fef2f2; }
.summary-latest.row-status-pass { border-left: 4px solid var(--lab-primary); background: #ecfdf6; }
.summary-latest.row-status-keep { border-left: 4px solid #eab308; background: #fffbeb; }

/* ── Summary history modal ── */
body.summary-history-open {
  overflow: hidden;
}

.summary-history-modal {
  position: fixed;
  inset: 0;
  z-index: 180;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s ease, visibility .2s ease;
  pointer-events: none;
}

.summary-history-modal.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.summary-history-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(3px);
}

.summary-history-panel {
  position: relative;
  width: min(96vw, 1440px);
  max-height: min(92vh, 940px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 18px;
  box-shadow: var(--lab-shadow-lg);
  overflow: hidden;
}

.summary-history-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid #e8f2ed;
  background: linear-gradient(180deg, #f8fcfa, #fff);
}

.summary-history-eyebrow {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--lab-primary);
}

.summary-history-head h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--lab-text);
}

.summary-history-meta {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--lab-text-muted);
}

.summary-history-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: #f0f7f4;
  color: var(--lab-text-muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.summary-history-close:hover {
  background: #e4f5ee;
  color: var(--lab-text);
}

.summary-history-body {
  padding: 12px 18px 20px;
  overflow: auto;
}

.summary-history-hint {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--lab-text-muted);
}

.summary-history-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 14px;
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1.5px solid var(--lab-accent-border);
  border-radius: 12px;
  background: linear-gradient(180deg, #f8fcfa, #fff);
}

.history-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.history-filter-icon {
  display: inline-flex;
  color: var(--lab-primary);
  flex-shrink: 0;
}

.history-filter-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--lab-text);
  white-space: nowrap;
}

.history-filter-select {
  min-width: 148px;
  max-width: 220px;
  padding: 8px 34px 8px 12px;
  border: 1.5px solid #c8e8dc;
  border-radius: 10px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' fill='none' stroke='%23009a73' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 10px center;
  color: var(--lab-text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  appearance: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.history-filter-select:hover {
  border-color: var(--lab-primary);
}

.history-filter-select:focus {
  outline: none;
  border-color: var(--lab-primary);
  box-shadow: 0 0 0 3px rgba(0, 154, 115, 0.15);
}

.history-filter-clear {
  margin-left: auto;
  padding: 8px 12px;
  border: 1.5px dashed #cbd5e1;
  border-radius: 10px;
  background: #fff;
  color: var(--lab-text-muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.history-filter-clear:hover {
  border-color: var(--lab-primary);
  color: var(--lab-primary);
  background: var(--lab-primary-soft);
}

.history-groups {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.history-group {
  border: 1px solid #e2ece7;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  border-left: 4px solid #cbd5e1;
}

.history-group.row-status-pass {
  border-left-color: var(--lab-primary);
  background: #fafffd;
}
.history-group.row-status-keep {
  border-left-color: #eab308;
  background: #fffdf8;
}
.history-group.row-status-fail {
  border-left-color: #ef4444;
  background: #fffcfc;
}

.history-group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid #edf3f0;
  background: rgba(255, 255, 255, .85);
}

.history-group-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #94a3b8;
  flex-shrink: 0;
}

.history-group.row-status-pass .history-group-dot { background: var(--lab-primary); }
.history-group.row-status-keep .history-group-dot { background: #eab308; }
.history-group.row-status-fail .history-group-dot { background: #ef4444; }

.history-group-title {
  margin: 0;
  flex: 1;
  font-size: 15px;
  font-weight: 700;
  color: var(--lab-text);
}

.history-group-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--lab-text-muted);
  padding: 4px 10px;
  border-radius: 999px;
  background: #f1f5f3;
}

.history-group-empty {
  margin: 0;
  padding: 18px 14px;
  font-size: 13px;
  color: var(--lab-text-muted);
  text-align: center;
}

.history-group .history-table-wrap {
  border: none;
  border-radius: 0;
}

.summary-history-empty {
  margin: 0;
  text-align: center;
  color: var(--lab-text-muted);
  padding: 24px 0;
}

.history-table-wrap {
  overflow: auto;
  border: 1px solid #e2ece7;
  border-radius: 12px;
  background: #fff;
}

.history-table {
  width: 100%;
  min-width: max-content;
  border-collapse: collapse;
  font-size: 13px;
}

.history-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--lab-text-muted);
  background: #f4faf7;
  border-bottom: 2px solid #dcefe6;
  white-space: nowrap;
  vertical-align: bottom;
}

.history-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid #edf3f0;
  color: var(--lab-text);
  vertical-align: middle;
  white-space: nowrap;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-table tbody tr:last-child td {
  border-bottom: none;
}

.history-row-clickable {
  cursor: pointer;
  transition: background .15s ease;
}

.history-row-clickable:hover {
  background: #f5f7f6;
}

.history-row-clickable:focus-visible {
  outline: 2px solid var(--lab-primary);
  outline-offset: -2px;
}

.history-row.row-status-fail.history-row-clickable:hover {
  background: #fff5f5;
}

.history-row.row-status-pass.history-row-clickable:hover {
  background: #f0fdf8;
}

.history-row.row-status-keep.history-row-clickable:hover {
  background: #fffbeb;
}

.history-th-round,
.history-td-round {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #fff;
  box-shadow: 2px 0 6px rgba(0, 0, 0, .04);
}

.history-th-usage,
.history-td-usage {
  min-width: 132px;
  white-space: nowrap;
}

.history-th-effective,
.history-td-effective {
  min-width: 128px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.history-table thead .history-th-round {
  z-index: 4;
  background: #f4faf7;
}

.history-round-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: var(--lab-text);
  background: #f3f4f6;
}

.history-row.row-status-fail {
  background: #fffbfb;
}
.history-row.row-status-fail .history-td-round {
  background: #fffbfb;
}
.history-row.row-status-fail .history-round-num {
  color: var(--lab-text);
  background: #fee2e2;
}

.history-row.row-status-pass {
  background: #f8fffc;
}
.history-row.row-status-pass .history-td-round {
  background: #f8fffc;
}
.history-row.row-status-pass .history-round-num {
  color: var(--lab-text);
  background: #d1fae5;
}

.history-row.row-status-keep {
  background: #fffdf5;
}
.history-row.row-status-keep .history-td-round {
  background: #fffdf5;
}
.history-row.row-status-keep .history-round-num {
  color: var(--lab-text);
  background: #fef3c7;
}

.history-td-time {
  font-size: 12px;
  color: var(--lab-text-muted);
  white-space: normal;
  min-width: 120px;
}

.history-td-usage {
  font-weight: 600;
}

.history-usage-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
}

.history-usage-badge.history-usage-change {
  background: #e8f2ff;
  color: #1d4ed8;
}

.history-usage-badge.history-usage-start {
  background: #ecfdf6;
  color: #047857;
}

.history-usage-badge.history-usage-unknown {
  background: #f3f4f6;
  color: var(--lab-text-muted);
}

.history-td-list {
  min-width: 100px;
}

.history-th-data,
.history-td-data {
  min-width: 88px;
}

.history-status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: #eef2f6;
  color: var(--lab-text-muted);
  white-space: nowrap;
}
.history-status-badge.row-status-fail {
  background: #fee2e2;
  color: #b91c1c;
}
.history-status-badge.row-status-pass {
  background: #d1fae5;
  color: #047857;
}
.history-status-badge.row-status-keep {
  background: #fef3c7;
  color: #a16207;
}

/* ── History record detail modal ── */
body.history-detail-open {
  overflow: hidden;
}

.history-detail-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s ease, visibility .2s ease;
  pointer-events: none;
}

.history-detail-modal.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.history-detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
}

.history-detail-panel {
  position: relative;
  width: min(94vw, 860px);
  max-height: min(90vh, 880px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 18px;
  box-shadow: var(--lab-shadow-lg);
  overflow: hidden;
}

.history-detail-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px 18px;
  border-top: 1px solid #e8f2ed;
  background: #fff;
}

.record-form-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.btn-secondary {
  border: 1.5px solid #d1d5db;
  background: #fff;
  color: var(--lab-text);
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.btn-secondary:hover {
  border-color: var(--lab-primary);
  color: var(--lab-primary);
  background: var(--lab-primary-soft);
}

.history-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid #e8f2ed;
  background: linear-gradient(180deg, #f8fcfa, #fff);
}

.history-detail-head h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--lab-text);
}

.history-detail-body {
  padding: 18px 24px 24px;
  overflow: auto;
}

.history-detail-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f8faf9;
  border: 1px solid #e8f0ec;
  font-size: 13px;
  font-weight: 600;
  color: var(--lab-text);
}

.history-detail-meta.row-status-pass {
  border-left: 4px solid var(--lab-primary);
  background: #f6fffb;
}

.history-detail-meta.row-status-keep {
  border-left: 4px solid #eab308;
  background: #fffdf5;
}

.history-detail-meta.row-status-fail {
  border-left: 4px solid #ef4444;
  background: #fff8f8;
}

.history-detail-sep {
  color: #cbd5e1;
}

.history-detail-time {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--lab-text-muted);
}

.history-detail-sections {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.history-detail-section {
  margin: 0;
}

.history-detail-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e8f0ec;
  font-size: 14px;
  font-weight: 700;
  color: var(--lab-text);
}

.history-detail-section-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--lab-text-muted);
  padding: 3px 10px;
  border-radius: 999px;
  background: #f1f5f3;
}

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

.history-detail-info-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f8faf9;
  border: 1px solid #e8f0ec;
  min-width: 0;
}

.history-detail-key {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--lab-text-muted);
  line-height: 1.3;
}

.history-detail-val {
  font-size: 15px;
  font-weight: 700;
  color: var(--lab-text);
  line-height: 1.4;
  word-break: break-word;
}

.history-detail-text-block {
  padding: 14px 16px;
  border-radius: 12px;
  background: #f8faf9;
  border: 1px solid #e8f0ec;
}

.history-detail-block-label {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--lab-text-muted);
}

.history-detail-block-text {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  color: var(--lab-text);
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.history-detail-ingredient-wrap {
  overflow: auto;
  border: 1px solid #e8f0ec;
  border-radius: 12px;
  background: #fff;
}

.history-detail-ingredient-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.history-detail-ingredient-table thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--lab-text-muted);
  background: #f4faf7;
  border-bottom: 2px solid #dcefe6;
  white-space: nowrap;
}

.history-detail-ingredient-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid #edf3f0;
  color: var(--lab-text);
  vertical-align: top;
  line-height: 1.45;
}

.history-detail-ingredient-table tbody tr:last-child td {
  border-bottom: none;
}

.history-detail-ingredient-table tbody tr:nth-child(even) {
  background: #fafcfb;
}

.history-detail-ing-th-num,
.history-detail-ing-td-num {
  width: 48px;
  text-align: center;
}

.history-detail-ing-td-num {
  font-weight: 700;
  color: var(--lab-text-muted);
}

.history-detail-ing-td-name {
  font-weight: 600;
  word-break: break-word;
}

.history-detail-ing-th-amount,
.history-detail-ing-td-amount {
  width: 28%;
  min-width: 120px;
  text-align: right;
}

.history-detail-ing-td-amount {
  font-weight: 700;
  white-space: nowrap;
}

.history-detail-section-results {
  margin: 0;
}

.history-detail-section-results .history-detail-section-title {
  margin-bottom: 10px;
}

.history-detail-section-results.row-status-pass .history-detail-result-wrap {
  border-left: 4px solid var(--lab-primary);
}

.history-detail-section-results.row-status-keep .history-detail-result-wrap {
  border-left: 4px solid #eab308;
}

.history-detail-section-results.row-status-fail .history-detail-result-wrap {
  border-left: 4px solid #ef4444;
}

.history-detail-result-wrap {
  overflow: auto;
  border: 1px solid #e8f0ec;
  border-radius: 12px;
  background: #fff;
}

.history-detail-result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.history-detail-result-table thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--lab-text-muted);
  background: #f4faf7;
  border-bottom: 2px solid #dcefe6;
}

.history-detail-result-table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid #edf3f0;
  vertical-align: top;
  line-height: 1.5;
}

.history-detail-result-table tbody tr:last-child td {
  border-bottom: none;
}

.history-detail-res-th-label,
.history-detail-res-td-label {
  width: 132px;
  min-width: 112px;
  max-width: 160px;
  font-weight: 700;
  color: var(--lab-text-muted);
  background: #fafcfb;
}

.history-detail-res-td-value {
  font-weight: 500;
  color: var(--lab-text);
  white-space: pre-wrap;
  word-break: break-word;
}

.history-detail-res-td-badge {
  font-weight: 700;
}

@media (max-width: 640px) {
  .summary-history-body {
    padding: 10px 12px 16px;
  }
  .summary-history-filters {
    flex-direction: column;
    align-items: stretch;
  }
  .history-filter {
    flex-direction: column;
    align-items: stretch;
  }
  .history-filter-select {
    max-width: none;
    width: 100%;
  }
  .history-filter-clear {
    margin-left: 0;
    width: 100%;
  }
  .history-detail-info-grid {
    grid-template-columns: 1fr;
  }
  .history-detail-body {
    padding: 14px 16px 18px;
  }
  .history-table thead th,
  .history-table tbody td {
    padding: 8px 10px;
  }
}

.result-form label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--lab-text);
}
.result-form input,
.result-form select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid #dce8e2;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  margin-bottom: 12px;
  background: #fff;
  outline: none;
  box-shadow: none;
}
.result-form input:focus,
.result-form select:focus {
  border-color: var(--lab-primary);
}
.result-form .btn-primary { margin-top: 4px; }

.results-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #e8f2ed;
}
.results-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--lab-text-muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.result {
  position: relative;
  padding: 12px 12px 12px 20px;
  margin-bottom: 8px;
  background: #f8fcfa;
  border-radius: 10px;
  border: 1px solid #e4f0ea;
}
.result::before {
  content: '';
  position: absolute;
  left: 8px; top: 14px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--lab-primary);
}
.result:last-child { margin-bottom: 0; }
.result b {
  display: block;
  font-size: 14px;
  color: var(--lab-text);
  line-height: 1.5;
  margin-bottom: 2px;
}
.result .result-note {
  font-size: 13px;
  color: var(--lab-text-muted);
  margin-top: 4px;
}
.result .meta { margin-top: 6px; }

/* Record card: split form / history on wide cards */
.item-record-grid {
  display: flex;
  flex-direction: column;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--lab-text);
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--lab-shadow-lg);
  opacity: 0;
  transition: transform .3s ease, opacity .3s ease;
  z-index: 100;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.toast.success { background: var(--lab-primary); }
.toast.error { background: var(--lab-danger); }

/* ── Save progress overlay ── */
body.save-busy {
  overflow: hidden;
}

.save-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  pointer-events: none;
}

.save-overlay.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.save-overlay-card {
  width: min(360px, 100%);
  padding: 28px 24px 22px;
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--lab-shadow-lg);
  text-align: center;
}

.save-overlay-spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 16px;
  border: 3px solid rgba(22, 163, 74, 0.2);
  border-top-color: var(--lab-primary);
  border-radius: 50%;
  animation: save-spin 0.75s linear infinite;
}

@keyframes save-spin {
  to { transform: rotate(360deg); }
}

.save-overlay-text {
  margin: 0 0 18px;
  font-size: 15px;
  font-weight: 600;
  color: var(--lab-text);
}

.save-progress-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(22, 163, 74, 0.15);
  overflow: hidden;
}

.save-progress-bar {
  height: 100%;
  width: 40%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--lab-primary), #4ade80, var(--lab-primary));
  background-size: 200% 100%;
  animation: save-progress-slide 1.2s ease-in-out infinite;
}

@keyframes save-progress-slide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

/* ── Desktop (≥ 900px) ── */
@media (min-width: 900px) {
  .app { padding: 24px 28px 48px; }

  .hero { padding: 22px 28px; margin-bottom: 20px; }
  h1 { font-size: 30px; }

  .workspace {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
  }

  .nav-wrap { margin-bottom: 0; position: sticky; top: 24px; }

  .nav-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 2px 4px 10px;
    margin-bottom: 2px;
  }
  .nav-toolbar-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    color: var(--lab-text-muted);
    text-transform: uppercase;
  }

  .workspace.nav-collapsed {
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 16px;
  }
  .workspace.nav-collapsed .nav-wrap { display: none; }
  .workspace.nav-collapsed .nav-expand-btn {
    display: flex;
    position: sticky;
    top: 24px;
    align-self: start;
  }

  .list-scroll {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--lab-accent-border) transparent;
  }
  .list-scroll::-webkit-scrollbar { width: 6px; }
  .list-scroll::-webkit-scrollbar-thumb {
    background: var(--lab-accent-border);
    border-radius: 999px;
  }

  .list-record,
  .list-summary {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .item-record-grid.has-results {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 24px;
    align-items: start;
  }
  .item-record-grid.has-results .result-form { margin-top: 0; }
  .item-record-grid.has-results .results-section {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    max-height: 360px;
    overflow-y: auto;
    padding-right: 4px;
  }

  .panel-head-record { margin-bottom: 20px; }

  .empty-state { padding: 60px 40px; }

  /* Record entry — wider columns with horizontal scroll */
  .record-table th,
  .record-table td {
    min-width: 148px;
    width: 148px;
  }
  .record-table thead th { padding: 12px 10px; }
  .record-table td {
    padding: 12px 10px;
  }
  .table-input {
    min-width: 0;
    padding: 11px 10px;
    font-size: 14px;
  }
  .record-content-area { padding: 24px 28px; }
  .record-picker-panel { padding: 22px 24px; }
  #recordEntryForm { padding: 18px 22px 22px; }
  .record-summary-value { max-width: 280px; }
}

/* ── Large desktop (≥ 1100px) ── */
@media (min-width: 1100px) {
  .app { padding: 28px 36px 48px; }

  .workspace {
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 28px;
  }

  .list-record,
  .list-summary {
    grid-template-columns: repeat(2, 1fr);
  }

  .item-record-grid.has-results {
    display: flex;
    flex-direction: column;
    gap: 0;
  }
  .item-record-grid.has-results .result-form { margin-top: 0; }
  .item-record-grid.has-results .results-section {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid #e8f2ed;
    max-height: 240px;
  }

  .record-picker-grid { grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.2fr); }
  .record-choice-list { max-height: 280px; }
}

/* ── Wide desktop (≥ 1400px) ── */
@media (min-width: 1400px) {
  .app { padding: 32px 48px 56px; }

  .workspace {
    grid-template-columns: 272px minmax(0, 1fr);
    gap: 32px;
  }

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

  .record-table th,
  .record-table td {
    min-width: 156px;
    width: 156px;
  }
  .th-label { font-size: 14px; }
  .th-amount { font-size: 12px; }
  .record-table td { padding: 12px 12px; }
  .table-input { padding: 12px 12px; }
}

/* ── Mobile ── */
@media (max-width: 480px) {
  .app { padding: 12px 12px 40px; }
  .hero { padding: 16px; }
  .nav-tab { padding: 12px 8px; font-size: 13px; }
  .tab-text { display: none; }
  .nav-tab .tab-icon { margin: 0; }
  .nav-tab.active .tab-text { display: inline; }
  .stat-pill { padding: 6px 12px 6px 10px; }
  .stat-label { display: none; }
}
