/* WSCG Construction CRM — brand: blue, black, white, light gray */
:root {
  --blue: #1747a6;
  --blue-600: #1d4ed8;
  --blue-50: #eff4ff;
  --blue-100: #dbe6fe;
  --ink: #0f172a;
  --ink-2: #1e293b;
  --text: #1f2937;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --bg: #f1f5f9;
  --card: #ffffff;
  --green: #15803d;
  --green-50: #ecfdf3;
  --amber: #b45309;
  --amber-50: #fffbeb;
  --red: #b91c1c;
  --red-50: #fef2f2;
  --purple: #6d28d9;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.18);
  --sidebar: 248px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { color: var(--ink); margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
h4 { font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.mono { font-variant-numeric: tabular-nums; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.top { align-items: flex-start; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.gap-s { gap: 6px; }
.mt { margin-top: 16px; }
.mt-s { margin-top: 8px; }
.mb { margin-bottom: 16px; }
.pre { white-space: pre-wrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { background: var(--ink); color: #cbd5e1; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; z-index: 40; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand-mark { width: 38px; height: 38px; border-radius: 8px; background: var(--blue); color: #fff; font-weight: 800; font-size: 11px; display: grid; place-items: center; letter-spacing: .03em; box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); }
.brand-name { color: #fff; font-weight: 750; font-size: 15px; line-height: 1.1; }
.brand-sub { font-size: 11px; color: #94a3b8; }
.nav { padding: 10px 10px 20px; flex: 1; }
.nav-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: #64748b; padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 7px; color: #cbd5e1; font-weight: 500; text-decoration: none; position: relative; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: var(--blue); color: #fff; }
.nav a.active::before { content: ""; position: absolute; left: -10px; top: 6px; bottom: 6px; width: 3px; border-radius: 3px; background: #60a5fa; }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav .count { margin-left: auto; background: #dc2626; color: #fff; font-size: 11px; border-radius: 10px; padding: 0 7px; font-weight: 700; }
.sidebar-foot { padding: 12px 18px; font-size: 11px; color: #64748b; border-top: 1px solid rgba(255,255,255,.07); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; background: #fff; border-bottom: 1px solid var(--line); height: 58px; display: flex; align-items: center; gap: 12px; padding: 0 20px; }
.menu-btn { display: none; }
.search { position: relative; flex: 1; max-width: 520px; }
.search input { width: 100%; padding: 8px 12px 8px 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.search input:focus { background: #fff; outline: 2px solid var(--blue-100); border-color: var(--blue-600); }
.search svg { position: absolute; left: 10px; top: 9px; width: 16px; height: 16px; color: var(--muted); }
.search-results { position: absolute; top: 42px; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); max-height: 420px; overflow: auto; z-index: 50; }
.search-results a { display: flex; gap: 10px; padding: 9px 12px; color: var(--text); border-bottom: 1px solid var(--line); }
.search-results a:hover, .search-results a.focus { background: var(--blue-50); text-decoration: none; }
.search-results .type { font-size: 11px; color: var(--muted); width: 80px; flex: none; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn { position: relative; width: 36px; height: 36px; border-radius: 8px; border: 1px solid transparent; background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { background: var(--bg); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn .dot { position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; border-radius: 8px; background: #dc2626; color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border-radius: 20px; cursor: pointer; border: 1px solid var(--line); background: #fff; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.user-chip .who { font-size: 12.5px; line-height: 1.1; }
.user-chip .role { font-size: 11px; color: var(--muted); }
.dropdown { position: absolute; right: 16px; top: 54px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); min-width: 280px; z-index: 60; overflow: hidden; }
.dropdown .item { display: block; padding: 10px 14px; border-bottom: 1px solid var(--line); color: var(--text); cursor: pointer; }
.dropdown .item:hover { background: var(--bg); text-decoration: none; }
.dropdown .item.unread { background: var(--blue-50); }
.content { padding: 22px 24px 60px; max-width: 1600px; width: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.crumbs { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }

/* ---------- Components ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card-body { padding: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: block; color: inherit; position: relative; overflow: hidden; }
a.kpi:hover { text-decoration: none; border-color: var(--blue-600); }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--blue); }
.kpi.warn::before { background: #dc2626; }
.kpi.money::before { background: var(--green); }
.kpi .label { font-size: 12px; color: var(--muted); font-weight: 550; }
.kpi .value { font-size: 24px; font-weight: 750; color: var(--ink); margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .hint { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line-2); background: #fff; color: var(--ink-2); font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none; line-height: 1.2; }
.btn:hover { background: var(--bg); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #123b8c; }
.btn.danger { color: var(--red); border-color: #fecaca; }
.btn.danger:hover { background: var(--red-50); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--bg); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn svg { width: 16px; height: 16px; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 8px 8px 0; }
.btn-group .btn.active { background: var(--blue-50); color: var(--blue); border-color: var(--blue-100); z-index: 1; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 650; background: var(--bg); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.badge.blue { background: var(--blue-50); color: var(--blue); border-color: var(--blue-100); }
.badge.green { background: var(--green-50); color: var(--green); border-color: #bbf7d0; }
.badge.amber { background: var(--amber-50); color: var(--amber); border-color: #fde68a; }
.badge.red { background: var(--red-50); color: var(--red); border-color: #fecaca; }
.badge.purple { background: #f5f3ff; color: var(--purple); border-color: #ddd6fe; }
.badge.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.badge.sample { background: #fff7ed; color: #c2410c; border-color: #fed7aa; font-size: 10px; letter-spacing: .05em; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 11.5px; font-weight: 600; color: #fff; margin: 1px 3px 1px 0; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #f8fafc; white-space: nowrap; position: sticky; top: 0; }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--ink); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--blue-50); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot td { font-weight: 700; background: #f8fafc; }
.table .title-cell { font-weight: 600; color: var(--ink); }
.table input, .table select { width: 100%; min-width: 60px; padding: 5px 6px; border: 1px solid transparent; border-radius: 5px; background: transparent; }
.table input:hover, .table select:hover { border-color: var(--line); }
.table input:focus, .table select:focus { border-color: var(--blue-600); background: #fff; outline: none; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 34px; height: 34px; color: var(--line-2); margin-bottom: 6px; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.toolbar .search-input { min-width: 220px; flex: 1; max-width: 360px; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; color: var(--muted); font-size: 12.5px; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.field .req { color: var(--red); }
.field .help { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.field .err { font-size: 12px; color: var(--red); margin-top: 3px; }
.input, .field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea, select.input, textarea.input {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 7px; background: #fff; }
.field textarea, textarea.input { min-height: 90px; resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--blue-100); border-color: var(--blue-600); }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--red); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--blue); }
.tags-input { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; border: 1px solid var(--line-2); border-radius: 7px; padding: 5px 6px; background: #fff; }
.tags-input input { border: 0 !important; outline: none !important; flex: 1; min-width: 100px; padding: 3px !important; }
.tags-input .tag { cursor: pointer; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; z-index: 100; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; box-shadow: var(--shadow-lg); width: 100%; max-width: 620px; display: flex; flex-direction: column; max-height: 90vh; }
.modal.wide { max-width: 920px; }
.modal.xwide { max-width: 1200px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: #f8fafc; border-radius: 0 0 12px 12px; flex-wrap: wrap; }

/* Toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 9px; box-shadow: var(--shadow-lg); max-width: 380px; font-weight: 500; animation: slidein .2s ease; }
.toast.error { background: #991b1b; }
.toast.success { background: #166534; }
@keyframes slidein { from { transform: translateY(10px); opacity: 0; } }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: thin; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--blue); border-bottom-color: var(--blue); }
.tabs .count { font-size: 11px; background: var(--bg); border-radius: 10px; padding: 0 6px; margin-left: 4px; color: var(--muted); }

/* Detail definition lists */
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; }
.dl dt { color: var(--muted); font-size: 12.5px; }
.dl dd { margin: 0; font-weight: 500; color: var(--ink-2); word-break: break-word; }

/* Kanban */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(258px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; min-height: 60vh; }
.k-col { background: #e9eef5; border-radius: 10px; display: flex; flex-direction: column; max-height: calc(100vh - 230px); }
.k-col.drop { outline: 2px dashed var(--blue-600); background: var(--blue-50); }
.k-head { padding: 10px 12px 8px; border-bottom: 1px solid #d8e0ea; }
.k-head .t { font-weight: 700; color: var(--ink); font-size: 13px; display: flex; justify-content: space-between; }
.k-head .s { font-size: 12px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.k-col.won .k-head { border-top: 3px solid var(--green); border-radius: 10px 10px 0 0; }
.k-col.lost .k-head { border-top: 3px solid #94a3b8; border-radius: 10px 10px 0 0; }
.k-cards { padding: 8px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 60px; }
.k-card { background: #fff; border-radius: 8px; border: 1px solid var(--line); padding: 10px 11px; box-shadow: var(--shadow); cursor: grab; }
.k-card:hover { border-color: var(--blue-600); }
.k-card.dragging { opacity: .45; }
.k-card .n { font-weight: 650; color: var(--ink); line-height: 1.25; }
.k-card .c { font-size: 12px; color: var(--muted); margin-top: 2px; }
.k-card .v { font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.k-card .meta { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-top: 6px; gap: 6px; }
.k-card .next { font-size: 11.5px; margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); color: var(--ink-2); }
.k-card .next.overdue { color: var(--red); }
.prob { height: 4px; background: var(--line); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.prob span { display: block; height: 100%; background: var(--blue-600); }

/* Calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal .dow { padding: 6px 8px; font-size: 11px; text-transform: uppercase; color: var(--muted); font-weight: 650; background: #f8fafc; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cal .day { min-height: 108px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px 5px; background: #fff; overflow: hidden; }
.cal .day.other { background: #f8fafc; color: var(--muted); }
.cal .day.today { background: var(--blue-50); }
.cal .day .d { font-size: 12px; font-weight: 650; margin-bottom: 3px; }
.cal .ev { display: block; font-size: 11.5px; padding: 2px 5px; border-radius: 4px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); background: var(--bg); border-left: 3px solid var(--line-2); }
.cal .ev:hover { text-decoration: none; filter: brightness(.96); }
.ev.bid_due { background: #fee2e2; border-left-color: #dc2626; }
.ev.walkthrough { background: #fef3c7; border-left-color: #d97706; }
.ev.task { background: var(--blue-50); border-left-color: var(--blue-600); }
.ev.followup { background: #ede9fe; border-left-color: var(--purple); }
.ev.inspection { background: #dcfce7; border-left-color: var(--green); }
.ev.material_order, .ev.equipment_rental { background: #f1f5f9; border-left-color: #475569; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; background: var(--c); }

/* Charts */
.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis text { font-size: 10.5px; fill: var(--muted); }
.chart .grid line { stroke: #eef2f7; }
.chart-tip { position: fixed; pointer-events: none; background: var(--ink); color: #fff; padding: 6px 9px; border-radius: 6px; font-size: 12px; z-index: 300; white-space: nowrap; box-shadow: var(--shadow-lg); }
.chart-legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* Progress / bars */
.progress { height: 8px; background: var(--line); border-radius: 5px; overflow: hidden; min-width: 60px; }
.progress span { display: block; height: 100%; background: var(--blue-600); border-radius: 5px; }
.progress.green span { background: var(--green); }
.bar-compare { display: grid; grid-template-columns: 110px 1fr 120px; gap: 6px 10px; align-items: center; font-size: 12.5px; }
.bar-compare .bars { display: flex; flex-direction: column; gap: 3px; }
.bar-compare .b { height: 8px; border-radius: 4px; }

/* Activity timeline */
.timeline { display: flex; flex-direction: column; }
.tl-item { display: grid; grid-template-columns: 32px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.tl-icon { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--blue-50); color: var(--blue); }
.tl-icon svg { width: 15px; height: 15px; }
.tl-item .t { font-weight: 600; color: var(--ink); }
.tl-item .m { font-size: 12px; color: var(--muted); }
.tl-item .b { margin-top: 4px; white-space: pre-wrap; }

/* Documents */
.folders { display: flex; flex-direction: column; gap: 2px; }
.folder { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-radius: 7px; cursor: pointer; color: var(--ink-2); font-weight: 500; }
.folder:hover { background: var(--bg); }
.folder.active { background: var(--blue-50); color: var(--blue); font-weight: 650; }
.dropzone { border: 2px dashed var(--line-2); border-radius: 10px; padding: 18px; text-align: center; color: var(--muted); background: #fafcff; transition: all .15s; }
.dropzone.over { border-color: var(--blue-600); background: var(--blue-50); color: var(--blue); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.photo-grid a { display: block; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; background: var(--bg); border: 1px solid var(--line); }
.photo-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview-frame { width: 100%; height: 72vh; border: 1px solid var(--line); border-radius: 8px; background: #f8fafc; }

/* AI */
.ai-out { background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 12px; white-space: pre-wrap; font-size: 13px; max-height: 420px; overflow: auto; }
.ai-banner { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; padding: 10px 12px; border-radius: 8px; font-size: 12.5px; }
.notice { background: var(--blue-50); border: 1px solid var(--blue-100); color: #1e3a8a; padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.notice.warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.notice.red { background: var(--red-50); border-color: #fecaca; color: #991b1b; }

/* Estimate editor */
.est-summary .line { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); font-variant-numeric: tabular-nums; }
.est-summary .line.total { border-bottom: 0; border-top: 2px solid var(--ink); font-size: 18px; font-weight: 800; color: var(--ink); padding-top: 10px; margin-top: 4px; }
.est-summary .line.sub { color: var(--muted); font-size: 12.5px; }
.cat-row td { background: #f8fafc; font-weight: 700; color: var(--ink); font-size: 12.5px; }
.items-table td { padding: 4px 6px; }
.items-table input { text-align: right; }
.items-table input.desc { text-align: left; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero { background: linear-gradient(140deg, #0b1324 0%, #0f172a 55%, #1747a6 140%); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login-hero h1 { color: #fff; font-size: 34px; margin-top: 40px; max-width: 460px; }
.login-hero p { color: #cbd5e1; max-width: 460px; font-size: 15px; }
.login-panel { display: grid; place-items: center; padding: 32px; background: #fff; }
.login-card { width: 100%; max-width: 380px; }
.login-card .field { margin-bottom: 14px; }
.demo-box { margin-top: 18px; font-size: 12px; background: var(--bg); border-radius: 8px; padding: 10px 12px; color: var(--muted); }

/* Proposal preview */
.proposal-doc { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 0; overflow: hidden; }
.proposal-doc .ph { background: var(--ink); color: #fff; padding: 18px 22px; display: flex; justify-content: space-between; border-bottom: 4px solid var(--blue); }
.proposal-doc .pb { padding: 20px 22px; }
.proposal-doc h3 { color: var(--blue); text-transform: uppercase; font-size: 12.5px; letter-spacing: .05em; margin: 16px 0 6px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.price-box { background: var(--ink); color: #fff; border-radius: 8px; padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.price-box .amt { font-size: 22px; }

/* Responsive */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 270px; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 35; }
  .menu-btn { display: grid; }
  .topbar { padding: 0 12px; }
  .user-chip .who-wrap { display: none; }
  .content { padding: 16px 14px 70px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 120px 1fr; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-hero { padding: 28px; }
  .login-hero h1 { margin-top: 16px; font-size: 24px; }
  .cal .day { min-height: 74px; }
  .cal .ev { font-size: 10px; }
  .kpi .value { font-size: 20px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 11px 12px; }
  .modal-backdrop { padding: 0; }
  .modal { max-height: 100vh; height: 100%; border-radius: 0; }
  .bar-compare { grid-template-columns: 90px 1fr; }
  .bar-compare .amt { grid-column: 2; }
  .hide-sm { display: none !important; }
}
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .app { display: block; }
  .content { padding: 0; }
  .card { box-shadow: none; }
}

/* address autocomplete */
.ac-wrap { position: relative; }
.ac-list { position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px 0; list-style: none; background: var(--card); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: var(--shadow-lg); max-height: 300px; overflow: auto; }
.ac-list li { display: flex; flex-direction: column; gap: 1px; padding: 8px 12px; cursor: pointer; }
.ac-list li:hover, .ac-list li.active { background: var(--blue-50); }
.ac-main { font-size: 14px; color: var(--text); }
.ac-sub { font-size: 12px; color: var(--muted); }
.ac-list li.ac-powered { cursor: default; align-items: flex-end; font-size: 11px; color: var(--muted); padding: 4px 12px; }
.ac-list li.ac-powered:hover { background: none; }

/* daily report photos */
.photo-pick { margin-top: 10px; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.photo-pick:empty { display: none; }
.photo-new { position: relative; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; border: 2px solid var(--blue-100); }
.photo-new img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-new button { position: absolute; top: 4px; right: 4px; background: rgba(255, 255, 255, .9); padding: 2px 4px; }
.photo-strip { display: flex; gap: 4px; align-items: center; }
.photo-strip a { width: 44px; height: 34px; border-radius: 4px; overflow: hidden; flex: none; border: 1px solid var(--line); }
.photo-strip img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* WSCG RoofCare */
.ev.roofcare { background: #e0f7fa; border-left-color: #0f9fb5; }
.rc-steps { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 12px; }
.rc-steps span { font-size: 11.5px; padding: 4px 9px; border-radius: 14px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.rc-steps span.done { background: var(--blue-50); color: var(--blue); border-color: var(--blue-100); }
.rc-steps span.now { background: var(--blue); color: #fff; border-color: var(--blue); font-weight: 650; }
.rc-steps span.off { background: var(--red-50); color: var(--red); border-color: #fecaca; font-weight: 650; }
.rc-total { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; font-size: 13.5px; }
.rc-total .big { font-size: 18px; font-weight: 750; color: var(--ink); }
.rc-check { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; background: #fff; }
.rc-check .lbl { font-weight: 650; margin-bottom: 8px; }
.rc-seg { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.rc-seg button { border: 1px solid var(--line-2); background: #fff; border-radius: 8px; padding: 10px 4px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; min-height: 44px; }
.rc-seg button.on.satisfactory { background: var(--green-50); border-color: var(--green); color: var(--green); }
.rc-seg button.on.attention_required { background: var(--amber-50); border-color: var(--amber); color: var(--amber); }
.rc-seg button.on.not_accessible, .rc-seg button.on.not_applicable { background: #f1f5f9; border-color: #475569; color: #334155; }
.rc-finding { border-left: 4px solid var(--amber); padding: 8px 12px; background: #fff; border-radius: 6px; margin-bottom: 8px; border-top: 1px solid var(--line); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.rc-finding.urgent, .rc-finding.high { border-left-color: var(--red); }
.rc-finding.low { border-left-color: var(--green); }
.rc-promo { max-width: 860px; }
.rc-promo .hero { background: var(--ink); color: #fff; border-radius: 12px; padding: 24px; border-bottom: 4px solid var(--blue); }
.rc-promo .hero h1 { color: #fff; margin: 4px 0 8px; font-size: 26px; }
.rc-promo .plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.rc-promo .plan { border: 1px solid var(--line); border-top: 4px solid var(--ink); border-radius: 10px; padding: 14px; background: #fff; }
.rc-promo .plan.featured { border-top-color: var(--blue); }
.rc-promo .price { font-size: 20px; font-weight: 750; color: var(--blue); }
@media (max-width: 640px) {
  .rc-seg { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Jobsite photos */
.pd-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; width: 100%; }
.pd-filters .input { width: auto; min-width: 0; max-width: 200px; padding: 6px 8px; }
.pd-filters input[type=search] { flex: 1; min-width: 140px; max-width: 260px; }
.pd-selbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 16px; background: var(--blue-50); border-bottom: 1px solid var(--blue-100); position: sticky; top: 0; z-index: 5; }
.pd-feed { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.pd-day { grid-column: 1 / -1; font-weight: 700; color: var(--ink); margin-top: 8px; padding-bottom: 2px; border-bottom: 1px solid var(--line); }
.pd-tile { position: relative; aspect-ratio: 1; padding: 0; border: 0; border-radius: 8px; overflow: hidden; background: var(--bg); cursor: pointer; }
.pd-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pd-tile .pd-meta { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 8px; padding: 14px 6px 4px; font-size: 11px; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.6)); }
.pd-tile .pd-badges { position: absolute; top: 5px; left: 5px; display: flex; gap: 3px; align-items: center; }
.pd-stage { background: rgba(15,23,42,.75); color: #fff; font-size: 10.5px; font-weight: 600; border-radius: 10px; padding: 1px 7px; }
.pd-dot { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid #fff; display: inline-block; }
.pd-job { position: absolute; top: 5px; right: 5px; max-width: 60%; background: rgba(255,255,255,.88); color: var(--ink); font-size: 10px; border-radius: 6px; padding: 1px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pd-check { display: none; position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%; background: rgba(255,255,255,.85); border: 2px solid #fff; color: transparent; font-weight: 800; align-items: center; justify-content: center; }
.selecting .pd-check { display: flex; }
.selecting .pd-job { display: none; }
.pd-tile.sel { outline: 3px solid var(--blue-600); outline-offset: -3px; }
.pd-tile.sel .pd-check { background: var(--blue-600); color: #fff; }
.pd-sentinel { height: 40px; }
.pd-tags, .pd-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pd-tag { border: 1.5px solid var(--tag); color: var(--tag); background: #fff; border-radius: 16px; padding: 4px 10px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.pd-tag.on { background: var(--tag); color: #fff; }
.pd-chip { border: 1px solid var(--line-2); background: #fff; border-radius: 18px; padding: 8px 14px; font-weight: 600; cursor: pointer; }
.pd-chip.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.pd-capture { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.pd-shoot { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pd-big { padding: 22px 12px; font-size: 16px; flex-direction: column; }
.pd-big svg { width: 28px; height: 28px; }
.pd-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.pd-pick button, .pd-qitem { padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; cursor: pointer; font-size: 11px; display: flex; flex-direction: column; text-align: left; }
.pd-pick img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.pd-pick span, .pd-qitem span { padding: 3px 5px; color: var(--muted); }
.pd-qitem.uploading { border-color: var(--blue-600); }
.pd-qitem.error { border-color: var(--red); }
.pd-qitem.error span { color: var(--red); }
.pd-modal { max-width: 1280px !important; }
.pd-view { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; }
.pd-view-img { position: relative; background: #0b1120; border-radius: 8px; display: flex; align-items: center; justify-content: center; min-height: 300px; }
.pd-view-img img { max-width: 100%; max-height: 72vh; display: block; }
.pd-view-side { display: flex; flex-direction: column; gap: 10px; max-height: 74vh; overflow-y: auto; }
.pd-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 42px; height: 64px; border: 0; border-radius: 8px; background: rgba(255,255,255,.18); color: #fff; font-size: 34px; cursor: pointer; }
.pd-nav:disabled { opacity: .2; }
.pd-nav.prev { left: 8px; }
.pd-nav.next { right: 8px; }
.pd-count { position: absolute; bottom: 8px; right: 10px; color: #fff; font-size: 12px; background: rgba(0,0,0,.4); padding: 1px 8px; border-radius: 8px; }
.pd-comments { display: flex; flex-direction: column; gap: 6px; }
.pd-comment { background: var(--bg); border-radius: 8px; padding: 6px 9px; }
.pd-annot-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pd-swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line-2); cursor: pointer; }
.pd-swatch.on { outline: 3px solid var(--blue-600); outline-offset: 1px; }
.pd-canvas-wrap { background: #0b1120; border-radius: 8px; display: flex; justify-content: center; }
.pd-canvas { max-width: 100%; max-height: 68vh; touch-action: none; cursor: crosshair; display: block; }
.pd-compare-side { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pd-compare-side figure { margin: 0; }
.pd-compare-side img { width: 100%; border-radius: 8px; display: block; }
.pd-compare-side figcaption { font-size: 12px; margin-top: 4px; }
.pd-slide { position: relative; border-radius: 8px; overflow: hidden; }
.pd-slide > img, .pd-slide-top img { width: 100%; display: block; }
.pd-slide-top { position: absolute; inset: 0; }
.pd-slide-top img { height: 100%; object-fit: cover; }
.pd-slide-l, .pd-slide-r { position: absolute; top: 8px; background: rgba(15,23,42,.7); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 6px; }
.pd-slide-l { left: 8px; }
.pd-slide-r { right: 8px; }
.pd-slide + input[type=range] { width: 100%; }
.pd-live { position: relative; background: #000; border-radius: 8px; overflow: hidden; }
.pd-live video { width: 100%; display: block; }
.pd-ghost { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.pd-lightbox { position: fixed; inset: 0; background: rgba(2,6,23,.94); z-index: 100; display: flex; align-items: center; justify-content: center; }
.pd-lightbox > img { max-width: 94vw; max-height: 82vh; }
.pd-close { position: absolute; top: 10px; right: 14px; background: none; border: 0; color: #fff; font-size: 36px; cursor: pointer; }
.pd-lb-cap { position: absolute; bottom: 0; left: 0; right: 0; color: #e2e8f0; padding: 12px 18px; background: rgba(0,0,0,.5); }
.pd-lb-cap a { color: #93c5fd; }
@media (max-width: 900px) {
  .pd-capture, .pd-view { grid-template-columns: 1fr; }
  .pd-view-side { max-height: none; }
  .pd-feed { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 4px; }
  .pd-filters .input { max-width: 46%; }
}
.pd-slide { width: min(100%, calc(62vh * 1.333)); margin: 0 auto; }
.pd-compare-side img { max-height: 62vh; object-fit: contain; background: #0b1120; }
.pd-plans { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.pd-plan-card { text-align: left; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 8px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.pd-plan-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #f8fafc; border-radius: 6px; }
.pd-plan-view { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; }
.pd-board-wrap { overflow: auto; max-height: 72vh; background: #e2e8f0; border-radius: 8px; }
.pd-board { position: relative; width: 100%; }
.pd-board img { width: 100%; display: block; user-select: none; }
.pd-board.adding { cursor: crosshair; }
.pd-pins { position: absolute; inset: 0; pointer-events: none; }
.pd-pin { position: absolute; transform: translate(-50%, -50%); pointer-events: auto; min-width: 26px; height: 26px; border-radius: 13px; border: 2px solid #fff; color: #fff; font-weight: 800; font-size: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.45); cursor: pointer; padding: 0 5px; }
.pd-pin.sel { outline: 3px solid #facc15; }
.pd-pin i { position: absolute; top: -8px; right: -10px; background: #0f172a; border-radius: 8px; font-size: 9px; font-style: normal; padding: 0 4px; line-height: 14px; }
.pd-pin.static { position: static; transform: none; display: inline-flex; align-items: center; justify-content: center; }
.pd-pin-row { display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 4px; border-radius: 6px; cursor: pointer; text-align: left; }
.pd-pin-row:hover { background: var(--bg); }
.pd-plan-side { display: flex; flex-direction: column; gap: 10px; max-height: 72vh; overflow-y: auto; }
.pd-pick button.sel { outline: 3px solid var(--blue-600); outline-offset: -3px; }
.pd-map { position: relative; width: 100%; border-radius: 10px; overflow: hidden; background: #cbd5e1; }
.pd-map > img, .pd-map-blank { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pd-map-blank { background: repeating-linear-gradient(0deg, #e2e8f0 0 1px, transparent 1px 40px), repeating-linear-gradient(90deg, #e2e8f0 0 1px, #f1f5f9 1px 40px); }
.pd-mapdot { position: absolute; transform: translate(-50%, -100%); width: 44px; height: 44px; padding: 0; border: 3px solid #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 6px rgba(0,0,0,.5); cursor: pointer; background: #fff; }
.pd-mapdot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pd-mapdot:hover { z-index: 2; transform: translate(-50%, -100%) scale(1.6); }
@media (max-width: 900px) { .pd-plan-view { grid-template-columns: 1fr; } .pd-plan-side { max-height: none; } }
.pd-map { max-width: 980px; }
.pd-role { border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.pd-qitem .btn.ghost { padding: 2px 6px; font-size: 11px; color: var(--red); }
.pd-thumbs { display: flex; flex-wrap: wrap; gap: 4px; }
.pd-thumbs button { width: 56px; height: 56px; padding: 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; cursor: pointer; background: #fff; }
.pd-thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pd-cl { display: flex; flex-direction: column; }
.pd-cl-section { margin: 12px 0 4px; }
.pd-cl-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.pd-cl-item.warn { background: #fffbeb; }
.pd-cl-ctrl { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.pd-cl-note { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pd-cl-note .input { max-width: 420px; padding: 5px 8px; }
.btn-group .btn.active.pd-fail { background: var(--red-50); color: var(--red); border-color: #fecaca; }
.pd-hist { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.pd-area { position: absolute; border: 2px solid var(--area, #2563eb); background: color-mix(in srgb, var(--area, #2563eb) 10%, transparent); pointer-events: none; }
.pd-area span { position: absolute; top: 2px; left: 4px; font-size: 11px; font-weight: 700; color: var(--area, #2563eb); background: rgba(255,255,255,.85); padding: 0 4px; border-radius: 4px; }
@media (max-width: 640px) { .pd-cl-item { grid-template-columns: 1fr; } .pd-cl-ctrl { align-items: flex-start; } }
.pd-board.adding { touch-action: none; }
.pd-tpl-item { display: grid; grid-template-columns: 140px minmax(0, 1fr) 120px 140px auto; gap: 6px; align-items: center; }
@media (max-width: 900px) { .pd-tpl-item { grid-template-columns: 1fr 1fr; } }
.pd-sigpad { width: 100%; aspect-ratio: 3 / 1; border: 1px solid var(--line-2); border-radius: 8px; touch-action: none; background: #fff; cursor: crosshair; }
.pd-sig { display: flex; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.pd-sig img { width: 180px; height: 60px; object-fit: contain; background: #fff; border-bottom: 1px solid var(--line); }
.pd-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.suggest-wrap { display: block; }
