/* Lux Production Quoter — site styles.
   Layout: a quote holds several part lines. Left: library, quote lines, the selected part's editor, breaks, schedule, history, rates. Right: sticky quote ticket. Company purple + grey, light only. */
:root {
  color-scheme: light;
  --bg: #dfe0e1;
  --sheet: #ffffff;
  --ink: #2e2d33;
  --muted: #66656c;
  --line: #cfd0d2;
  --field: #fbfbfb;
  --accent: #844c82;
  --accent-soft: #f4edf4;
  --accent-ink: #ffffff;
  --warn: #9a5b00;
  --warn-soft: #fff4e0;
  --good: #2f7a3e;
  --danger: #b3261e;
  --display: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --body: "Archivo", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
* { box-sizing: border-box; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 15px; line-height: 1.45;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 24px 48px;
}
.wrap { max-width: 1200px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
header { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; }
h1 { font-family: var(--display); font-stretch: 72%; font-weight: 800; font-size: clamp(30px, 5vw, 44px); line-height: 1; margin: 0; text-transform: uppercase; color: var(--accent); text-wrap: balance; }
.sub { color: var(--muted); margin: 6px 0 0; max-width: 72ch; }
.proto { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; background: var(--warn-soft); color: var(--warn); border: 1px solid currentColor; border-radius: 999px; padding: 2px 10px; vertical-align: middle; margin-left: 8px; }
.grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
@media (max-width: 920px) { .grid { grid-template-columns: minmax(0, 1fr); } }
.col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.card { background: var(--sheet); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.card-head { background: var(--accent-soft); padding: 10px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card-head h2 { margin: 0; font-family: var(--display); font-stretch: 80%; font-weight: 700; font-size: 17px; text-transform: uppercase; letter-spacing: .03em; color: var(--accent); }
.card-head .meta { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.card-body { padding: 14px; display: grid; gap: 12px; }
.row { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.editing { border-color: var(--accent); }
.editing .card-head { background: var(--accent); }
.editing .card-head h2, .editing .card-head .meta { color: var(--accent-ink); }

label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); min-width: 0; }
input, select { font: 500 15px var(--body); color: var(--ink); background: var(--field); border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px; width: 100%; min-width: 0; }
input[type=number] { font-family: var(--mono); font-variant-numeric: tabular-nums; }
input:focus-visible, select:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.check { flex-direction: row; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; font-size: 14px; font-weight: 500; color: var(--ink); min-height: 38px; align-self: end; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.calc-val { font-family: var(--mono); font-size: 15px; color: var(--ink); padding: 8px 0; }
.calc-val small { color: var(--muted); font-size: 12px; }

.stats { display: flex; flex-wrap: wrap; gap: 1px; background: var(--line); border-top: 1px solid var(--line); }
.stat { background: var(--sheet); padding: 10px 14px; flex: 1 1 120px; }
.stat .k { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stat .v { font-family: var(--mono); font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .n { font-size: 12px; color: var(--muted); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 3px 9px; border-radius: 999px; border: 1px solid currentColor; }
.tag.ok { color: var(--good); }
.tag.warn { color: var(--warn); background: var(--warn-soft); }
.tag.bad { color: var(--danger); }

.rackviz { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.rackviz svg { width: 150px; height: auto; flex: none; }
.rackviz .why { font-size: 13px; color: var(--muted); max-width: 46ch; }
.rackviz .why b { color: var(--ink); }

.lines { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 4px; }
.line { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; background: var(--sheet); }
.line:last-child { border-bottom: 0; }
.line:hover { background: var(--field); }
.line.sel { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.line .no { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.line .main { min-width: 0; }
.line .main b { font-family: var(--mono); font-weight: 600; }
.line .main small { display: block; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.line .price { font-family: var(--mono); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.line .price small { display: block; color: var(--muted); font-size: 12px; }
.line button { padding: 4px 8px; }
.line-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.ticket { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 16px); background: var(--sheet); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; box-shadow: 0 6px 24px rgba(80, 40, 78, .10); }
@media (max-width: 920px) { .ticket { position: static; } }
.ticket-top { background: var(--accent); color: var(--accent-ink); padding: 14px 16px; }
.ticket-top .lbl { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; }
.total { font-family: var(--display); font-stretch: 75%; font-weight: 800; font-size: 48px; line-height: 1.05; font-variant-numeric: tabular-nums; }
.ticket-top .per { font-family: var(--mono); font-size: 13px; }
.ticket dl { margin: 0; padding: 12px 16px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 12px; font-size: 14px; }
.ticket dt { color: var(--muted); min-width: 0; overflow-wrap: anywhere; }
.ticket dd { margin: 0; text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.ticket .sep { grid-column: 1 / -1; border-top: 1px solid var(--line); margin: 4px 0; }
.ticket .strong { color: var(--ink); font-weight: 700; }
.ticket .sect { grid-column: 1 / -1; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); padding-top: 4px; }
.flags { padding: 0 16px 14px; display: grid; gap: 6px; }
.flag { font-size: 12px; color: var(--warn); font-weight: 600; background: var(--warn-soft); border-radius: 4px; padding: 6px 8px; }
.flag.bad { color: var(--danger); background: #fdecea; }
.flag.ok { color: var(--good); background: #e9f5ec; }

.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 8px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
th { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--field); }
th:first-child, td:first-child { text-align: left; }
td { font-family: var(--mono); }
tr.current td { background: var(--accent-soft); font-weight: 600; }

.sched { display: grid; gap: 1px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); background: var(--line); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.sched .stat { flex: none; }
.sched .stat.big .v { color: var(--accent); font-size: 22px; }

details.panel { background: var(--sheet); border: 1px solid var(--line); border-radius: 6px; }
details.panel summary { cursor: pointer; padding: 12px 14px; font-family: var(--display); font-stretch: 80%; font-weight: 700; font-size: 17px; text-transform: uppercase; letter-spacing: .03em; color: var(--accent); }
details.panel .panel-body { padding: 4px 14px 16px; display: grid; gap: 16px; }
.panel h3 { margin: 0 0 8px; font-size: 13px; font-weight: 700; }
.hint { font-size: 12px; color: var(--muted); margin: 0; max-width: 72ch; }
.ph { display: inline-block; margin-left: 4px; font-size: 9px; letter-spacing: .06em; color: var(--warn); background: var(--warn-soft); border-radius: 3px; padding: 0 4px; vertical-align: 1px; }
button { font: 600 14px var(--body); cursor: pointer; border-radius: 4px; padding: 9px 14px; border: 1px solid var(--line); background: var(--sheet); color: var(--ink); }
button:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--danger); border-color: transparent; }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.ticket-actions { padding: 0 16px 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.ticket-actions button { flex: 1 1 120px; }
.toast { font-size: 12px; color: var(--muted); padding: 0 16px 14px; min-height: 1em; }
textarea.fallback { height: 160px; font: 12px var(--mono); margin: 0 16px 12px; width: calc(100% - 32px); background: var(--field); color: var(--ink); border: 1px solid var(--line); }

.list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 4px; max-height: 320px; overflow-y: auto; }
.list:empty { display: none; }
.li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); min-width: 0; }
.li:last-child { border-bottom: 0; }
.li .main { min-width: 0; }
.li .main b { font-family: var(--mono); font-weight: 600; }
.li .main small { display: block; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.li .acts { display: flex; gap: 6px; flex: none; align-items: center; }
.li button { padding: 6px 10px; font-size: 13px; }
.li .price { font-family: var(--mono); font-weight: 600; white-space: nowrap; }
.empty { font-size: 13px; color: var(--muted); padding: 4px 0; }

/* ---------- Site shell: sign-in gate, user bar, demo banner ---------- */
html, body { margin: 0; }
[hidden] { display: none !important; }
a { color: var(--accent); }
.gate { min-height: 100vh; display: grid; place-items: center; }
.gate-card { background: var(--sheet); border: 1px solid var(--line); border-radius: 8px; padding: 28px; width: min(420px, 100%); display: grid; gap: 16px; box-shadow: 0 10px 40px rgba(80, 40, 78, .12); }
.brand { font-family: var(--display); font-stretch: 75%; font-weight: 800; font-size: 34px; line-height: 1; color: var(--accent); letter-spacing: .02em; }
.brand span { display: block; font-family: var(--body); font-stretch: 100%; font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.gate h1 { font-size: 26px; }
.gate-btn { width: 100%; padding: 12px 14px; font-size: 15px; }
.gate-msg { color: var(--danger); font-size: 13px; margin: 0; min-height: 1em; }
.userbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.userbar button { padding: 6px 12px; font-size: 13px; }
.demo { background: var(--warn-soft); color: var(--warn); border: 1px solid currentColor; border-radius: 6px; padding: 8px 12px; font-size: 13px; font-weight: 600; }

/* ---------- Two modes: staff (default) and customer (html[data-mode="customer"]) ---------- */
html[data-mode="customer"] .internal { display: none !important; }
.customer-only { display: none !important; }
html[data-mode="customer"] .customer-only { display: revert !important; }
html[data-mode="customer"] .ticket-actions.customer-only { display: flex !important; }
html[data-mode="customer"] .card.customer-only { display: block !important; }
html[data-mode="customer"] .customer-only[hidden] { display: none !important; }
header .brand { margin-bottom: 8px; }
textarea { font: 500 15px var(--body); color: var(--ink); background: var(--field); border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px; width: 100%; resize: vertical; }
textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.field-error { border-color: var(--danger) !important; }

/* Zoho account lookup (staff) */
.acct { display: grid; gap: 6px; }
.acct .list { max-height: 220px; }
.acct .li { cursor: pointer; }
.acct .li:hover, .acct .li:focus-visible { background: var(--accent-soft); outline: none; }
.acct-chip { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; background: var(--accent-soft); border: 1px solid var(--accent); color: var(--ink); border-radius: 999px; padding: 4px 6px 4px 12px; width: fit-content; max-width: 100%; }
.acct-chip b { font-weight: 700; }
.acct-chip button { padding: 2px 8px; font-size: 12px; }

/* Submitted confirmation (customer) and Zoho result (staff) */
.submitted { margin: 0 16px 14px; padding: 12px 14px; border-radius: 6px; background: #e9f5ec; color: var(--good); font-size: 14px; }
.submitted b { color: var(--ink); }
.zoho-result { margin: 0 16px 12px; font-size: 13px; color: var(--muted); }

/* Color picker */
.swatch { display: inline-block; flex: none; width: 26px; height: 26px; border: 1px solid rgba(0,0,0,.28); border-radius: 4px; background-color: var(--field); }
.swatch.dot { width: 11px; height: 11px; margin-right: 5px; vertical-align: -1px; border-radius: 2px; }
.swatch.none { background-image: repeating-linear-gradient(45deg, var(--line) 0 3px, transparent 3px 6px); }
.swatch.fx-metal { background-image: linear-gradient(135deg, rgba(255,255,255,.42), rgba(255,255,255,0) 45%, rgba(0,0,0,.28)); }
.swatch.fx-texture { background-image: radial-gradient(rgba(255,255,255,.28) 1px, transparent 1.5px), radial-gradient(rgba(0,0,0,.3) 1px, transparent 1.5px); background-size: 5px 5px, 5px 5px; background-position: 0 0, 2px 2px; }
.color-field { display: flex; align-items: center; gap: 8px; }
.color-field input { flex: 1; min-width: 0; }
.color-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; }
.color-picker { margin-top: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--sheet); }
.color-picker[hidden] { display: none; }
.color-preview { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.color-preview .swatch { width: 72px; height: 72px; border-radius: 6px; }
.color-preview small { display: block; color: var(--muted); }
.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px; max-height: 340px; overflow-y: auto; margin: 8px 0; }
.color-tile { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 6px 8px; text-align: left; font: inherit; color: var(--ink); background: var(--field); border: 1px solid var(--line); border-radius: 4px; cursor: pointer; }
.color-tile:hover, .color-tile:focus-visible { border-color: var(--accent); }
.color-tile.sel { border-color: var(--accent); background: var(--accent-soft); }
.color-tile span:last-child { min-width: 0; overflow-wrap: anywhere; }
.color-tile b { display: block; font-size: 13px; }
.color-tile small { display: block; color: var(--muted); font-size: 11px; line-height: 1.3; }

/* Staff / customer view switch */
.view-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 14px; font-size: 13px; }
.view-bar[hidden] { display: none; }
.view-label { color: var(--muted); font-weight: 700; margin-right: 4px; }
.view-bar a { padding: 5px 12px; border: 1px solid var(--line); border-radius: 4px; background: var(--sheet); color: var(--ink); font-weight: 600; text-decoration: none; }
.view-bar a:hover, .view-bar a:focus-visible { border-color: var(--accent); }
.view-bar a[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.view-warn { margin-left: 6px; color: var(--warn); }

/* Drawing reader */
.drawing-part { margin: 10px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--field); }
.drawing-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.drawing-head button { margin-left: auto; }
.conf { padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 700; }
.conf-high { background: #e9f5ec; color: var(--good); }
.conf-medium { background: var(--warn-soft); color: var(--warn); }
.conf-low { background: #fbe9e7; color: var(--danger); }
.drawing-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
#drawing-status:not(:empty) { margin-top: 8px; font-weight: 600; color: var(--ink); }

/* Admin tabs */
.app-tabs { display: flex; gap: 4px; margin: 14px 0 0; border-bottom: 2px solid var(--line); }
.app-tabs[hidden] { display: none; }
.app-tabs a { padding: 8px 16px; margin-bottom: -2px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 700; text-decoration: none; }
.app-tabs a:hover, .app-tabs a:focus-visible { color: var(--ink); }
.app-tabs a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
#settings-view { display: grid; gap: 16px; margin-top: 16px; }
#settings-view[hidden] { display: none; }
#user-msg:not(:empty) { margin-top: 8px; font-weight: 600; color: var(--ink); }
#users-list { margin-top: 12px; }

#quoter-view[hidden] { display: none; }

/* Shop rates tab: the panel is always open here, so its toggle goes away */
#rates-view { margin-top: 16px; }
#rates-view[hidden] { display: none; }
#rates-view > details > summary { display: none; }
.app-tabs a[hidden] { display: none; }

/* Login screen: way through for customers */
.gate-customer { display: block; margin-top: 8px; padding: 10px 16px; border: 1px solid var(--accent); border-radius: 4px; background: var(--sheet); color: var(--accent); font-weight: 700; text-align: center; text-decoration: none; }
.gate-customer:hover, .gate-customer:focus-visible { background: var(--accent-soft); }

/* Primer and topcoat powder fields */
.layer-fields { display: contents; }
.layer-fields[hidden] { display: none; }
#cust-form, #user-form { display: grid; gap: 10px; }

/* Top bar with the Lux logo (customer pages: quote page, portal) */
.topbar { display: flex; align-items: center; gap: 16px; background: var(--sheet); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 18px; box-shadow: 0 1px 3px rgba(40, 20, 40, .05); }
.topbar .logo { display: flex; line-height: 0; }
.topbar .logo img { height: 48px; width: auto; }
.topbar-title { padding-left: 16px; border-left: 1px solid var(--line); font: 700 12px var(--body); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.topbar .userbar { margin-left: auto; }
.topbar-link { color: var(--accent); font-weight: 600; text-decoration: none; }
.topbar-link:hover { text-decoration: underline; }
html[data-mode="customer"] .topbar.customer-only { display: flex !important; }
.page-head { display: block; padding: 4px 2px 0; }
.page-head h1 { font-size: clamp(28px, 4vw, 40px); }
.gate-logo { line-height: 0; }
.gate-logo img { height: 64px; width: auto; }
@media (max-width: 560px) {
  .topbar { padding: 8px 12px; gap: 10px; }
  .topbar-title { display: none; }
  .topbar .logo img { height: 36px; }
}
