:root {
  color-scheme: light;
  --bg: #f4f6f1;
  --surface: #ffffff;
  --surface-soft: #f7faf5;
  --surface-2: #eef2eb;
  --ink: #18211f;
  --muted: #64706c;
  --line: #d9dfd7;
  --line-strong: #bdc9c2;
  --accent: #008b6d;
  --accent-strong: #007a60;
  --accent-soft: #dcefe9;
  --blue: #3659a8;
  --cobalt: #3659a8;
  --cobalt-soft: #e4eafb;
  --green: #008b6d;
  --amber: #c7841d;
  --amber-soft: #fbefd8;
  --rose: #c43f72;
  --cyan: #0ea5b7;
  --violet: #6d5bd0;
  --red: #c9573d;
  --red-soft: #fae6e0;
  --graphite: #26302e;
  --graphite-deep: #1f2826;
  --shadow: 0 18px 45px rgba(29, 42, 38, 0.1);
  --shadow-soft: 0 12px 26px rgba(29, 42, 38, 0.08);
  --shadow-card: 0 16px 38px rgba(29, 42, 38, 0.1);
  --gradient-brand: linear-gradient(135deg, #008b6d 0%, #3659a8 66%, #26302e 100%);
  --gradient-soft: linear-gradient(135deg, rgba(0, 139, 109, 0.1), rgba(54, 89, 168, 0.08), rgba(199, 132, 29, 0.06));
  --radius: 8px;
  --topbar: 64px;
  --sidebar: 248px;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(245, 248, 244, 0.96), rgba(239, 243, 236, 0.96)),
    repeating-linear-gradient(90deg, rgba(38, 48, 46, 0.04) 0 1px, transparent 1px 72px);
  color: var(--ink);
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(15, 139, 141, 0.12), rgba(58, 103, 177, 0.08), rgba(32, 149, 104, 0.07)),
    linear-gradient(90deg, rgba(255, 255, 255, 0.62) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.56) 1px, transparent 1px),
    #eaf2f8;
  background-size: auto, 42px 42px, 42px 42px, auto;
}

.login-panel {
  width: min(440px, 100%);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(249, 252, 255, 0.98));
  border: 1px solid rgba(197, 211, 225, 0.88);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px;
  position: relative;
  overflow: hidden;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.brand-icon {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  box-shadow:
    0 12px 28px rgba(15, 139, 141, 0.2),
    0 0 0 1px rgba(255, 255, 255, 0.72);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

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

.brand-lockup h1 {
  margin: 0;
  font-size: clamp(24px, 7vw, 32px);
  line-height: 1.15;
}

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

.login-autofill-trap {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.login-autofill-trap input {
  position: absolute;
  width: 1px;
  min-height: 1px;
  padding: 0;
  border: 0;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.checkbox-field input {
  width: 16px;
  min-height: 16px;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background:
    linear-gradient(180deg, #ffffff 0%, #fbfcfa 100%);
  color: var(--ink);
  font-size: 13px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.82);
  transition: 160ms ease;
  transition-property: border-color, box-shadow, background;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.keyword-picker {
  position: relative;
  min-width: 0;
}

.keyword-picker label {
  margin-bottom: 6px;
}

.keyword-picker input[readonly] {
  cursor: pointer;
  background: #fff;
  color: var(--ink);
}

.keyword-dropdown {
  position: relative;
  min-width: 0;
}

.keyword-dropdown summary {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #fbfcfa);
  cursor: pointer;
  list-style: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.86);
}

.keyword-dropdown summary::-webkit-details-marker {
  display: none;
}

.keyword-dropdown summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.keyword-dropdown summary strong {
  color: var(--ink);
  font-size: 13px;
}

.keyword-option-grid {
  position: absolute;
  z-index: 12;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow: auto;
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 36px rgba(29, 42, 38, 0.14);
}

.keyword-option {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  font-size: 13px;
  font-weight: 800;
}

.keyword-option input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}

.summary-keyword-output input[readonly] {
  border-color: #b8d7e8;
  background: linear-gradient(180deg, #ffffff 0%, #f4fbff 100%);
  color: #12314a;
  font-weight: 800;
}

.summary-keyword-output input {
  border-color: #b8d7e8;
  background: #ffffff;
  color: #12314a;
  font-weight: 800;
}

.summary-keywords {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #cfe0ea;
  border-radius: 8px;
  background: #f8fbfd;
}

.summary-keyword-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.summary-keyword-head strong {
  font-size: 13px;
}

.summary-keyword-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.keyword-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.keyword-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid #bdd5e2;
  background: #ecf7fb;
  color: #175d66;
  font-size: 12px;
  font-weight: 800;
}

.detail-keywords {
  margin: 10px 0;
}

.confidentiality-field small,
.query-clearance-field small {
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.5;
}

.confidentiality-badge {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.confidentiality-private {
  color: #315f9c;
  background: #e8f1ff;
}

.confidentiality-role {
  color: #087346;
  background: #e3f4ec;
}

.confidentiality-strict {
  color: #b23624;
  background: #fde8e6;
}

.query-clearance-own {
  color: #315f9c;
  background: #e8f1ff;
}

.query-clearance-role {
  color: #087346;
  background: #e3f4ec;
}

.query-clearance-all {
  color: #7c2d12;
  background: #ffedd5;
}

select {
  appearance: none;
  padding-right: 34px;
  background-image:
    linear-gradient(180deg, #ffffff 0%, #fbfcfa 100%),
    linear-gradient(45deg, transparent 50%, #64706c 50%),
    linear-gradient(135deg, #64706c 50%, transparent 50%);
  background-position:
    0 0,
    calc(100% - 17px) 50%,
    calc(100% - 12px) 50%;
  background-size:
    100% 100%,
    5px 5px,
    5px 5px;
  background-repeat: no-repeat;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow:
    0 0 0 3px rgba(13, 124, 131, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.86);
}

.button,
.icon-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--ink);
  background: #fff;
  transition: 160ms ease;
  transition-property: background, border-color, color, box-shadow, transform;
}

.button {
  padding: 7px 11px;
  font-size: 13px;
  font-weight: 700;
}

.button:hover,
.icon-button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.button.primary {
  color: #fff;
  background: var(--accent-strong);
  border-color: var(--accent);
  box-shadow: 0 12px 26px rgba(0, 139, 109, 0.18);
}

.button.primary:hover {
  background: #006f58;
}

.button.secondary {
  border-color: var(--line);
  background: var(--surface);
}

.button.ghost {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.button.danger {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

.button.success {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

.button.warning {
  color: #fff;
  background: var(--amber);
  border-color: var(--amber);
}

.button.wide {
  width: 100%;
}

.button.compact,
.icon-button {
  min-height: 34px;
}

.button.compact {
  padding: 5px 9px;
}

.icon-button {
  width: 36px;
  padding: 0;
  border-color: var(--line);
}

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

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

.form-error.text-success {
  color: var(--green);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  grid-template-rows: var(--topbar) minmax(0, 1fr);
  grid-template-areas:
    "topbar topbar"
    "sidebar main";
  font-size: 13px;
}

.topbar {
  grid-area: topbar;
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(213, 223, 235, 0.86);
  background:
    linear-gradient(90deg, rgba(31, 40, 38, 0.98) 0 var(--sidebar), rgba(255, 255, 255, 0.92) var(--sidebar)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(247, 250, 245, 0.86));
  backdrop-filter: blur(14px);
  box-shadow: 0 8px 24px rgba(15, 31, 48, 0.05);
}

.nav-toggle {
  display: none;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar-brand img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(13, 124, 131, 0.16);
}

.topbar-brand strong,
.topbar-brand span {
  display: block;
  white-space: nowrap;
}

.topbar-brand strong {
  color: #edf4ef;
  font-size: 15px;
  line-height: 1.1;
}

.topbar-brand span {
  color: rgba(237, 244, 239, 0.66);
  font-size: 12px;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-doc-link {
  text-decoration: none;
}

.user-chip {
  min-height: 36px;
  display: grid;
  align-content: center;
  padding: 4px 10px;
  border: 1px solid #dbe6f0;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, #f8fbfd);
  font-size: 12px;
  line-height: 1.2;
  color: var(--muted);
}

.user-chip strong {
  color: var(--ink);
}

.sidebar {
  grid-area: sidebar;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, #1f2826 0%, #26302e 52%, #202927 100%);
  padding: 20px 14px 22px;
  box-shadow:
    inset -1px 0 0 rgba(255, 255, 255, 0.05),
    12px 0 32px rgba(29, 42, 38, 0.08);
}

.main-nav {
  display: grid;
  gap: 6px;
}

.nav-section-label {
  margin: 12px 8px 3px;
  color: rgba(237, 244, 239, 0.5);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
}

.nav-section-label:first-child {
  margin-top: 0;
}

.nav-item {
  --nav-icon-color: #5eead4;
  width: 100%;
  min-height: 39px;
  border: 1px solid transparent;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: transparent;
  color: rgba(237, 244, 239, 0.74);
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  box-shadow: none;
  transition: 160ms ease;
  transition-property: background, border-color, color, box-shadow, transform;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  transform: translateY(-1px);
}

.nav-item.active {
  color: #ffffff;
  background:
    linear-gradient(135deg, rgba(0, 139, 109, 0.3), rgba(54, 89, 168, 0.18)),
    rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow:
    inset 0 0 0 1px rgba(94, 224, 183, 0.16),
    0 12px 26px rgba(0, 0, 0, 0.14);
}

.nav-item .icon {
  color: var(--nav-icon-color);
  filter: drop-shadow(0 2px 5px color-mix(in srgb, var(--nav-icon-color) 34%, transparent));
}

.nav-item[data-nav-id="dashboard"] {
  --nav-icon-color: #22d3ee;
}

.nav-item[data-nav-id="entry"] {
  --nav-icon-color: #34d399;
}

.nav-item[data-nav-id="analysis"] {
  --nav-icon-color: #60a5fa;
}

.nav-item[data-nav-id="audit"] {
  --nav-icon-color: #fbbf24;
}

.nav-item[data-nav-id="query"] {
  --nav-icon-color: #a78bfa;
}

.nav-item[data-nav-id="inventory"] {
  --nav-icon-color: #2dd4bf;
}

.nav-item[data-nav-id="wechatImport"] {
  --nav-icon-color: #fb7185;
}

.nav-item[data-nav-id="users"] {
  --nav-icon-color: #c084fc;
}

.nav-item[data-nav-id="engineeringDocs"] {
  --nav-icon-color: #38bdf8;
}

.nav-item[data-nav-id="database"] {
  --nav-icon-color: #f59e0b;
}

.view-root {
  grid-area: main;
  min-width: 0;
  padding: 20px;
  outline: none;
}

.view-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 15px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(0, 139, 109, 0.08), rgba(54, 89, 168, 0.06)),
    rgba(255, 255, 255, 0.88);
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.88);
}

.view-heading h2 {
  margin: 0 0 4px;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: 0;
}

.view-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  min-height: 84px;
  position: relative;
  overflow: hidden;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, #ffffff 0%, #fbfcfa 100%);
  box-shadow:
    var(--shadow-soft),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.metric::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(0, 139, 109, 0.11), transparent 42%);
}

.metric:nth-child(2)::before {
  background: linear-gradient(135deg, rgba(54, 89, 168, 0.12), transparent 42%);
}

.metric:nth-child(3)::before {
  background: linear-gradient(135deg, rgba(0, 139, 109, 0.12), transparent 42%);
}

.metric:nth-child(4)::before {
  background: linear-gradient(135deg, rgba(199, 132, 29, 0.12), transparent 42%);
}

.metric span {
  position: relative;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric strong {
  position: relative;
  font-size: 26px;
  line-height: 1;
}

.metric strong.metric-small {
  font-size: 22px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 16px;
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.form-panel {
  width: min(75vw, 1320px);
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
  position: relative;
  overflow: hidden;
  border-color: var(--line-strong);
  background:
    linear-gradient(135deg, rgba(0, 139, 109, 0.06), rgba(54, 89, 168, 0.05)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(251, 252, 250, 0.96));
  box-shadow:
    0 20px 48px rgba(29, 42, 38, 0.12),
    0 8px 18px rgba(29, 42, 38, 0.07),
    inset 0 1px 0 rgba(255, 255, 255, 0.96);
}

.form-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.72),
    inset 0 10px 24px rgba(255, 255, 255, 0.7);
}

.form-panel > * {
  position: relative;
  z-index: 1;
}

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

.structured-form fieldset {
  --fieldset-accent: var(--accent);
  --fieldset-tint: rgba(15, 127, 134, 0.08);
  position: relative;
  margin: 0;
  padding: 18px 18px 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, var(--fieldset-tint), transparent 34%),
    linear-gradient(180deg, #ffffff 0%, #fbfcfa 100%);
  box-shadow:
    0 14px 30px rgba(29, 42, 38, 0.07),
    0 3px 8px rgba(29, 42, 38, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
  transition: 160ms ease;
  transition-property: box-shadow, border-color, transform;
}

.structured-form fieldset:focus-within {
  border-color: color-mix(in srgb, var(--fieldset-accent) 58%, var(--line));
  box-shadow:
    0 20px 42px rgba(29, 42, 38, 0.11),
    0 0 0 3px rgba(0, 139, 109, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
  transform: translateY(-1px);
}

.structured-form fieldset:nth-of-type(2) {
  --fieldset-accent: var(--blue);
  --fieldset-tint: rgba(49, 95, 156, 0.09);
}

.structured-form fieldset:nth-of-type(3) {
  --fieldset-accent: var(--green);
  --fieldset-tint: rgba(35, 131, 95, 0.09);
}

.structured-form fieldset:nth-of-type(4) {
  --fieldset-accent: var(--amber);
  --fieldset-tint: rgba(168, 101, 22, 0.1);
}

.structured-form fieldset:nth-of-type(5) {
  --fieldset-accent: var(--violet);
  --fieldset-tint: rgba(109, 91, 208, 0.08);
}

.structured-form fieldset:nth-of-type(6) {
  --fieldset-accent: var(--rose);
  --fieldset-tint: rgba(196, 63, 114, 0.07);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(180deg, #ffffff, #f8faf6);
}

.panel-header h3 {
  margin: 0;
  font-size: 15px;
}

.panel-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.panel-body {
  padding: 16px;
}

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

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

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

.structured-form fieldset > .form-grid > label,
.structured-form fieldset > .form-grid > .field,
.structured-form fieldset > .form-grid > .managed-select-field {
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow:
    0 8px 18px rgba(29, 42, 38, 0.045),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.structured-form fieldset > .form-grid > label:focus-within,
.structured-form fieldset > .form-grid > .field:focus-within,
.structured-form fieldset > .form-grid > .managed-select-field:focus-within {
  border-color: #9fcfc6;
  box-shadow:
    0 12px 24px rgba(29, 42, 38, 0.07),
    0 0 0 3px rgba(0, 139, 109, 0.1);
}

.element-metrics {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid #c8d8e8;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(47, 95, 159, 0.08), rgba(34, 122, 90, 0.05)),
    #ffffff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.86);
}

.element-metrics-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.element-metrics-title strong {
  color: var(--ink);
  font-size: 13px;
}

.periodic-table {
  display: grid;
  grid-template-columns: repeat(18, minmax(38px, 1fr));
  grid-auto-rows: minmax(48px, auto);
  gap: 5px;
  overflow-x: auto;
  padding: 10px;
  border: 1px solid #d7e2ef;
  border-radius: 8px;
  background: #fff;
}

.periodic-element {
  min-width: 38px;
  min-height: 48px;
  display: grid;
  align-content: center;
  gap: 1px;
  padding: 4px 2px;
  border: 1px solid #d7e2ef;
  border-radius: 6px;
  background: linear-gradient(180deg, #ffffff, #f5fbff);
  color: var(--ink);
  text-align: center;
  transition: 160ms ease;
  transition-property: border-color, background, color, transform, box-shadow;
}

.periodic-element.element-alkali {
  border-color: #f4b37d;
  background: linear-gradient(180deg, #fff7ed, #ffedd5);
}

.periodic-element.element-alkaline {
  border-color: #e7cf62;
  background: linear-gradient(180deg, #fffbea, #fef3c7);
}

.periodic-element.element-transition {
  border-color: #7cc8be;
  background: linear-gradient(180deg, #ecfeff, #ccfbf1);
}

.periodic-element.element-post-transition {
  border-color: #9db8e8;
  background: linear-gradient(180deg, #eff6ff, #dbeafe);
}

.periodic-element.element-metalloid {
  border-color: #91d080;
  background: linear-gradient(180deg, #f0fdf4, #dcfce7);
}

.periodic-element.element-nonmetal {
  border-color: #c7a5f6;
  background: linear-gradient(180deg, #faf5ff, #ede9fe);
}

.periodic-element.element-halogen {
  border-color: #f0a6c2;
  background: linear-gradient(180deg, #fff1f2, #ffe4e6);
}

.periodic-element.element-noble {
  border-color: #8bc5f7;
  background: linear-gradient(180deg, #f0f9ff, #dbeafe);
}

.periodic-element strong {
  font-size: 14px;
  line-height: 1;
}

.periodic-element small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.1;
}

.periodic-element:hover,
.periodic-element.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: 0 8px 18px rgba(15, 127, 134, 0.12);
  transform: translateY(-1px);
}

.selected-element-panel {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #d7e2ef;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.selected-element-head,
.selected-element-row {
  display: grid;
  align-items: center;
  gap: 8px;
}

.selected-element-head {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.selected-element-list {
  display: grid;
  grid-template-columns: repeat(6, minmax(132px, 1fr));
  gap: 8px;
}

.selected-element-row {
  grid-template-columns: minmax(3ch, 3.5ch) minmax(10ch, 1fr) 24px;
  grid-template-areas: "name input remove";
  gap: 4px;
  padding: 6px;
  border: 1px solid #d7e2ef;
  border-radius: 6px;
  background: #fff;
  font-size: 12.5px;
}

.selected-element-name {
  grid-area: name;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 3ch;
  max-width: 3.5ch;
  overflow: hidden;
}

.selected-element-name strong {
  color: var(--accent-strong);
  font-size: 15px;
  line-height: 1;
}

.selected-element-name span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.selected-element-row label {
  grid-area: input;
  width: 100%;
  min-width: 0;
  max-width: none;
}

.selected-element-row label > span {
  display: none;
}

.selected-element-row .unit-input input {
  flex: 1 1 8ch;
  width: 8ch;
  min-width: 8ch;
  max-width: 100%;
  min-height: 30px;
  padding: 0 4px;
  color: var(--ink);
  -webkit-text-fill-color: var(--ink);
  caret-color: var(--accent-strong);
  appearance: none;
  -webkit-appearance: none;
  opacity: 1;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.selected-element-row .unit-input {
  width: 100%;
  min-width: 10ch;
  font-size: 12px;
}

.selected-element-row .unit-input b {
  width: 2ch;
  flex: 0 0 2ch;
  font-size: 11px;
}

.selected-element-row .icon-button {
  grid-area: remove;
  width: 24px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  justify-self: end;
}

.choice-panel {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid #c9ddda;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(34, 122, 90, 0.08), rgba(13, 124, 131, 0.04)),
    #ffffff;
}

.choice-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.choice-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.choice-panel-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.choice-check {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #fbfcfa);
  font-size: 13px;
  font-weight: 700;
  transition: 160ms ease;
  transition-property: border-color, background, box-shadow, transform;
}

.choice-check:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 18px rgba(0, 139, 109, 0.1);
  transform: translateY(-1px);
}

.choice-check:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.choice-check input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}

.instrument-choice-panel {
  border-color: #c9ddda;
  background: linear-gradient(135deg, rgba(54, 89, 168, 0.09), rgba(0, 139, 109, 0.05), #ffffff 62%);
}

.equipment-dropdown-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.equipment-dropdown-row select,
.equipment-dropdown-row input {
  min-height: 40px;
  border-color: var(--line-strong);
}

.add-choice-button {
  color: var(--accent-strong);
  border-color: #9ccfca;
  background: var(--accent-soft);
}

.add-choice-button:hover {
  background: #ddf4ee;
}

.selected-equipment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 38px;
  align-items: center;
  padding: 8px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.selected-equipment-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  padding: 5px 5px 5px 10px;
  border: 1px solid #b8d9d1;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.selected-equipment-chip > span {
  overflow-wrap: anywhere;
}

.selected-equipment-chip .icon-button {
  width: 28px;
  min-height: 28px;
  color: var(--accent-strong);
}

.selected-equipment-empty {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.selected-reagent-empty {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.selected-reagent-list {
  display: grid;
  gap: 10px;
  align-items: stretch;
}

.selected-reagent-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.25fr) repeat(4, minmax(110px, 0.8fr)) auto;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px solid #c9ddda;
  border-radius: 8px;
  background:
    linear-gradient(135deg, #ffffff, #f2f8f4);
  box-shadow: 0 8px 18px rgba(29, 42, 38, 0.06);
}

.selected-reagent-title {
  min-width: 0;
  display: grid;
  gap: 4px;
  align-self: center;
}

.selected-reagent-title strong {
  color: var(--accent-strong);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.selected-reagent-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.selected-reagent-row label {
  min-width: 0;
  gap: 4px;
}

.selected-reagent-row label span {
  font-size: 11px;
}

.selected-reagent-row input[type="text"] {
  min-height: 36px;
  padding: 7px 8px;
}

.selected-reagent-row .icon-button {
  align-self: center;
  color: var(--accent-strong);
}

.managed-select-field select,
.managed-select-field input {
  min-height: 40px;
}

.procedure-template-panel {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  background:
    linear-gradient(135deg, #f8fbff, #ffffff);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.86);
}

.procedure-template-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.procedure-template-row select {
  min-height: 40px;
}

.procedure-template-panel small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.procedure-template-card {
  grid-column: 1 / -1;
}

.procedure-template-form {
  display: grid;
  grid-template-columns: minmax(180px, 0.85fr) minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.procedure-template-form textarea {
  min-height: 108px;
}

.summary-template-editor-wrap {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.template-editor-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.template-editor-title > span {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.template-editor-title small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.summary-template-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid #d7e2ef;
  border-radius: 8px;
  background: #f8fbff;
}

.summary-template-color {
  width: auto;
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 4px 8px;
  border: 1px solid #d7e2ef;
  border-radius: 6px;
  background: #fff;
}

.summary-template-color span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.summary-template-color input {
  width: 34px;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
}

.summary-template-editor {
  min-height: 180px;
  max-height: 420px;
  overflow: auto;
  padding: 12px;
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #fcfdff);
  color: var(--ink);
  line-height: 1.65;
  outline: none;
}

.record-summary-editor,
.record-procedure-editor {
  min-height: 240px;
  max-height: 560px;
}

.summary-template-editor:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 127, 134, 0.12);
}

.summary-template-editor table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  table-layout: fixed;
}

.summary-template-editor th,
.summary-template-editor td {
  min-width: 90px;
  padding: 8px;
  border: 1px solid #cbd5e1;
  vertical-align: top;
}

.summary-template-editor th {
  background: #eff6ff;
  color: var(--blue);
  font-weight: 900;
}

.rich-text-block {
  display: block;
  white-space: normal;
}

.rich-text-block table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  table-layout: fixed;
}

.rich-text-block th,
.rich-text-block td {
  min-width: 80px;
  padding: 8px;
  border: 1px solid #cbd5e1;
  vertical-align: top;
  word-break: break-word;
}

.rich-text-block th {
  background: #eff6ff;
  color: var(--blue);
  font-weight: 900;
}

.rich-text-block p {
  margin: 0 0 8px;
}

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

.procedure-template-item {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid #d7e2ef;
  border-radius: 8px;
  background: #fff;
}

.procedure-template-item div {
  display: grid;
  gap: 4px;
}

.procedure-template-item strong {
  color: var(--ink);
  font-size: 14px;
}

.procedure-template-item span,
.procedure-template-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.select-card {
  padding: 12px;
  border: 1px solid #c9ddda;
  border-radius: 6px;
  background: linear-gradient(135deg, #effaf8, #ffffff);
}

.readonly-field input[readonly],
input[readonly] {
  border-color: #c7d2fe;
  background: #f5f7ff;
  color: #315f9c;
  font-weight: 800;
}

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

.managed-config-card {
  min-width: 0;
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid #d4ddec;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(15, 127, 134, 0.07), rgba(49, 95, 156, 0.05)),
    #fff;
  box-shadow: 0 10px 24px rgba(20, 33, 51, 0.05);
}

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

.managed-config-head div {
  display: grid;
  gap: 3px;
}

.managed-config-head strong {
  font-size: 14px;
}

.managed-config-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.managed-config-head b {
  min-width: 34px;
  min-height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 13px;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.compact-inline-form {
  grid-template-columns: minmax(180px, 1fr) auto;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.compact-tag-list {
  margin-top: 0;
}

.managed-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 5px 5px 10px;
  border: 1px solid #d9e4ee;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, #f8fbfd);
  font-size: 13px;
  font-weight: 800;
}

.managed-tag .icon-button {
  width: 28px;
  min-height: 28px;
}

.compact-empty {
  width: 100%;
  padding: 12px;
}

.element-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(86px, 1fr));
  gap: 10px;
}

.element-field {
  min-width: 0;
  gap: 5px;
  font-size: 12px;
}

.element-field > span {
  display: flex;
  align-items: baseline;
  gap: 4px;
  color: var(--muted);
  font-weight: 800;
}

.element-field > span small {
  color: #7b8798;
  font-size: 10px;
  font-weight: 700;
}

.element-import-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(180px, 0.9fr);
  gap: 10px;
  align-items: stretch;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.element-import-grid .procedure-source-actions {
  grid-column: 1 / -1;
}

.unit-input {
  display: flex;
  min-width: 0;
  border: 1px solid #d6e1ec;
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
}

.unit-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 124, 131, 0.15);
}

.unit-input input {
  min-width: 0;
  min-height: 34px;
  border: 0;
  border-radius: 0;
  padding: 6px 7px;
  text-align: right;
  box-shadow: none;
}

.unit-input input:focus {
  box-shadow: none;
}

.unit-input input.auto-filled {
  background: #e9f8f4;
  color: var(--accent-strong);
  font-weight: 800;
}

.unit-input b {
  width: 28px;
  flex: 0 0 28px;
  display: grid;
  place-items: center;
  border-left: 1px solid var(--line);
  background: #eef6f6;
  color: var(--accent-strong);
  font-size: 12px;
}

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

.free-text-query {
  min-width: min(100%, 360px);
}

.free-text-query small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.35;
}

.span-4 {
  grid-column: 1 / -1;
}

.tall textarea,
textarea.tall {
  min-height: 138px;
}

.inline-check {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.inline-check input {
  width: 16px;
  min-height: 16px;
}

.procedure-source-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.procedure-source-status {
  min-height: 20px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.procedure-source-status.error {
  color: var(--red);
}

.button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

fieldset {
  min-width: 0;
  margin: 0 0 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

legend {
  padding: 0 8px;
  color: var(--fieldset-accent, var(--accent-strong));
  font-size: 13px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 3px 10px rgba(15, 31, 48, 0.05);
  border-radius: 999px;
}

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

.table-wrap {
  contain: inline-size;
  display: block;
  max-width: 100%;
  min-width: 0;
  width: 100%;
  overflow: auto;
  border-radius: 8px;
}

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

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

th {
  color: #40536b;
  background:
    linear-gradient(180deg, #f8fbfd, #eef5f8);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

td {
  color: #263447;
  font-size: 12.5px;
}

tr:hover td {
  background: #f8fcff;
}

.inventory-flow-row.inventory-flow-in td {
  background: #f0fbf5;
}

.inventory-flow-row.inventory-flow-out td {
  background: #fff5f3;
}

.inventory-flow-row.inventory-flow-in:hover td {
  background: #e5f7ee;
}

.inventory-flow-row.inventory-flow-out:hover td {
  background: #ffece8;
}

.inventory-direction {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.inventory-direction-in {
  color: #087346;
  background: #dff6ea;
}

.inventory-direction-out {
  color: #b23624;
  background: #ffe0d9;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.status-badge,
.role-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.62);
}

.status-draft,
.role-viewer {
  color: var(--muted);
  background: var(--surface-2);
}

.status-submitted,
.role-reviewer {
  color: var(--cobalt);
  background: var(--cobalt-soft);
}

.status-approved,
.role-admin {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.status-rejected,
.role-chemist {
  color: var(--red);
  background: var(--red-soft);
}

.role-operator {
  color: var(--amber);
  background: var(--amber-soft);
}

.role-custom {
  color: var(--violet);
  background: #eeeeff;
}

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

.role-management-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.role-management-title strong {
  font-size: 15px;
}

.role-management-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.role-config-card {
  min-width: 0;
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid #cfe0ea;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(8, 115, 70, 0.06), rgba(49, 95, 156, 0.06)),
    #fff;
  box-shadow: 0 12px 28px rgba(20, 33, 51, 0.06);
}

.role-config-head,
.role-config-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.role-config-head div {
  display: grid;
  gap: 3px;
}

.role-config-head strong {
  font-size: 15px;
}

.role-config-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.compact-role-grid {
  gap: 10px;
}

.role-sync-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.role-sync-check input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}

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

.permission-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.permission-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.permission-card-head strong,
.permission-card-head span {
  display: block;
}

.permission-card-head span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.permission-fieldset {
  margin: 0;
  background: #fff;
}

.permission-fieldset p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.permission-check {
  display: flex;
  grid-template-columns: none;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
  padding: 9px;
  border: 1px solid #d9e4ee;
  border-radius: 6px;
  background: linear-gradient(180deg, #ffffff, #fbfdff);
  color: var(--ink);
  font-weight: 700;
}

.permission-check:has(input:checked) {
  border-color: #9ccfca;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.permission-check input {
  width: 16px;
  min-height: 16px;
  margin-top: 2px;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

.permission-check span {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.permission-check small {
  line-height: 1.35;
}

.empty-state {
  padding: 36px 20px;
  color: var(--muted);
  text-align: center;
}

.filter-bar {
  display: grid;
  grid-template-columns: 2fr repeat(4, minmax(140px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #fbfcfa);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.audit-layout {
  display: grid;
  grid-template-columns: minmax(260px, 330px) minmax(0, 1fr);
  gap: 16px;
}

.audit-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 220px);
  overflow: auto;
}

.audit-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: linear-gradient(180deg, #ffffff, #fbfcfa);
  text-align: left;
  transition: 160ms ease;
  transition-property: border-color, box-shadow, transform;
}

.audit-item.active {
  border-color: var(--accent);
  box-shadow:
    inset 0 0 0 1px rgba(0, 139, 109, 0.2),
    0 14px 30px rgba(0, 139, 109, 0.11);
}

.audit-item:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

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

.audit-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

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

.detail-cell {
  min-height: 62px;
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #fbfcfa);
}

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

.detail-cell strong {
  display: block;
  margin-top: 0;
  overflow-wrap: break-word;
  word-break: normal;
}

.report-section {
  margin: 0 0 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff, #fbfcfa);
  box-shadow: var(--shadow-soft);
}

.report-section h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.text-block {
  margin: 0 0 12px;
  white-space: pre-wrap;
  line-height: 1.7;
}

.text-block.muted {
  color: var(--muted);
}

.procedure-list {
  margin: 0;
  padding-left: 22px;
  line-height: 1.7;
}

.procedure-list li + li {
  margin-top: 5px;
}

.compact-table {
  min-width: 640px;
}

.text-table-wrap {
  margin: 8px 0 12px;
}

.text-derived-table {
  min-width: min(640px, 100%);
}

.text-derived-table td {
  vertical-align: top;
  white-space: pre-wrap;
  word-break: normal;
  overflow-wrap: break-word;
}

.spectrum-preview,
.analysis-figure {
  min-height: 150px;
  margin: 0;
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 12px;
  border: 1px dashed #cbd9e8;
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--muted);
  text-align: center;
}

.spectrum-preview.compact {
  min-height: 116px;
  padding: 8px;
}

.spectrum-preview img,
.analysis-figure img {
  max-width: 100%;
  max-height: 360px;
  object-fit: contain;
  border-radius: 4px;
}

.spectrum-preview video,
.analysis-figure video {
  width: 100%;
  max-width: 100%;
  max-height: 360px;
  object-fit: contain;
  border-radius: 4px;
  background: #101827;
}

.experiment-video-preview {
  border-color: #bfdbfe;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(5, 150, 105, 0.06)),
    #fff;
}

.engineering-doc-preview {
  min-height: 178px;
  border-color: #c7d2fe;
  background:
    linear-gradient(135deg, rgba(49, 95, 156, 0.08), rgba(35, 131, 95, 0.06)),
    #fff;
}

.document-text-preview textarea {
  min-height: 190px;
  line-height: 1.7;
}

.engineering-filter-bar {
  grid-template-columns: 2fr minmax(160px, 0.9fr) repeat(2, minmax(140px, 0.8fr)) auto;
}

.spectrum-preview figcaption,
.analysis-figure figcaption {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 12px;
}

.spectrum-preview figcaption small,
.analysis-figure figcaption small {
  color: var(--accent-strong);
  font-size: 11px;
}

.analysis-figure {
  margin-bottom: 12px;
  border-style: solid;
  box-shadow: var(--shadow-soft);
}

.approval-flow-panel {
  display: grid;
  gap: 6px;
  margin: 0 0 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(0, 139, 109, 0.08), rgba(54, 89, 168, 0.06)),
    #fff;
  box-shadow: var(--shadow-soft);
}

.approval-flow-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.approval-flow-head strong,
.approval-flow-head span {
  display: block;
}

.approval-flow-head span {
  margin-top: 1px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.approval-flow-head strong {
  font-size: 12px;
}

.approval-flow-head .status-badge {
  padding: 3px 7px;
  font-size: 10px;
}

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

.approval-step {
  position: relative;
  min-height: 52px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  grid-template-areas:
    "index title"
    "index note"
    "index time";
  align-content: start;
  column-gap: 7px;
  row-gap: 1px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.approval-step::after {
  content: "";
  position: absolute;
  top: 18px;
  right: -7px;
  width: 6px;
  height: 1px;
  background: var(--line-strong);
}

.approval-step:last-child::after {
  display: none;
}

.approval-step-index {
  grid-area: index;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--graphite);
  font-size: 10px;
  font-weight: 900;
}

.approval-step strong {
  grid-area: title;
  font-size: 11px;
  line-height: 1.25;
}

.approval-step span {
  grid-area: note;
}

.approval-step small {
  grid-area: time;
}

.approval-step span,
.approval-step small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.25;
}

.approval-step.done {
  border-color: #9ccfca;
  background: linear-gradient(180deg, #ffffff, #f2fbf7);
}

.approval-step.done .approval-step-index {
  background: var(--accent-strong);
}

.approval-step.current {
  border-color: rgba(0, 139, 109, 0.5);
  box-shadow:
    inset 0 0 0 1px rgba(0, 139, 109, 0.18),
    0 14px 30px rgba(0, 139, 109, 0.12);
}

.approval-step.current .approval-step-index {
  background: var(--accent);
}

.approval-step.rejected {
  border-color: #efb0a2;
  background: linear-gradient(180deg, #ffffff, #fff6f3);
}

.approval-step.rejected .approval-step-index {
  background: var(--red);
}

.approval-step.pending {
  background: #fbfcfa;
}

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

.audit-log li {
  padding: 11px;
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: #f8fbfc;
}

.audit-log strong {
  display: block;
}

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

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

.db-layout .wide {
  grid-column: 1 / -1;
}

.schema-list {
  display: grid;
  min-width: 0;
}

.schema-block {
  min-width: 0;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
}

.schema-block:last-child {
  border-bottom: 0;
}

.schema-block summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  list-style: none;
}

.schema-block summary::-webkit-details-marker {
  display: none;
}

.schema-block summary strong {
  color: var(--ink);
}

.schema-block summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.schema-block p {
  margin: 10px 0 12px;
  color: var(--muted);
  line-height: 1.65;
}

.schema-table td:first-child {
  font-family: Consolas, "Courier New", monospace;
  font-weight: 700;
}

.permission-matrix th,
.permission-matrix td {
  text-align: center;
}

.permission-matrix th:first-child,
.permission-matrix th:nth-child(2),
.permission-matrix td:first-child,
.permission-matrix td:nth-child(2) {
  text-align: left;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(20, 33, 51, 0.44);
}

.modal {
  width: min(980px, 100%);
  max-height: min(860px, calc(100vh - 36px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.modal-narrow {
  width: min(520px, 100%);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.modal-header h3 {
  margin: 0;
}

.modal-body {
  overflow: auto;
  padding: 16px;
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  display: grid;
  gap: 10px;
}

.toast {
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(20, 33, 51, 0.16);
  font-weight: 700;
}

.toast.error {
  border-left-color: var(--red);
}

#print-root {
  display: none;
}

.print-document {
  color: #111827;
  font-family: "Microsoft YaHei", SimSun, serif;
}

.print-document h1 {
  text-align: center;
  font-size: 24px;
}

.print-section {
  break-inside: avoid;
  margin-top: 12px;
}

.print-section h2 {
  margin: 12px 0 8px;
  font-size: 16px;
}

.print-document table {
  min-width: 0;
  margin: 14px 0;
  border: 1px solid #222;
}

.print-document th,
.print-document td {
  border: 1px solid #222;
  background: #fff;
}

.print-document .analysis-figure {
  border: 1px solid #222;
  background: #fff;
}

.print-document .analysis-figure img {
  max-height: 420px;
}

.print-document .analysis-figure video {
  max-height: 320px;
}

.print-signatures {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-top: 34px;
}

.print-signatures div {
  border-top: 1px solid #222;
  padding-top: 8px;
}

@media (max-width: 1100px) {
  #app-shell {
    font-size: 12.5px;
  }

  .topbar-brand strong {
    font-size: 14px;
  }

  .nav-item {
    min-height: 37px;
    font-size: 12.5px;
  }

  .button,
  .icon-button {
    min-height: 35px;
    font-size: 12.5px;
  }

  .view-root {
    padding: 18px;
  }

  .view-heading {
    padding: 13px 15px;
    margin-bottom: 14px;
  }

  .view-heading h2 {
    font-size: 22px;
  }

  .view-heading p {
    font-size: 12px;
  }

  .metric {
    min-height: 78px;
    padding: 13px;
  }

  .metric strong {
    font-size: 24px;
  }

  .panel-header {
    padding: 12px 14px;
  }

  .panel-header h3 {
    font-size: 14px;
  }

  input,
  select,
  textarea {
    min-height: 36px;
    padding: 7px 9px;
    font-size: 12.5px;
  }

  th,
  td {
    padding: 8px 9px;
  }

  td {
    font-size: 12px;
  }

  .approval-flow {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .form-panel {
    width: 100%;
  }

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

  .filter-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-bar .toolbar {
    grid-column: 1 / -1;
  }

  .selected-element-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  :root {
    --topbar: 58px;
  }

  #app-shell {
    font-size: 13px;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }

  .topbar {
    padding: 0 12px;
  }

  .topbar-brand {
    gap: 8px;
  }

  .topbar-brand img {
    width: 32px;
    height: 32px;
  }

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

  .nav-toggle {
    display: inline-flex;
  }

  .topbar-brand span {
    display: none;
  }

  .topbar-actions {
    gap: 6px;
  }

  .user-chip {
    display: none;
  }

  .sidebar {
    position: fixed;
    top: var(--topbar);
    left: 0;
    bottom: 0;
    z-index: 30;
    width: min(280px, 82vw);
    transform: translateX(-100%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow);
  }

  .topbar {
    background:
      linear-gradient(90deg, rgba(31, 40, 38, 0.98) 0 58px, rgba(255, 255, 255, 0.94) 58px);
  }

  .main-nav {
    gap: 5px;
  }

  .nav-section-label {
    margin: 10px 8px 2px;
    font-size: 10px;
  }

  .nav-item {
    min-height: 38px;
    gap: 8px;
    padding: 0 10px;
    font-size: 13px;
  }

  .button,
  .icon-button {
    min-height: 36px;
    font-size: 13px;
  }

  .button.compact,
  .icon-button {
    padding-inline: 9px;
  }

  .sidebar.open {
    transform: translate3d(0, 0, 0) !important;
  }

  .view-root {
    padding: 16px;
  }

  .view-heading {
    padding: 14px;
    gap: 10px;
  }

  .view-heading h2 {
    font-size: 22px;
  }

  .view-heading p {
    font-size: 13px;
    line-height: 1.45;
  }

  .panel-header {
    gap: 10px;
    padding: 14px;
  }

  .panel-header h3 {
    font-size: 15px;
  }

  .card,
  .panel,
  .metric {
    border-radius: 8px;
  }

  .metric {
    min-height: 78px;
    padding: 14px;
  }

  .metric span {
    font-size: 12px;
  }

  .metric strong {
    font-size: 24px;
  }

  .structured-form fieldset {
    padding: 14px;
  }

  .structured-form legend,
  label,
  .field label {
    font-size: 12px;
  }

  input,
  select,
  textarea {
    min-height: 38px;
    padding: 7px 9px;
    font-size: 13px;
  }

  textarea,
  .rich-editor,
  .summary-template-editor {
    font-size: 13px;
    line-height: 1.55;
  }

  th,
  td {
    padding: 9px 10px;
    font-size: 12px;
  }

  .status-badge,
  .role-badge,
  .tag,
  .keyword-chip {
    font-size: 11px;
  }

  .view-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar {
    justify-content: flex-start;
  }

  .permission-card-head {
    align-items: stretch;
    flex-direction: column;
  }

  .role-config-actions,
  .role-config-head,
  .role-management-title {
    align-items: stretch;
    flex-direction: column;
  }

  .role-management-title span {
    text-align: left;
  }

  .permission-grid {
    grid-template-columns: 1fr;
  }

  .inline-form {
    grid-template-columns: 1fr;
  }

  .equipment-dropdown-row {
    grid-template-columns: 1fr;
  }

  .procedure-template-row,
  .procedure-template-form,
  .procedure-template-item {
    grid-template-columns: 1fr;
  }

  .template-editor-title {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .selected-reagent-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .selected-reagent-row .icon-button {
    justify-self: end;
  }

  .audit-layout,
  .db-layout,
  .detail-grid,
  .form-grid,
  .form-grid.three,
    .form-grid.two,
    .managed-config-grid,
    .role-management-grid,
    .metrics-grid,
  .filter-bar {
    grid-template-columns: 1fr;
  }

  .detail-cell {
    grid-template-columns: 92px minmax(0, 1fr);
    min-height: auto;
  }

  .span-2,
  .span-4 {
    grid-column: auto;
  }

  .element-metrics-grid,
  .selected-element-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .element-import-grid {
    grid-template-columns: 1fr;
  }

  .schema-block summary {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .schema-block summary span {
    text-align: left;
  }

  .approval-flow {
    grid-template-columns: 1fr;
  }

  .approval-step::after {
    display: none;
  }

  .login-panel {
    padding: 22px;
  }
}

@media (max-width: 560px) {
  #app-shell {
    font-size: 12px;
  }

  .topbar-brand strong {
    font-size: 14px;
  }

  .view-root {
    padding: 12px;
  }

  .view-heading {
    padding: 12px;
    margin-bottom: 12px;
  }

  .view-heading h2 {
    font-size: 20px;
  }

  .view-heading p {
    font-size: 12px;
  }

  .panel-header h3 {
    font-size: 14px;
  }

  .button,
  .icon-button,
  input,
  select,
  textarea {
    font-size: 12px;
  }

  th,
  td {
    padding: 8px;
    font-size: 11px;
  }

  .nav-item {
    font-size: 12px;
  }

  .detail-cell {
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .selected-element-list {
    grid-template-columns: 1fr;
  }
}

@media print {
  @page {
    margin: 16mm;
  }

  body.printing {
    background: #fff;
  }

  body.printing #app-shell,
  body.printing #login-screen,
  body.printing #modal-root,
  body.printing .toast-region {
    display: none !important;
  }

  body.printing #print-root {
    display: block;
  }
}
