/* ==========================================================================
   TZ Quote — internal quoting app for TZ Gillani Kft.
   Self-contained dark UI in the TZ Manufacturing brand.
   ========================================================================== */

:root {
  --brand: #ff6a1a;
  --brand-2: #ff8a3d;
  --brand-deep: #d6500a;
  --ok: #15c8a0;

  --bg: #0c0f14;
  --bg-2: #11161d;
  --bg-3: #171d26;
  --card: #131922;
  --card-2: #1a2230;

  --text: #eef2f7;
  --text-soft: #aab4c2;
  --text-mute: #6b7787;

  --line: rgba(255, 255, 255, 0.09);
  --line-2: rgba(255, 255, 255, 0.16);

  --font-head: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-pill: 999px;

  --t: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

* , *::before, *::after { box-sizing: border-box; margin: 0; }

html, body { height: 100%; }
body {
  font-family: var(--font-body);
  background:
    radial-gradient(90% 60% at 80% -10%, #18222e 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 700; letter-spacing: -0.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
::selection { background: var(--brand); color: #fff; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* ---------- app bar ---------- */
.app-bar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 22px;
  padding: 10px 18px;
  background: rgba(12, 15, 20, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand img { height: 34px; width: auto; }
.brand span {
  font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; line-height: 1.1;
}
.brand small {
  display: block; font-family: var(--font-body); font-weight: 500;
  font-size: 0.62rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-mute);
}
.tabs { display: flex; gap: 4px; flex: 1; }
.tab-btn {
  border: 0; background: none; cursor: pointer;
  color: var(--text-soft); font-weight: 600; font-size: 0.9rem;
  padding: 8px 14px; border-radius: var(--r-pill);
  transition: color var(--t), background var(--t);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { background: var(--card-2); color: var(--text); }
.tab-count {
  display: inline-block; min-width: 20px; text-align: center;
  background: var(--brand); color: #fff; border-radius: var(--r-pill);
  font-size: 0.68rem; font-weight: 700; padding: 1px 6px; margin-left: 4px;
}
.tab-count:empty { display: none; }

.qa-currency { display: flex; border: 1px solid var(--line-2); border-radius: var(--r-pill); overflow: hidden; }
.qa-currency button {
  border: 0; background: none; cursor: pointer; padding: 5px 13px;
  font-size: 0.76rem; font-weight: 700; color: var(--text-soft);
}
.qa-currency button.active { background: var(--brand); color: #fff; }
.qa-currency button:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--brand-2); }

/* ---------- tabs / layout ---------- */
main { padding: 18px; max-width: 1720px; margin-inline: auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--r-pill); border: 1px solid transparent; cursor: pointer;
  font-weight: 600; font-size: 0.9rem; padding: 9px 18px;
  transition: background var(--t), border-color var(--t), color var(--t), transform var(--t);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); }
.btn-ghost { background: none; border-color: var(--line-2); color: var(--text-soft); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand-2); }
.btn-ghost.danger:hover { border-color: #e05555; color: #ff8a8a; }
.btn-lg { padding: 12px 26px; font-size: 1rem; }

/* ---------- dropzone ---------- */
.qa-drop {
  border: 2px dashed var(--line-2);
  border-radius: var(--r-lg);
  background: var(--bg-2);
  padding: clamp(48px, 10vh, 110px) 24px;
  text-align: center;
  max-width: 860px; margin: 6vh auto 0;
  transition: border-color var(--t), background var(--t);
}
.qa-drop.over { border-color: var(--brand); background: #1c1710; }
.qa-drop-icon { width: 66px; height: 66px; margin: 0 auto 18px; color: var(--brand); }
.qa-drop h2 { font-size: 1.5rem; margin-bottom: 8px; }
.qa-drop p { color: var(--text-soft); max-width: 520px; margin: 0 auto 24px; }
.qa-drop-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.qa-drop-note { margin-top: 18px; font-size: 0.8rem; color: var(--text-mute); }

.qa-step-notice {
  display: none; margin: 18px auto 0; max-width: 560px; text-align: left;
  border: 1px solid rgba(255, 138, 61, 0.45); background: #201710;
  border-radius: var(--r-md); padding: 14px 40px 14px 16px;
  font-size: 0.9rem; position: relative; color: var(--text-soft);
}
.qa-step-notice.show { display: block; }
.qa-step-notice b { color: var(--brand-2); }
.qa-step-close {
  position: absolute; top: 6px; right: 10px; border: 0; background: none;
  font-size: 1.2rem; cursor: pointer; color: var(--text-mute);
}

/* ---------- workspace grid ---------- */
.qa-work { display: none; }
.qa-grid {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 400px;
  gap: 16px;
  align-items: start;
}
@media (max-width: 1180px) {
  .qa-grid { grid-template-columns: minmax(0, 1fr) 400px; }
  .qa-left { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
}
@media (max-width: 860px) {
  .qa-grid { grid-template-columns: 1fr; }
  .qa-left { grid-template-columns: 1fr; }
}

.qa-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.qa-card + .qa-card { margin-top: 16px; }
.qa-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.qa-card-head h3 {
  font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-soft);
}
.qa-card-body { padding: 14px 16px; }

.qa-help { font-size: 0.78rem; color: var(--text-mute); }

/* ---------- customer ---------- */
.qa-cust { display: grid; gap: 8px; }
.qa-cust input {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 9px 12px; width: 100%;
}
.qa-cust input::placeholder { color: var(--text-mute); }

/* ---------- parts ---------- */
.qa-parts { display: grid; gap: 8px; }
.qa-part {
  display: flex; align-items: stretch;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--bg-2);
  transition: border-color var(--t), box-shadow var(--t);
}
.qa-part:hover { border-color: var(--brand-2); }
.qa-part.active { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(255, 106, 26, 0.15); }
.qa-part-select {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px;
  text-align: left; cursor: pointer; border: 0; background: none;
  padding: 9px 4px 9px 12px; border-radius: var(--r-md) 0 0 var(--r-md);
}
.qa-part-select b { font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.qa-part-select small { color: var(--text-mute); font-size: 0.72rem; }
.qa-part-select .price { color: var(--brand-2); font-weight: 700; font-size: 0.82rem; }
.qa-part-del {
  flex: none; align-self: center; width: 26px; height: 26px; margin-right: 8px;
  border: 0; background: none; cursor: pointer; border-radius: 50%;
  display: grid; place-items: center; color: var(--text-mute); font-size: 1.05rem; line-height: 1;
}
.qa-part-del:hover { background: rgba(255, 106, 26, 0.18); color: var(--brand-2); }
.qa-badge {
  display: inline-block; font-size: 0.62rem; font-weight: 700; letter-spacing: 0.04em;
  padding: 2px 8px; border-radius: var(--r-pill); margin-right: 6px;
}
.qa-badge.warn { background: rgba(220, 60, 60, 0.22); color: #ff9d9d; }
.qa-badge.note { background: rgba(240, 170, 60, 0.2); color: #ffce7a; }
.qa-chip {
  border: 1px solid var(--line-2); background: none; cursor: pointer; color: var(--text-soft);
  border-radius: var(--r-pill); padding: 4px 11px; font-size: 0.74rem; font-weight: 600;
}
.qa-chip:hover { border-color: var(--brand); color: var(--brand-2); }
.qa-chip.active { border-color: var(--brand); background: rgba(255, 106, 26, 0.14); color: var(--brand-2); }

/* ---------- viewer ---------- */
.qa-viewer-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.qa-viewer {
  position: relative; width: 100%;
  height: clamp(340px, calc(100vh - 210px), 860px);
  background: radial-gradient(120% 90% at 50% 0%, #1d2733 0%, var(--bg-2) 55%, var(--bg) 100%);
}
.qa-viewer canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.qa-viewer-hud { position: absolute; left: 14px; top: 12px; display: grid; gap: 4px; pointer-events: none; }
.qa-viewer-hud span {
  font-family: var(--font-head); font-size: 0.8rem;
  background: rgba(12, 15, 20, 0.6); border: 1px solid var(--line);
  padding: 4px 10px; border-radius: var(--r-pill); width: fit-content;
}
.qa-viewer-hud span.sub { color: var(--text-soft); font-size: 0.72rem; font-family: var(--font-body); }
.qa-viewer-actions { position: absolute; right: 12px; top: 12px; }
.qa-viewer-actions button {
  border: 1px solid var(--line-2); background: rgba(12, 15, 20, 0.6); color: var(--text);
  border-radius: var(--r-pill); font-size: 0.76rem; padding: 6px 12px; cursor: pointer;
}
.qa-viewer-actions button:hover { border-color: var(--brand); color: var(--brand-2); }
.qa-fit-warn {
  position: absolute; left: 14px; right: 14px; bottom: 12px;
  background: rgba(12, 15, 20, 0.82); border: 1px solid rgba(255, 138, 61, 0.5);
  color: #ffd9bd; font-size: 0.8rem; border-radius: var(--r-md); padding: 8px 12px;
}
.qa-viewer-help { padding: 8px 16px; font-size: 0.74rem; color: var(--text-mute); border-top: 1px solid var(--line); }
.qa-viewer-fallback { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--text-soft); padding: 30px; }

/* ---------- spec controls ---------- */
.qa-group { margin-bottom: 16px; }
.qa-group:last-child { margin-bottom: 0; }
.qa-label {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-soft); margin-bottom: 8px;
}
select, .qa-inline input[type="number"] {
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  padding: 8px 10px; color: var(--text); width: 100%;
}
select { appearance: auto; }
select option { background: var(--bg-2); color: var(--text); }
.qa-mat-info { font-size: 0.78rem; color: var(--text-mute); margin-top: 6px; min-height: 2.2em; }

.qa-segs { display: flex; gap: 6px; flex-wrap: wrap; }
.qa-seg {
  border: 1px solid var(--line-2); background: var(--bg-2); cursor: pointer;
  border-radius: var(--r-sm); padding: 6px 9px; text-align: center; color: var(--text);
  font-family: var(--font-head); font-weight: 600; font-size: 0.84rem; min-width: 56px;
  transition: border-color var(--t), background var(--t);
}
.qa-seg small { display: block; font-family: var(--font-body); font-weight: 500; font-size: 0.62rem; color: var(--text-mute); }
.qa-seg:hover { border-color: var(--brand-2); }
.qa-seg.active { border-color: var(--brand); background: rgba(255, 106, 26, 0.14); }
.qa-seg.active small { color: var(--brand-2); }

.qa-infill-row { display: flex; align-items: center; gap: 10px; }
.qa-infill-row input[type="range"] { flex: 1; accent-color: var(--brand); }
.qa-infill-row input[type="number"] {
  width: 72px; background: var(--bg-2); border: 1px solid var(--line-2);
  border-radius: var(--r-sm); padding: 7px 8px; font-weight: 600; text-align: center; color: var(--text);
}
.qa-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

.qa-patterns { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 7px; }
.qa-pattern {
  border: 1px solid var(--line-2); background: var(--bg-2); cursor: pointer; color: var(--text);
  border-radius: var(--r-md); padding: 9px 5px 7px; text-align: center;
  transition: border-color var(--t), box-shadow var(--t);
}
.qa-pattern svg { width: 30px; height: 30px; margin: 0 auto 5px; color: var(--text-soft); }
.qa-pattern b { display: block; font-size: 0.7rem; }
.qa-pattern small { font-size: 0.6rem; color: var(--text-mute); }
.qa-pattern:hover { border-color: var(--brand-2); }
.qa-pattern.active { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(255, 106, 26, 0.15); }
.qa-pattern.active svg { color: var(--brand); }
.qa-pattern-desc { margin-top: 8px; font-size: 0.76rem; color: var(--text-mute); min-height: 2.2em; }

.qa-inline { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.qa-inline label.plain { display: flex; align-items: center; gap: 7px; font-size: 0.86rem; }
.qa-inline select { width: auto; }
.qa-inline input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--brand); }

/* ---------- quote panel ---------- */
.qa-del-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 14px; }
.qa-del-opt {
  border: 1px solid var(--line-2); background: var(--bg-2); border-radius: var(--r-md);
  padding: 8px 10px; cursor: pointer; text-align: left; color: var(--text);
  transition: border-color var(--t), box-shadow var(--t);
}
.qa-del-opt b { display: block; font-size: 0.8rem; }
.qa-del-opt small { color: var(--text-mute); font-size: 0.68rem; }
.qa-del-opt span { display: block; font-size: 0.68rem; font-weight: 700; color: var(--brand-2); margin-top: 1px; }
.qa-del-opt:hover { border-color: var(--brand-2); }
.qa-del-opt.active { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(255, 106, 26, 0.15); }

.qa-qrow {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 6px 0; font-size: 0.9rem; border-bottom: 1px dashed var(--line);
}
.qa-qrow span { min-width: 0; overflow-wrap: anywhere; color: var(--text-soft); }
.qa-qrow > b { flex: none; white-space: nowrap; }
.qa-qrow small { color: var(--text-mute); }
.qa-qrow.muted { color: var(--text-mute); font-size: 0.82rem; }
.qa-qrow.total { border-bottom: 0; padding-top: 11px; font-size: 1.02rem; }
.qa-qrow.total span { color: var(--text); }
.qa-qrow.total b { font-family: var(--font-head); font-size: 1.3rem; color: var(--brand-2); }
.qa-qrow.gross { border-bottom: 0; }
.qa-qmeta { font-size: 0.76rem; color: var(--text-mute); padding: 8px 0 2px; }

.qa-insight {
  margin-top: 12px; border: 1px dashed rgba(21, 200, 160, 0.4);
  background: rgba(21, 200, 160, 0.06); border-radius: var(--r-md);
  padding: 10px 12px; font-size: 0.8rem; color: var(--text-soft);
}
.qa-insight b { color: var(--ok); }
.qa-insight .row { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }
.qa-insight .head {
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ok); margin-bottom: 4px;
}

.qa-actions {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px; margin-top: 14px;
}
.qa-actions .btn { white-space: normal; padding-inline: 12px; }
.qa-saved-as { margin-top: 10px; font-size: 0.8rem; color: var(--ok); }

/* ---------- saved quotes ---------- */
.qa-saved-card { max-width: 1100px; margin-inline: auto; }
.qa-saved-empty { color: var(--text-mute); text-align: center; padding: 40px 10px; }
table.qa-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.qa-table th {
  text-align: left; font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-mute); padding: 6px 10px 8px 0; border-bottom: 1px solid var(--line-2);
}
.qa-table td { padding: 9px 10px 9px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
.qa-table td.num { white-space: nowrap; font-weight: 600; }
.qa-table .ref { font-family: var(--font-head); font-weight: 600; color: var(--brand-2); }
.qa-table select {
  width: auto; padding: 4px 8px; font-size: 0.78rem; border-radius: var(--r-pill);
}
.qa-table .row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.qa-table .row-actions button {
  border: 1px solid var(--line-2); background: none; color: var(--text-soft); cursor: pointer;
  border-radius: var(--r-pill); font-size: 0.74rem; padding: 4px 11px;
}
.qa-table .row-actions button:hover { border-color: var(--brand); color: var(--brand-2); }
.qa-table .row-actions button.del:hover { border-color: #e05555; color: #ff8a8a; }
.qa-status-draft { color: var(--text-soft); }
.qa-status-sent { color: #7ab8ff; }
.qa-status-won { color: var(--ok); }
.qa-status-lost { color: #ff8a8a; }

/* ---------- settings ---------- */
.qa-set-toolbar {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; max-width: 1100px; margin: 0 auto 18px;
}
.qa-set-toolbar h2 { font-size: 1.3rem; }
.qa-set-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.qa-io-btn {
  font-size: 0.8rem; font-weight: 600; color: var(--text-soft); cursor: pointer;
  border: 1px solid var(--line-2); border-radius: var(--r-pill); padding: 8px 15px; background: none;
  display: inline-block;
}
.qa-io-btn:hover { border-color: var(--brand); color: var(--brand-2); }

.qa-set-body { max-width: 1100px; margin-inline: auto; display: grid; gap: 16px; }
.qa-set-section {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 20px;
}
.qa-set-section h3 {
  font-size: 0.76rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-soft); margin-bottom: 12px;
}
.qa-set-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.qa-set-field { display: grid; gap: 4px; font-size: 0.76rem; color: var(--text-soft); }
.qa-set-field input, .qa-set-field select {
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  padding: 8px 10px; width: 100%; color: var(--text);
}
table.qa-set-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.qa-set-table th {
  text-align: left; font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-mute); padding: 4px 6px 6px 0;
}
.qa-set-table td { padding: 3px 6px 3px 0; }
.qa-set-table input[type="text"], .qa-set-table input[type="number"] {
  width: 100%; min-width: 52px; background: var(--bg-2); border: 1px solid var(--line-2);
  border-radius: var(--r-sm); padding: 6px 8px; color: var(--text);
}
.qa-set-table input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--brand); }
.qa-set-del {
  border: 0; background: none; color: var(--text-mute); cursor: pointer;
  font-size: 1.05rem; padding: 2px 6px; border-radius: var(--r-sm);
}
.qa-set-del:hover { background: rgba(255, 106, 26, 0.18); color: var(--brand-2); }
.qa-set-add { margin-top: 10px; }

/* ---------- toast ---------- */
.qa-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: #222d3c; color: var(--text); font-size: 0.88rem;
  padding: 11px 20px; border-radius: var(--r-pill); border: 1px solid var(--line-2);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  opacity: 0; pointer-events: none; transition: opacity var(--t), transform var(--t);
  z-index: 300; max-width: min(92vw, 560px); text-align: center;
}
.qa-toast.show { opacity: 1; transform: translate(-50%, 0); }
.qa-toast.err { background: #4a1d1d; border-color: rgba(224, 85, 85, 0.5); }

/* ---------- print ---------- */
#qa-print { display: none; }
@media print {
  body.qa-printing > *:not(#qa-print) { display: none !important; }
  body.qa-printing { background: #fff; }
  body.qa-printing #qa-print { display: block; font-size: 12px; color: #111; font-family: "Inter", "Segoe UI", sans-serif; }
  #qa-print .p-head { display: flex; align-items: center; gap: 18px; border-bottom: 3px solid #ff6a1a; padding-bottom: 14px; margin-bottom: 18px; }
  #qa-print .p-head img { height: 62px; width: auto; }
  #qa-print h1 { font-size: 26px; margin: 0; color: #111; }
  #qa-print .p-head p { color: #555; margin: 2px 0 0; }
  #qa-print .p-cols { display: flex; gap: 30px; margin-bottom: 18px; }
  #qa-print .p-cols h3 { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: #888; margin: 0 0 4px; }
  #qa-print .p-cols p { margin: 0; line-height: 1.5; }
  #qa-print table { width: 100%; border-collapse: collapse; }
  #qa-print th { text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: #888; border-bottom: 1.5px solid #ccc; padding: 6px 8px 6px 0; }
  #qa-print td { border-bottom: 1px solid #e5e5e5; padding: 7px 8px 7px 0; vertical-align: top; }
  #qa-print td small { color: #666; }
  #qa-print tr.tot td { font-weight: 700; font-size: 14px; border-bottom: 2px solid #ff6a1a; }
  #qa-print .p-foot { margin-top: 22px; font-size: 10px; color: #777; line-height: 1.6; }
}
