:root {
  --brand: #b51224;
  --brand-dark: #8f0f1f;
  --brand-soft: #fee8eb;
  --ink: #17202b;
  --muted: #667085;
  --line: #d9e0ea;
  --panel: #ffffff;
  --bg: #f3f5f8;
  --blue: #0ea5e9;
  --orange: #f59e0b;
  --green: #10b981;
  --danger: #b42318;
  --shadow: 0 10px 30px rgba(15, 23, 42, .08);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

code {
  background: #eef2f7;
  border-radius: 4px;
  padding: 1px 4px;
}

.app-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 1120px;
}

.topbar {
  height: 64px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 18px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 4px rgba(15, 23, 42, .05);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, var(--brand), #222b38);
  letter-spacing: -.04em;
}

.brand-logo {
  background: #fff;
  border: 1px solid var(--line);
  padding: 4px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .08);
}

.brand-logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand strong {
  display: block;
  font-size: 15px;
  line-height: 1.2;
}

.brand span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.topbar-actions,
.stage-toolbar,
.zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.workspace {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 310px minmax(520px, 1fr) 350px;
}

.sidebar {
  overflow: auto;
  padding: 14px;
  background: #fff;
}

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

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

.panel {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .03);
  margin-bottom: 14px;
}

.panel-title {
  margin: -2px 0 12px;
  color: #344054;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.button,
.tool-button,
.view-tab {
  border: 1px solid transparent;
  border-radius: 9px;
  min-height: 36px;
  padding: 8px 12px;
  background: #fff;
  color: #344054;
  font-weight: 700;
  transition: background .12s, border-color .12s, transform .12s;
}

.button:hover,
.tool-button:hover,
.view-tab:hover {
  border-color: #b8c2d2;
}

.button:active,
.tool-button:active,
.view-tab:active {
  transform: translateY(1px);
}

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

.button-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

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

.button-secondary {
  background: #eef2f7;
  border-color: #e2e8f0;
}

.button-ghost {
  background: transparent;
  border-color: #e2e8f0;
}

.button-danger {
  background: #fee4e2;
  border-color: #fecdca;
  color: var(--danger);
}

.button-full {
  width: 100%;
  margin-top: 8px;
}

.view-tabs,
.tool-grid,
.action-grid,
.price-grid {
  display: grid;
  gap: 8px;
}

.view-tabs {
  grid-template-columns: 1fr;
}

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

.action-grid,
.price-grid {
  grid-template-columns: repeat(2, 1fr);
}

.view-tab {
  text-align: left;
}

.view-tab strong,
.view-tab span {
  display: block;
}

.view-tab span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.view-tab.is-active,
.tool-button.is-active {
  color: var(--brand-dark);
  background: var(--brand-soft);
  border-color: #f8b4bd;
}

.field,
.switch {
  display: block;
  margin-bottom: 10px;
}

.field > span,
.switch span {
  display: block;
  margin-bottom: 4px;
  color: #475467;
  font-size: 12px;
  font-weight: 700;
}

.switch {
  display: flex;
  align-items: center;
  gap: 8px;
}

.switch span {
  margin: 0;
}

.field input {
  width: 100%;
  height: 36px;
  padding: 7px 10px;
  border: 1px solid #cfd8e3;
  border-radius: 9px;
  background: #fff;
}

.field input:focus {
  outline: 2px solid rgba(181, 18, 36, .18);
  border-color: var(--brand);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.hint,
.empty {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.warning {
  padding: 8px;
  border-radius: 8px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 12px;
}

.upload-box {
  display: grid;
  place-items: center;
  min-height: 94px;
  padding: 14px;
  border: 1.5px dashed #b8c2d2;
  border-radius: 12px;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
}

.upload-box strong {
  display: block;
}

.upload-box span {
  color: var(--muted);
  font-size: 12px;
}

.stage-wrap {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.stage-toolbar {
  height: 48px;
  flex: 0 0 auto;
  justify-content: space-between;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.status-line {
  color: var(--muted);
  font-size: 12px;
}

.status-line.is-error {
  color: var(--danger);
}

.stage {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 18px;
  background-color: #eef2f7;
  background-image:
    linear-gradient(45deg, #e1e7ef 25%, transparent 25%),
    linear-gradient(-45deg, #e1e7ef 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e1e7ef 75%),
    linear-gradient(-45deg, transparent 75%, #e1e7ef 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}

.svg-mount {
  width: min(100%, 1240px);
  height: min(100%, 680px);
  display: grid;
  place-items: center;
}

.bus-svg {
  width: 100%;
  height: 100%;
  max-height: 660px;
  filter: drop-shadow(0 12px 22px rgba(15, 23, 42, .13));
  transform-origin: center center;
  transition: transform .12s ease-out;
}

.sponsor-area {
  fill: rgba(79, 70, 229, .14);
  stroke: #6366f1;
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
  transition: fill .12s, stroke .12s, stroke-width .12s;
  cursor: pointer;
}

.sponsor-area:hover {
  fill: rgba(181, 18, 36, .18);
  stroke: var(--brand);
  stroke-width: 2;
}

.sponsor-area.is-window {
  fill: rgba(14, 165, 233, .18);
  stroke: var(--blue);
}

.sponsor-area.is-premium {
  fill: rgba(245, 158, 11, .2);
  stroke: var(--orange);
}

.sponsor-area.is-selected {
  fill: rgba(181, 18, 36, .26);
  stroke: var(--brand);
  stroke-width: 2.5;
}

.sponsor-area.is-occupied {
  fill: rgba(16, 185, 129, .22);
  stroke: var(--green);
}

.sponsor-area.is-disabled {
  cursor: not-allowed;
  fill: rgba(148, 163, 184, .16);
  stroke: #94a3b8;
  stroke-dasharray: 5 4;
}

.area-code {
  pointer-events: none;
  fill: #293241;
  font-size: 11px;
  font-weight: 800;
  font-family: Inter, Arial, sans-serif;
}

.surface-outline {
  fill: none;
  stroke: var(--brand);
  stroke-width: 2;
  stroke-dasharray: 7 4;
  vector-effect: non-scaling-stroke;
}

.logo-item {
  cursor: move;
}

.logo-frame {
  fill: none;
  stroke: var(--brand);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
  vector-effect: non-scaling-stroke;
}

.logo-handle {
  fill: var(--brand);
  stroke: #fff;
  stroke-width: 2;
  cursor: pointer;
  vector-effect: non-scaling-stroke;
}

.logo-resize {
  cursor: nwse-resize;
}

.logo-rotate {
  cursor: grab;
}

.metric-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.metric-row div,
.total-box {
  padding: 10px;
  border-radius: 10px;
  background: #f8fafc;
}

.metric-row span,
.total-box span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.metric-row strong,
.total-box strong {
  display: block;
  margin-top: 3px;
}

.area-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.area-list li {
  padding: 8px 0;
  border-top: 1px solid #edf1f6;
}

.area-list span,
.surface-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.surface-card,
.logo-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 11px;
  margin-bottom: 8px;
  background: #fff;
}

.surface-card {
  grid-template-columns: 1fr auto;
}

.surface-price {
  color: var(--brand-dark);
  font-weight: 800;
  text-align: right;
}

.icon-button {
  border: 0;
  background: transparent;
  color: var(--danger);
  font-weight: 800;
  padding: 0;
  justify-self: start;
}

.logo-card {
  grid-template-columns: 52px 1fr auto;
  align-items: center;
}

.logo-card.is-active {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(181, 18, 36, .1);
}

.logo-thumb {
  width: 52px;
  height: 52px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}

.logo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.logo-fields label {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.logo-fields input[type="range"] {
  width: 100%;
}

.logo-fields input[type="number"] {
  width: 70px;
  height: 26px;
}

.logo-numbers {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-top: 5px;
}

.logo-numbers label {
  font-size: 10px;
}

.logo-numbers input[type="number"] {
  width: 100%;
  height: 25px;
  padding: 2px 4px;
  border: 1px solid #cfd8e3;
  border-radius: 6px;
}

.total-box {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.total-box strong {
  color: var(--brand-dark);
  font-size: 22px;
}

.print-offer {
  display: none;
}

@media (max-width: 1180px) {
  .app-shell {
    min-width: 0;
    height: auto;
  }

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

  .sidebar {
    border: 0;
  }

  .stage {
    min-height: 520px;
  }

  .topbar {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
    padding: 12px;
  }

  .topbar-actions {
    flex-wrap: wrap;
  }
}

@media print {
  body > .app-shell {
    display: none !important;
  }

  .print-offer {
    display: block;
  }

  body {
    background: #fff;
    color: #111827;
  }

  .offer-page {
    padding: 18mm;
    font-family: Arial, sans-serif;
  }

  .offer-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 2px solid var(--brand);
    padding-bottom: 10mm;
    margin-bottom: 8mm;
  }

  .offer-header h1 {
    margin: 0 0 3mm;
    color: var(--brand);
  }

  .offer-meta span {
    display: block;
    text-align: right;
  }

  .print-view {
    page-break-inside: avoid;
    margin-bottom: 7mm;
  }

  .print-svg svg {
    width: 100%;
    max-height: 90mm;
  }

  table {
    width: 100%;
    border-collapse: collapse;
    font-size: 9pt;
  }

  th,
  td {
    border-bottom: 1px solid #d1d5db;
    padding: 6px;
    text-align: left;
  }

  th {
    background: #f3f4f6;
  }

  tfoot td {
    font-weight: 800;
  }

  .price {
    text-align: right;
    font-weight: 800;
  }

  .offer-note {
    margin-top: 10mm;
    color: #6b7280;
    font-size: 8pt;
  }
}
