/*
VOICE: Icon Media's operations desk: calm, dense, built for a Pro AVL integrator.
IDEA: an integrator's job binder: client, quote, proposal, PO, all one record.
PICTURE: the working tables (quote builder, pipeline, PO lines) are the picture.
COLOUR and TYPE: charcoal sidebar #0f1a20 from the logo, Icon green accent (#467d12 light / #8fc02b dark), system UI type, tabular numbers.
LAYOUT: fixed sidebar, sticky title bar, cards on a cool grey ground; tab bar on phones.
*/
:root {
  --bg: #f3f5f9; --card: #ffffff; --text: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --side: #0f1a20; --side-text: #c7d2d9; --side-active: #1f3340; --brand: #8fc02b; --on-accent: #ffffff;
  --accent: #467d12; --green: #16a34a; --orange: #ea580c; --red: #dc2626; --blue: #2563eb;
  --teal: #0d9488; --indigo: #4f46e5; --purple: #9333ea; --yellow: #ca8a04; --gray: #64748b;
  --radius: 14px; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 1px 8px rgba(15,23,42,.04);
  --input: #f7f9f8;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) { --bg: #0b1216; --card: #131c22; --text: #e6ebe8; --muted: #94a3a8; --line: #24323a; --shadow: none; --side: #081014; --side-active: #1a2c36; --input: #0f171c; --accent: #8fc02b; --on-accent: #0c1404; }
}
:root[data-theme=dark] { color-scheme: dark; --bg: #0b1216; --card: #131c22; --text: #e6ebe8; --muted: #94a3a8; --line: #24323a; --shadow: none; --side: #081014; --side-active: #1a2c36; --input: #0f171c; --accent: #8fc02b; --on-accent: #0c1404; }
:root[data-theme=light] { color-scheme: light; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; overflow-x: clip; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
#app { display: grid; grid-template-columns: 232px minmax(0,1fr); min-height: 100vh; }

/* Sidebar */
#sidebar { background: var(--side); color: var(--side-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 12px; }
.brand { display: block; padding: 6px 10px 20px; }
.brand img { width: 150px; height: auto; display: block; }
.brand span { display: block; margin-top: 8px; font-size: 11px; letter-spacing: .02em; opacity: .65; }
#nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; color: var(--side-text); text-decoration: none; margin-bottom: 2px; }
#nav a:hover { background: rgba(255,255,255,.06); }
#nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--brand); }
.ico { width: 20px; height: 20px; flex: none; display: inline-grid; place-items: center; }
.ico svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-foot { margin-top: auto; font-size: 12px; opacity: .7; padding: 8px; }

/* Main */
#main { min-width: 0; padding: 0 24px 40px; }
#topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 0 12px; position: sticky; top: 0; background: var(--bg); z-index: 5; flex-wrap: wrap; }
.tb-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
#topbar h1 { margin: 0; font-size: 26px; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.icon-btn { border: 1px solid var(--line); background: var(--card); border-radius: 10px; width: 38px; height: 38px; font-size: 22px; cursor: pointer; display: inline-grid; place-items: center; text-decoration: none; color: var(--text); flex: none; }
#tabbar { display: none; }

/* Building blocks */
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); margin-bottom: 16px; }
.cols { display: grid; gap: 12px; grid-template-columns: minmax(0,1fr) minmax(0,1fr); margin-bottom: 16px; align-items: start; }
.cols.eq { align-items: stretch; } .cols.eq > .card { display: flex; flex-direction: column; margin: 0; }
.po-notes textarea { flex: 1; min-height: 120px; resize: vertical; } .po-notes .toolbar { margin-top: auto !important; padding-top: 14px; }
.cols.wide-l { grid-template-columns: minmax(0,1.6fr) minmax(0,1fr); }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; border: 1px solid var(--line); min-width: 0; }
.stack > * + * { margin-top: 12px; }
.card h3 { margin: 0 0 12px; font-size: 15px; display: flex; align-items: center; gap: 8px; justify-content: space-between; flex-wrap: wrap; }
.tile { display: flex; flex-direction: column; gap: 4px; min-height: 100px; }
.tile .t-head { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.tile .t-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.tile .t-val { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.01em; white-space: nowrap; }
.tile .t-cap { font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.right { text-align: right; }
.clickable { cursor: pointer; }
.clickable:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.chip { display: inline-block; font-size: 11px; font-weight: 650; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c); white-space: nowrap; }
.bar { height: 8px; border-radius: 99px; background: color-mix(in srgb, var(--muted) 18%, transparent); overflow: hidden; margin: 6px 0 4px; }
.bar > div { height: 100%; border-radius: 99px; background: var(--c); }
.banner { padding: 11px 14px; border-radius: 10px; margin-bottom: 10px; font-size: 14px; background: color-mix(in srgb, var(--c) 12%, transparent); color: var(--c); }
.btn { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); border-radius: 9px; padding: 8px 13px; cursor: pointer; font-weight: 550; white-space: nowrap; min-height: 38px; }
.btn:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.danger { color: var(--red); }
.btn.small { padding: 4px 9px; font-size: 13px; min-height: 30px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible, .icon-btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.x { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 4px 6px; border-radius: 6px; }
.x:hover { color: var(--red); background: color-mix(in srgb, var(--red) 10%, transparent); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--card); flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 7px 12px; cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--accent); color: var(--on-accent); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .sp { flex: 1; }
input:not([type]), input[type=text], input[type=number], input[type=date], input[type=search], input[type=email], input[type=tel], input[type=url], input[type=password], select, textarea { border: 1px solid var(--line); background: var(--card); border-radius: 9px; padding: 8px 10px; width: 100%; min-height: 38px; }
input[type=color] { width: 44px; height: 38px; border: 1px solid var(--line); border-radius: 9px; padding: 2px; background: var(--card); }
textarea { min-height: 80px; resize: vertical; line-height: 1.45; }
.toolbar select, .toolbar input { width: auto; }
.search { min-width: 200px; max-width: 280px; }
.section-title { font-size: 13px; color: var(--muted); margin: 18px 0 8px; font-weight: 600; }
.loading { padding: 60px; text-align: center; color: var(--muted); }
.empty { padding: 22px; text-align: center; color: var(--muted); }
.kv { display: grid; grid-template-columns: max-content minmax(0,1fr); gap: 6px 16px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.scroll { overflow-x: auto; }

/* Tables */
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
.t th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t th.r, .t td.r { text-align: right; }
.t tbody tr.clickable:hover td { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.t td .title { font-weight: 550; }
.t td .sub { font-size: 12px; color: var(--muted); }
.t tfoot td { font-weight: 650; border-top: 1px solid var(--line); border-bottom: 0; }

/* Editable grid (quote, PO, rates) */
table.ed { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 1000px; table-layout: fixed; }
.ed th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 600; padding: 6px 4px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ed th.r { text-align: right; }
.ed th.c { text-align: center; }
.ed td { padding: 3px 3px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ed input, .ed select { min-height: 34px; padding: 5px 7px; border-radius: 7px; border-color: transparent; background: var(--input); }
.ed input:hover, .ed select:hover { border-color: var(--line); }
.ed input:focus, .ed select:focus { border-color: var(--accent); background: var(--card); outline: none; }
.ed input.r { text-align: right; font-variant-numeric: tabular-nums; }
.ed .out { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; padding: 0 8px; font-weight: 550; }
table.ed.small-min { min-width: 600px; }
.w-qty { width: 64px; } .w-money { width: 104px; } .w-pct { width: 78px; } .w-x { width: 34px; }
.qsec { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; }
.qsec-h { display: flex; gap: 10px; align-items: center; margin-bottom: 4px; }
.qsec-h input { font-weight: 650; font-size: 15px; border-color: transparent; background: transparent; padding-left: 4px; }
.qsec-h input:hover, .qsec-h input:focus { border-color: var(--line); background: var(--card); }
.qsec-h .num { color: var(--muted); }
.qgrid { display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: 12px; align-items: start; }
.qsum-cols { display: block; }
.sticky { position: sticky; top: 84px; }
.sum-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; font-size: 14px; }
.sum-row .num { font-weight: 600; }
.sum-row.total { border-top: 2px solid var(--text); margin-top: 6px; padding-top: 10px; font-size: 18px; font-weight: 700; }
.sum-row input { width: 110px; text-align: right; min-height: 32px; padding: 4px 8px; }
.sum-sep { border-top: 1px solid var(--line); margin: 8px 0; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 4px 0 14px; overflow-x: auto; }
.tabs button { border: 0; background: transparent; padding: 10px 14px; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.tabs .count { font-size: 11px; background: color-mix(in srgb, var(--muted) 16%, transparent); border-radius: 99px; padding: 1px 7px; margin-left: 4px; }

/* Header record */
.rec-h { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 10px 14px; }
.rec-h label, .field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.two { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 10px; }
.three { display: grid; grid-template-columns: minmax(0,2fr) minmax(0,1fr) minmax(0,1.2fr); gap: 10px; }
.check-line { display: flex; align-items: center; gap: 10px; padding: 6px 0; cursor: pointer; }
.check-line input { width: 18px; height: 18px; accent-color: var(--accent); }

/* Charts */
.fig { position: relative; height: 230px; }
.fig > svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.fig text { fill: var(--muted); font-size: 11px; }
.fig .gl { stroke: var(--line); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 170px) minmax(0,1fr) max-content; gap: 10px; align-items: center; padding: 6px 0; font-size: 13.5px; }
.hbar .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .bars { display: flex; flex-direction: column; gap: 3px; }
.hbar .bars div { height: 9px; border-radius: 4px; background: var(--c); min-width: 2px; }
.hbar .v { text-align: right; font-variant-numeric: tabular-nums; font-size: 12.5px; white-space: nowrap; }

/* Notes / activity */
.note { padding: 10px 0; border-bottom: 1px solid var(--line); }
.note:last-child { border-bottom: 0; }
.note .when { font-size: 12px; color: var(--muted); }
.note .txt { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; }

/* Proposal preview frame */
.paper { background: #fff; color: #111; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(15,23,42,.10); max-width: 880px; margin: 0 auto; }
.preview-wrap { background: color-mix(in srgb, var(--muted) 10%, var(--bg)); border-radius: var(--radius); padding: 18px; }

/* Modal */
.modal-back { position: fixed; inset: 0; background: rgba(2,6,23,.45); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal { background: var(--card); border-radius: 16px; width: min(600px, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { width: min(820px, 100%); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); z-index: 1; }
.modal header h2 { margin: 0; font-size: 17px; }
.modal .body { padding: 16px 18px; }
.modal footer { display: flex; justify-content: space-between; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--card); flex-wrap: wrap; }
.modal footer .r { display: flex; gap: 8px; margin-left: auto; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60; max-width: 90vw; }
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }

.onb { max-width: 640px; margin: 40px auto; text-align: center; }
.onb h2 { font-size: 24px; margin: 12px 0 6px; }
.onb p { color: var(--muted); }
.onb .acts { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }

.dcols { display: grid; gap: 12px; grid-template-columns: minmax(0,450px) minmax(0,1fr); align-items: start; }
.dprev-wrap { position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow: auto; }
@media (max-width: 1560px) {
  .qgrid { grid-template-columns: minmax(0,1fr); }
  .qgrid > .qsum { position: static; display: grid; grid-template-columns: repeat(auto-fit, minmax(250px,1fr)); column-gap: 32px; align-items: start; }
  .qgrid > .qsum > h3 { grid-column: 1 / -1; }
  .qgrid > .qsum > div > .sum-sep:first-child { display: none; }
}
@media (max-width: 1100px) {
  .dcols { grid-template-columns: minmax(0,1fr); }
  .dprev-wrap { position: static; max-height: none; }
  .qgrid { grid-template-columns: minmax(0,1fr); }
  .sticky { position: static; }
}
@media (max-width: 900px) {
  .cols, .cols.wide-l { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 760px) {
  #app { grid-template-columns: minmax(0,1fr); }
  #sidebar { display: none; }
  #main { padding: 0 14px calc(84px + env(safe-area-inset-bottom)); }
  #topbar { padding-top: calc(14px + env(safe-area-inset-top)); }
  #topbar h1 { font-size: 22px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { min-height: 88px; padding: 12px; }
  .tile .t-val { font-size: 20px; }
  #tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--card); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 30; overflow-x: auto; }
  #tabbar a { flex: 1 0 64px; text-align: center; text-decoration: none; color: var(--muted); font-size: 10.5px; padding: 4px 0; display: flex; flex-direction: column; align-items: center; gap: 2px; }
  #tabbar a.active { color: var(--accent); }
  .search { max-width: none; flex: 1; }
  .two { grid-template-columns: minmax(0,1fr); }
  .three { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
  .three > .field:first-child { grid-column: 1 / -1; }
  input, select, textarea { font-size: 16px !important; }
  .hbar { grid-template-columns: 90px minmax(0,1fr) max-content; }
  .preview-wrap { padding: 6px; }
}
@media (max-width: 600px) {
  table.t.mstack thead { display: none; }
  table.t.mstack tr { display: grid; padding: 8px 0; border-bottom: 1px solid var(--line); }
  table.t.mstack td { display: flow-root; border: 0; padding: 3px 0 3px 7.5em; text-align: left !important; }
  table.t.mstack td::before { content: attr(data-l); float: left; width: 7em; margin-left: -7.5em; color: var(--muted); font-size: 12px; }
  table.t.mstack td:empty { display: none; }
}
.toolbar input[type=color] { flex: none; width: 44px; }
.toolbar input[type=color] + input[type=text] { flex: 1; width: auto; min-width: 0; }
.qsec-h input { min-width: 0; flex: 1; }

/* Drag & drop import */
.drop { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; border: 2px dashed color-mix(in srgb, var(--accent) 40%, var(--line)); border-radius: var(--radius); padding: 22px; margin-bottom: 12px; background: color-mix(in srgb, var(--accent) 4%, var(--card)); transition: background .15s, border-color .15s; }
.drop.slim { padding: 12px 14px; margin: 8px 0 0; }
.drop b { display: block; }
[data-drop].over, .drop.over, [data-drop].over .drop { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--card)); }
.card[data-drop].over, .qsec[data-drop].over { outline: 2px dashed var(--accent); outline-offset: 2px; }
body.dragging .drop.slim { border-color: var(--accent); }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0 12px; }
.add-wrap { display: inline-flex; gap: 6px; align-items: center; }
.add-wrap input { min-height: 30px; padding: 3px 6px; width: 64px; }
/* Receiving & picking */
.rcv { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.rcv-h { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.rcv-g { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.rcv label, .rcv-g label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.pk-check { width: 22px; height: 22px; accent-color: var(--green); cursor: pointer; }
@media (prefers-reduced-motion: reduce) { .drop { transition: none; } }

/* Barcode scanning */
.scanbar { display: flex; align-items: center; gap: 8px; border: 2px solid color-mix(in srgb, var(--accent) 45%, var(--line)); border-radius: 12px; padding: 4px 6px 4px 12px; background: var(--card); }
.scanbar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 15%, transparent); }
.scanbar input[type=text] { border: 0; background: transparent; font-size: 17px; min-height: 44px; padding: 6px 4px; outline: none !important; }
.scan-ico { color: var(--accent); display: inline-grid; place-items: center; flex: none; }
.scanmsg { min-height: 0; font-size: 14px; margin: 6px 2px 0; }
.scanmsg:empty { display: none; }
.scanmsg.ok { color: var(--green); }
.scanmsg.err { color: var(--red); font-weight: 600; }
.scanmsg .btn { margin: 4px 4px 0 0; color: var(--text); }
.scancard { margin-bottom: 12px; padding: 12px; }
.scancard > .small { margin-top: 8px; }
.scanmini { margin-bottom: 12px; }
.choose { border: 1px solid color-mix(in srgb, var(--orange) 50%, var(--line)); background: color-mix(in srgb, var(--orange) 8%, var(--card)); border-radius: 10px; padding: 10px 12px; margin-top: 10px; }
.scanhelp { margin: 10px 0 0; font-size: 14px; }
.scanhelp summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.scanhelp ol { margin: 8px 0; padding-left: 20px; }
.rcv { cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.rcv.sel { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
tr.here td { background: color-mix(in srgb, var(--yellow) 14%, transparent); }
tr.flash td { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: color-mix(in srgb, var(--green) 30%, transparent); } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { tr.flash td { animation: none; } .rcv { transition: none; } }

/* Icon Media brand */
.logo-prev { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; background: #fff; }
.logo-prev.dark { background: #14212a; }
.logo-prev img { height: 44px; width: auto; display: block; }
.onb-logo { background: var(--side); border-radius: 14px; padding: 18px 24px; display: inline-block; }
.onb-logo img { height: 64px; width: auto; display: block; }

/* Signed-in user + sign-in screens (iconmedia.app) */
.me { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.me-n { color: #fff; font-weight: 600; font-size: 13px; opacity: 1; }
.me-r { font-size: 11px; }
.side-link { background: none; border: 0; color: var(--brand); padding: 0; cursor: pointer; font-size: 12px; font-weight: 600; }
body.auth-mode #app { display: none; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); background: radial-gradient(1100px 600px at 15% -10%, #1f3340 0%, #0f1a20 55%, #081014 100%); }
.auth-card { width: min(420px, 100%); background: var(--card); color: var(--text); border-radius: 18px; padding: 0 28px 26px; box-shadow: 0 30px 80px rgba(0,0,0,.4); overflow: hidden; }
.auth-brand { background: #0f1a20; margin: 0 -28px 18px; padding: 22px 28px; }
.auth-brand img { height: 54px; width: auto; display: block; }
.auth-card h1 { font-size: 22px; margin: 4px 0 2px; }
.auth-card h1 + .field { margin-top: 16px; }
.auth-card > p { margin: 0 0 16px; font-size: 14px; }
.auth-card input[type=password] { border: 1px solid var(--line); background: var(--card); border-radius: 9px; padding: 8px 10px; width: 100%; min-height: 44px; font-size: 16px; }
.auth-card input[type=text] { min-height: 44px; font-size: 16px; }
.btn.wide { width: 100%; justify-content: center; min-height: 46px; margin-top: 6px; font-size: 16px; }
.auth-msg { color: var(--red); font-size: 14px; margin-top: 10px; min-height: 1em; }

.ed th:empty { width: 40px; }

/* Client details: balanced layout */
.grid.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; align-items: stretch; }
.cgrid > .card { display: flex; flex-direction: column; min-height: 260px; }
.cgrid .cbody { flex: 1; max-height: 340px; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
@media (max-width: 900px) { .cgrid { grid-template-columns: minmax(0, 1fr); } .cgrid > .card { min-height: 0; } }
@media (max-width: 760px) { .grid.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; } .grid.g3 .tile { padding: 10px; min-height: 0; } .grid.g3 .t-val { font-size: 16px; white-space: normal; overflow-wrap: anywhere; } .grid.g3 .t-head { font-size: 11.5px; } }

.cb-field { margin-top: 24px; min-height: 38px; }
@media (max-width: 760px) { .cb-field { margin-top: 0; } }
input:disabled { opacity: .55; }
.field label.check-line { font-size: 15px; color: var(--text); margin-bottom: 0; }

/* Dashboard: one even row of tiles, matched halves below */
.grid.g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.cgrid.dash > .card { min-height: 330px; }
.cgrid.dash .fig { flex: 1; min-height: 230px; }
@media (max-width: 1280px) { .grid.g6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) { .grid.g6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cgrid.dash > .card { min-height: 0; } }

/* Purchasing: four even tiles, full-width filter */
.grid.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.po-tools { flex-direction: column; align-items: stretch; gap: 10px; }
.po-tools .search { max-width: none; width: 100%; }
.seg.full { display: flex; width: 100%; flex-wrap: nowrap; }
.seg.full button { flex: 1 1 0; min-width: 0; padding: 9px 6px; text-align: center; overflow: hidden; text-overflow: ellipsis; }
.seg.full button + button { border-left: 1px solid var(--line); }
.seg.full button.on + button, .seg.full button + button.on { border-left-color: transparent; }
@media (max-width: 900px) { .grid.g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .seg.full { flex-wrap: wrap; } .seg.full button { flex: 1 1 30%; font-size: 13.5px; white-space: normal; line-height: 1.2; min-height: 42px; } }

/* Inventory: filters span the table width */
.inv-tools { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.inv-tools .search, .inv-tools select { width: 100%; max-width: none; min-width: 0; }
@media (max-width: 760px) { .inv-tools { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .inv-tools .search { grid-column: 1 / -1; } }

/* Reports: selectors fill the row */
.rep-tools { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 5fr); gap: 10px; }
@media (max-width: 760px) { .rep-tools { grid-template-columns: minmax(0, 1fr); } }

/* Company: matched pairs */
.cgrid.co > .card { min-height: 0; }
.cgrid.co > .card > p.small:last-of-type { margin-top: auto; padding-top: 10px; margin-bottom: 0; }
.list-ed td input { width: 100%; }
.cgrid.co > .card > .btn, .cgrid.co .card > .btn.small { align-self: flex-start; }
.list-ed td input.r { text-align: right; }

/* Price list editor */
.ple-head { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr); }
.ple-meta { min-height: 38px; display: flex; align-items: center; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.ple-tools { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.ple-tools .search { max-width: none; width: 100%; }
@media (max-width: 760px) { .ple-head { grid-template-columns: minmax(0, 1fr); } }
.ple-disc { display: flex; gap: 6px; } .ple-disc input { flex: 1; min-width: 0; } .ple-disc .btn { flex: none; }

/* ---- Jetbuilt-style quoting: rooms × systems, labor, factors, margins, change orders ---- */
table.ed.qtab { min-width: 1080px; }
.ed select { width: 100%; }
.lab-btn { width: 100%; min-height: 34px; border-radius: 7px; border: 1px dashed var(--line); background: transparent; color: var(--muted); cursor: pointer; font: inherit; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.lab-btn:hover { border-color: var(--accent); color: var(--accent); }
.lab-btn.on { border-style: solid; border-color: transparent; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--text); font-weight: 600; }
.x.lock { color: var(--muted); opacity: .55; }
.x.lock:hover { opacity: 1; }
.x.lock.on { color: var(--accent); opacity: 1; }
.cu-cell { position: relative; }
.cu-dot { position: absolute; left: -2px; top: 50%; transform: translateY(-50%); z-index: 1; width: 15px; height: 15px; border-radius: 50%; background: var(--red); color: #fff; font-size: 10.5px; font-weight: 800; display: grid; place-items: center; cursor: help; }
tr.cost-up td:first-child { box-shadow: inset 3px 0 0 var(--red); }
.qgrid .banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; --c: var(--blue); }
.qgrid .banner.warn { --c: var(--red); }
.chip-btn { border: 0; background: transparent; padding: 0; cursor: pointer; }
.ov3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; align-items: stretch; }
.ov2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; align-items: stretch; }
.ov3 > .card, .ov2 > .card { margin: 0; }
@media (max-width: 1000px) { .ov3, .ov2 { grid-template-columns: minmax(0, 1fr); } }
.ov-t td, .ov-t th { padding: 6px 4px; }
.ov-t tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
.mbar { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 5px 0; font-size: 13.5px; }
.mbar .mb-n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mbar .mb-n b { font-weight: 650; }
.mbar .mb-t { height: 10px; border-radius: 99px; background: color-mix(in srgb, var(--muted) 18%, transparent); overflow: hidden; }
.mbar .mb-t i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.mbar .mb-v { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.mbar.tot { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 9px; font-weight: 700; }
.mbar.tot .mb-t i { background: var(--text); }
.fac-t td.c, .fac-t th.c, .list-ed td.c { text-align: center; }
.fac-t input[type=checkbox], .list-ed input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
.gate { text-align: center; padding: 34px 20px; }
.gate h3 { justify-content: center; }
.gate p { max-width: 520px; margin: 6px auto 16px; }
.scope-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 900px) { .scope-grid { grid-template-columns: minmax(0, 1fr); } }
.co-h { grid-template-columns: 150px minmax(0, 2fr) 170px 160px !important; }

/* ---- operations: activity, discussion, files, time, calendar, bulk edit, dashboard ---- */
#nav a { position: relative; }
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
.act-list { padding: 4px 14px; }
.act { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.act:last-child { border-bottom: 0; }
.act.new { background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 9%, transparent), transparent 60%); margin: 0 -14px; padding-left: 14px; padding-right: 14px; }
.act-h { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13.5px; }
.act-t { margin-top: 3px; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.talk { align-items: stretch; }
.talk > .card { display: flex; flex-direction: column; margin: 0; }
.thread { flex: 1; max-height: 460px; min-height: 160px; overflow-y: auto; }
.msg { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.msg-tools { margin-left: auto; display: inline-flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.msg:hover .msg-tools { opacity: 1; }
.file-ico { width: 40px; height: 40px; border-radius: 9px; display: grid; place-items: center; font-size: 10.5px; font-weight: 800; color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); flex: none; }
[data-drop="files"].over { outline: 2px dashed var(--accent); outline-offset: 2px; }
.time-add { display: grid; grid-template-columns: 150px 160px minmax(150px, 200px) 90px minmax(0, 1fr) auto; gap: 8px; margin-bottom: 10px; align-items: center; }
@media (max-width: 1000px) { .time-add { grid-template-columns: 1fr 1fr; } }
.pl-t tr.tot td { font-weight: 700; border-top: 2px solid var(--line); }
.big-cb, [data-pc], [data-sk], [data-psel], #pc-all, #psel-all { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.po-view { margin-bottom: 12px; }
.seg .count, .po-view .count { font-size: 11px; background: color-mix(in srgb, var(--muted) 18%, transparent); border-radius: 99px; padding: 1px 7px; margin-left: 4px; }
.po-view .count.low { background: var(--red); color: #fff; }
.pc-tools { flex-wrap: wrap; }
.pc-tools select { max-width: 280px; }
tr.low td { background: color-mix(in srgb, var(--red) 6%, transparent); }
/* calendar */
.cal-tools .cal-m { font-size: 17px; min-width: 150px; text-align: center; }
.cal { padding: 0; overflow: hidden; margin-bottom: 12px; }
.cal-g { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-dh { padding: 8px 10px; font-size: 12px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--muted) 5%, transparent); }
.cal-d { min-height: 112px; padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); cursor: pointer; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-d:nth-child(7n) { border-right: 0; }
.cal-d:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.cal-d.out { background: color-mix(in srgb, var(--muted) 6%, transparent); }
.cal-d.out .cal-n { color: var(--muted); }
.cal-n { font-size: 12.5px; font-weight: 600; }
.cal-d.today .cal-n { background: var(--accent); color: var(--on-accent, #fff); border-radius: 99px; width: 24px; height: 24px; display: grid; place-items: center; }
.cal-ev { display: block; width: 100%; text-align: left; border: 0; border-left: 3px solid var(--c); background: color-mix(in srgb, var(--c) 15%, transparent); color: var(--text); font: inherit; font-size: 11.5px; padding: 2px 5px; border-radius: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.cal-ev.cont { opacity: .75; }
.cal-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
@media (max-width: 760px) { .cal-d { min-height: 70px; padding: 3px; } .cal-ev { font-size: 10px; padding: 1px 3px; } }
/* projects list */
.w-cb { width: 34px; }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover, th.sorted { color: var(--text); }
.sort-i { font-size: 9px; margin-left: 4px; }
tr.sel td { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.bulk-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; margin-bottom: 10px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 12%, var(--card)); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.bulk-bar select, .bulk-bar input { width: auto; min-height: 34px; padding: 4px 8px; }
/* dashboard */
.dash-g { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: stretch; }
.dash-b { margin: 0; display: flex; flex-direction: column; min-height: 300px; min-width: 0; }
.dash-b.full { grid-column: 1 / -1; min-height: 0; }
.dash-b .cbody { flex: 1; max-height: 340px; overflow-y: auto; }
.dash-b .fig { flex: 1; min-height: 230px; }
.dash-b.full .grid { margin-bottom: 0; }
.dash-g.editing .dash-b { outline: 2px dashed color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
.dash-ctl { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px dashed var(--line); font-size: 12.5px; color: var(--muted); }
.dash-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
@media (max-width: 900px) { .dash-g { grid-template-columns: minmax(0, 1fr); } .dash-b { min-height: 0; } }

.scope-row { align-items: stretch; margin-bottom: 0; }
.scope-row > .card { display: flex; flex-direction: column; margin: 0; }
.scope-row > .card textarea[data-pf="scope"] { flex: 1; min-height: 220px; resize: vertical; }
.scope-row > .stack > .card:last-child { margin-bottom: 0; }

.bystage { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: center; }
.bs-leg { display: flex; flex-direction: column; gap: 4px; }
.bs-row { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 6px 6px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: 14px; }
.bs-row:hover { background: color-mix(in srgb, var(--muted) 10%, transparent); }
.bs-row i { width: 16px; height: 16px; border-radius: 4px; }
.bs-row .num { color: var(--muted); font-size: 13px; }
.bs-pie svg { width: 100%; max-width: 240px; display: block; margin: 0 auto; }
@media (max-width: 1100px) { .bystage { grid-template-columns: minmax(0, 1fr); } }
.dash-b h3 select, .card h3 #bs-mode { width: auto; flex: none; min-height: 30px; padding: 2px 28px 2px 10px; font-size: 13px; font-weight: 500; }

/* ---- proposal designer ---- */
.dctl .dgrp { padding: 0; margin: 0; }
.dctl .dgrp > summary { list-style: none; cursor: pointer; padding: 14px 16px; display: flex; align-items: center; }
.dctl .dgrp > summary::-webkit-details-marker { display: none; }
.dctl .dgrp > summary h3 { margin: 0; flex: 1; }
.dctl .dgrp > summary::after { content: '▾'; color: var(--muted); transition: transform .15s; }
.dctl .dgrp:not([open]) > summary::after { transform: rotate(-90deg); }
.dctl .dgrp > :not(summary) { margin-left: 16px; margin-right: 16px; }
.dctl .dgrp > :last-child { margin-bottom: 16px; }
.unit-in { display: flex; align-items: center; gap: 6px; }
.unit-in span { color: var(--muted); font-size: 12px; }
.fmt-toggles { display: flex; flex-wrap: wrap; gap: 2px 14px; }
.fmt-toggles .check-line { padding: 4px 0; }
.fmt-bar { display: flex; gap: 4px; margin-bottom: 4px; flex-wrap: wrap; }
.fmt-bar button { border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 6px; min-width: 32px; height: 28px; padding: 0 8px; cursor: pointer; font: inherit; font-size: 12.5px; }
.fmt-bar button:hover { border-color: var(--accent); color: var(--accent); }
.dsec-row { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.dsec-row.off { opacity: .55; }
.dsec-top { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.dsec-row textarea { width: 100%; }
.chip-unsaved { font-size: 12px; font-weight: 600; color: var(--orange); background: color-mix(in srgb, var(--orange) 14%, transparent); padding: 3px 10px; border-radius: 99px; }
.dprev-col { position: sticky; top: 12px; align-self: start; }

/* Google Calendar sync */
#gcal-card .chk { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-size: 13px; cursor: pointer; }
#gcal-card .chk input { width: auto; margin: 0; }
#gcal-card .kv dd select { max-width: 340px; }
.gc-steps { margin: 6px 0 10px; padding-left: 20px; line-height: 1.6; }
.gc-steps li { margin-bottom: 6px; }
.gc-steps code, #gcal-card code { font-size: 12px; background: var(--bg2, rgba(127,127,127,.12)); padding: 1px 5px; border-radius: 4px; }
.gc-uri { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.gc-uri code { word-break: break-all; }
.gc-g { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: #fff; color: #4285F4; font-weight: 800; font-size: 12px; font-family: Arial, sans-serif; box-shadow: 0 0 0 1px rgba(0,0,0,.12); }
.gc-connect { display: inline-flex; align-items: center; gap: 8px; }
.gc-badge-wrap { display: inline-flex; align-items: center; gap: 8px; margin-right: 8px; }
.gc-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.gc-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #4285F4; margin-right: 4px; vertical-align: middle; }
@media (max-width: 700px) { .gc-badge { display: none; } }
