/* ==========================================================================
   Quote request dialog (js/quote-ui.js)
   Self-contained: every class is prefixed qd-/qf- and the tokens are scoped,
   so it renders identically on pages with their own stylesheets (the demo).
   ========================================================================== */

.qd {
  --qd-bg: #101218;
  --qd-field: #0B0C10;
  --qd-line: rgba(245, 246, 250, 0.1);
  --qd-line-2: rgba(245, 246, 250, 0.18);
  --qd-text: #F5F6FA;
  --qd-text-2: #A5A9B8;
  --qd-text-3: #7D8294;
  --qd-accent: #5CE6F4;
  --qd-danger: #FF8A99;
  --qd-ok: #3DDC97;
  --qd-grad: linear-gradient(90deg, #C034FF 0%, #7250FF 34%, #5085FF 52%, #29BFFF 76%, #0CF4FF 100%);
  --qd-font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --qd-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --qd-ease: cubic-bezier(0.16, 1, 0.3, 1);

  position: fixed;
  inset: 0 0 0 auto;
  width: min(620px, 100vw);
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--qd-line);
  background: var(--qd-bg);
  color: var(--qd-text);
  font-family: var(--qd-font);
  font-size: 16px;
  line-height: 1.55;
  box-shadow: -40px 0 120px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
.qd[open] { animation: qd-in 0.42s var(--qd-ease); }
.qd.is-closing { animation: qd-out 0.18s ease-in forwards; }
.qd::backdrop {
  background: rgba(5, 6, 9, 0.66);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.qd[open]::backdrop { animation: qd-fade 0.3s ease-out; }
.qd.is-closing::backdrop { opacity: 0; transition: opacity 0.18s; }
@keyframes qd-in { from { transform: translateX(28px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes qd-out { to { transform: translateX(20px); opacity: 0; } }
@keyframes qd-fade { from { opacity: 0; } }
html.qd-open { overflow: hidden; }

.qd *, .qd *::before, .qd *::after { box-sizing: border-box; }
.qd :focus-visible { outline: 2px solid var(--qd-accent); outline-offset: 2px; }
.qd h2, .qd h3, .qd p, .qd ol, .qd ul, .qd fieldset { margin: 0; }
.qd fieldset { border: 0; padding: 0; min-width: 0; }
.qd code { font-family: var(--qd-mono); font-size: 0.85em; background: rgba(245, 246, 250, 0.08); padding: 1px 5px; border-radius: 4px; }
.qd a:not(.qd-btn) { color: var(--qd-text); text-decoration: underline; text-decoration-color: var(--qd-line-2); text-underline-offset: 0.2em; }
.qd a:not(.qd-btn):hover { text-decoration-color: var(--qd-accent); }

.qd-panel { height: 100%; display: flex; flex-direction: column; }
.qd-head {
  flex: none;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 28px 32px 22px;
  border-bottom: 1px solid var(--qd-line);
  position: relative;
}
.qd-head::after {
  content: "";
  position: absolute;
  left: 32px;
  bottom: -1px;
  width: 64px;
  height: 1px;
  background: var(--qd-grad);
}
.qd-kicker {
  font-family: var(--qd-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--qd-text-3);
}
.qd-title:focus { outline: none; }
.qd-title {
  margin-top: 8px !important;
  font-size: 30px;
  line-height: 1.1;
  font-weight: 600;
  letter-spacing: -0.03em;
}
.qd-close {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid var(--qd-line-2);
  background: transparent;
  color: var(--qd-text);
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
}
.qd-close:hover { border-color: rgba(245, 246, 250, 0.45); background: rgba(245, 246, 250, 0.05); }
.qd-close svg { width: 18px; height: 18px; }

.qd-scroll {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 26px 32px calc(40px + env(safe-area-inset-bottom));
  scrollbar-width: thin;
  scrollbar-color: rgba(245, 246, 250, 0.18) transparent;
}
.qd-intro { color: var(--qd-text-2); font-size: 15px; margin-bottom: 22px !important; max-width: 46ch; }

.qd-notice {
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.5;
  display: grid;
  gap: 6px;
}
.qd-notice--error { background: rgba(255, 125, 142, 0.08); border: 1px solid rgba(255, 125, 142, 0.38); color: #FFD9DE; }
.qd-notice ul { margin: 4px 0 0; padding-left: 18px; display: grid; gap: 4px; list-style: disc; }
.qd .qd-notice a { color: #FFD9DE; }
.qd-notice:focus { outline: 2px solid var(--qd-danger); outline-offset: 2px; }

/* ---------- Form ---------- */
.qf { display: grid; gap: 28px; }
.qf-group { display: grid; gap: 16px; }
.qf-legend {
  padding: 0;
  margin-bottom: 4px;
  font-family: var(--qd-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--qd-text-3);
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}
.qf-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 14px; }
.qf-field { display: grid; gap: 7px; align-content: start; min-width: 0; }
.qf-field--wide { grid-column: 1 / -1; }
.qf-label { font-size: 14px; font-weight: 500; color: var(--qd-text); display: flex; align-items: baseline; gap: 8px; }
.qf-opt { font-family: var(--qd-mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--qd-text-3); font-weight: 400; }
.qf-input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--qd-line-2);
  background: var(--qd-field);
  color: var(--qd-text);
  font: inherit;
  font-size: 16px; /* prevents iOS zoom on focus */
  line-height: 1.4;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}
.qf-input::placeholder { color: #5E6374; }
.qf-input:hover { border-color: rgba(245, 246, 250, 0.28); }
.qf-input:focus { outline: none; border-color: var(--qd-accent); box-shadow: 0 0 0 3px rgba(92, 230, 244, 0.16); }
.qf-textarea { min-height: 116px; resize: vertical; }
.qf-textarea--sm { min-height: 76px; }
.qf-select { position: relative; }
.qf-select::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 1.5px solid var(--qd-text-2);
  border-bottom: 1.5px solid var(--qd-text-2);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.qf-select select { padding-right: 40px; cursor: pointer; }
.qf-select select:invalid, .qf-select select option[value=""] { color: var(--qd-text-2); }
.qf-select option { color: #111; background: #fff; }
.qf-count { justify-self: end; font-family: var(--qd-mono); font-size: 11px; color: var(--qd-text-3); margin-top: -2px !important; }
.qf-hint { font-size: 13px; color: var(--qd-text-3); }
.qf-error { font-size: 13px; color: var(--qd-danger); font-weight: 500; }
.qf-error:empty { display: none; }
.qf-field.is-invalid .qf-input { border-color: rgba(255, 125, 142, 0.7); }
.qf-field.is-invalid .qf-input:focus { box-shadow: 0 0 0 3px rgba(255, 125, 142, 0.16); }

.qf-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.qf-chip { position: relative; }
.qf-chip input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.qf-chip span {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 15px;
  border-radius: 999px;
  border: 1px solid var(--qd-line-2);
  font-size: 14px;
  color: var(--qd-text-2);
  transition: all 0.2s;
  cursor: pointer;
}
.qf-chip input:checked + span { border-color: var(--qd-accent); color: var(--qd-text); background: rgba(92, 230, 244, 0.08); }
.qf-chip input:focus-visible + span { outline: 2px solid var(--qd-accent); outline-offset: 2px; }
.qf-chip:hover span { border-color: rgba(245, 246, 250, 0.35); }

.qf-context {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(92, 230, 244, 0.32);
  background: rgba(92, 230, 244, 0.06);
  font-size: 14px;
}
.qf-context-k { font-family: var(--qd-mono); font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--qd-text-3); }
.qf-context-v { font-weight: 600; flex: 1; min-width: 0; }
.qf-context-x {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--qd-text-2);
  cursor: pointer;
}
.qf-context-x:hover { background: rgba(245, 246, 250, 0.08); color: var(--qd-text); }
.qf-context-x svg { width: 14px; height: 14px; }

.qf-submit { display: grid; gap: 12px; padding-top: 4px; }
.qf-note { font-size: 13.5px; color: var(--qd-text-2); }
.qf-note strong { color: var(--qd-text); font-weight: 600; }
.qf-privacy { font-size: 12.5px; color: var(--qd-text-3); }

/* ---------- Buttons ---------- */
.qd-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid var(--qd-line-2);
  background: transparent;
  color: var(--qd-text);
  font: inherit;
  font-size: 15px;
  font-weight: 560;
  text-decoration: none !important;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, opacity 0.2s, transform 0.2s;
}
.qd-btn:hover { border-color: rgba(245, 246, 250, 0.45); background: rgba(245, 246, 250, 0.05); }
.qd-btn:active { transform: translateY(1px); }
.qd-btn svg { width: 19px; height: 19px; flex: none; }
.qd-btn--primary { background: var(--qd-text); color: #0B0C10; border-color: transparent; }
.qd-btn--primary:hover { background: #fff; border-color: transparent; }
.qd-btn--lg { min-height: 56px; width: 100%; font-size: 16px; }
.qd-btn[disabled] { opacity: 0.6; cursor: progress; }
.qd-btn.is-busy svg { animation: qd-pulse 0.9s ease-in-out infinite alternate; }
@keyframes qd-pulse { to { opacity: 0.25; } }
.qd-link {
  border: 0;
  background: none;
  padding: 6px 0;
  color: var(--qd-text-2);
  font: inherit;
  font-size: 14px;
  text-decoration: underline;
  text-decoration-color: var(--qd-line-2);
  text-underline-offset: 0.2em;
  cursor: pointer;
}
.qd-link:hover { color: var(--qd-text); }

/* ---------- Confirmation ---------- */
.qd-done { display: grid; gap: 20px; padding-top: 6px; }
.qd-done-mark {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  position: relative;
  background: #0B0C10;
  color: var(--qd-text);
}
.qd-done-mark::before {
  content: "";
  position: absolute;
  inset: 0;
  padding: 1px;
  border-radius: inherit;
  background: var(--qd-grad);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}
.qd-done-mark svg { width: 26px; height: 26px; }
.qd-done-title { font-size: 26px; line-height: 1.15; font-weight: 600; letter-spacing: -0.025em; }
.qd-done-title:focus { outline: none; }
.qd-done-text { color: var(--qd-text-2); }
.qd-done-text strong { color: var(--qd-text); font-weight: 600; }
.qd-next { list-style: none; padding: 0; border-top: 1px solid var(--qd-line); }
.qd-next li {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--qd-line);
  font-size: 15px;
}
.qd-next .qd-n {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--qd-mono);
  font-size: 11px;
  border: 1px solid var(--qd-line-2);
  color: var(--qd-text-2);
}
.qd-next strong { font-weight: 600; }
.qd-preview { display: grid; gap: 8px; }
.qd-preview-text { font-family: var(--qd-mono); font-size: 13px !important; line-height: 1.55; min-height: 180px; resize: vertical; }
.qd-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.qd-actions--quiet { gap: 20px; margin-top: -6px; }
.qd-alt { font-size: 13.5px; color: var(--qd-text-3); }

@media (max-width: 639px) {
  .qd { width: 100vw; border-left: 0; box-shadow: none; }
  .qd[open] { animation-name: qd-up; }
  @keyframes qd-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
  .qd-head { padding: 18px 20px 16px; }
  .qd-head::after { left: 20px; }
  .qd-title { font-size: 26px; }
  .qd-scroll { padding: 20px 20px calc(32px + env(safe-area-inset-bottom)); }
  .qf-grid { grid-template-columns: minmax(0, 1fr); }
  .qd-actions .qd-btn { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .qd[open], .qd.is-closing, .qd[open]::backdrop { animation: none; }
}
