:root {
  color-scheme: dark;
  font-family: "Aptos", "Segoe UI Variable", "Segoe UI", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: #090d13;
  color: #eef5fb;
  --panel: #111923;
  --panel2: #162331;
  --line: #2a3b4c;
  --muted: #a4b3c0;
  --accent: #168be0;
  --accent2: #0d68b5;
  --accent-soft: #102d46;
  --warn: #f0b35a;
  --danger: #ff7d7d;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 72% 0%, #15314a 0, #090d13 42%); }
button, input, select { font: inherit; }
button { cursor: pointer; }
.topbar { padding: 26px 36px; display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; border-bottom: 1px solid var(--line); }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: "Aptos Display", "Segoe UI Variable Display", "Segoe UI", sans-serif; letter-spacing: -.015em; }
h1 { font-size: clamp(1.6rem, 3vw, 2.6rem); margin-bottom: 8px; }
.topbar p { color: var(--muted); max-width: 850px; margin-bottom: 0; }
.brand-wordmark { display: block; width: clamp(210px, 22vw, 292px); height: auto; margin: 0 0 10px; }
.header-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.unit-toggle { display: inline-grid; grid-template-columns: 1fr 1fr; padding: 3px; border: 1px solid var(--line); background: #0b121a; border-radius: 10px; }
.unit-option { border: 0; border-radius: 7px; color: var(--muted); background: transparent; padding: 7px 11px; font-weight: 750; }
.unit-option.active { color: #fff; background: var(--accent2); box-shadow: 0 3px 12px rgba(0,0,0,.28); }
.badge { border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; white-space: nowrap; font-size: .85rem; }
.badge.ok { border-color: #1b73b8; color: #83c8ff; background: #0d2940; }
.badge.error { border-color: #7d3838; color: var(--danger); background: #2a1212; }
.layout { display: grid; grid-template-columns: minmax(330px, 410px) 1fr; gap: 22px; padding: 22px; max-width: 1640px; margin: 0 auto; }
.panel, .viewer-card, .result-card { background: linear-gradient(145deg, rgba(23,35,48,.98), rgba(13,20,28,.98)); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 18px 50px rgba(0,0,0,.24); }
.controls { padding: 0; align-self: start; position: sticky; top: 14px; max-height: calc(100vh - 28px); overflow: hidden; }
.controls-scroll {
  max-height: calc(100vh - 30px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 22px;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
}
.controls-scroll { scrollbar-width: thin; scrollbar-color: #82909b #111923; }
.controls-scroll::-webkit-scrollbar { width: 11px; }
.controls-scroll::-webkit-scrollbar-track { background: #111923; border-radius: 0 15px 15px 0; }
.controls-scroll::-webkit-scrollbar-thumb { background: #82909b; border: 3px solid #111923; border-radius: 999px; }
.controls-scroll::-webkit-scrollbar-thumb:hover { background: #a6b1ba; }
.controls h2 { font-size: 1.05rem; margin: 23px 0 12px; }
.control-toolbar { display: flex; justify-content: flex-end; align-items: center; margin-bottom: 2px; }
.utility-button { border: 1px solid var(--line); color: #e8f6ff; background: #101a25; padding: 9px 12px; border-radius: 9px; font-weight: 750; white-space: nowrap; }
.utility-button:hover { border-color: var(--accent); background: #123a59; }
label { display: block; margin: 14px 0; }
label > span { display: block; font-weight: 750; font-size: .9rem; margin-bottom: 7px; }
small { display: block; color: var(--muted); line-height: 1.4; margin-top: 6px; }
input, select { width: 100%; border: 1px solid var(--line); background: #0a1119; color: #f4fbff; padding: 10px 11px; border-radius: 9px; }
input:focus, select:focus { outline: 2px solid rgba(22,139,224,.33); border-color: var(--accent); }
.range-number { display: grid; grid-template-columns: minmax(130px, 1fr) 124px; gap: 10px; align-items: center; }
input[type="range"] { appearance: none; height: 6px; padding: 0; border: 0; border-radius: 999px; background: linear-gradient(90deg, var(--accent2), var(--accent)); }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 19px; height: 19px; border-radius: 50%; background: #f7fbff; border: 3px solid var(--accent); box-shadow: 0 2px 10px rgba(0,0,0,.4); }
input[type="range"]::-moz-range-thumb { width: 15px; height: 15px; border-radius: 50%; background: #f7fbff; border: 3px solid var(--accent); box-shadow: 0 2px 10px rgba(0,0,0,.4); }
.input-unit { display: grid; grid-template-columns: 1fr auto; align-items: center; border: 1px solid var(--line); background: #0a1119; border-radius: 9px; overflow: hidden; }
.input-unit input { border: 0; border-radius: 0; min-width: 0; }
.input-unit b { color: var(--muted); padding: 0 9px; font-size: .78rem; }
.preset-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.preset, .mini-preset, .fit-preset { border: 1px solid var(--line); color: #eef4f8; background: #101a25; padding: 10px 12px; border-radius: 9px; text-align: center; text-decoration: none; }
.preset:hover, .mini-preset:hover, .fit-preset:hover, .utility-button:hover:hover { border-color: var(--accent); }
.preset.active, .mini-preset.active, .fit-preset.active { background: #123a59; border-color: #207fc2; color: #e8f6ff; }
.fit-presets { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; margin-bottom: 12px; }
.fit-preset { border: 1px solid var(--line); color: #eef4f8; background: #101a25; padding: 10px 8px; border-radius: 9px; text-align: center; }
.width-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: -5px; }
.mini-preset { padding: 8px 5px; font-size: .76rem; }

.mini-preset:disabled { cursor: not-allowed; opacity: .42; border-color: var(--line); background: #0c131b; }
.preview-badge { position: absolute; right: 30px; bottom: 31px; padding: 7px 10px; border-radius: 999px; border: 1px solid #2b74aa; background: rgba(8,30,47,.92); color: #b9e2ff; font-size: .74rem; font-weight: 760; pointer-events: none; box-shadow: 0 7px 20px rgba(0,0,0,.3); }
.result-subtitle { color: var(--muted); font-size: .75rem; line-height: 1.35; margin: -6px 0 12px; }
.slice-error { display: inline-block; max-width: 320px; color: #ffb0b0; font-weight: 650; white-space: normal; }

.status { margin-top: 18px; padding: 11px 12px; color: var(--muted); font-size: .86rem; min-height: 42px; border: 1px solid var(--line); border-radius: 10px; background: #0b121a; line-height: 1.4; }
.status.error { color: var(--danger); border-color: #663535; background: #271313; }
.status.ok { color: #8fcfff; border-color: #205f91; background: #0c263a; }
.status.busy::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 50%; border: 2px solid rgba(22,139,224,.3); border-top-color: var(--accent); animation: spin .8s linear infinite; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }
details { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
summary { cursor: pointer; color: #74c4ff; font-weight: 800; }
.hidden { display: none !important; }
.workspace { min-width: 0; }
.viewer-card { padding: 18px; position: relative; }
.viewer-head { display: flex; justify-content: space-between; gap: 20px; align-items: start; }
.viewer-head h2 { margin-bottom: 0; }
.viewer-tools { display: flex; gap: 10px; align-items: center; }
.viewer-help { color: var(--muted); font-size: .8rem; white-space: nowrap; }
#viewer { display: block; width: 100%; height: min(56vh, 650px); min-height: 400px; border-radius: 12px; background: radial-gradient(circle, #1e3d57 0, #0b131c 72%); margin-top: 14px; }
.viewer-empty { position: absolute; inset: 50% 10% auto; transform: translateY(-50%); color: var(--muted); text-align: center; pointer-events: none; }
.results-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 14px; }
.result-card { padding: 17px; min-width: 0; }
.result-card h3 { font-size: 1rem; }
dl { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; margin: 0; font-size: .86rem; }
dt { color: var(--muted); min-width: 0; }
dd { margin: 0; font-weight: 750; text-align: right; word-break: break-word; }
.approval { padding: 9px 10px; border-radius: 8px; font-size: .78rem; margin-bottom: 12px; }
.approval.warning { color: #ffd79a; background: #2e2110; border: 1px solid #674a20; }
.approval.ok { color: #8fcfff; background: #0d2940; border: 1px solid #215f91; }
.warnings { margin-top: 14px; padding: 14px; border: 1px solid #5c4827; background: #2b2112; border-radius: 12px; color: #f5d39c; font-size: .85rem; line-height: 1.5; }
footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 8px 20px 24px; }
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .controls { position: static; max-height: none; }
  .controls-scroll { max-height: none; overflow: visible; padding: 22px; }
  .results-grid { grid-template-columns: 1fr; }
}
@media (max-width: 650px) {
  .topbar { padding: 22px; flex-direction: column; }
  .brand-wordmark { width: min(260px, 82vw); }
  .header-actions { justify-content: flex-start; }
  .layout { padding: 12px; }
  #viewer { min-height: 330px; }
  .viewer-head { flex-direction: column; gap: 8px; }
  .viewer-tools { width: 100%; justify-content: space-between; }
  .control-toolbar { grid-template-columns: 1fr; }
  .range-number { grid-template-columns: 1fr; }
  .width-presets { grid-template-columns: 1fr 1fr; }
}

.customer-price { color: #8fd0ff; font-size: 1.22rem; letter-spacing: -.02em; }
.price-card { border-color: #245d88; }


.checkout-card {
  margin-top: 14px;
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  background: linear-gradient(135deg, rgba(15, 53, 79, .98), rgba(12, 25, 36, .98));
  border: 1px solid #246a9e;
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0,0,0,.24);
}
.checkout-card h2 { margin: 4px 0 7px; }
.checkout-card p { color: var(--muted); margin: 0; max-width: 850px; }
.checkout-actions { display: grid; gap: 7px; min-width: 245px; text-align: right; }
.checkout-actions strong { color: #a9dcff; font-size: 1.55rem; }
.primary-order {
  border: 1px solid #43a9ef;
  border-radius: 10px;
  background: linear-gradient(180deg, #178fe3, #0b67af);
  color: #fff;
  padding: 12px 16px;
  font-weight: 820;
  box-shadow: 0 8px 24px rgba(0, 91, 160, .32);
}
.primary-order:hover:not(:disabled) { filter: brightness(1.08); }
.primary-order:disabled { cursor: not-allowed; opacity: .48; box-shadow: none; }
.order-confirmation { margin-top: 14px; padding: 15px; border: 1px solid #2b7cac; border-radius: 12px; background: #0d2d43; color: #dff2ff; line-height: 1.55; }
.order-confirmation a { color: #8ed2ff; }
.checkout-dialog { width: min(760px, calc(100vw - 24px)); border: 1px solid #31506a; border-radius: 16px; padding: 0; color: #edf7ff; background: #101923; box-shadow: 0 35px 100px rgba(0,0,0,.65); }
.checkout-dialog::backdrop { background: rgba(2, 6, 10, .78); backdrop-filter: blur(4px); }
.checkout-dialog form { padding: 22px; }
.dialog-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.dialog-head h2 { margin: 4px 0 0; }
.dialog-close { border: 0; background: transparent; color: #dceeff; font-size: 2rem; line-height: 1; padding: 0 6px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .span-2 { grid-column: span 2; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.dialog-error { margin-top: 12px; color: #ffb0b0; border: 1px solid #6e3838; background: #2a1414; border-radius: 9px; padding: 10px; }

@media (max-width: 650px) {
  .checkout-card { grid-template-columns: 1fr; gap: 16px; }
  .checkout-actions { min-width: 0; text-align: left; }
  .primary-order { min-height: 48px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .checkout-dialog form { padding: 17px; }
}
