.ph-takeoff {
  --takeoff-ink: #172033;
  --takeoff-muted: #64748b;
  --takeoff-line: #d9e1ec;
  --takeoff-surface: #ffffff;
  --takeoff-soft: #f6f8fc;
  --takeoff-accent: #3157d5;
  --takeoff-danger: #b42318;
  color: var(--takeoff-ink);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.ph-takeoff *,
.ph-takeoff *::before,
.ph-takeoff *::after { box-sizing: border-box; }

.ph-takeoff-shell {
  overflow: hidden;
  border: 1px solid var(--takeoff-line);
  border-radius: 22px;
  background: var(--takeoff-surface);
  box-shadow: 0 18px 50px rgba(45, 61, 100, .12);
}

.ph-takeoff-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--takeoff-line);
  background: linear-gradient(135deg, #f7f9ff, #eef7ff);
}

.ph-takeoff-header h2,
.ph-takeoff-sidebar h3 { margin: 0; }
.ph-takeoff-header h2 { font-size: clamp(24px, 4vw, 36px); letter-spacing: -.035em; }
.ph-takeoff-eyebrow { margin: 0 0 3px; color: var(--takeoff-accent); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.ph-takeoff-warning { max-width: 560px; margin: 0; padding: 12px 14px; border: 1px solid #f7c873; border-radius: 13px; background: #fffbeb; color: #704b09; }

.ph-takeoff-sourcebar,
.ph-takeoff-toolbar,
.ph-takeoff-calibration,
.ph-takeoff-category-add,
.ph-takeoff-export {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
}

.ph-takeoff-sourcebar { padding: 12px 16px; border-bottom: 1px solid var(--takeoff-line); background: #fff; }
.ph-takeoff-sourcebar label,
.ph-takeoff-calibration label,
.ph-takeoff-sidebar label { display: grid; gap: 5px; color: var(--takeoff-muted); font-size: 12px; font-weight: 700; }

.ph-takeoff-file {
  display: inline-flex !important;
  cursor: pointer;
  border-radius: 10px;
  padding: 9px 12px;
  background: var(--takeoff-accent);
  color: #fff !important;
}
.ph-takeoff-file-secondary { background: #475569; }
.ph-takeoff-file input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.ph-takeoff button,
.ph-takeoff select,
.ph-takeoff input {
  min-height: 36px;
  border: 1px solid var(--takeoff-line);
  border-radius: 9px;
  background: #fff;
  color: var(--takeoff-ink);
  font: inherit;
}
.ph-takeoff select,
.ph-takeoff input { padding: 7px 9px; }
.ph-takeoff button { cursor: pointer; padding: 7px 11px; font-weight: 750; }
.ph-takeoff button:hover { border-color: #9badc6; background: #f8faff; }
.ph-takeoff button:focus-visible,
.ph-takeoff select:focus-visible,
.ph-takeoff input:focus-visible,
.ph-takeoff canvas:focus-visible { outline: 3px solid rgba(49, 87, 213, .28); outline-offset: 2px; }
.ph-takeoff button:disabled { cursor: not-allowed; opacity: .48; }
.ph-takeoff button.is-active,
.ph-takeoff .ph-takeoff-primary { border-color: var(--takeoff-accent); background: var(--takeoff-accent); color: #fff; }

.ph-takeoff-workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); min-height: 620px; }
.ph-takeoff-main { min-width: 0; background: var(--takeoff-soft); }
.ph-takeoff-toolbar { padding: 11px 14px; border-bottom: 1px solid var(--takeoff-line); background: #fff; }
.ph-takeoff-calibration { padding: 11px 14px; border-bottom: 1px solid var(--takeoff-line); background: #f8fbff; }
.ph-takeoff-calibration input { width: 120px; }
.ph-takeoff-calibration [data-role="scale-summary"] { color: #075985; font-weight: 750; }

.ph-takeoff-canvas-wrap {
  position: relative;
  min-height: 480px;
  max-height: 72vh;
  overflow: auto;
  padding: 18px;
  background-color: #dbe3ee;
  background-image: linear-gradient(45deg, rgba(255,255,255,.35) 25%, transparent 25%), linear-gradient(-45deg, rgba(255,255,255,.35) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(255,255,255,.35) 75%), linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.35) 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}
.ph-takeoff canvas { display: block; width: 100%; height: auto; margin: auto; cursor: crosshair; background: #fff; box-shadow: 0 8px 24px rgba(15, 23, 42, .18); touch-action: none; }
.ph-takeoff-empty { display: grid; min-height: 440px; place-items: center; padding: 30px; color: var(--takeoff-muted); text-align: center; }
.ph-takeoff-empty[hidden] { display: none; }
.ph-takeoff-help { margin: 0; padding: 10px 15px; border-top: 1px solid var(--takeoff-line); background: #fff; color: var(--takeoff-muted); }

.ph-takeoff-sidebar { overflow: auto; border-left: 1px solid var(--takeoff-line); background: #fff; }
.ph-takeoff-sidebar section { display: grid; gap: 10px; padding: 16px; border-bottom: 1px solid var(--takeoff-line); }
.ph-takeoff-sidebar h3 { font-size: 15px; }
.ph-takeoff-sidebar p { margin: 0; color: var(--takeoff-muted); font-size: 12px; }
.ph-takeoff-category-add { display: grid; grid-template-columns: minmax(0, 1fr) 42px auto; }
.ph-takeoff-category-add input[type="color"] { width: 42px; padding: 3px; }

.ph-takeoff-total { display: grid; gap: 2px; padding: 8px 0; border-bottom: 1px dashed var(--takeoff-line); }
.ph-takeoff-total:last-child { border-bottom: 0; }
.ph-takeoff-total strong { padding-left: 8px; border-left: 4px solid; }
.ph-takeoff-total span { color: var(--takeoff-muted); font-size: 12px; }
.ph-takeoff-measurements { display: grid; gap: 6px; max-height: 270px; overflow: auto; }
.ph-takeoff-measurements > button { display: grid; grid-template-columns: 11px minmax(0, 1fr); gap: 8px; width: 100%; height: auto; text-align: left; }
.ph-takeoff-measurements > button.is-selected { border-color: var(--takeoff-accent); background: #eef3ff; }
.ph-takeoff-measurements > button span:nth-child(2) { display: grid; min-width: 0; }
.ph-takeoff-measurements strong,
.ph-takeoff-measurements small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ph-takeoff-measurements small { color: var(--takeoff-muted); font-weight: 500; }
.ph-takeoff-swatch { width: 10px; height: 10px; margin-top: 5px; border-radius: 50%; }

.ph-takeoff-status { min-height: 40px; margin: 0; padding: 10px 16px; background: #f8fafc; color: var(--takeoff-muted); }
.ph-takeoff-status[data-tone="success"] { color: #166534; }
.ph-takeoff-status[data-tone="error"] { color: var(--takeoff-danger); }
.ph-takeoff[data-busy="true"] .ph-takeoff-canvas-wrap { opacity: .68; pointer-events: none; }

@media (max-width: 880px) {
  .ph-takeoff-header { display: grid; }
  .ph-takeoff-workspace { grid-template-columns: 1fr; }
  .ph-takeoff-sidebar { border-top: 1px solid var(--takeoff-line); border-left: 0; }
  .ph-takeoff-canvas-wrap { min-height: 360px; padding: 10px; }
  .ph-takeoff-empty { min-height: 340px; }
}

@media (prefers-reduced-motion: reduce) {
  .ph-takeoff * { scroll-behavior: auto !important; transition: none !important; }
}
