:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #0f172a;
  --muted: #667085;
  --muted-2: #98a2b3;
  --line: #e3e8ef;
  --line-strong: #d4dbe5;
  --accent: #6d4aff;
  --accent-2: #8b5cf6;
  --accent-soft: #f0ecff;
  --blue: #18a9ff;
  --success: #0e9f6e;
  --danger: #d92d20;
  --dark: #0a1020;
  --shadow: 0 18px 55px rgba(15, 23, 42, .08);
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% -5%, rgba(109,74,255,.08), transparent 34rem),
    radial-gradient(circle at 100% 5%, rgba(24,169,255,.07), transparent 35rem),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
.hidden { display: none !important; }
.app { min-height: 100vh; }

.appbar {
  height: 74px;
  padding: 0 max(24px, calc((100vw - 1500px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,.88);
  border-bottom: 1px solid rgba(227,232,239,.9);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 46px; height: 46px; border-radius: 14px;
  display: grid; place-items: center;
  color: white; font-size: 12px; font-weight: 900; letter-spacing: .08em;
  background: linear-gradient(135deg, #111827, #38258e 68%, #6d4aff);
  box-shadow: 0 10px 24px rgba(64,43,180,.22);
}
.brand strong { display: block; font-size: 17px; letter-spacing: -.02em; }
.brand strong span { color: var(--accent); font-size: 10px; vertical-align: 5px; margin-left: 3px; letter-spacing: .08em; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; letter-spacing: .02em; }
.privacy-pill {
  border: 1px solid #e1dafa; background: #faf8ff; color: #51468a;
  height: 36px; padding: 0 14px; border-radius: 999px;
  display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 11px;
}
.privacy-pill span { color: #18b77a; font-size: 10px; }

.shell { width: min(1500px, calc(100% - 40px)); margin: 26px auto 44px; }
.upload-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 8px 30px rgba(15,23,42,.045); overflow: hidden; margin-bottom: 18px;
}
.drop-zone {
  min-height: 92px; padding: 16px 18px;
  display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 14px;
  border: 1.5px dashed #cbd5e1; border-radius: 14px; margin: 10px;
  transition: .18s ease; background: linear-gradient(180deg, #fff, #fcfdff);
}
.drop-zone:hover, .drop-zone:focus, .drop-zone.dragover { border-color: var(--accent); background: #fbfaff; outline: none; box-shadow: 0 0 0 4px rgba(109,74,255,.07); }
.upload-icon {
  width: 50px; height: 50px; border-radius: 15px; display: grid; place-items: center;
  color: var(--accent); background: var(--accent-soft);
}
.upload-icon svg { width: 24px; height: 24px; }
.upload-copy { min-width: 0; }
.upload-copy strong { display: block; font-size: 14px; letter-spacing: -.01em; }
.upload-copy span { display: block; color: var(--muted); font-size: 11px; margin-top: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-button {
  height: 42px; padding: 0 17px; border-radius: 11px; display: flex; align-items: center;
  color: #fff; font-size: 12px; font-weight: 800; background: var(--dark); box-shadow: 0 8px 18px rgba(15,23,42,.12);
}
.file-meta {
  border-top: 1px solid var(--line); padding: 9px 17px 10px; color: #475467; background: #fbfcfe;
  font-size: 11px; font-weight: 600;
}
.file-meta.empty { color: var(--muted-2); }

.workspace { display: grid; grid-template-columns: 390px minmax(0,1fr); gap: 18px; align-items: start; }
.control-card, .viewer-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); overflow: hidden;
}
.control-card { position: sticky; top: 92px; }
.control-head, .viewer-head { padding: 19px 20px 17px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.control-head h1, .viewer-head h2 { margin: 4px 0 0; font-size: 20px; line-height: 1.1; letter-spacing: -.035em; }
.kicker { color: var(--accent); font-size: 9px; font-weight: 900; letter-spacing: .16em; }
.step-chip { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: #111827; color: white; font-size: 10px; font-weight: 900; }
.control-body { padding: 0 18px; }
.group { padding: 17px 0 5px; }
.first-group { padding-bottom: 13px; }
.field { display: block; margin-bottom: 13px; }
.field-label { display: block; margin-bottom: 7px; color: #344054; font-size: 11px; font-weight: 800; }
.field-label.split { display: flex; justify-content: space-between; align-items: center; }
.field-label.split b { color: var(--accent); font-size: 11px; }
select, input[type="text"], input[type="number"] {
  width: 100%; height: 42px; border: 1px solid var(--line-strong); border-radius: 10px; padding: 0 11px;
  color: var(--ink); background: #fff; outline: none; transition: .15s ease; font-size: 12px;
}
select:focus, input[type="text"]:focus, input[type="number"]:focus { border-color: #9b87ff; box-shadow: 0 0 0 3px rgba(109,74,255,.09); }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 42px; }
.input-suffix em { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); font-size: 10px; color: var(--muted-2); font-style: normal; pointer-events: none; }
.input-suffix.readonly input { background: #f8fafc; color: #667085; }
.field-row { display: grid; gap: 10px; }
.field-row.two { grid-template-columns: 1fr 1fr; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.range-scale { margin-top: 2px; display: flex; justify-content: space-between; color: #98a2b3; font-size: 9px; }

.settings-section { border-top: 1px solid var(--line); }
.settings-section summary { list-style: none; padding: 15px 1px; display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 850; cursor: pointer; user-select: none; }
.settings-section summary::-webkit-details-marker { display: none; }
.chevron { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 7px; background: #f5f7fa; color: #667085; transition: transform .18s ease; }
.settings-section[open] .chevron { transform: rotate(180deg); }
.settings-content { padding: 0 0 6px; }
.switch-row {
  min-height: 49px; padding: 10px 11px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 11px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #fff;
}
.switch-row.highlight-switch { background: #faf9ff; border-color: #e7e0ff; }
.switch-row span { min-width: 0; }
.switch-row b { display: block; font-size: 10.5px; color: #344054; }
.switch-row small { display: block; margin-top: 3px; color: #98a2b3; font-size: 9px; line-height: 1.35; }
.switch-row input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; width: 37px; height: 22px; border-radius: 999px; background: #d6dde8; position: relative; flex: 0 0 auto; transition: .18s ease; cursor: pointer;
}
.switch-row input[type="checkbox"]::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: white; top: 3px; left: 3px; box-shadow: 0 2px 5px rgba(15,23,42,.2); transition: .18s ease; }
.switch-row input[type="checkbox"]:checked { background: var(--accent); }
.switch-row input[type="checkbox"]:checked::after { transform: translateX(15px); }

.control-footer { padding: 14px 18px 18px; border-top: 1px solid var(--line); background: #fcfdff; display: grid; grid-template-columns: 1fr 1.35fr; gap: 9px; }
.status-box { grid-column: 1/-1; min-height: 40px; padding: 9px 11px; border-radius: 10px; display: flex; align-items: flex-start; gap: 8px; font-size: 10px; line-height: 1.4; font-weight: 650; background: #f8fafc; color: #667085; border: 1px solid var(--line); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #98a2b3; flex: 0 0 auto; margin-top: 3px; }
.status-box.success { background: #effbf6; color: #067a55; border-color: #ccefe1; }
.status-box.success .status-dot { background: #0e9f6e; }
.status-box.error { background: #fff3f2; color: #b42318; border-color: #fecdca; }
.status-box.error .status-dot { background: #d92d20; }
.button { height: 44px; border-radius: 11px; border: 0; font-size: 11px; font-weight: 850; transition: transform .15s ease, opacity .15s ease, box-shadow .15s ease; }
.button:not(:disabled):active { transform: translateY(1px); }
.button:disabled { opacity: .45; }
.button.secondary { background: #eef1f5; color: #344054; }
.button.primary { background: linear-gradient(135deg, #5b38f2, #7b55ff); color: #fff; display: flex; align-items: center; justify-content: center; gap: 7px; box-shadow: 0 9px 20px rgba(109,74,255,.22); }
.button.primary svg { width: 17px; height: 17px; }

.viewer-card { min-width: 0; }
.viewer-head { min-height: 76px; }
.viewer-actions { display: flex; align-items: center; gap: 10px; }
.tabs { display: flex; padding: 4px; gap: 3px; border-radius: 11px; background: #f2f4f7; }
.tab { height: 32px; padding: 0 13px; border: 0; border-radius: 8px; background: transparent; color: #667085; font-size: 10px; font-weight: 850; }
.tab.active { background: #fff; color: #101828; box-shadow: 0 2px 7px rgba(15,23,42,.08); }
.badge { height: 28px; padding: 0 10px; border-radius: 999px; display: inline-flex; align-items: center; background: #f2f4f7; color: #667085; font-size: 9px; font-weight: 850; white-space: nowrap; }
.badge.accent { color: #6941c6; background: #f4f0ff; }
.preview-pane { display: none; }
.preview-pane.active { display: block; }
.preview-stage { height: min(64vh, 690px); min-height: 470px; margin: 16px; border-radius: 15px; overflow: hidden; position: relative; }
.checkerboard { background-color: #fff; background-image: linear-gradient(45deg,#eef2f6 25%,transparent 25%),linear-gradient(-45deg,#eef2f6 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#eef2f6 75%),linear-gradient(-45deg,transparent 75%,#eef2f6 75%); background-size: 20px 20px; background-position: 0 0,0 10px,10px -10px,-10px 0; }
.source-stage { border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; }
#sourcePreview { max-width: calc(100% - 34px); max-height: calc(100% - 34px); object-fit: contain; display: none; filter: drop-shadow(0 12px 26px rgba(15,23,42,.08)); }
.placeholder { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: #667085; padding: 24px; }
.placeholder-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; margin-bottom: 10px; background: #f2f4f7; color: #667085; font-size: 22px; }
.placeholder strong { color: #344054; font-size: 13px; }
.placeholder span { margin-top: 5px; font-size: 10px; color: #98a2b3; }
.preview-toolbar { height: 48px; padding: 8px 16px 0; display: flex; align-items: center; justify-content: space-between; }
.tool-group { display: flex; align-items: center; gap: 6px; }
.tool-group button { height: 32px; min-width: 32px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: #344054; font-size: 11px; font-weight: 800; }
.tool-group button:last-child { padding: 0 11px; }
#zoomLabel { width: 52px; text-align: center; color: #667085; font-size: 10px; font-weight: 800; }
.toolbar-hint { color: #98a2b3; font-size: 9px; }
.dxf-stage { margin-top: 8px; background: #0a1020; border: 1px solid #18243b; }
#dxfCanvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#dxfCanvas.dragging { cursor: grabbing; }
.dark-placeholder { color: #8fa1bb; }
.dark-placeholder .placeholder-icon { background: #131d30; color: #59c3ff; }
.dark-placeholder strong { color: #dbe8f8; }
.dark-placeholder span { color: #8091aa; }
.stats-grid { margin: 0 16px 16px; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; display: grid; grid-template-columns: .8fr .8fr 1.35fr .95fr .9fr .75fr; }
.stats-grid > div { min-width: 0; padding: 10px 12px; border-right: 1px solid var(--line); background: #fbfcfe; }
.stats-grid > div:last-child { border-right: 0; }
.stats-grid span { display: block; color: #98a2b3; font-size: 8px; font-weight: 850; text-transform: uppercase; letter-spacing: .07em; }
.stats-grid strong { display: block; margin-top: 4px; color: #344054; font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.support-strip { margin-top: 18px; padding: 14px 18px; background: rgba(255,255,255,.72); border: 1px solid var(--line); border-radius: 16px; display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 20px; }
.support-strip div { min-width: 0; }
.support-strip b { display: block; color: #344054; font-size: 10px; }
.support-strip span { display: block; margin-top: 3px; color: #98a2b3; font-size: 9px; line-height: 1.4; }
.svg-sandbox { position: fixed; left: -99999px; top: -99999px; width: 4000px; height: 4000px; visibility: hidden; pointer-events: none; }

@media (max-width: 1100px) {
  .shell { width: min(100% - 24px, 960px); }
  .workspace { grid-template-columns: 1fr; }
  .control-card { position: static; }
  .preview-stage { min-height: 420px; height: 58vh; }
  .stats-grid { grid-template-columns: repeat(3,1fr); }
  .stats-grid > div { border-bottom: 1px solid var(--line); }
  .stats-grid > div:nth-child(3), .stats-grid > div:nth-child(6) { border-right: 0; }
  .stats-grid > div:nth-child(n+4) { border-bottom: 0; }
}
@media (max-width: 720px) {
  .appbar { height: 64px; padding: 0 12px; }
  .brand-mark { width: 40px; height: 40px; border-radius: 12px; }
  .brand strong { font-size: 14px; }
  .brand small, .privacy-pill { display: none; }
  .shell { width: calc(100% - 16px); margin-top: 12px; }
  .drop-zone { grid-template-columns: auto 1fr; min-height: 80px; padding: 12px; }
  .upload-icon { width: 42px; height: 42px; border-radius: 12px; }
  .upload-button { display: none; }
  .upload-copy span { white-space: normal; }
  .control-head, .viewer-head { padding: 16px; }
  .control-body { padding: 0 14px; }
  .control-footer { padding: 12px 14px 14px; grid-template-columns: 1fr; }
  .status-box { grid-column: 1; }
  .viewer-head { align-items: flex-start; gap: 12px; flex-direction: column; }
  .viewer-actions { width: 100%; justify-content: space-between; }
  .badge { display: none; }
  .preview-stage { margin: 10px; min-height: 330px; height: 50vh; }
  .preview-toolbar { padding: 7px 10px 0; }
  .toolbar-hint { display: none; }
  .stats-grid { margin: 0 10px 10px; grid-template-columns: repeat(2,1fr); }
  .stats-grid > div { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line) !important; }
  .stats-grid > div:nth-child(2n) { border-right: 0; }
  .stats-grid > div:nth-last-child(-n+2) { border-bottom: 0 !important; }
  .support-strip { grid-template-columns: 1fr; gap: 10px; padding: 13px 15px; }
}
@media (max-width: 430px) {
  .field-row.two { grid-template-columns: 1fr; }
  .control-footer { grid-template-columns: 1fr; }
}
