:root {
  --bg: #f3ede2;
  --bg-deep: #e5d7bf;
  --paper: rgba(255, 251, 245, 0.9);
  --paper-strong: #fffdf9;
  --ink: #22313b;
  --muted: #5f6d77;
  --line: rgba(58, 72, 82, 0.14);
  --accent: #ab5a2a;
  --accent-strong: #8d461e;
  --accent-soft: rgba(171, 90, 42, 0.12);
  --sidebar-bg: rgba(31, 38, 44, 0.94);
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --sidebar-text: #f6efe5;
  --sidebar-muted: rgba(246, 239, 229, 0.7);
  --success: #1d7d56;
  --warning: #9b6a13;
  --danger: #b33d2f;
  --shadow: 0 28px 60px rgba(54, 42, 28, 0.14);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --sidebar-collapsed: 92px;
  --sidebar-expanded: 308px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Bahnschrift", "Segoe UI Variable Text", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(171, 90, 42, 0.18), transparent 28%),
    radial-gradient(circle at bottom right, rgba(110, 129, 142, 0.14), transparent 22%),
    repeating-linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.18) 0,
      rgba(255, 255, 255, 0.18) 1px,
      transparent 1px,
      transparent 22px
    ),
    linear-gradient(180deg, var(--bg-deep) 0%, var(--bg) 44%, #f6f1e8 100%);
}

h1,
h2,
h3,
.brand-copy strong,
.stat-value,
.module-index {
  font-family: "Constantia", "Palatino Linotype", Georgia, serif;
  letter-spacing: -0.02em;
}

a {
  color: var(--accent-strong);
}

code {
  font-family: "Cascadia Code", Consolas, monospace;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: var(--sidebar-collapsed);
  height: 100vh;
  padding: 20px 16px;
  border-right: 1px solid var(--sidebar-border);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 30%),
    linear-gradient(180deg, rgba(15, 19, 23, 0.96), var(--sidebar-bg));
  box-shadow: 18px 0 42px rgba(17, 22, 26, 0.18);
  overflow: hidden;
  transition: width 220ms ease, box-shadow 220ms ease;
}

.sidebar:hover,
.sidebar:focus-within {
  width: var(--sidebar-expanded);
  box-shadow: 20px 0 50px rgba(17, 22, 26, 0.24);
}

.brand-link,
.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
}

.brand-link {
  min-height: 64px;
}

.brand-mark,
.nav-mark {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 14px;
  color: var(--sidebar-text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.brand-mark {
  width: 56px;
  height: 56px;
  min-width: 56px;
  min-height: 56px;
  background: linear-gradient(135deg, rgba(171, 90, 42, 0.95), rgba(112, 61, 31, 0.95));
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.22);
}

.sidebar-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.sidebar:hover .sidebar-copy,
.sidebar:focus-within .sidebar-copy {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.brand-copy strong,
.nav-copy strong {
  color: var(--sidebar-text);
  font-size: 1rem;
}

.brand-copy span,
.nav-copy span {
  color: var(--sidebar-muted);
  font-size: 0.88rem;
  line-height: 1.3;
}

.sidebar-nav,
.sidebar-footer {
  display: grid;
  gap: 12px;
}

.sidebar-nav {
  flex: 1 1 auto;
}

.primary-item {
  min-height: 60px;
}

.nav-item {
  min-height: 68px;
  padding: 10px;
  border-radius: 20px;
  border: 1px solid transparent;
  background: transparent;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.nav-item:hover,
.nav-item:focus-visible {
  transform: translateX(2px);
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.08);
  outline: none;
}

.nav-item.is-active {
  background: linear-gradient(135deg, rgba(171, 90, 42, 0.28), rgba(171, 90, 42, 0.12));
  border-color: rgba(215, 151, 112, 0.32);
}

.nav-item.is-active .nav-mark {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.nav-copy.is-single-line {
  gap: 0;
}

.primary-item .nav-copy strong {
  font-size: 0.96rem;
  white-space: nowrap;
}

.nav-mark-icon {
  padding: 6px;
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(255, 255, 255, 0.32);
}

.nav-icon-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 10px;
}

.utility .nav-copy strong {
  white-space: nowrap;
}

.page-shell {
  margin-left: calc(var(--sidebar-collapsed) + 18px);
  padding: 30px 28px 36px;
}

.page-hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  padding: 28px 30px;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(171, 90, 42, 0.15);
  background:
    linear-gradient(135deg, rgba(255, 253, 249, 0.9), rgba(245, 235, 219, 0.84)),
    var(--paper-strong);
  box-shadow: var(--shadow);
  animation: rise-in 420ms ease both;
}

.hero-copy-block {
  max-width: 68ch;
}

.page-hero h1 {
  margin: 10px 0 12px;
  font-size: clamp(2rem, 3.2vw, 3.5rem);
  line-height: 0.98;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

.hero-copy,
.muted {
  color: var(--muted);
}

.hero-copy {
  margin: 0;
  font-size: 1rem;
  line-height: 1.6;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.content,
.settings-layout,
.dashboard-grid,
.info-grid,
.status-grid,
.module-detail-grid {
  display: grid;
  gap: 22px;
}

.content {
  margin-top: 24px;
}

.info-grid,
.module-detail-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.status-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-top: 18px;
}

.card-grid,
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 22px;
}

.card {
  position: relative;
  padding: 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(255, 250, 244, 0.92)),
    var(--paper);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: rise-in 500ms ease both;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 40%);
  pointer-events: none;
}

.card > * {
  position: relative;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 1.5rem;
}

.spotlight {
  background:
    radial-gradient(circle at top right, rgba(171, 90, 42, 0.16), transparent 22%),
    linear-gradient(135deg, rgba(255, 250, 244, 0.96), rgba(247, 239, 228, 0.92));
}

.stat-card {
  display: grid;
  gap: 12px;
  align-content: start;
}

.stat-label,
.status-label {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.stat-value {
  font-size: clamp(1.9rem, 2.6vw, 2.8rem);
  line-height: 1;
}

.module-card {
  display: grid;
  gap: 14px;
}

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

.module-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(171, 90, 42, 0.18), rgba(171, 90, 42, 0.08));
  color: var(--accent-strong);
  font-size: 1.25rem;
  font-weight: 700;
}

.feature-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 10px;
  line-height: 1.55;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.button,
button.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 12px 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  text-decoration: none;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease, border-color 140ms ease;
  box-shadow: 0 12px 24px rgba(141, 70, 30, 0.22);
}

.button:hover,
.button:focus-visible,
button.button:hover,
button.button:focus-visible {
  transform: translateY(-1px);
  outline: none;
  box-shadow: 0 16px 28px rgba(141, 70, 30, 0.28);
}

.button.secondary,
.button.secondary:visited {
  background: rgba(255, 255, 255, 0.45);
  color: var(--ink);
  border-color: rgba(34, 49, 59, 0.12);
  box-shadow: none;
}

.hero-action {
  white-space: nowrap;
}

.section-dashboard .page-shell {
  min-height: 100vh;
}

.section-dashboard .page-hero {
  min-height: calc(100vh - 72px);
  align-items: center;
  justify-content: center;
  padding: 40px 56px;
  text-align: center;
}

.section-dashboard .hero-copy-block {
  max-width: 760px;
  margin: 0 auto;
}

.section-dashboard .page-hero h1 {
  margin: 0 0 18px;
  font-size: clamp(3rem, 5vw, 4.8rem);
  line-height: 0.96;
}

.section-dashboard .hero-copy {
  max-width: 32ch;
  margin: 0 auto;
  font-size: clamp(1.1rem, 1.5vw, 1.35rem);
}

.section-dashboard .content {
  margin-top: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-ok {
  color: var(--success);
  background: rgba(29, 125, 86, 0.12);
}

.badge-warn {
  color: var(--warning);
  background: rgba(155, 106, 19, 0.14);
}

.badge-error {
  color: var(--danger);
  background: rgba(179, 61, 47, 0.13);
}

.badge-soft {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.48);
  border: 1px solid rgba(34, 49, 59, 0.08);
}

.flash-stack {
  margin-top: 18px;
  display: grid;
  gap: 10px;
}

.flash {
  padding: 15px 18px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  box-shadow: var(--shadow);
}

.flash-success {
  background: rgba(29, 125, 86, 0.12);
  color: var(--success);
  border-color: rgba(29, 125, 86, 0.18);
}

.flash-error {
  background: rgba(179, 61, 47, 0.12);
  color: var(--danger);
  border-color: rgba(179, 61, 47, 0.18);
}

.section-head,
.session-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.stack-form,
.cabinet-stack,
.auth-form,
.session-meta {
  display: grid;
  gap: 14px;
}

.cabinet-card,
.status-panel,
.session-card {
  display: grid;
  gap: 10px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(34, 49, 59, 0.1);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(252, 247, 240, 0.94));
}

.inline-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(34, 49, 59, 0.14);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  font: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(171, 90, 42, 0.18);
  border-color: rgba(171, 90, 42, 0.36);
}

input::file-selector-button {
  margin-right: 12px;
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(171, 90, 42, 0.12);
  color: var(--accent-strong);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

textarea {
  resize: vertical;
}

.report-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
  line-height: 1.55;
}

.scroll-panel {
  max-height: 320px;
  overflow-y: auto;
  padding-right: 6px;
}

.scroll-panel::-webkit-scrollbar {
  width: 10px;
}

.scroll-panel::-webkit-scrollbar-thumb {
  background: rgba(95, 109, 119, 0.36);
  border-radius: 999px;
}

.inline-form {
  margin: 0;
}

.auth-body {
  min-height: 100vh;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 26px;
}

.auth-card {
  width: min(100%, 540px);
  padding: 30px;
  border-radius: 32px;
  border: 1px solid rgba(171, 90, 42, 0.16);
  background:
    radial-gradient(circle at top right, rgba(171, 90, 42, 0.16), transparent 26%),
    linear-gradient(135deg, rgba(255, 253, 249, 0.97), rgba(243, 232, 215, 0.95));
  box-shadow: var(--shadow);
  display: grid;
  gap: 22px;
}

.auth-copy h1 {
  margin: 8px 0 12px;
  font-size: clamp(2rem, 4vw, 2.9rem);
  line-height: 1.02;
}

.auth-copy p {
  margin: 0;
}

.auth-submit {
  width: 100%;
  margin-top: 6px;
}

.session-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
}

.instruction-box {
  margin-top: 18px;
  padding: 18px;
  border-radius: 18px;
  border: 1px dashed rgba(34, 49, 59, 0.18);
  background: rgba(255, 252, 246, 0.82);
}

.instruction-box ol {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
}

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

.calc-path {
  word-break: break-word;
}

.settings-inline-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
  color: var(--muted);
}

.calc-toolbar-grid {
  grid-template-columns: minmax(0, 1fr);
}

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

.field-label {
  color: var(--muted);
  font-size: 0.92rem;
}

.source-actions {
  margin-top: 14px;
}

.stack-form textarea,
.stack-form input,
.stack-form select,
.row-editor textarea,
.row-editor input,
.row-editor select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid rgba(58, 72, 82, 0.16);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  font: inherit;
}

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

.compact-form-grid label,
.row-editor label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

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

.readonly-field {
  display: grid;
  gap: 6px;
  padding: 11px 12px;
  border: 1px solid rgba(58, 72, 82, 0.12);
  border-radius: 14px;
  background: rgba(245, 239, 230, 0.7);
  color: var(--muted);
  font-size: 0.9rem;
}

.readonly-field strong {
  color: var(--ink);
  font-size: 1rem;
}

.calc-table-card {
  overflow: hidden;
}

.calc-table-scroll {
  max-height: 76vh;
  overflow: auto;
  padding-right: 6px;
}

.calc-table {
  width: 100%;
  min-width: 1600px;
  border-collapse: separate;
  border-spacing: 0 14px;
}

.calc-table th {
  padding: 0 10px 10px;
  text-align: left;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(243, 237, 226, 0.96);
}

.calc-table td {
  vertical-align: top;
  padding: 0 10px;
}

.calc-table tbody tr td {
  background: rgba(255, 255, 255, 0.72);
  border-top: 1px solid rgba(58, 72, 82, 0.08);
  border-bottom: 1px solid rgba(58, 72, 82, 0.08);
}

.calc-table tbody tr td:first-child {
  border-left: 1px solid rgba(58, 72, 82, 0.08);
  border-radius: 18px 0 0 18px;
}

.calc-table tbody tr td:last-child {
  border-right: 1px solid rgba(58, 72, 82, 0.08);
  border-radius: 0 18px 18px 0;
}

.calc-index {
  width: 56px;
  font-weight: 700;
  text-align: center;
  color: var(--accent-strong);
}

.select-col {
  width: 52px;
  text-align: center;
}

.select-cell {
  padding-top: 18px;
}

.product-cell,
.inputs-cell,
.scenarios-cell {
  padding-top: 16px;
  padding-bottom: 16px;
}

.product-cell {
  min-width: 290px;
  display: grid;
  gap: 6px;
}

.product-cell strong {
  font-size: 1rem;
}

.product-cell span {
  color: var(--muted);
  line-height: 1.35;
}

.warning-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.inputs-cell {
  min-width: 320px;
}

.calc-bulk-card {
  min-width: 0;
  width: 100%;
}

.scenario-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(210px, 1fr));
  gap: 12px;
}

.scenario-card {
  height: 100%;
  padding: 14px;
  border: 1px solid rgba(171, 90, 42, 0.12);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 253, 249, 0.94), rgba(245, 237, 226, 0.72));
}

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

.scenario-card-header strong {
  display: block;
  font-size: 0.96rem;
}

.scenario-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
}

.scenario-metrics span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.2;
}

.scenario-metrics strong {
  display: block;
  margin-top: 3px;
  font-size: 0.98rem;
  line-height: 1.15;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1180px) {
  .primary-item .nav-copy strong {
    white-space: normal;
  }
}

@media (max-width: 880px) {
  .calc-summary-grid,
  .calc-toolbar-grid {
    grid-template-columns: 1fr;
  }

  .compact-form-grid,
  .row-editor {
    grid-template-columns: 1fr;
  }

  .scenario-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }

  .sidebar {
    position: sticky;
    width: auto;
    height: auto;
    margin: 0 14px;
    border-radius: 0 0 24px 24px;
    padding: 14px;
  }

  .sidebar:hover,
  .sidebar:focus-within {
    width: auto;
  }

  .sidebar-copy {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }

  .sidebar-nav,
  .sidebar-footer {
    grid-auto-flow: column;
    grid-auto-columns: minmax(220px, 1fr);
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .page-shell {
    margin-left: 0;
    padding: 18px 14px 30px;
  }

  .page-hero {
    flex-direction: column;
    padding: 24px 22px;
  }

  .section-dashboard .page-hero {
    min-height: auto;
    padding: 28px 24px;
  }

  .hero-meta {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .settings-inline-grid,
  .scenario-metrics {
    grid-template-columns: 1fr;
  }

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

  .page-hero h1 {
    font-size: 2.1rem;
  }

  .section-dashboard .page-hero h1 {
    font-size: 2.5rem;
  }

  .card,
  .auth-card {
    padding: 20px;
  }

  .section-head,
  .session-header {
    flex-direction: column;
  }

  .button-row {
    flex-direction: column;
    align-items: stretch;
  }

  .button,
  button.button {
    width: 100%;
  }

  .sidebar-nav,
  .sidebar-footer {
    grid-auto-columns: minmax(180px, 1fr);
  }
}
