/* Badrumsplaneraren: warm paper, architectural plan, one accent colour. */

:root {
  --paper: #f4f1ea;
  --paper-raised: #fbfaf7;
  --paper-sunken: #ece7dd;
  --line: #ded7ca;
  --line-soft: #ebe5db;
  --ink: #2c2823;
  --ink-soft: #5a5349;
  --ink-muted: #8a8175;
  --accent: #1f7a6b;
  --accent-ink: #155c50;
  --accent-soft: rgba(31, 122, 107, 0.12);
  --warn: #a8402a;
  --warn-soft: #fbf0ec;
  --radius: 10px;
  --shadow-soft: 0 1px 2px rgba(44, 40, 35, 0.05);
  --shadow-float: 0 10px 30px rgba(44, 40, 35, 0.12);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button,
input,
select,
textarea {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

svg {
  display: block;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---- shell ------------------------------------------------------------ */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.topbar {
  flex: 0 0 auto;
  background: var(--paper-raised);
  border-bottom: 1px solid var(--line);
  padding: 0 16px;
  z-index: 20;
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 62px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  text-decoration: none;
  color: inherit;
}

.brand-word {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.brand-sep {
  width: 1px;
  height: 18px;
  background: var(--line);
}

.brand-product {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  letter-spacing: -0.01em;
}

.brand:hover .brand-word {
  color: var(--accent-ink);
}

.top-link {
  font-size: 12px;
  color: var(--ink-muted);
  text-decoration: none;
  padding: 6px 4px;
  white-space: nowrap;
}

.top-link:hover {
  color: var(--accent-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.project-fields {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
}

.title-input {
  flex: 0 1 280px;
  min-width: 80px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
}

.customer-input {
  flex: 0 1 180px;
  min-width: 70px;
  font-size: 13px;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
}

.title-input:hover,
.customer-input:hover {
  border-color: var(--line);
  background: #fff;
}

.title-input:focus,
.customer-input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.workspace {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 344px minmax(320px, 1fr) 336px;
}

.panel {
  background: var(--paper-raised);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.panel-left {
  border-right: 1px solid var(--line);
}

.panel-right {
  border-left: 1px solid var(--line);
}

.panel-inner {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.stage {
  position: relative;
  overflow: hidden;
  background: var(--paper-sunken);
  min-height: 0;
}

#plan {
  position: absolute;
  inset: 0;
  display: block;
  touch-action: none;
}

#plan:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ---- buttons ---------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 11px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  white-space: nowrap;
}

.btn svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.btn-quiet {
  border-color: var(--line);
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.btn-quiet:hover {
  border-color: #cbc2b3;
  background: #fdfbf7;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(20, 70, 60, 0.25);
}

.btn-primary:hover {
  background: var(--accent-ink);
}

.btn-danger {
  border-color: #e7d2cb;
  background: #fff;
  color: var(--warn);
}

.btn-danger:hover {
  background: var(--warn-soft);
}

.btn-sm {
  padding: 6px 9px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

.btn-row {
  display: flex;
  gap: 8px;
}

.btn-row .btn {
  flex: 1 1 0;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-muted);
}

.icon-btn:hover {
  background: var(--paper-sunken);
  color: var(--ink);
}

.icon-btn svg {
  width: 15px;
  height: 15px;
}

.icon-btn-sm {
  width: 24px;
  height: 24px;
}

.icon-btn-sm svg {
  width: 13px;
  height: 13px;
}

.icon-only svg {
  width: 15px;
  height: 15px;
}

/* ---- sections --------------------------------------------------------- */

.section {
  border-bottom: 1px solid var(--line-soft);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 16px 9px;
}

.section-head h2 {
  margin: 0;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.section-note {
  font-size: 11px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.section-body {
  padding: 0 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.section-grow .section-body {
  gap: 9px;
}

.empty {
  margin: 4px 0;
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.5;
}

/* ---- form controls ---------------------------------------------------- */

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

.field-row-tight {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  flex: 1 1 auto;
  min-width: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.field-label {
  font-size: 10.5px;
  color: var(--ink-muted);
  font-weight: 500;
}

.input-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 34px;
  padding: 0 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  padding: 0;
}

.input-number {
  height: 34px;
  min-width: 0;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.input-number:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field .input-number {
  width: 100%;
}

.input-number::-webkit-outer-spin-button,
.input-number::-webkit-inner-spin-button {
  margin: 0;
  opacity: 0.35;
}

.select {
  appearance: none;
  height: 34px;
  padding: 0 30px 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff
    url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='%238a8175' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E")
    no-repeat right 9px center / 10px 7px;
  font-size: 12.5px;
  width: 100%;
}

.select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.select-sm {
  height: 32px;
  padding-left: 7px;
  font-size: 12px;
}

.select-wrap {
  display: flex;
}

.unit {
  font-size: 11px;
  color: var(--ink-muted);
  flex: 0 0 auto;
}

.search-wrap {
  display: flex;
}

.search-input {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  font-size: 13px;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.brand-select {
  height: 32px;
  font-size: 12px;
}

/* ---- doors ------------------------------------------------------------ */

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

.door-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.door-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: #fff;
}

.door-row.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.door-row .select {
  flex: 1 1 auto;
  height: 30px;
}

.door-row .input-number {
  width: 58px;
  height: 30px;
  flex: 0 0 auto;
}

/* ---- work rows -------------------------------------------------------- */

.section-help {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ink-muted);
}

.service-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.service-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 9px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: #fff;
}

.service-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1 1 auto;
}

.service-name {
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.25;
}

.service-meta {
  font-size: 10.5px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.service-qty {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
}

.service-qty .input-number {
  width: 64px;
  height: 30px;
  text-align: right;
}

/* ---- catalog ---------------------------------------------------------- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.chip {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-soft);
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.chip:hover {
  border-color: #cbc2b3;
  color: var(--ink);
}

.chip.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #f7f3ec;
}

.product-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0 -6px;
}

.product {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.product:hover {
  background: #fff;
  border-color: var(--line);
  box-shadow: var(--shadow-soft);
}

.product:active {
  transform: translateY(0.5px);
}

.thumb {
  width: 44px;
  height: 44px;
  border-radius: 9px;
  border: 1px solid var(--line-soft);
  background: #fff;
}

.thumb-lg {
  width: 46px;
  height: 46px;
}

.product-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.product-brand {
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.product-name {
  font-size: 13px;
  font-weight: 550;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-meta {
  font-size: 11px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.product-price {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-size: 12px;
  font-weight: 550;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.product-unit {
  font-size: 10px;
  font-weight: 400;
  color: var(--ink-muted);
}

.badge {
  font-size: 9.5px;
  font-weight: 550;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 1px 6px;
  white-space: nowrap;
}

/* ---- inspector -------------------------------------------------------- */

.inspector {
  position: relative;
  z-index: 4;
  margin: 0 12px 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-float);
}

.inspector-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.inspector-heading {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1 1 auto;
}

.inspector-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inspector-hint {
  margin: 0;
  font-size: 11.5px;
  color: var(--ink-muted);
  line-height: 1.45;
}

.inspector-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inspector-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.inspector-actions .btn {
  flex: 1 1 auto;
}

.inspector-issue {
  margin: 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--warn);
  background: var(--warn-soft);
  border-radius: 7px;
  padding: 6px 8px;
}

/* ---- stage tools ------------------------------------------------------ */

.tools {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 4px;
  background: rgba(252, 250, 246, 0.94);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-float);
}

.tool {
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 28px;
  padding: 0 5px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  transition: background 0.12s ease, color 0.12s ease;
}

.tool svg {
  width: 17px;
  height: 17px;
}

.tool:hover {
  background: var(--paper-sunken);
  color: var(--ink);
}

.tool.is-on {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.tool:disabled {
  opacity: 0.3;
  cursor: default;
  background: transparent;
}

.zoom-label {
  min-width: 46px;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  font-weight: 550;
  letter-spacing: -0.01em;
}

.tools-sep {
  width: 1px;
  height: 17px;
  background: var(--line);
  margin: 0 3px;
}

.placing-banner {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 7;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 24px);
  padding: 8px 10px 8px 12px;
  background: var(--ink);
  color: #f7f3ec;
  border-radius: 999px;
  box-shadow: var(--shadow-float);
  font-size: 12px;
}

.placing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6fd0bd;
  flex: 0 0 auto;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 1;
  }
}

.placing-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.placing-cancel {
  border: 1px solid rgba(247, 243, 236, 0.28);
  background: transparent;
  color: #f7f3ec;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.placing-cancel:hover {
  background: rgba(247, 243, 236, 0.12);
}

/* ---- summary ---------------------------------------------------------- */

.summary {
  overflow: hidden;
}

.summary-head {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--line-soft);
}

.summary-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.summary-warning {
  flex: 0 0 auto;
  margin: 10px 12px 0;
  padding: 7px 9px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--warn);
  background: var(--warn-soft);
  border-radius: 8px;
}

.summary-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.summary-empty {
  padding: 20px 8px;
  text-align: center;
}

.empty-title {
  margin: 0 0 4px;
  font-size: 12.5px;
  font-weight: 600;
}

.empty-text {
  margin: 0;
  font-size: 11.5px;
  color: var(--ink-muted);
  line-height: 1.5;
}

.group {
  display: flex;
  flex-direction: column;
}

.group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 0 6px 5px;
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.group-total {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  text-transform: none;
}

.line {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: baseline;
  width: 100%;
  padding: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  text-align: left;
}

.line:hover {
  background: #fff;
  border-color: var(--line-soft);
}

.line-qty {
  font-size: 10.5px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.line-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.line-name {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.line-brand {
  font-size: 10px;
  color: var(--ink-muted);
}

.line-total {
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

.summary-note {
  margin: 0 6px;
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--ink-muted);
}

.summary-footer {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 12px 14px 14px;
  background: #fff;
  border-top: 1px solid var(--line);
}

.total {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.total-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 11.5px;
  color: var(--ink-muted);
}

.total-line-big {
  font-size: 13px;
  color: var(--ink);
  font-weight: 550;
  align-items: center;
  margin-top: 2px;
}

.total-value {
  font-size: 23px;
  font-weight: 650;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
}

.total-count {
  font-variant-numeric: tabular-nums;
}

.fineprint {
  margin: 3px 0 0;
  font-size: 10px;
  line-height: 1.45;
  color: var(--ink-muted);
}

/* ---- overlays --------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 14px);
  z-index: 50;
  max-width: min(460px, calc(100vw - 32px));
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--ink);
  color: #f7f3ec;
  font-size: 12.5px;
  line-height: 1.4;
  box-shadow: var(--shadow-float);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast[data-tone="error"] {
  background: #7f2c1b;
}

.boot-error {
  position: fixed;
  inset: auto 16px 16px 16px;
  z-index: 60;
  padding: 12px 14px;
  border-radius: 10px;
  background: #7f2c1b;
  color: #fff;
  font-size: 12.5px;
}

/* ---- responsive ------------------------------------------------------- */

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 312px minmax(280px, 1fr) 300px;
  }
  .brand-product {
    display: none;
  }
  .brand-sep {
    display: none;
  }
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }
  .app {
    height: auto;
    min-height: 100dvh;
  }
  .topbar-inner {
    flex-wrap: wrap;
    padding: 8px 0;
    gap: 8px 12px;
  }
  .project-fields {
    order: 3;
    flex-basis: 100%;
  }
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(380px, 58vh) auto auto;
  }
  .stage {
    order: 1;
  }
  .panel-left {
    order: 2;
    border-right: 0;
    border-top: 1px solid var(--line);
    max-height: none;
  }
  .panel-right {
    order: 3;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .panel-inner {
    overflow: visible;
  }
  .summary-list {
    overflow: visible;
  }
  .inspector {
    position: static;
  }
  .tools {
    top: 8px;
    right: 8px;
  }
}
