:root {
  color-scheme: light;
  --bg: #f2f0ea;
  --surface: #ffffff;
  --surface-soft: #f7f5f0;
  --surface-warm: #ebe6dc;
  --text: #3f3c38;
  --ink: #24211e;
  --muted: #6f665b;
  --quiet: #8b7c68;
  --line: #e2ddd3;
  --line-strong: #cfc6b7;
  --accent: #a78955;
  --accent-dark: #755f39;
  --moss: #5f6c61;
  --wine: #7b4e45;
  --danger: #9e4a35;
  --shadow: 0 22px 58px rgba(63, 60, 56, 0.12);
  --soft-shadow: 0 12px 28px rgba(63, 60, 56, 0.08);
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.54) 0, rgba(255, 255, 255, 0) 260px),
    repeating-linear-gradient(90deg, rgba(63, 60, 56, 0.025) 0 1px, transparent 1px 94px),
    var(--bg);
  color: var(--text);
}

body.is-locked {
  overflow: hidden;
}

body.is-locked .app {
  display: none;
}

body:not(.is-locked) .login-screen {
  display: none;
}

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

button {
  cursor: pointer;
}

button,
input,
textarea,
select {
  letter-spacing: 0;
}

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

h1,
h2 {
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  letter-spacing: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(2rem, 4vw, 3.1rem);
  line-height: 1.03;
}

h2 {
  margin-bottom: 0;
  font-size: 1.45rem;
  line-height: 1.15;
}

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

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 460px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 30px;
}

.login-logo {
  width: 128px;
  height: 128px;
  object-fit: contain;
  margin: 0 auto 20px;
}

.login-copy {
  margin-bottom: 22px;
  color: var(--muted);
  line-height: 1.55;
}

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

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 0.92rem;
  font-weight: 800;
}

.app {
  width: min(1420px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 38px;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 24px;
  align-items: end;
  padding: 2px 0 24px;
}

.brand-lockup {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.brand-logo {
  width: 88px;
  height: 88px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
  box-shadow: var(--soft-shadow);
}

.intro-actions {
  display: grid;
  justify-items: end;
  gap: 14px;
}

.intro-copy {
  max-width: 620px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
  text-align: right;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--quiet);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tool-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.tool-tab {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  padding: 0 13px;
  font-size: 0.9rem;
  font-weight: 800;
}

.tool-tab:hover {
  border-color: var(--accent);
  background: #ffffff;
}

.tool-tab.active {
  border-color: var(--text);
  background: var(--text);
  color: #ffffff;
}

.tool-section {
  display: none;
}

.tool-section.active {
  display: block;
}

.metres-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

.tool-grid {
  display: grid;
  gap: 18px;
}

.tool-grid.two-columns {
  grid-template-columns: minmax(0, 0.9fr) minmax(320px, 1.1fr);
}

.tool-panel,
.reference-band {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  padding: 24px;
}

.metre-card {
  display: grid;
  align-content: start;
  gap: 18px;
  min-width: 0;
}

.thermal-card {
  padding: 0;
  overflow: hidden;
}

.thermal-card .panel-heading,
.thermal-card .controls,
.thermal-card .thermal-result {
  margin: 0;
}

.thermal-card .panel-heading {
  padding: 24px 24px 0;
}

.controls {
  display: grid;
  gap: 0;
  padding: 0 24px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.panel-heading {
  margin-bottom: 18px;
}

.field-group {
  display: grid;
  gap: 9px;
  min-width: 0;
}

form {
  display: grid;
  gap: 16px;
}

label,
legend {
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 800;
}

.inline-input,
.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.inline-input {
  grid-template-columns: minmax(0, 1fr) auto;
}

input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--ink);
  padding: 0 13px;
  outline: none;
}

textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(167, 137, 85, 0.18);
}

input[type="file"] {
  min-height: auto;
  padding: 12px;
}

.file-upload {
  position: relative;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.file-control {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 56px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  background: var(--surface-soft);
  padding: 8px;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 4px;
  background: var(--text);
  color: #ffffff;
  padding: 0 14px;
  font-size: 0.88rem;
  font-weight: 800;
  white-space: nowrap;
}

.file-name {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-control:hover {
  border-color: var(--accent);
  background: #ffffff;
}

.file-control.is-drag-over {
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(167, 137, 85, 0.18);
}

.file-control.has-file {
  border-style: solid;
}

.file-input:focus-visible + .file-control {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(167, 137, 85, 0.18);
}

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

input[type="color"] {
  width: 100%;
  min-height: 44px;
  padding: 5px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 48px);
  min-height: 46px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.segmented.wide {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 0;
}

.unit-button,
.tva-mode,
.salary-mode {
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.unit-button:last-child,
.tva-mode:last-child,
.salary-mode:last-child {
  border-right: 0;
}

.unit-button.active,
.tva-mode.active,
.salary-mode.active {
  background: var(--text);
  color: #ffffff;
}

input:disabled {
  color: var(--quiet);
  opacity: 0.72;
}

.material-picker {
  min-width: 0;
  margin: 18px 0 0;
  padding: 0;
  border: 0;
}

.material-list {
  display: grid;
  gap: 9px;
  margin-top: 10px;
}

.material-option {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  min-height: 68px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  padding: 9px;
}

.material-option:has(input:checked) {
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: inset 4px 0 0 var(--accent);
}

.material-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.swatch {
  width: 50px;
  height: 50px;
  border: 1px solid rgba(63, 60, 56, 0.1);
  border-radius: 6px;
}

.swatch.granite {
  background:
    radial-gradient(circle at 22% 28%, #d7dde1 0 2px, transparent 3px),
    radial-gradient(circle at 68% 38%, #2d3438 0 2px, transparent 3px),
    radial-gradient(circle at 38% 72%, #9ca6ad 0 3px, transparent 4px),
    linear-gradient(135deg, #707b84, #b8c0c5);
}

.swatch.limestone {
  background:
    linear-gradient(30deg, transparent 0 42%, rgba(255, 255, 255, 0.55) 43% 47%, transparent 48%),
    radial-gradient(circle at 72% 25%, rgba(114, 96, 58, 0.4) 0 2px, transparent 3px),
    linear-gradient(135deg, #d9d0a4, #a99d71);
}

.swatch.earth {
  background:
    radial-gradient(circle at 22% 24%, rgba(255, 255, 255, 0.22) 0 2px, transparent 3px),
    radial-gradient(circle at 76% 68%, rgba(40, 25, 18, 0.33) 0 3px, transparent 4px),
    linear-gradient(135deg, #a56a45, #593927);
}

.material-title {
  display: block;
  color: var(--ink);
  font-weight: 850;
}

.material-meta {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.lambda-badge {
  grid-column: 1 / -1;
  justify-self: start;
  border-radius: 999px;
  background: #efe7d8;
  color: var(--accent-dark);
  padding: 6px 9px;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 850;
}

.lambda-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-top: 18px;
}

.lambda-input {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) auto;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.lambda-input input {
  min-height: 44px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.lambda-input span {
  padding: 0 11px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
  white-space: nowrap;
}

.ghost-button {
  min-height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #ffffff;
  color: var(--text);
  padding: 0 14px;
  font-weight: 850;
}

.ghost-button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.logout-button {
  min-width: 132px;
}

.ghost-button:disabled,
.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary-button {
  min-height: 46px;
  border: 1px solid var(--accent-dark);
  border-radius: 4px;
  background: var(--accent);
  color: #ffffff;
  padding: 0 16px;
  font-weight: 850;
}

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

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.48;
}

.result-panel {
  display: grid;
  align-content: space-between;
  min-height: 100%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(167, 137, 85, 0.18), rgba(167, 137, 85, 0) 190px),
    var(--text);
  color: #ffffff;
  padding: 22px;
  box-shadow: none;
}

.thermal-result {
  border-radius: 0;
  margin-top: 2px;
}

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

.result-label {
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.8rem;
  font-weight: 850;
  text-transform: uppercase;
}

.status-pill {
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  padding: 6px 10px;
  color: #f2e3c3;
  font-size: 0.8rem;
  font-weight: 800;
}

.status-pill.error {
  color: #ffd9cc;
}

.main-result {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: baseline;
  margin-top: 34px;
}

.main-result span {
  font-size: clamp(2.55rem, 5vw, 3.85rem);
  font-weight: 900;
  line-height: 0.96;
}

.main-result small {
  color: rgba(255, 255, 255, 0.72);
  font-size: 1rem;
  font-weight: 800;
}

.salary-main span {
  font-size: clamp(2rem, 4vw, 3rem);
}

.formula {
  margin: 12px 0 22px;
  color: rgba(255, 255, 255, 0.74);
  line-height: 1.45;
}

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

.metric-grid div {
  min-height: 82px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  padding: 13px;
}

.metric-label {
  display: block;
  margin-bottom: 8px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.8rem;
  font-weight: 800;
}

.metric-grid strong {
  color: #ffffff;
  font-size: 1.02rem;
}

.metric-grid.stacked {
  grid-template-columns: 1fr;
  align-content: start;
  margin-top: 18px;
}

.scale {
  height: 9px;
  overflow: hidden;
  margin-top: 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
}

.scale span {
  display: block;
  width: 12%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #d7b46c, #c9ad7a, #8ea08d);
  transition: width 160ms ease;
}

.result-note {
  margin: 10px 0 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.9rem;
  line-height: 1.48;
}

.reference-band {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
  box-shadow: none;
}

.reference-table {
  display: grid;
  gap: 10px;
}

.reference-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.reference-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.reference-row strong {
  display: block;
  margin-bottom: 4px;
}

.reference-row span {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.reference-row a {
  color: var(--accent-dark);
  font-weight: 850;
  text-decoration: none;
}

.range-badge {
  border-radius: 999px;
  background: #efe7d8;
  color: var(--accent-dark);
  padding: 8px 10px;
  white-space: nowrap;
  font-size: 0.86rem;
  font-weight: 850;
}

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

.color-grid label {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  padding: 10px;
}

.color-grid span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 2px;
}

.file-list {
  display: grid;
  gap: 10px;
}

.file-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  padding: 12px;
}

.file-item strong {
  display: block;
  overflow-wrap: anywhere;
}

.file-item span {
  color: var(--muted);
  font-size: 0.88rem;
}

.file-item a {
  border-radius: 4px;
  background: #efe7d8;
  color: var(--accent-dark);
  padding: 9px 11px;
  text-decoration: none;
  font-weight: 850;
  white-space: nowrap;
}

.output-panel textarea {
  min-height: 150px;
  margin-bottom: 12px;
}

.pdf-summary {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  padding: 16px;
}

.pdf-summary strong {
  font-size: 1.2rem;
}

.pdf-summary span {
  color: var(--muted);
  line-height: 1.5;
}

.compact-result {
  min-height: 360px;
}

.qr-preview-panel {
  display: grid;
  min-height: 420px;
  place-items: center;
}

#qr-canvas {
  width: min(100%, 380px);
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px;
}

.check-row {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--text);
  font-weight: 750;
}

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

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

#password-output {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.05rem;
  line-height: 1.5;
}

@media (max-width: 1180px) {
  .metres-grid {
    grid-template-columns: 1fr;
  }

  .metre-card {
    grid-template-columns: minmax(0, 1fr) minmax(320px, 0.85fr);
    align-items: stretch;
  }

  .metre-card .panel-heading {
    grid-column: 1 / -1;
  }

  .thermal-card .controls {
    padding-bottom: 24px;
  }

  .thermal-result {
    border-radius: 0 0 8px 8px;
  }
}

@media (max-width: 860px) {
  body.is-locked {
    overflow: auto;
  }

  .app {
    width: min(100% - 24px, 720px);
    padding-top: 18px;
  }

  .intro,
  .tool-grid.two-columns,
  .reference-band,
  .metre-card {
    grid-template-columns: 1fr;
  }

  .intro {
    align-items: start;
  }

  .intro-actions {
    justify-items: start;
  }

  .intro-copy {
    max-width: none;
    text-align: left;
  }

  h1 {
    font-size: 2.25rem;
  }
}

@media (max-width: 540px) {
  .login-screen {
    padding: 14px;
  }

  .login-card {
    padding: 22px;
  }

  .app {
    width: min(100% - 20px, 480px);
  }

  .brand-lockup,
  .inline-input,
  .field-row,
  .metric-grid,
  .reference-row,
  .file-item,
  .option-grid,
  .color-grid {
    grid-template-columns: 1fr;
  }

  .brand-logo {
    width: 76px;
    height: 76px;
  }

  .tool-panel,
  .reference-band,
  .result-panel {
    padding: 18px;
  }

  .thermal-card {
    padding: 0;
  }

  .thermal-card .panel-heading {
    padding: 18px 18px 0;
  }

  .controls {
    padding: 0 18px 18px;
  }

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

  .tool-tab {
    flex: 1 1 132px;
  }

  .main-result {
    margin-top: 28px;
  }

  .main-result span {
    font-size: 2.65rem;
  }

  .range-badge {
    justify-self: start;
  }
}
