:root {
  --ink: #152033;
  --steel: #1f3a5f;
  --fog: #e8eef5;
  --sand: #f6f3ee;
  --accent: #c45c26;
  --muted: #5c6b7a;
}

* { box-sizing: border-box; }

.mq-body {
  margin: 0;
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, #d9e4f2 0%, transparent 40%),
    linear-gradient(160deg, var(--sand), #ffffff 45%, var(--fog));
  min-height: 100vh;
}

.mq-hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4rem 8vw;
  background:
    linear-gradient(120deg, rgba(21, 32, 51, 0.88), rgba(31, 58, 95, 0.55)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cpath fill='none' stroke='%23ffffff22' stroke-width='1' d='M0 40h160M0 80h160M0 120h160M40 0v160M80 0v160M120 0v160'/%3E%3C/svg%3E");
  color: #fff;
}

.mq-brand {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 1rem;
}

.mq-hero h1 {
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(2.4rem, 5vw, 4rem);
  margin: 0 0 1rem;
  max-width: 12ch;
  line-height: 1.05;
}

.mq-lede { max-width: 36ch; color: #e6edf7; font-size: 1.15rem; }

.mq-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  border-bottom: 1px solid #d5dde8;
  background: rgba(255,255,255,0.8);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.mq-layout { padding: 1.5rem 2rem 3rem; max-width: 1100px; margin: 0 auto; }

.mq-panel {
  background: rgba(255,255,255,0.92);
  border: 1px solid #d7deea;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}

.mq-tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.mq-tabs button {
  border: 1px solid #c9d3e2;
  background: #fff;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
}
.mq-tabs button.active { background: var(--steel); color: #fff; border-color: var(--steel); }

.mq-btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.7rem 1.2rem;
  text-decoration: none;
  cursor: pointer;
  font-weight: 600;
}
.mq-btn-ghost { background: transparent; color: var(--steel); border: 1px solid #c9d3e2; }

label { display: block; margin: 0.6rem 0; font-size: 0.92rem; }
input, select {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid #c9d3e2;
  background: #fff;
}

.mq-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 800px) { .mq-grid-2 { grid-template-columns: 1fr; } }
.mq-required::after { content: " *"; color: #d64545; font-weight: 700; }

.mq-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: none;
  color: #2e5fb0;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0;
  margin-bottom: 0.5rem;
}
.mq-back-btn:hover { text-decoration: underline; }

.mq-section-divider {
  border: none;
  border-top: 2px solid #dde3ee;
  margin: 2.5rem 0 1.5rem;
}

.mq-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border: none;
  background: transparent;
  color: #7a8ba8;
  cursor: pointer;
  border-radius: 6px;
  vertical-align: middle;
  margin-left: 0.15rem;
}
.mq-icon-btn:hover { background: #eef2f8; color: #1f2a44; }

.mq-rename-btn {
  opacity: 0;
  transition: opacity 0.12s ease;
}
.mq-list-item:hover .mq-rename-btn,
.mq-rename-btn:focus-visible {
  opacity: 1;
}

.mq-field-group {
  border: 1px solid #aab6cc;
  border-radius: 10px;
  padding: 1rem 1.25rem 1.25rem;
  margin: 0 0 1.25rem;
}
.mq-field-group legend {
  padding: 0.3rem 0.6rem;
  font-weight: 700;
  font-size: 0.95rem;
  color: #1f2a44;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: 6px;
  margin-left: -0.6rem;
}
.mq-field-group legend:hover { background: #eef2f8; }
.mq-field-group legend .mq-muted { font-weight: 400; }
.mq-field-group .mq-grid-2 { gap: 1rem 1.5rem; }
.mq-field-group .mq-grid-2[style*="display: none"] { margin: 0; }
.mq-collapse-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  flex: none;
  transition: transform 0.15s ease;
  font-size: 0.65rem;
  line-height: 1;
  color: #fff;
  background: #5a6b85;
  border-radius: 50%;
}
.mq-collapse-arrow-closed { transform: rotate(-90deg); }

.mq-upload-box {
  display: block;
  position: relative;
  margin-top: 0.75rem;
  border: 2px dashed #c9d3e2;
  border-radius: 10px;
  background: #f7f9fc;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.mq-upload-box:hover { border-color: #7a8ba8; background: #eef2f8; }
.mq-upload-box input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.mq-upload-box-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 2rem 1rem;
  color: #5a6b85;
  text-align: center;
  pointer-events: none;
}
.mq-upload-plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 2px solid #c9d3e2;
  font-size: 1.5rem;
  line-height: 1;
  color: #5a6b85;
}
.mq-upload-box-filled { border-style: solid; border-color: #3f9d5e; background: #eef8f0; }
.mq-upload-box-filled .mq-upload-plus { border-color: #3f9d5e; color: #3f9d5e; }

.mq-upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 0.75rem;
  align-items: stretch;
}
.mq-upload-grid .mq-upload-box { margin-top: 0; height: 100%; }
.mq-upload-grid .mq-upload-box-empty { height: 100%; box-sizing: border-box; }
@media (max-width: 700px) { .mq-upload-grid { grid-template-columns: 1fr; } }

.mq-upload-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  border: 2px solid #c9d3e2;
  color: #5a6b85;
}
.mq-upload-icon-pdf { color: #b03a2e; border-color: #e3b3ac; }
.mq-upload-icon-cad { color: #2e5fb0; border-color: #aec3e6; }
.mq-upload-icon-check {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #3f9d5e;
  color: #3f9d5e;
  font-size: 1.4rem;
}

.mq-list { list-style: none; padding: 0; margin: 0; }
.mq-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid #e3e8f0;
  cursor: pointer;
}
.mq-link { color: #2e5fb0; text-decoration: underline; text-underline-offset: 2px; }

.mq-list-item-won { background: #eaf7ee; margin: 0 -0.5rem; padding-left: 0.5rem; padding-right: 0.5rem; border-radius: 6px; }

.mq-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
  font-size: 0.9rem;
  color: #1f2a44;
}
.mq-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.mq-toggle-track {
  position: relative;
  width: 2.4rem;
  height: 1.35rem;
  background: #c9d3e2;
  border-radius: 999px;
  transition: background 0.15s ease;
  flex: none;
}
.mq-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 1.15rem;
  height: 1.15rem;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.mq-toggle input:checked + .mq-toggle-track { background: #3f9d5e; }
.mq-toggle input:checked + .mq-toggle-track .mq-toggle-thumb { transform: translateX(1.05rem); }

.mq-chip {
  background: var(--fog);
  color: var(--steel);
  padding: 0.15rem 0.5rem;
  font-size: 0.8rem;
}
.mq-conf-ok { background: #e4f5e9; color: #1f7a41; }
.mq-conf-flag { background: #fbe4e2; color: #b03a2e; }
.mq-conf-high { background: #e4f5e9; color: #1f7a41; }
.mq-conf-med { background: #fdf1da; color: #9a6a11; }
.mq-conf-low { background: #fbe4e2; color: #b03a2e; }
.mq-conf-unknown { background: var(--fog); color: var(--steel); }
.mq-chip-default { background: #e2ecfa; color: #2b5fa8; }
.mq-conf-ok, .mq-conf-flag, .mq-conf-high, .mq-conf-med, .mq-conf-low, .mq-conf-unknown {
  cursor: pointer;
}
.mq-code {
  background: #0f1724;
  color: #d7e2f2;
  padding: 1rem;
  overflow: auto;
  font-size: 0.8rem;
  max-height: 360px;
}
.mq-muted { color: var(--muted); }
.mq-error { color: #a32020; }
.mq-row { display: flex; gap: 0.4rem; align-items: center; }
.mq-detail { margin-top: 1rem; }
.mq-library-lists { margin-bottom: 1.5rem; }
.mq-library-item { cursor: default; }
.mq-library-meta { font-size: 0.85rem; margin-top: 0.2rem; }
.mq-reasoning-list { margin: 0.2rem 0 0; padding-left: 1.1rem; }
.mq-reasoning-list li { margin: 0.15rem 0; }
.mq-library-actions { margin: 0.5rem 0 1rem; gap: 0.75rem; }
.mq-inbox-item { cursor: pointer; }
.mq-inbox-item:hover { background: var(--fog); }

.mq-quote-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem 1.25rem;
  margin: 0 0 1.25rem;
}
.mq-quote-meta div { display: flex; gap: 0.5rem; align-items: baseline; }
.mq-quote-meta dt {
  margin: 0;
  font-weight: 600;
  color: var(--muted);
  min-width: 8.5rem;
  flex-shrink: 0;
}
.mq-quote-meta dd { margin: 0; }
.mq-detail h4 { margin: 1.25rem 0 0.5rem; font-size: 1rem; }
.mq-span-2 { grid-column: 1 / -1; }
.mq-span-2 textarea { width: 100%; }

.mq-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  margin-bottom: 0.5rem;
}
.mq-table th,
.mq-table td {
  border: 1px solid #d7deea;
  padding: 0.45rem 0.65rem;
  text-align: left;
}
.mq-table thead th { background: var(--fog); }
.mq-table tbody th {
  width: 40%;
  background: #fafbfd;
  font-weight: 600;
}
.mq-table td { text-align: right; font-variant-numeric: tabular-nums; }
.mq-table thead th:first-child,
.mq-table tbody td:first-child { text-align: left; }
.mq-export-row { margin-top: 1rem; flex-wrap: wrap; }

@media (max-width: 800px) {
  .mq-quote-meta { grid-template-columns: 1fr; }
}

.mq-nav-actions { display: flex; align-items: center; gap: 0.75rem; }
.mq-nav-user { gap: 0.75rem; }
.mq-nav-user .mq-btn-ghost {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

.mq-auth-panel { max-width: 420px; margin-left: auto; margin-right: auto; }
.mq-auth-lede { margin: 0 0 1rem; }
.mq-auth-form fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}
.mq-auth-form .mq-btn {
  width: 100%;
  margin-top: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
}
.mq-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.mq-btn:disabled[aria-busy="true"] {
  opacity: 0.72;
}
.mq-btn-spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: mq-spin 0.7s linear infinite;
  flex: 0 0 auto;
}
.mq-auth-status {
  margin: 0.85rem 0 0;
  text-align: center;
  color: var(--steel);
  font-size: 0.95rem;
  font-weight: 600;
}
.mq-auth-panel[aria-busy="true"] {
  opacity: 0.96;
}
.mq-auth-panel[aria-busy="true"] .mq-auth-form {
  pointer-events: none;
}
.mq-link:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
@keyframes mq-spin {
  to { transform: rotate(360deg); }
}
.mq-auth-switch {
  margin: 1.25rem 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}
.mq-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--steel);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.mq-link:hover { color: var(--accent); }

.mq-cad-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(220px, 0.7fr);
  gap: 1rem;
  align-items: stretch;
}
@media (max-width: 800px) {
  .mq-cad-layout { grid-template-columns: 1fr; }
}
.mq-cad-viewport {
  min-height: 320px;
  height: 420px;
  border: 1px solid #d7deea;
  background: #f0f3f7;
  position: relative;
}
.mq-cad-viewport canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}
.mq-cad-props h4 { margin: 0 0 0.75rem; }
.mq-props-list {
  margin: 0 0 1rem;
  display: grid;
  gap: 0.55rem;
}
.mq-props-list > div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  border-bottom: 1px solid #e8eef5;
  padding-bottom: 0.35rem;
}
.mq-props-list dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}
.mq-props-list dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-size: 0.9rem;
}

[x-cloak] { display: none !important; }
