:root {
  --panel-green: #006b39;
  --panel-green-dark: #004f2c;
  --accent-orange: #f37021;
  --paper: #f8faf7;
  --ink: #17201b;
  --muted: #66736c;
  --line: rgba(16, 24, 20, 0.16);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  min-height: 100vh;
}

.plan-area {
  min-width: 0;
  padding: clamp(18px, 2vw, 32px);
}

.map-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.map-actions {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.draw-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.color-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.color-picker input {
  width: 32px;
  height: 26px;
  padding: 0;
  border: 0;
  background: transparent;
}

.draw-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
  padding: 0 10px;
  font-size: 13px;
  font-weight: 800;
}

.draw-button.is-primary {
  border-color: var(--panel-green);
  background: var(--panel-green);
  color: #ffffff;
}

.draw-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.zoom-level {
  display: inline-flex;
  min-width: 54px;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.draw-status {
  max-width: 480px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-align: right;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--panel-green);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 3vw, 48px);
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1;
}

.floor-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.floor-tab {
  min-width: 46px;
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.floor-tab.is-active {
  background: var(--panel-green);
  color: #ffffff;
}

.plans-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  justify-items: center;
  gap: clamp(10px, 1.4vw, 24px);
  min-height: calc(100vh - 118px);
}

.plan-board {
  position: relative;
  width: min(100%, calc((100vh - 124px) * 0.707));
  aspect-ratio: 3182 / 4500;
  transition: opacity 180ms ease, transform 180ms ease;
}

.plan-board img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 1;
  user-select: none;
}

.plans-grid[data-focus="first"] .plan-board[data-floor="b1"],
.plans-grid[data-focus="b1"] .plan-board[data-floor="first"] {
  opacity: 0.3;
  transform: scale(0.985);
}

.zone-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.zone-shape {
  pointer-events: auto;
  cursor: pointer;
  fill: var(--zone-color);
  fill-opacity: 0.12;
  stroke: var(--zone-color);
  stroke-width: 0.35;
  stroke-opacity: 0.55;
  transition: fill-opacity 140ms ease, stroke-opacity 140ms ease, stroke-width 140ms ease;
}

.zone-shape:hover,
.zone-shape:focus-visible {
  fill-opacity: 0.24;
  stroke-opacity: 0.95;
  outline: none;
}

.zone-shape.is-selected {
  fill-opacity: 0.32;
  stroke-opacity: 1;
  stroke-width: 0.55;
}

body.is-drawing-zone .zone-overlay {
  cursor: crosshair;
}

body.is-drawing-zone .zone-shape {
  pointer-events: none;
}

.drawing-line {
  fill: none;
  stroke: var(--zone-color);
  stroke-width: 0.7;
  stroke-dasharray: 1.8 1.2;
  stroke-linejoin: round;
}

.drawing-point {
  fill: #ffffff;
  stroke: var(--zone-color);
  stroke-width: 0.5;
}

.edit-point {
  cursor: grab;
  fill: #ffffff;
  stroke: var(--zone-color);
  stroke-width: 0.55;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.32));
  pointer-events: auto;
}

.edit-point:active,
body.is-editing-point .edit-point {
  cursor: grabbing;
}

.floor-label {
  position: absolute;
  left: 14px;
  bottom: 14px;
  padding: 7px 10px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.budget-panel {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 34px 24px 28px;
  background: var(--panel-green);
  color: #ffffff;
  box-shadow: -18px 0 46px rgba(0, 46, 24, 0.18);
}

.brand-lockup {
  width: min(280px, 88%);
  margin: 0 auto 26px;
}

.brand-lockup img {
  display: block;
  width: 100%;
  height: auto;
}

.total-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 18px;
}

.total-card span {
  font-size: 25px;
}

.total-card output {
  display: inline-flex;
  min-width: 214px;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border-radius: var(--radius);
  background: #ffffff;
  color: #030303;
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
}

.panel-tools {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  gap: 8px;
  margin-bottom: 10px;
}

.tool-button {
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-weight: 800;
}

.tool-button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.add-zone {
  margin-bottom: 14px;
}

.add-zone-toggle {
  display: flex;
  width: 100%;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  font-weight: 800;
}

.add-zone-toggle span:first-child {
  display: inline-flex;
  width: 24px;
  height: 24px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #ffffff;
  color: var(--panel-green);
  line-height: 1;
}

.add-zone-form {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  padding: 10px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.12);
}

.add-zone-form[hidden] {
  display: none;
}

.add-zone-form label {
  display: grid;
  gap: 4px;
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
}

.add-zone-form input {
  min-height: 36px;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: var(--radius);
  background: #ffffff;
  color: #111111;
  padding: 4px 10px;
}

.add-zone-form button {
  min-height: 36px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent-orange);
  color: #ffffff;
  font-weight: 800;
}

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

.zone-card {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 12px 24px rgba(0, 37, 20, 0.16);
  overflow: hidden;
}

.zone-card.is-open {
  border-color: rgba(243, 112, 33, 0.8);
}

.zone-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 116px 32px;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: 7px 8px 7px 10px;
}

.zone-title {
  display: grid;
  grid-template-columns: 18px 14px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.zone-select {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  width: 18px;
  min-height: 36px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.zone-arrow {
  flex: 0 0 auto;
  width: 0;
  height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 11px solid var(--accent-orange);
  transition: transform 160ms ease;
}

.zone-card.is-open .zone-arrow {
  transform: rotate(90deg);
}

.zone-swatch {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border: 1px solid rgba(16, 24, 20, 0.18);
  border-radius: 50%;
  background: var(--zone-color);
}

.zone-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 15px;
  font-weight: 700;
}

.zone-name-input {
  min-width: 0;
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  padding: 2px 4px;
  font-size: 15px;
  font-weight: 800;
}

.zone-name-input:focus {
  border-color: rgba(16, 24, 20, 0.28);
  background: #ffffff;
  outline: 2px solid rgba(243, 112, 33, 0.18);
}

.delete-zone-button {
  display: inline-flex;
  width: 32px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(16, 24, 20, 0.16);
  border-radius: 6px;
  background: #ffffff;
  color: #b3261e;
}

.delete-zone-button:hover {
  border-color: rgba(179, 38, 30, 0.38);
  background: #fff1ef;
}

.delete-zone-button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.money-input {
  width: 100%;
  min-height: 36px;
  border: 1px solid rgba(16, 24, 20, 0.52);
  border-radius: 0;
  background: #ffffff;
  color: #111111;
  text-align: right;
  padding: 3px 8px;
  font-size: 20px;
  line-height: 1;
}

.zone-summary > .money-input {
  padding: 3px 6px;
  font-size: 18px;
}

.money-input:focus {
  border-color: var(--accent-orange);
  outline: 2px solid rgba(243, 112, 33, 0.2);
}

.zone-detail {
  display: grid;
  gap: 6px;
  padding: 0 8px 10px;
  background: #e5e5e5;
}

.line-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px 30px;
  align-items: center;
  gap: 8px;
}

.line-label {
  min-width: 0;
  overflow-wrap: anywhere;
  color: #111111;
  font-size: 14px;
}

.line-label-input {
  min-width: 0;
  min-height: 28px;
  border: 1px solid rgba(16, 24, 20, 0.28);
  background: #ffffff;
  color: #111111;
  padding: 2px 6px;
  font-size: 13px;
}

.line-item .money-input {
  min-height: 28px;
  padding: 2px 6px;
  background: #d7d7d7;
  font-size: 13px;
}

.delete-line-button {
  display: inline-flex;
  width: 30px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(16, 24, 20, 0.16);
  border-radius: 5px;
  background: #ffffff;
  color: #b3261e;
}

.delete-line-button:hover {
  border-color: rgba(179, 38, 30, 0.38);
  background: #fff1ef;
}

.delete-line-button svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.add-line-button {
  min-height: 32px;
  border: 1px dashed rgba(16, 24, 20, 0.32);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.54);
  color: var(--panel-green);
  font-size: 13px;
  font-weight: 800;
}

.add-line-button:hover {
  border-color: var(--panel-green);
  background: #ffffff;
}

.empty-state {
  display: grid;
  gap: 5px;
  padding: 18px;
  border: 1px dashed rgba(255, 255, 255, 0.45);
  border-radius: var(--radius);
  color: #ffffff;
  text-align: center;
}

.empty-state strong {
  font-size: 18px;
}

.empty-state span {
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
}

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

  .budget-panel {
    position: relative;
    height: auto;
  }

  .plans-grid {
    min-height: 0;
  }
}

@media (max-width: 820px) {
  .map-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .map-actions,
  .floor-tabs {
    align-self: start;
    justify-items: start;
  }

  .draw-tools {
    justify-content: flex-start;
  }

  .draw-status {
    text-align: left;
  }

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

  .plan-board {
    width: min(100%, 560px);
  }

  .budget-panel {
    padding: 28px 16px;
  }
}

@media (max-width: 430px) {
  .zone-summary {
    grid-template-columns: 1fr;
  }

  .line-item {
    grid-template-columns: 1fr;
  }

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

  .total-card output {
    width: 100%;
    min-width: 0;
    font-size: 30px;
  }
}
