:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #182033;
  background: #eef2f8;
  --green: #2457d6;
  --green-dark: #1b45ac;
  --green-soft: #eff3fc;
  --line: #e1e6f0;
  --muted: #707a8b;
  --surface: #ffffff;
  --canvas: #f5f7fb;
  --danger: #a33b34;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--canvas);
}

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

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  position: relative;
  z-index: 5;
}

.brand-block, .topbar-actions { display: flex; align-items: center; gap: 14px; }
.brand { font-size: 23px; font-weight: 800; letter-spacing: -0.055em; color: #182033; }
.brand-divider { width: 1px; height: 24px; background: #d9deea; }
.product-name { color: #657083; font-size: 14px; }

.button {
  min-height: 39px;
  padding: 0 15px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 650;
  transition: 150ms ease;
  white-space: nowrap;
}

.button.primary { color: white; background: var(--green); }
.button.primary:hover { background: var(--green-dark); }
.button.secondary { color: var(--green); background: var(--green-soft); border-color: #dbe3f6; }
.button.secondary:hover { background: #e5ebf8; }
.button.ghost { color: #465065; background: white; border-color: #d9deea; }
.button.ghost:hover { background: #f3f5fa; }
.button:disabled { cursor: not-allowed; opacity: .55; }

.save-status {
  padding-left: 15px;
  color: #7b8493;
  font-size: 12px;
  position: relative;
}

.save-status::before {
  content: "";
  position: absolute;
  left: 0;
  top: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #adb5c2;
}

.save-status.saved::before { background: #5178da; }
.save-status.saving::before { background: #d59d3a; }
.save-status.dirty::before { background: #818b9c; }
.save-status.error { color: var(--danger); }
.save-status.error::before { background: var(--danger); }

.workspace {
  height: calc(100vh - 64px);
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(640px, 3fr) minmax(390px, 2fr);
  overflow: hidden;
}

.builder-pane {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
  background: var(--canvas);
  border-right: 1px solid var(--line);
  transition: box-shadow 300ms ease;
}

.builder-pane.updated { box-shadow: inset 0 0 0 3px rgba(36, 87, 214, .15); }
.builder-scroll { min-height: 0; overflow-y: auto; padding: 30px 32px 42px; }

.project-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 30px;
}

.eyebrow {
  margin-bottom: 5px;
  color: #858e9d;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.project-name {
  width: min(540px, 70vw);
  min-height: 0;
  padding: 0;
  resize: none;
  overflow: hidden;
  color: #182033;
  background: transparent;
  border: 0;
  border-bottom: 1px solid transparent;
  outline: none;
  font-size: clamp(27px, 3vw, 38px);
  font-weight: 760;
  line-height: 1.08;
  letter-spacing: -.045em;
}

.project-name.compact { font-size: clamp(23px, 2.4vw, 31px); }
.project-name.dense { font-size: clamp(18px, 1.9vw, 24px); }
.project-name:focus { border-bottom-color: #a8b2c3; }
.camera-count-badge { padding: 7px 11px; color: #576174; background: white; border: 1px solid var(--line); border-radius: 999px; font-size: 12px; white-space: nowrap; }

.builder-section {
  margin-bottom: 22px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 7px 24px rgba(30, 45, 80, .04);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 20px;
}

.section-heading > div { position: relative; padding-left: 39px; }
.section-heading h2 { margin: 0; font-size: 18px; letter-spacing: -.02em; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.step-number { position: absolute; left: 0; top: 1px; color: #7e9be3; font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.section-heading.compact { margin-bottom: 12px; }

.models-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); align-items: start; gap: 12px; }
.model-card { min-width: 0; padding: 15px; background: #fbfcff; border: 1px solid #e3e8f2; border-radius: 14px; }
.model-card-top { display: flex; gap: 12px; align-items: flex-start; }
.model-icon { width: 38px; height: 38px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 11px; color: #2b57b9; background: #edf2fc; font-size: 10px; font-weight: 850; letter-spacing: -.02em; }
.model-icon.audio { color: #684b19; background: #f8edda; }
.model-icon.frame_classifier { color: #4e4777; background: #ebe9f7; }
.model-info { min-width: 0; }
.model-type { display: block; margin-bottom: 2px; color: #858e9d; font-size: 10px; }
.model-info h3 { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.model-info p { margin: 4px 0 0; color: #697486; font-size: 11px; line-height: 1.4; overflow-wrap: anywhere; }
.model-description { display: -webkit-box; max-height: 5.6em; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 4; }
.model-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.model-metric { padding: 9px 10px; background: white; border: 1px solid #e7eaf1; border-radius: 9px; }
.model-metric span { display: block; color: #8c94a2; font-size: 9px; }
.model-metric strong { display: block; margin-top: 2px; color: #182033; font-size: 12px; }
.price-tooltip-target { cursor: help; outline: none; }
.price-tooltip-target:focus-visible { box-shadow: 0 0 0 2px rgba(36, 87, 214, .18); }
.card-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 10px; }
.text-button { padding: 0; color: #49659f; background: none; border: 0; font-size: 10px; }
.text-button:hover { color: var(--green); }
.danger { color: var(--danger) !important; }

.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; min-height: 116px; padding: 22px; color: #7b8595; background: #fafbfe; border: 1px dashed #d9dfeb; border-radius: 12px; text-align: center; }
.empty-state strong { color: #515b6d; font-size: 13px; }
.empty-state span { max-width: 420px; font-size: 11px; line-height: 1.5; }
.model-empty { grid-column: 1 / -1; }

.section-subtotal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #e7eaf1;
}
.section-subtotal > span, .section-subtotal > div > span { color: #707a8b; font-size: 11px; }
.section-subtotal > strong { color: #182033; font-size: 16px; letter-spacing: -.02em; white-space: nowrap; }
.camera-subtotal > div { display: flex; flex-direction: column; gap: 3px; }
.camera-subtotal small { color: #929aa8; font-size: 9px; }
.camera-subtotal small strong { color: #667184; }

.table-wrap { overflow-x: auto; border: 1px solid #e2e6ef; border-radius: 12px; }
.camera-table { width: 100%; min-width: 640px; border-collapse: collapse; table-layout: fixed; }
.camera-table th:nth-child(1) { width: 18%; }
.camera-table th:nth-child(2) { width: 17%; }
.camera-table th:nth-child(3) { width: 24%; }
.camera-table th:nth-child(4) { width: 17%; }
.camera-table th:nth-child(5) { width: 15%; }
.camera-table th:nth-child(6) { width: 9%; }
.camera-table th { padding: 11px 12px; color: #848d9c; background: #f7f9fc; border-bottom: 1px solid #e1e6ef; font-size: 9px; font-weight: 750; letter-spacing: .04em; text-align: left; text-transform: uppercase; }
.camera-table td { padding: 14px 12px; border-bottom: 1px solid #eaedf3; vertical-align: middle; font-size: 12px; }
.camera-table tr:last-child td { border-bottom: 0; }
.camera-table tbody tr:hover { background: #fafbfe; }
.price-column { text-align: right !important; }
.price-cell { color: #182033; font-weight: 750; text-align: right; white-space: nowrap; }
.group-name { display: block; max-width: 170px; overflow-wrap: anywhere; }
.group-id { display: block; max-width: 145px; margin-top: 3px; color: #99a1ae; font-size: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quantity-column { text-align: center !important; }
.quantity-stepper { display: inline-grid; grid-template-columns: 27px minmax(30px, auto) 27px; align-items: center; overflow: hidden; border: 1px solid #dce3f3; border-radius: 9px; }
.quantity-button { width: 27px; height: 28px; padding: 0; color: #3159b8; background: #f3f6fc; border: 0; font-size: 15px; line-height: 1; }
.quantity-button:hover:not(:disabled) { background: #e7ecf8; }
.quantity-button:disabled { cursor: not-allowed; color: #b2b8c2; }
.quantity-value { min-width: 30px; padding-inline: 4px; font-weight: 750; text-align: center; }
.stacked-value { display: flex; flex-direction: column; gap: 2px; }
.stacked-value span { color: #788293; font-size: 10px; }
.stacked-value .audio-label { color: #8a641e; }
.model-tags { display: flex; flex-wrap: wrap; gap: 5px; max-width: 230px; }
.model-tag { padding: 4px 7px; color: #3458a7; background: #eff3fc; border-radius: 6px; font-size: 9px; }
.muted { color: #9aa2af; }
.row-actions { display: flex; gap: 3px; justify-content: flex-end; }
.icon-button { width: 34px; height: 34px; padding: 0; color: #636d7e; background: transparent; border: 1px solid transparent; border-radius: 9px; font-size: 20px; line-height: 1; }
.icon-button:hover { background: #eff2f7; border-color: #e2e6ee; }
.icon-button.small { width: 26px; height: 26px; font-size: 13px; }
.table-empty { min-width: 0; border: 0; border-radius: 0; }

.total-bar {
  display: grid;
  grid-template-columns: minmax(180px, 1.3fr) minmax(100px, .7fr) minmax(120px, .8fr) auto;
  align-items: center;
  gap: 22px;
  padding: 16px 32px;
  background: rgba(255, 255, 255, .96);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 30px rgba(25, 55, 125, .06);
  backdrop-filter: blur(12px);
}

.total-metric span { display: block; color: #788293; font-size: 10px; }
.total-metric strong { display: block; margin-top: 2px; color: #182033; font-size: 18px; letter-spacing: -.025em; }
.total-metric small { display: block; margin-top: 2px; color: #98a0ad; font-size: 8px; }
.primary-total strong { color: #182033; font-size: 21px; }
.muted-metric strong { font-size: 15px; }
.pay-button { min-height: 45px; padding-inline: 20px; }

.chat-pane { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; background: white; }
.chat-header { padding: 19px 22px 16px; border-bottom: 1px solid var(--line); }
.assistant-title { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 750; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #5178da; box-shadow: 0 0 0 4px #eaf0fc; }
.chat-header p { margin: 5px 0 0 16px; color: #828b9a; font-size: 10px; }
.messages { min-height: 0; overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 12px; background: linear-gradient(180deg, #fafbff, #fff 26%); }
.message { max-width: 88%; padding: 11px 13px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.48; font-size: 12px; }
.message.user { align-self: flex-end; color: white; background: var(--green); border-bottom-right-radius: 4px; }
.message.assistant { align-self: flex-start; color: #273249; background: #f0f4ff; border: 1px solid #dfe6f8; border-bottom-left-radius: 4px; }
.message.loading { color: #7d8695; }
.message.error { color: #913a34; background: #fff0ef; border-color: #f0d5d2; }
.welcome-message { max-width: 94%; }
.composer { padding: 14px 18px 17px; border-top: 1px solid var(--line); background: white; }
.chat-form { display: flex; align-items: flex-end; gap: 8px; }
.chat-form textarea { flex: 1; min-height: 46px; max-height: 150px; resize: none; padding: 12px 13px; color: #1d2638; background: #f8faff; border: 1px solid #dce2ef; border-radius: 12px; outline: none; line-height: 1.45; overflow-y: hidden; font-size: 12px; }
.chat-form textarea:focus { border-color: #7e9be3; box-shadow: 0 0 0 3px rgba(36, 87, 214, .1); }
.send-button { width: 46px; height: 46px; flex: 0 0 auto; color: white; background: var(--green); border: 0; border-radius: 12px; font-size: 22px; }
.send-button:hover { background: var(--green-dark); }
.send-button:disabled, textarea:disabled { cursor: not-allowed; opacity: .55; }
.composer-hint { margin-top: 6px; color: #a0a7b2; font-size: 8px; text-align: right; }

.dialog { width: min(500px, calc(100vw - 28px)); padding: 0; color: #1d2638; background: white; border: 0; border-radius: 18px; box-shadow: 0 24px 90px rgba(19, 31, 58, .25); }
.dialog.wide-dialog { width: min(680px, calc(100vw - 28px)); }
.dialog::backdrop { background: rgba(17, 23, 36, .48); backdrop-filter: blur(3px); }
.dialog form { padding: 22px; }
.dialog-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.dialog-header h3 { margin: 0; font-size: 21px; letter-spacing: -.03em; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; color: #526074; font-size: 11px; font-weight: 650; }
.field input, .field select, .assignment-row select { width: 100%; min-height: 42px; padding: 0 11px; color: #242d3e; background: #f9fafe; border: 1px solid #dce2ed; border-radius: 9px; outline: none; font-weight: 450; }
.field input:focus, .field select:focus, .assignment-row select:focus { border-color: #7e9be3; box-shadow: 0 0 0 3px rgba(36, 87, 214, .1); }
.field small { color: #939ba8; font-size: 9px; font-weight: 450; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.span-two { grid-column: 1 / -1; }
.check-field { display: flex; gap: 10px; align-items: flex-start; margin: 13px 0; padding: 12px; background: #f7f9fc; border: 1px solid #e2e6ef; border-radius: 10px; cursor: pointer; }
.check-field input { margin-top: 2px; accent-color: var(--green); }
.check-field span { display: flex; flex-direction: column; gap: 2px; }
.check-field strong { font-size: 11px; }
.check-field small { color: #848e9d; font-size: 9px; }
.check-field.unavailable { background: #fafbfe; cursor: default; opacity: .76; }
.check-field.unavailable input { cursor: not-allowed; }
.compact-check { margin-top: 18px; }
.detector-fields { margin-top: 13px; }
.detector-objects-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 8px; }
.detector-objects-heading > span { display: flex; flex-direction: column; gap: 2px; }
.detector-objects-heading strong { font-size: 11px; }
.detector-objects-heading small { color: #848e9d; font-size: 9px; }
.compact-button { min-height: 30px; padding: 6px 10px; font-size: 9px; }
.detector-object-row { padding: 10px; border: 1px solid #e2e6ef; border-radius: 10px; background: #f8faff; }
.detector-object-row + .detector-object-row { margin-top: 8px; }
.detector-object-main { display: grid; grid-template-columns: minmax(0, 1fr) 30px; gap: 8px; align-items: end; }
.compact-field { margin: 0; font-size: 9px; }
.compact-field input { margin-top: 5px; }
.detector-object-remove { width: 30px; height: 34px; margin-bottom: 1px; }
.detector-attributes-section { margin-top: 10px; padding-top: 9px; border-top: 1px solid #e3e8f2; }
.detector-attributes-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 7px; color: #526074; font-size: 9px; font-weight: 650; }
.detector-attributes-list { display: flex; flex-direction: column; gap: 6px; }
.detector-attribute-row { display: grid; grid-template-columns: minmax(0, 1fr) 30px; gap: 7px; }
.detector-attribute-row input { width: 100%; min-height: 34px; padding: 0 10px; color: #242d3e; background: white; border: 1px solid #dce2ed; border-radius: 8px; outline: none; font-size: 10px; }
.detector-attribute-row input:focus { border-color: #7e9be3; box-shadow: 0 0 0 3px rgba(36, 87, 214, .1); }
.detector-attribute-remove { width: 30px; height: 34px; }
.model-features-field { margin-top: 13px; }
.model-features-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 8px; }
.model-features-heading > span { display: flex; flex-direction: column; gap: 2px; }
.model-features-heading strong { font-size: 11px; }
.model-features-heading small { color: #848e9d; font-size: 9px; }
.model-features-list { display: flex; flex-direction: column; gap: 6px; }
.model-feature-row { display: grid; grid-template-columns: minmax(0, 1fr) 30px; gap: 7px; }
.model-feature-row input { width: 100%; min-height: 38px; padding: 0 10px; color: #242d3e; background: #f9fafe; border: 1px solid #dce2ed; border-radius: 8px; outline: none; font-size: 10px; }
.model-feature-row input:focus { border-color: #7e9be3; box-shadow: 0 0 0 3px rgba(36, 87, 214, .1); }
.model-feature-remove { width: 30px; height: 38px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.assignments-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 15px; margin: 8px 0; }
.assignments-heading strong { font-size: 12px; }
.assignments-heading span { color: #87909f; font-size: 9px; }
.assignment-list { max-height: 260px; overflow-y: auto; border: 1px solid #e1e6ef; border-radius: 11px; }
.assignment-row { display: grid; grid-template-columns: auto minmax(130px, 1fr) minmax(180px, .7fr); align-items: center; gap: 10px; padding: 11px 12px; border-bottom: 1px solid #eceff4; cursor: pointer; }
.assignment-row.detector-assignment { grid-template-columns: minmax(150px, 1fr) minmax(210px, .8fr); cursor: default; }
.assignment-row:last-child { border-bottom: 0; }
.assignment-row > input { accent-color: var(--green); }
.assignment-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.assignment-info strong { font-size: 11px; overflow-wrap: anywhere; }
.assignment-info small { color: #8b94a1; font-size: 9px; }
.assignment-row select { min-height: 34px; font-size: 10px; }
.compact-empty { min-height: 80px; border: 0; }
.price-breakdown { margin-top: 16px; padding: 14px; background: #f8faff; border: 1px solid #e0e6f2; border-radius: 11px; }
.price-breakdown h4 { margin: 0 0 11px; color: #182033; font-size: 12px; }
.breakdown-section + .breakdown-section { margin-top: 13px; padding-top: 12px; border-top: 1px solid #e3e8f2; }
.breakdown-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 7px; color: #677286; font-size: 10px; }
.breakdown-heading strong { color: #182033; font-size: 12px; }
.breakdown-row + .breakdown-row { margin-top: 8px; }
.breakdown-row span, .breakdown-row small { display: block; }
.breakdown-title { color: #303a4e; font-size: 10px; line-height: 1.35; }
.breakdown-row small { margin-top: 2px; color: #7f8999; font-size: 9px; }
.breakdown-empty, .breakdown-placeholder, .breakdown-note { margin: 0; color: #8791a1; font-size: 9px; line-height: 1.45; }
.breakdown-included { display: flex; flex-direction: column; gap: 3px; margin-top: 12px; padding-top: 11px; border-top: 1px solid #e3e8f2; color: #6f798b; font-size: 9px; }
.breakdown-included strong { color: #3d485b; font-size: 10px; }
.breakdown-note { margin-top: 11px; }
.price-tooltip { position: fixed; z-index: 100; width: max-content; max-width: min(420px, calc(100vw - 20px)); padding: 10px 12px; color: white; background: #202b42; border-radius: 9px; box-shadow: 0 10px 35px rgba(12, 23, 48, .24); white-space: pre-line; pointer-events: none; font-size: 10px; line-height: 1.45; }
.hidden { display: none !important; }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 30; max-width: calc(100vw - 30px); padding: 11px 15px; color: white; background: #23345e; border-radius: 10px; box-shadow: 0 12px 35px rgba(20, 42, 92, .2); font-size: 11px; opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: 180ms ease; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #913a34; }
.mobile-tabs { display: none; }

@media (max-width: 1100px) {
  .workspace { grid-template-columns: minmax(570px, 1.5fr) minmax(340px, 1fr); }
  .builder-scroll { padding-inline: 22px; }
  .total-bar { padding-inline: 22px; gap: 14px; }
  .pay-button { padding-inline: 13px; }
}

@media (max-width: 850px) {
  .topbar { height: 58px; padding-inline: 15px; }
  .product-name, .brand-divider, .save-status { display: none; }
  .workspace { height: calc(100vh - 104px); display: block; }
  .mobile-tabs { height: 46px; display: grid; grid-template-columns: 1fr 1fr; padding: 5px; background: white; border-bottom: 1px solid var(--line); }
  .mobile-tab { color: #727c8d; background: transparent; border: 0; border-radius: 8px; font-size: 11px; font-weight: 650; }
  .mobile-tab.active { color: var(--green); background: var(--green-soft); }
  .builder-pane, .chat-pane { display: none; height: 100%; }
  .builder-pane.active { display: grid; }
  .chat-pane.active { display: grid; }
  .camera-table, .table-empty { min-width: 680px; }
  .camera-table { table-layout: auto; }
}

@media (max-width: 620px) {
  .builder-scroll { padding: 20px 12px 28px; }
  .project-heading { align-items: flex-start; margin-bottom: 20px; }
  .project-name { width: 72vw; font-size: 25px; }
  .project-name.compact { font-size: 21px; }
  .project-name.dense { font-size: 17px; }
  .builder-section { padding: 16px; border-radius: 14px; }
  .section-heading { flex-direction: column; }
  .section-heading .button { width: 100%; }
  .models-list { grid-template-columns: 1fr; }
  .section-subtotal { align-items: flex-start; }
  .total-bar { grid-template-columns: 1fr 1fr; padding: 12px; gap: 10px; }
  .muted-metric { order: 3; }
  .pay-button { order: 4; width: 100%; }
  .total-metric strong { font-size: 16px; }
  .primary-total strong { font-size: 18px; }
  .field-grid { grid-template-columns: 1fr; }
  .span-two { grid-column: auto; }
  .assignment-row { grid-template-columns: auto 1fr; }
  .assignment-row select { grid-column: 2; }
}
