:root {
  --bg-a: #dff5e1;
  --bg-b: #b7e4be;
  --card: #ffffff;
  --ink: #1f2b37;
  --accent: #0b6d77;
  --accent-2: #d36f2f;
  --line: #d7dde5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 10%, #efffee 0%, transparent 45%),
    radial-gradient(circle at 90% 0%, #d5f7da 0%, transparent 35%),
    linear-gradient(135deg, var(--bg-a), var(--bg-b));
  min-height: 100vh;
}

.page {
  width: min(1200px, 96vw);
  margin: 1.2rem auto;
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 12px 30px rgba(31, 43, 55, 0.09);
}

h1,
h2 {
  margin: 0 0 0.6rem;
}

h3 {
  margin: 0.4rem 0 0.6rem;
}

.form-grid {
  display: grid;
  gap: 0.7rem;
}

.subtle {
  margin: 0 0 0.45rem;
  color: #415366;
}

.schema-form {
  overflow-x: auto;
}

.input-sheet {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.input-sheet th,
.input-sheet td {
  border: 1px solid var(--line);
  padding: 0.35rem 0.45rem;
  font-size: 0.88rem;
  vertical-align: middle;
}

.input-sheet th {
  background: #f5f8fc;
  text-align: left;
}

.input-sheet td:first-child {
  width: 49%;
}

.input-sheet td:nth-child(2) {
  width: 24%;
  background: #e8f5d8;
}

.input-sheet td:nth-child(3) {
  width: 27%;
  background: #e8f5d8;
}

.input-sheet .section-row td {
  background: #ffffff;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0;
}

.input-sheet tr.is-precondition-disabled td:nth-child(2),
.input-sheet tr.is-precondition-disabled td:nth-child(3) {
  background: #edf7df;
}

.input-sheet tr.is-precondition-disabled input,
.input-sheet tr.is-precondition-disabled select,
.input-sheet tr.is-precondition-disabled textarea {
  opacity: 1;
  background: #edf7df;
  color: #4f5f50;
  cursor: not-allowed;
}

label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.95rem;
}

input,
select,
button,
textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  font-size: 0.95rem;
  font-family: inherit;
}

.input-sheet input,
.input-sheet select {
  width: 100%;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  font-size: 0.86rem;
}

.input-sheet input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

button {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #fff;
  border: none;
  font-weight: 700;
  cursor: pointer;
}

.actions,
.admin-actions {
  margin-top: 0.9rem;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.section-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.section-header-title {
  display: inline-block;
}

.section-row-columns {
  display: grid;
  grid-template-columns: 49% 24% 27%;
  align-items: stretch;
  gap: 0;
  min-height: 42px;
  width: 100%;
}

.section-row-col {
  min-width: 0;
  padding: 0.35rem 0.45rem;
  display: flex;
  align-items: center;
  box-sizing: border-box;
}

.section-row-col + .section-row-col {
  border-left: 1px solid rgba(23, 48, 71, 0.16);
}

.section-row-col-value,
.section-row-col-option {
  font-size: 0.78rem;
  font-weight: 500;
  text-transform: none;
  color: #4f6478;
  padding-left: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.section-row-col-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.section-toggle-indicator-edge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: #1f3b57;
  color: #d7e7f6;
  flex: 0 0 auto;
  margin-left: auto;
}

.section-toggle-button {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 8px;
  border: 1px solid #b7c6d6;
  background: #ffffff;
  color: #173047;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
}

.section-toggle-button:hover {
  background: #eef5fd;
}

.section-row-collapsed {
  display: none;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.85rem;
  line-height: 1.45;
  background: #0b1320;
  color: #d3ecff;
  border-radius: 12px;
  padding: 0.8rem;
}

.sum {
  margin: 0.25rem 0;
}

.result-card table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.8rem;
}

.result-card th,
.result-card td {
  border-bottom: 1px solid var(--line);
  padding: 0.45rem;
  text-align: left;
  font-size: 0.92rem;
}

.calc-details {
  margin-top: 1rem;
}

.detail-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem;
  margin-bottom: 0.6rem;
  background: #fbfdff;
}

.detail-card h4 {
  margin: 0 0 0.45rem;
  font-size: 0.94rem;
}

.detail-card p {
  margin: 0.22rem 0;
  font-size: 0.86rem;
}

.formula {
  font-family: Consolas, "Courier New", monospace;
}

.admin-panel summary {
  cursor: pointer;
  font-weight: 800;
  color: #173047;
}

.admin-note {
  margin: 0.6rem 0;
  font-size: 0.9rem;
  color: #415366;
}

.admin-panel details {
  margin-top: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem;
  background: #f9fcff;
}

.admin-panel details > summary {
  font-weight: 700;
  color: #1f3a54;
}

.admin-panel details button {
  margin-top: 0.6rem;
}

.admin-panel label {
  display: grid;
  gap: 0.3rem;
  margin-top: 0.6rem;
}

.wizard-inline-check {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.35rem;
}

.wizard-inline-check input[type="checkbox"] {
  margin: 0;
  width: 16px;
  height: 16px;
}

.admin-grid {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.admin-grid > label {
  min-width: 0;
}

.admin-grid-span-all {
  grid-column: 1 / -1;
}

.admin-grid select,
.admin-grid input,
.admin-grid textarea {
  width: 100%;
  min-width: 0;
}

.result-title {
  font-weight: 600;
}

.result-longdescription {
  margin-top: 0.35rem;
  color: inherit;
}

.result-longdescription p {
  margin: 0 0 0.35rem;
  white-space: pre-line;
}

.result-longdescription ul {
  margin: 0 0 0.35rem 1.1rem;
  padding: 0;
}

.result-longdescription li {
  margin: 0 0 0.2rem;
}

.result-longdescription p,
.result-longdescription ul,
.result-longdescription li,
.result-longdescription li::marker {
  color: inherit;
}

.admin-kv-list {
  display: grid;
  gap: 0.45rem;
}

.admin-kv-row,
.admin-transform-row,
.admin-column-row {
  display: grid;
  gap: 0.45rem;
  grid-template-columns: 1fr 1fr auto;
  align-items: center;
}

.admin-transform-row,
.admin-column-row {
  grid-template-columns: 1fr 1fr 1fr auto;
}

.colwiz-row {
  grid-template-columns: 96px 84px 170px 1fr 84px auto;
}

.colwiz-row > * {
  min-width: 0;
}

.colwiz-row select,
.colwiz-row input {
  width: 100%;
  min-width: 0;
}

.colwiz-row .form-select,
.colwiz-row select {
  padding-right: 1.8rem;
}

.colwiz-row [data-field="op"],
.colwiz-row [data-field="openParens"],
.colwiz-row [data-field="closeParens"] {
  font-size: 0.85rem;
}

.colwiz-source-cell {
  min-width: 0;
}

#calc-colwiz-preview {
  font-family: Consolas, "Courier New", monospace;
}

.admin-kv-row button,
.admin-transform-row button,
.admin-column-row button {
  margin-top: 0;
}

.admin-panel textarea {
  width: 100%;
  min-height: 9rem;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.84rem;
}

.schema-preconditions-box {
  border: 1px dashed #bfd0e3;
  border-radius: 10px;
  background: #f7fbff;
  padding: 0.6rem;
  margin-bottom: 0.6rem;
}

.schema-preconditions-box h4 {
  margin: 0 0 0.45rem;
  color: #173047;
}

.schema-preconditions-list {
  display: grid;
  gap: 0.45rem;
}

.schema-precondition-row {
  border: 1px solid #d6e0eb;
  border-radius: 10px;
  background: #ffffff;
  padding: 0.5rem;
  display: grid;
  gap: 0.4rem;
}

.schema-precondition-grid {
  display: grid;
  gap: 0.45rem;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.schema-precondition-remove {
  justify-self: end;
  background: #d95454;
  color: #fff;
}

.schema-compact-check {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  align-self: end;
  margin-top: 0;
}

.schema-compact-check input[type="checkbox"] {
  margin: 0;
  width: 16px;
  height: 16px;
}

#schema-capture-quantity,
#capture-include-warranty {
  appearance: auto;
  -webkit-appearance: checkbox;
  pointer-events: auto;
  cursor: pointer;
}

#admin-article-details {
  margin-top: 0.5rem;
  margin-bottom: 0.7rem;
}

#admin-result {
  margin-top: 0.8rem;
}

@media (max-width: 740px) {
  .page {
    width: 95vw;
  }

  .input-sheet {
    min-width: 640px;
  }

  .admin-kv-row,
  .admin-transform-row,
  .admin-column-row,
  .colwiz-row {
    grid-template-columns: 1fr;
  }
}

/* Modern visual refresh (behavior unchanged) */
:root {
  --bg-a: #f5f1e8;
  --bg-b: #eaf4ff;
  --bg-c: #fffaf0;
  --card: rgba(255, 255, 255, 0.84);
  --ink: #132433;
  --ink-soft: #4c5f72;
  --accent: #0c6e78;
  --accent-2: #e08a3b;
  --line: #d8e2eb;
  --focus: #1e7fca;
  --ok-tint: #e8f6e7;
  --ok-tint-soft: #f0faef;
}

body {
  font-family: "Aptos", "Segoe UI Variable Text", "Bahnschrift", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at -5% -10%, #fff3d8 10%, transparent 60%),
    radial-gradient(720px 320px at 105% 0%, #d9efff 0%, transparent 64%),
    linear-gradient(140deg, var(--bg-a), var(--bg-b) 60%, var(--bg-c));
}

.page {
  width: min(1240px, 95vw);
  margin: 1.3rem auto 1.9rem;
  gap: 1.15rem;
}

.card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 18px;
  padding: 1.15rem;
  backdrop-filter: blur(8px);
  box-shadow:
    0 14px 30px rgba(15, 36, 55, 0.1),
    0 2px 0 rgba(255, 255, 255, 0.45) inset;
}

h1 {
  font-size: clamp(1.85rem, 2.3vw, 2.35rem);
  letter-spacing: 0.01em;
  color: #12283a;
}

h2 {
  font-size: clamp(1.25rem, 1.6vw, 1.55rem);
  color: #18354c;
}

.subtle,
.admin-note {
  color: var(--ink-soft);
}

input,
select,
textarea,
button {
  border-radius: 12px;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 120ms ease, background 140ms ease;
}

input,
select,
textarea {
  border: 1px solid #ccdae7;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(30, 127, 202, 0.2);
}

button {
  background: #16a8c5;
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.01em;
  box-shadow: 0 8px 18px rgba(12, 68, 78, 0.22);
}

button:hover {
  transform: translateY(-1px);
  background: #1eb5d3;
}

button:active {
  transform: translateY(0);
  background: #1098b3;
}

button[hidden] {
  display: none;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #285a78 50%),
    linear-gradient(135deg, #285a78 50%, transparent 50%),
    linear-gradient(to right, rgba(203, 219, 233, 0.8), rgba(203, 219, 233, 0.8));
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 13px) calc(50% - 2px),
    calc(100% - 2.4rem) 50%;
  background-size: 6px 6px, 6px 6px, 1px 62%;
  background-repeat: no-repeat;
  padding-right: 2.55rem;
}

.input-sheet {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid #d4e0ea;
}

.input-sheet th,
.input-sheet td {
  border-color: #d9e3ec;
}

.input-sheet th {
  background: linear-gradient(180deg, #f9fcff, #eff5fb);
  color: #26445a;
  font-weight: 700;
}

.input-sheet td:nth-child(2),
.input-sheet td:nth-child(3) {
  background: var(--ok-tint);
}

.input-sheet tr.is-precondition-disabled td:nth-child(2),
.input-sheet tr.is-precondition-disabled td:nth-child(3),
.input-sheet tr.is-precondition-disabled input,
.input-sheet tr.is-precondition-disabled select,
.input-sheet tr.is-precondition-disabled textarea {
  background: var(--ok-tint-soft);
}

.section-toggle-button {
  border-radius: 10px;
  border-color: #b8cade;
  background: linear-gradient(180deg, #ffffff, #edf4fb);
  box-shadow: 0 2px 8px rgba(17, 50, 77, 0.08);
}

.section-toggle-button:hover {
  background: #f4f9ff;
}

.result-card table {
  border: 1px solid #d7e1eb;
  border-radius: 12px;
  overflow: hidden;
}

.result-card th {
  background: #f4f8fd;
  color: #27455d;
}

.result-card tbody tr:hover td {
  background: #f9fcff;
}

pre {
  background: linear-gradient(160deg, #0e1b2b, #13263c);
  border: 1px solid #253a53;
}

.admin-panel > summary,
.admin-panel details > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.admin-panel details {
  border: none;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 14px;
}

.schema-preconditions-box {
  border-color: #c6d7e9;
  background: #f4f9ff;
}

.schema-precondition-row {
  border-color: #d4e0ec;
  box-shadow: 0 4px 10px rgba(16, 44, 67, 0.05);
}

.schema-precondition-remove {
  background: linear-gradient(95deg, #be3f3f, #d65959);
}

@media (max-width: 980px) {
  .actions,
  .admin-actions {
    gap: 0.5rem;
  }

  .actions button,
  .admin-actions button {
    flex: 1 1 210px;
  }
}

/* Final UX/contrast overrides */
p,
.subtle,
.admin-note,
label {
  color: #d7e6f5;
}

.input-sheet td:first-child,
.result-card td,
.result-card p {
  color: #dce9f7;
}

.section-header-inner {
  width: 100%;
  min-height: 32px;
  padding: 0.2rem 0.1rem;
  border-radius: 8px;
  cursor: pointer;
}

.section-row:hover .section-header-inner {
  background: rgba(33, 63, 91, 0.34);
}

.section-header-inner:focus-visible {
  outline: 2px solid #57bff7;
  outline-offset: 2px;
}

.section-toggle-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  color: #cbe4f8;
  background: rgba(58, 91, 123, 0.36);
  font-weight: 700;
}

#admin-panel details > summary {
  display: block;
  width: 100%;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  cursor: pointer;
  list-style: none;
  color: #ebf5ff;
}

#admin-panel details > summary::-webkit-details-marker {
  display: none;
}

#admin-panel details > summary::after {
  content: "▸";
  float: right;
  color: #b9d3e8;
}

#admin-panel details[open] > summary::after {
  content: "▾";
}

#admin-panel details > summary:hover {
  background: rgba(38, 70, 98, 0.34);
}

/* Section row polish: align hints under columns and avoid isolated hover pill. */
.section-header-inner {
  min-height: 24px !important;
  padding: 0 !important;
  border-radius: 0 !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.section-row:hover .section-header-inner {
  background: transparent !important;
}

.section-row:hover td {
  background: rgba(30, 56, 79, 0.32) !important;
}

#result-table {
  width: max(100%, 700px);
  table-layout: auto;
}

.result-table-wrap {
  margin-top: 0.8rem;
  max-height: min(62vh, 760px);
  overflow-x: auto;
  overflow-y: auto;
  border: 1px solid #2e4660;
  border-radius: 12px;
}

.result-card .result-table-wrap table {
  margin-top: 0;
  border: 0;
  border-radius: 0;
}

#result-table th {
  position: sticky;
  top: 0;
  z-index: 2;
}

#result-table th,
#result-table td {
  vertical-align: top;
}

#result-table th:nth-child(1),
#result-table td:nth-child(1) {
  min-width: 110px;
  white-space: nowrap;
  word-break: keep-all;
}

#result-table th:nth-child(3),
#result-table td:nth-child(3),
#result-table th:nth-child(4),
#result-table td:nth-child(4) {
  min-width: 110px;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

#result-table th:nth-child(2),
#result-table td:nth-child(2) {
  min-width: 280px;
  white-space: normal;
  overflow-wrap: anywhere;
}

@media (max-width: 700px) {
  .page {
    width: 100vw;
    margin: 0.55rem auto 0.95rem;
    padding: 0 0.28rem;
  }

  .card {
    padding: 0.68rem;
  }

  .result-card {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .result-table-wrap {
    margin-left: -0.2rem;
    margin-right: -0.2rem;
    width: calc(100% + 0.4rem);
    border-radius: 10px;
  }

  #result-table {
    width: max(100%, 620px);
  }

  #result-table th:nth-child(1),
  #result-table td:nth-child(1) {
    min-width: 88px;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  #result-table th:nth-child(3),
  #result-table td:nth-child(3),
  #result-table th:nth-child(4),
  #result-table td:nth-child(4) {
    min-width: 92px;
  }

  #result-table th:nth-child(2),
  #result-table td:nth-child(2) {
    font-size: 0.88rem;
    line-height: 1.35;
  }
}

.top-tabs {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.top-nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.locale-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-left: auto;
}

.locale-switch label {
  display: inline-block;
  margin: 0;
  color: #d4e7fb;
  font-size: 0.9rem;
  font-weight: 600;
}

.locale-switch select {
  min-width: 130px;
  padding: 0.45rem 0.6rem;
  border-radius: 999px;
  border: 1px solid #345474;
  background: rgba(14, 34, 54, 0.9);
  color: #d9ebfd;
  font-weight: 700;
}

.locale-switch select:focus {
  outline: 2px solid #4dd3df;
  outline-offset: 2px;
}

.top-tab {
  border: 1px solid #345474;
  background: rgba(14, 34, 54, 0.9);
  color: #d9ebfd;
  border-radius: 999px;
  padding: 0.5rem 0.95rem;
  font-weight: 700;
}

.top-tab:hover {
  background: rgba(25, 57, 88, 0.95);
}

.top-tab.is-active {
  background: linear-gradient(90deg, #12b8c8, #3dc4d1);
  color: #082133;
  border-color: #49d2dd;
}

@media (max-width: 680px) {
  .locale-switch {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
  }

  .locale-switch select {
    min-width: 0;
    width: 180px;
  }
}

.catalog-filters {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 0.8rem;
}

.catalog-filter-dropdown {
  position: relative;
  max-width: 620px;
}

.catalog-card {
  position: relative;
  z-index: 40;
}

.admin-card {
  position: relative;
  z-index: 10;
}

.catalog-filter-toggle {
  width: 100%;
  text-align: left;
  background: rgba(9, 20, 35, 0.86);
  border: 1px solid #35506d;
  color: #eaf3ff;
}

.catalog-filter-toggle::after {
  content: "▾";
  float: right;
  color: #8ec3ea;
}

.catalog-filter-menu {
  position: absolute;
  z-index: 120;
  margin-top: 0.35rem;
  width: 100%;
  border: 1px solid #35506d;
  border-radius: 12px;
  background: #0e1f33;
  box-shadow: 0 14px 32px rgba(3, 10, 18, 0.5);
}

.catalog-filter-menu-actions {
  display: flex;
  gap: 0.45rem;
  padding: 0.55rem;
  border-bottom: 1px solid #27435d;
}

.catalog-filter-menu-actions button {
  flex: 1;
}

.catalog-filter-options {
  max-height: 260px;
  overflow: auto;
  padding: 0.35rem 0.55rem 0.6rem;
}

.catalog-filter-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.38rem 0.2rem;
  cursor: pointer;
  color: #e3f0fd;
}

.catalog-filter-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
}

.catalog-filter-option:hover {
  background: rgba(28, 60, 90, 0.45);
  border-radius: 8px;
}

.catalog-empty {
  border: 1px dashed #3b5a79;
  border-radius: 12px;
  padding: 0.75rem;
  color: #bdd4e9;
  background: rgba(12, 30, 48, 0.6);
}

.catalog-list {
  display: grid;
  gap: 0.7rem;
}

.catalog-item {
  border: 1px solid #2f4861;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(18, 40, 62, 0.72), rgba(11, 25, 39, 0.74));
  padding: 0.75rem 0.85rem;
}

.catalog-item-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.7rem;
  flex-wrap: wrap;
  margin-bottom: 0.28rem;
}

.catalog-article-no {
  font-family: Consolas, "Courier New", monospace;
  color: #9fd0fb;
  font-weight: 700;
}

.catalog-title {
  color: #f0f7ff;
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
}

.catalog-subtitle {
  color: #d8e7f6;
  margin: 0 0 0.35rem;
  font-weight: 600;
}

.catalog-description {
  color: #d6e5f4;
}

.catalog-description p {
  margin: 0 0 0.35rem;
  white-space: pre-line;
}

.catalog-description ul {
  margin: 0 0 0.35rem 1.15rem;
  padding: 0;
}

.catalog-description li {
  margin: 0 0 0.2rem;
}

.catalog-description-empty {
  margin: 0;
  color: #9bbad5;
  font-style: italic;
}

@media (max-width: 740px) {
  .page {
    width: 96vw;
    margin: 0.8rem auto 1.2rem;
  }

  .card {
    padding: 0.8rem;
    border-radius: 14px;
  }

  .input-sheet {
    min-width: 560px;
  }

  .input-sheet th,
  .input-sheet td {
    padding: 0.4rem 0.45rem;
  }

  .input-sheet td {
    min-height: 52px;
  }

  .section-header-inner {
    min-height: 40px;
  }

  .section-toggle-button {
    width: 32px;
    height: 32px;
  }

  .actions button,
  .admin-actions button {
    flex: 1 1 100%;
  }
}

/* Uniform input row sizing in calculator grid */
.input-sheet td {
  min-height: 58px;
  padding: 0.5rem 0.55rem;
}

.input-sheet td:first-child {
  font-size: 0.92rem;
}

.input-sheet input:not([type="checkbox"]),
.input-sheet select,
.input-sheet .form-control,
.input-sheet .form-select {
  min-height: 40px;
}

.input-sheet input[type="checkbox"] {
  width: 20px;
  height: 20px;
}

.input-sheet td:nth-child(2),
.input-sheet td:nth-child(3) {
  vertical-align: middle;
}

.input-sheet .ts-wrapper.single .ts-control,
.input-sheet .ts-wrapper.multi .ts-control {
  min-height: 40px;
}

#admin-panel input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(84%) sepia(28%) saturate(680%) hue-rotate(154deg) brightness(98%) contrast(91%);
  opacity: 0.95;
  cursor: pointer;
}

#admin-panel input[type="date"]::-webkit-date-and-time-value {
  color: #eaf3ff;
}

.metrics-table-wrap {
  margin-top: 0.75rem;
  border: 1px solid #2e4762;
  border-radius: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  background: rgba(10, 21, 35, 0.84);
}

.metrics-chart-wrap {
  margin-top: 0.75rem;
  border: 1px solid #2e4762;
  border-radius: 12px;
  background: rgba(10, 21, 35, 0.84);
  padding: 0.65rem 0.75rem 0.45rem;
}

.metrics-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  color: #e2edf8;
  margin-bottom: 0.45rem;
}

.metrics-chart-legend {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  color: #c9ddf0;
  font-size: 0.82rem;
}

.metrics-chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.metrics-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.metrics-dot-total {
  background: #12b8c8;
}

.metrics-dot-non-empty {
  background: #ff9a4f;
}

.metrics-dot-article-count {
  background: #35c46a;
}

.metrics-dot-article-amount {
  background: #f7b24b;
}

.metrics-chart {
  width: 100%;
  height: 320px;
  display: block;
}

@media (max-width: 700px) {
  .metrics-chart-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .metrics-chart {
    height: 260px;
  }
}

.metrics-table {
  width: 100%;
  border-collapse: collapse;
}

.metrics-table th,
.metrics-table td {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid #2d445b;
  color: #e2edf8;
  text-align: left;
  font-size: 0.88rem;
}

.metrics-table th {
  background: #13293f;
  color: #d4e6fa;
  font-weight: 700;
}

.metrics-table th.metrics-num,
.metrics-table td.metrics-num {
  text-align: right;
}

.metrics-table tbody tr:hover td {
  background: #13283b;
}

.metrics-table td.metrics-num {
  font-variant-numeric: tabular-nums;
}

#admin-panel h4,
#admin-panel .schema-preconditions-box h4,
#admin-panel .admin-note,
#admin-panel label {
  color: #e6f2ff !important;
}

#admin-panel input::placeholder,
#admin-panel textarea::placeholder,
#admin-panel .form-control::placeholder {
  color: #9fb9d1 !important;
  opacity: 1;
}

#admin-panel .schema-preconditions-box {
  background: rgba(18, 40, 62, 0.72) !important;
  border-color: #466687 !important;
}

#admin-panel .schema-precondition-row {
  background: rgba(13, 33, 52, 0.92) !important;
  border-color: #4b6c8d !important;
}

/* Bold Tech dark layer */
:root {
  --bg-a: #070d16;
  --bg-b: #0c1728;
  --bg-c: #071423;
  --card: rgba(13, 24, 39, 0.84);
  --ink: #e7f0fb;
  --ink-soft: #9eb5cd;
  --accent: #12b8c8;
  --accent-2: #ff9a4f;
  --line: #2a3e57;
  --focus: #3cb8ff;
  --ok-tint: #102534;
  --ok-tint-soft: #162c3a;
}

body {
  position: relative;
  color: var(--ink);
  font-family: "Bahnschrift", "Segoe UI Variable Text", "Aptos", sans-serif;
  background:
    radial-gradient(1000px 420px at 0% 0%, #0e2740 0%, transparent 58%),
    radial-gradient(820px 360px at 100% 0%, #3a1f27 0%, transparent 60%),
    linear-gradient(145deg, var(--bg-a), var(--bg-b) 55%, var(--bg-c));
}

body::before {
  content: "";
  position: fixed;
  inset: -22% -14%;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(36% 30% at 20% 34%, rgba(18, 184, 200, 0.18), transparent 62%),
    radial-gradient(34% 30% at 72% 22%, rgba(255, 154, 79, 0.12), transparent 60%),
    radial-gradient(32% 28% at 54% 78%, rgba(83, 119, 255, 0.12), transparent 65%);
  filter: blur(8px);
  animation: techDrift 26s ease-in-out infinite alternate;
}

@keyframes techDrift {
  0% {
    transform: translate3d(-1.4%, -0.6%, 0) scale(1);
  }
  100% {
    transform: translate3d(1.8%, 1.1%, 0) scale(1.03);
  }
}

.card {
  background: linear-gradient(180deg, rgba(17, 31, 49, 0.9), rgba(11, 23, 39, 0.88));
  border: 1px solid rgba(73, 109, 142, 0.42);
  box-shadow: 0 18px 42px rgba(2, 8, 18, 0.45), 0 1px 0 rgba(255, 255, 255, 0.06) inset;
}

h1,
h2,
h3 {
  color: #eef6ff;
}

.subtle,
.admin-note,
label {
  color: #bfd2e7;
}

input,
textarea,
select {
  background: rgba(9, 20, 35, 0.86);
  border-color: #35506d;
  color: #eaf3ff;
}

input::placeholder,
textarea::placeholder {
  color: #7e9ab5;
}

select {
  background-image:
    linear-gradient(45deg, transparent 50%, #7fc2df 50%),
    linear-gradient(135deg, #7fc2df 50%, transparent 50%),
    linear-gradient(to right, rgba(92, 122, 150, 0.65), rgba(92, 122, 150, 0.65));
}

button {
  background: #18a9c6;
  box-shadow: 0 10px 26px rgba(5, 22, 34, 0.55);
}

button:hover {
  background: #22b8d6;
}

button:active {
  background: #1393ad;
}

.input-sheet {
  border-color: #2e4660;
}

.input-sheet th {
  background: linear-gradient(180deg, #1a334d, #13293f);
  color: #d6e7fa;
}

.input-sheet th,
.input-sheet td {
  border-color: #2d445b;
}

.input-sheet td:nth-child(2),
.input-sheet td:nth-child(3) {
  background: #122a39;
}

.input-sheet .section-row td {
  background: #0f2234;
  color: #e7f1fb;
}

.input-sheet tr.is-precondition-disabled td:nth-child(2),
.input-sheet tr.is-precondition-disabled td:nth-child(3),
.input-sheet tr.is-precondition-disabled input,
.input-sheet tr.is-precondition-disabled select,
.input-sheet tr.is-precondition-disabled textarea {
  background: #1a2f3f;
  color: #88a3bc;
}

.result-card th {
  background: #13293f;
  color: #d4e6fa;
}

.result-card td {
  border-bottom-color: #2a3f56;
}

.result-card tbody tr:hover td {
  background: #13283b;
}

pre {
  background: linear-gradient(160deg, #08111d, #0d1a2a);
  border-color: #273c53;
  color: #ccf1ff;
}

.admin-panel details {
  background: linear-gradient(180deg, #112236, #0d1c2f);
  border-color: #2e4762;
}

.schema-preconditions-box {
  border-color: #375169;
  background: #102236;
}

.schema-precondition-row {
  border-color: #33506b;
  background: #0f2033;
}

#admin-panel {
  border: none;
  background: transparent;
  box-shadow: none;
}

#admin-panel > summary {
  color: #e9f4ff;
  font-weight: 800;
}

#admin-panel[open] > summary {
  color: #f3fbff;
}

#admin-panel .admin-note,
#admin-panel label,
#admin-panel p {
  color: #c8daec;
}

#admin-panel details {
  border: none;
  background: rgba(17, 35, 54, 0.48);
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(72, 106, 136, 0.25);
}

#admin-panel details > summary {
  color: #e7f2ff;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.calculate-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: rgba(3, 11, 20, 0.48);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 140ms ease;
}

.calculate-loading-overlay.is-visible {
  opacity: 1;
}

.calculate-loading-popup {
  min-width: 210px;
  padding: 1rem 1.2rem;
  border-radius: 14px;
  border: 1px solid rgba(104, 140, 172, 0.56);
  background: linear-gradient(180deg, rgba(20, 38, 57, 0.95), rgba(13, 28, 45, 0.96));
  color: #eaf4ff;
  display: grid;
  justify-items: center;
  gap: 0.65rem;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.46);
}

.calculate-loading-spinner {
  width: 42px;
  height: 42px;
  border: 4px solid rgba(90, 128, 162, 0.45);
  border-top-color: #16b8d5;
  border-radius: 50%;
  animation: calcSpinnerTurn 0.85s linear infinite;
}

.calculate-loading-text {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

@keyframes calcSpinnerTurn {
  to {
    transform: rotate(360deg);
  }
}

#admin-panel details[open] > summary {
  color: #ffffff;
}

#admin-panel select,
#admin-panel input,
#admin-panel textarea {
  background: rgba(9, 22, 37, 0.95);
  border-color: #416486;
  color: #eaf3ff;
}

/* Bootstrap/Tom Select harmonization */
.btn.btn-primary {
  --bs-btn-bg: #18a9c6;
  --bs-btn-border-color: #18a9c6;
  --bs-btn-hover-bg: #22b8d6;
  --bs-btn-hover-border-color: #22b8d6;
  --bs-btn-active-bg: #1393ad;
  --bs-btn-active-border-color: #1393ad;
  --bs-btn-disabled-bg: #2a6171;
  --bs-btn-disabled-border-color: #2a6171;
}

.form-control,
.form-select {
  background-color: rgba(9, 20, 35, 0.88);
  border-color: #35506d;
  color: #eaf3ff;
}

.form-control:focus,
.form-select:focus {
  background-color: rgba(9, 20, 35, 0.96);
  color: #f1f8ff;
  border-color: #4abdf8;
  box-shadow: 0 0 0 0.2rem rgba(74, 189, 248, 0.2);
}

.ts-wrapper {
  min-height: 40px;
}

.ts-wrapper.single .ts-control,
.ts-wrapper.multi .ts-control {
  min-height: 40px;
  border-radius: 12px;
  position: relative;
  background: rgba(9, 20, 35, 0.9);
  background-image: none !important;
  border: 1px solid #35506d;
  box-shadow: none;
}

.ts-wrapper.single .ts-control::after {
  right: 12px;
  left: auto;
}

.ts-wrapper.single .ts-control input,
.ts-wrapper.multi .ts-control input,
.ts-control,
.ts-control input {
  color: #eaf3ff;
}

.ts-control > input,
.ts-wrapper.single .ts-control > input,
.ts-wrapper.multi .ts-control > input {
  display: none !important;
  width: 0 !important;
  min-width: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}

.ts-control {
  display: flex;
  align-items: center;
}

.ts-wrapper.focus .ts-control {
  border-color: #4abdf8;
  box-shadow: 0 0 0 0.2rem rgba(74, 189, 248, 0.2);
}

.ts-dropdown {
  border: 1px solid #35506d;
  border-radius: 12px;
  background: #0f1f33;
  color: #eaf3ff;
  z-index: 2100;
}

.ts-dropdown .option,
.ts-dropdown .optgroup-header,
.ts-dropdown .create {
  background: #0f1f33;
  color: #eaf3ff;
}

.ts-dropdown .active {
  background: #15314b;
  color: #ffffff;
}

/* Final lock for consistent dropdown control backgrounds */
.input-sheet select,
.input-sheet .form-select,
.input-sheet .ts-control,
.input-sheet .ts-wrapper.single .ts-control,
.input-sheet .ts-wrapper.multi .ts-control {
  background: rgba(9, 20, 35, 0.9) !important;
  background-image: none !important;
}

#admin-article-select,
#admin-add-form select,
#schema-section-select,
#schema-row-select {
  min-height: 40px;
  background-color: rgba(10, 23, 39, 0.93);
  color: #eaf3ff;
  border-color: #3f5f7e;
}

#admin-article-select:focus,
#admin-add-form select:focus,
#schema-section-select:focus,
#schema-row-select:focus {
  border-color: #45b9ff;
}

.form-control:disabled,
.form-select:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  background-color: #1a2f3f !important;
  color: #9bb2c9 !important;
  border-color: #35506d !important;
  opacity: 1;
}

.ts-wrapper.disabled .ts-control,
.ts-wrapper.disabled .ts-control input {
  background: #1a2f3f !important;
  color: #9bb2c9 !important;
  border-color: #35506d !important;
  opacity: 1;
}

/* Final cascade lock: readability + full-row toggles */
p,
.subtle,
.admin-note,
label {
  color: #dbe8f5 !important;
}

.input-sheet td:first-child,
.result-card td,
.result-card p {
  color: #e2edf8 !important;
}

.section-header-inner {
  width: 100%;
  min-height: 34px;
  padding: 0.2rem 0.1rem;
  border-radius: 8px;
  cursor: pointer;
}

.section-row:hover .section-header-inner {
  background: rgba(33, 63, 91, 0.34);
}

.section-header-inner:focus-visible {
  outline: 2px solid #57bff7;
  outline-offset: 2px;
}

.section-toggle-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  color: #cbe4f8;
  background: rgba(58, 91, 123, 0.36);
  font-weight: 700;
}

#admin-panel details > summary {
  display: block !important;
  width: 100% !important;
  padding: 0.55rem 0.7rem !important;
  border-radius: 10px;
  cursor: pointer;
  list-style: none;
  color: #ebf5ff;
}

#admin-panel details > summary::-webkit-details-marker {
  display: none;
}

#admin-panel details > summary::after {
  content: "▸";
  float: right;
  color: #b9d3e8;
}

#admin-panel details[open] > summary::after {
  content: "▾";
}

#admin-panel details > summary:hover {
  background: rgba(38, 70, 98, 0.34);
}
