/* Urgent incoming-PO banner — impossible to miss on the dashboard. */
@keyframes urgentPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(185,28,28,0.55); } 50% { box-shadow: 0 0 0 10px rgba(185,28,28,0); } }
.urgent-banner { background: linear-gradient(135deg,#dc2626,#7f1d1d); border-radius: 12px; padding: 16px 20px; margin-bottom: 18px; color: #fff; animation: urgentPulse 1.8s ease-in-out infinite; }
.urgent-banner .ub-title { font-size: 19px; font-weight: 800; letter-spacing: 0.2px; }
.urgent-banner .ub-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 9px 12px; margin-top: 8px; background: rgba(255,255,255,0.12); border-radius: 8px; cursor: pointer; }
.urgent-banner .ub-row:hover { background: rgba(255,255,255,0.22); }
.urgent-banner .ub-tag { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 10px; white-space: nowrap; letter-spacing: 0.4px; }

:root {
  --navy: #0e2235; --navy-2: #15314c; --ink: #1a1a1a; --bg: #f4f6fa; --card: #ffffff;
  --border: #e1e6ee; --muted: #6b7280; --accent: #ff6b1a; --accent-2: #e85a0c;
  --green: #15803d; --green-soft: #d1fae5; --amber: #b45309; --amber-soft: #fef3c7;
  --red: #b91c1c; --red-soft: #fee2e2; --blue: #1d4ed8; --blue-soft: #dbeafe; --grey-soft: #e5e7eb;
  --shadow: 0 1px 3px rgba(14,34,53,0.06), 0 1px 2px rgba(14,34,53,0.04);
  --shadow-lg: 0 10px 25px rgba(14,34,53,0.08), 0 4px 10px rgba(14,34,53,0.04);
}
* { box-sizing: border-box; }
html, body { margin:0; padding:0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5; }
header.top { background: linear-gradient(135deg, var(--navy), var(--navy-2)); color: #fff; padding: 14px 24px; display:flex; align-items:center; justify-content:space-between; box-shadow: var(--shadow-lg); position: sticky; top: 0; z-index: 50; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo { width: 42px; height: 42px; background: var(--accent); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 20px; color: #fff; box-shadow: 0 3px 10px rgba(255,107,26,0.4); }
.brand-logo-img { height: 44px; width: auto; background: #fff; padding: 4px 10px; border-radius: 8px; box-shadow: 0 3px 10px rgba(0,0,0,0.25); display: block; }
.brand-text h1 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: 0.3px; }
.brand-text .sub { font-size: 11px; opacity: 0.75; text-transform: uppercase; letter-spacing: 1px; }
.header-right { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.header-right .date { opacity: 0.8; }
.btn { background: var(--accent); color: #fff; border: none; padding: 8px 14px; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; transition: background 0.15s; }
.btn:hover { background: var(--accent-2); }
.btn.secondary { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); color: #fff; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--border); }
.btn.danger { background: var(--red); color: #fff; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
/* Wrap the tab bar onto a second row instead of overflowing into a horizontal
   scrollbar - there are ~18 tabs, too many for one row on most screens. */
nav.tabs { background: #fff; border-bottom: 1px solid var(--border); padding: 0 16px; display: flex; flex-wrap: wrap; gap: 0 4px; overflow-x: visible; position: sticky; top: 70px; z-index: 40; }
nav.tabs button { background: none; border: none; padding: 13px 14px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
nav.tabs button:hover { color: var(--ink); }
nav.tabs button.active { color: var(--navy); border-bottom-color: var(--accent); }
main { padding: 24px; max-width: 1600px; margin: 0 auto; }
.page { display: none; } .page.active { display: block; }
h2.page-title { margin: 0 0 4px 0; font-size: 22px; color: var(--navy); }
.page-sub { color: var(--muted); margin-bottom: 20px; font-size: 13px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.kpi { background: var(--card); border-radius: 10px; padding: 16px; box-shadow: var(--shadow); border: 1px solid var(--border); border-left: 4px solid var(--accent); }
.kpi.green { border-left-color: var(--green); } .kpi.blue { border-left-color: var(--blue); } .kpi.amber { border-left-color: var(--amber); } .kpi.red { border-left-color: var(--red); }
.kpi-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.kpi-value { font-size: 26px; font-weight: 700; color: var(--navy); margin-top: 4px; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); margin-bottom: 20px; overflow: hidden; }
.card-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; background: #fafbfd; }
.card-header h3 { margin: 0; font-size: 14px; color: var(--navy); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.card-body { padding: 16px 18px; } .card-body.flush { padding: 0; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; padding: 10px 14px; background: #fafbfd; border-bottom: 1px solid var(--border); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); font-weight: 700; }
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tr.clickable { cursor: pointer; } table.data tr.clickable:hover { background: #fafbfd; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.pill.grey { background: var(--grey-soft); color: #374151; } .pill.blue { background: var(--blue-soft); color: var(--blue); }
.pill.amber { background: var(--amber-soft); color: var(--amber); } .pill.green { background: var(--green-soft); color: var(--green); }
.pill.red { background: var(--red-soft); color: var(--red); } .pill.navy { background: #cdd5e0; color: var(--navy); }
.pill.orange { background: #ffe1cc; color: var(--accent-2); }
/* 7 equal columns that always fit the window width (minmax(0,1fr) lets each
   track shrink below its content instead of forcing a horizontal scrollbar). */
.kanban { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 12px; padding-bottom: 8px; }
.kcol { background: #eef1f6; border-radius: 8px; padding: 10px; min-height: 200px; }
.kcol h4 { margin: 0 0 10px 0; font-size: 12px; text-transform: uppercase; color: var(--navy); display: flex; justify-content: space-between; align-items: center; }
.kcol h4 .count { background: #fff; color: var(--muted); padding: 1px 7px; border-radius: 999px; font-size: 11px; }
.kcard { background: #fff; border-radius: 6px; padding: 10px 12px; margin-bottom: 8px; box-shadow: 0 1px 2px rgba(14,34,53,0.06); cursor: pointer; border-left: 8px solid var(--accent); transition: background 0.15s; }
.kcard:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.kcard .name { font-weight: 600; font-size: 13px; color: var(--navy); margin-bottom: 4px; overflow-wrap: anywhere; }
.kcard .meta { font-size: 11px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
/* Make workflow pills inside kanban cards a bit more prominent */
.kcard .meta .pill { padding: 3px 9px; font-size: 11px; font-weight: 700; letter-spacing: 0.3px; }
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { padding: 9px 11px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--navy); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.3px; }
input[type="text"], input[type="number"], input[type="date"], input[type="email"], input[type="tel"], select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; font-family: inherit; }
textarea { min-height: 80px; resize: vertical; }
.modal-bg { display: none; position: fixed; inset: 0; background: rgba(14,34,53,0.55); z-index: 100; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 40px 16px; }
.modal-bg.open { display: flex; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 720px; box-shadow: 0 25px 50px rgba(0,0,0,0.25); overflow: hidden; }
.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: var(--navy); color: #fff; }
.modal-header h3 { margin: 0; font-size: 16px; }
.modal-header .close { background: none; border: none; color: #fff; font-size: 22px; cursor: pointer; }
.modal-body { padding: 22px; max-height: 70vh; overflow-y: auto; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; background: #fafbfd; }
.tpl-var { display: inline-block; background: #eef2ff; color: #3730a3; border: 1px solid #c7d2fe; border-radius: 4px; padding: 1px 5px; margin: 2px 2px 0 0; font-size: 11px; cursor: pointer; user-select: none; }
.tpl-var:hover { background: #c7d2fe; }
/* Streaks "Hide $" mode: collapse every dollar-bearing element + table column */
#page-streaks.hide-money .streak-money { display: none !important; }
#page-streaks.hide-money .streak-col-money { display: none !important; }

/* ---- Tasks / to-do ---- */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { background: #fff; border: none; padding: 7px 14px; font-size: 13px; cursor: pointer; color: var(--ink); border-right: 1px solid var(--border); }
.seg button:last-child { border-right: none; }
.seg button.active { background: var(--navy); color: #fff; font-weight: 600; }
.task-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.task-row:hover { background: #fafbfd; }
.task-check { width: 20px; height: 20px; flex: none; margin-top: 2px; cursor: pointer; }
.task-main { flex: 1; min-width: 0; cursor: pointer; }
.task-title { font-weight: 600; }
.task-row.done .task-title { text-decoration: line-through; color: var(--muted); font-weight: 400; }
.task-sub { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.task-pri { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.4px; }
.task-pri.high { background: #fee2e2; color: #b91c1c; }
.task-pri.med  { background: #fef3c7; color: #92400e; }
.task-pri.low  { background: #e0e7ff; color: #3730a3; }
.task-due.overdue { color: #dc2626; font-weight: 700; }
.task-status { font-size: 11px; border: 1px solid var(--border); border-radius: 10px; padding: 1px 8px; background: #fff; }
.task-group-head { font-weight: 700; padding: 10px 12px 6px; border-top: 2px solid var(--border); background: #f3f4f6; }
.tt-item-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.tt-item-row input[type=text] { flex: 2; min-width: 140px; }
.hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.hub-tile { background: var(--card); border-radius: 10px; padding: 20px; box-shadow: var(--shadow); border: 1px solid var(--border); text-align: center; cursor: pointer; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.hub-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--accent); }
.hub-icon { width: 50px; height: 50px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; color: #fff; background: var(--navy); }
.small { font-size: 12px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; font-size: 13px; }
@media (max-width: 768px) { main { padding: 14px; } nav.tabs { padding: 0 12px; } .form-grid { grid-template-columns: 1fr; } .kanban { grid-template-columns: minmax(240px, 1fr); } .header-right .date { display: none; } }
.scope-block { background: #f9fafb; border: 1px solid var(--border); border-radius: 6px; padding: 10px; margin-bottom: 8px; }
.scope-block .scope-head { display: flex; gap: 8px; align-items: center; }
.scope-block textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; min-height: 80px; }
.btn.small { padding: 5px 9px; font-size: 12px; }

/* ==================== SCHEDULE BOARD ==================== */
.sb-controls { display: flex; align-items: center; gap: 6px; padding: 10px 0 12px; flex-wrap: wrap; }
.sb-legend-chip { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: middle; margin: 0 4px 0 10px; }
.sb-wrap { display: grid; grid-template-columns: 1fr; gap: 14px; align-items: start; }
.sb-board { background: var(--card); border: 1px solid var(--border); border-radius: 10px; overflow: auto; max-height: calc(100vh - 220px); min-width: 0; scrollbar-width: none; -ms-overflow-style: none; }
.sb-board::-webkit-scrollbar { width: 0; height: 0; display: none; }
.sb-grid { display: grid; min-width: 100%; }
.sb-corner { background: var(--navy); padding: 12px 14px; position: sticky; left: 0; top: 0; z-index: 4; }
.sb-day-head { background: var(--navy); color: #fff; padding: 8px 10px; border-left: 1px solid rgba(255,255,255,0.12); font-size: 12px; text-align: center; line-height: 1.2; position: sticky; top: 0; z-index: 3; cursor: grab; user-select: none; }
.sb-board.sb-grabbing { cursor: grabbing; }
.sb-board.sb-grabbing .sb-day-head { cursor: grabbing; }
.sb-day-head.weekend { background: #1c3a55; }
.sb-day-head.today { background: var(--accent); }
.sb-day-head strong { font-size: 16px; }
.sb-worker-cell { padding: 8px 12px; background: #f9fafb; border-top: 1px solid var(--border); border-right: 1px solid var(--border); font-size: 12.5px; color: var(--navy); position: sticky; left: 0; z-index: 2; display: flex; align-items: center; gap: 6px; }
.sb-worker-cell.is-foreman { font-weight: 700; background: #fff7ed; }
.sb-foreman-tag { display: inline-block; background: var(--accent); color: #fff; border-radius: 3px; padding: 1px 5px; font-size: 9px; font-weight: 700; }
.sb-sep { grid-column: 1 / -1; background: var(--navy); color: #fff; font-size: 10px; text-transform: uppercase; letter-spacing: 1px; padding: 5px 14px; opacity: 0.8; position: sticky; left: 0; z-index: 2; }
.sb-cell { border-top: 1px solid var(--border); border-left: 1px solid var(--border); min-height: 44px; padding: 3px; display: flex; flex-direction: column; gap: 3px; transition: background 0.1s; }
.sb-cell.weekend { background: #fafbfd; }
.sb-cell.today { background: #fff7ed; }
.sb-cell.drag-over { background: #fde68a !important; box-shadow: inset 0 0 0 2px var(--accent); }
/* Add-shift picker rows (TSheets-style) */
.addsh-row { display: flex; align-items: center; gap: 14px; padding: 15px 20px; border-bottom: 1px solid var(--border); }
.addsh-ic { font-size: 20px; width: 24px; text-align: center; opacity: 0.6; flex: 0 0 24px; }
.addsh-f { flex: 1; min-width: 0; }
.addsh-l { font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); font-weight: 600; margin-bottom: 3px; }
.addsh-f select, .addsh-f input { width: 100%; border: none; padding: 2px 0; font-size: 15px; background: transparent; color: var(--ink); }
.addsh-f select:focus, .addsh-f input:focus { outline: none; }
.shift-crew { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.shift-av { width: 36px; height: 36px; border-radius: 50%; background: #e2e8f0; color: #475569; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex: 0 0 36px; }

/* Painter tick-list — multi-select of crew (Add-shift modal + shift detail). */
.pick-list { max-height: 190px; overflow-y: auto; border: 1px solid var(--border); border-radius: 9px; background: #fff; }
.pick-row { display: flex; align-items: center; gap: 11px; padding: 9px 12px; cursor: pointer; font-size: 14px; border-bottom: 1px solid #f1f3f5; user-select: none; }
.pick-row:last-child { border-bottom: 0; }
.pick-row:hover { background: #f6f8fb; }
.pick-row.on { background: #eaf6ee; font-weight: 600; }
.pick-row input[type=checkbox] { width: 18px; height: 18px; flex: 0 0 18px; margin: 0; cursor: pointer; accent-color: #16a34a; }

/* Shift-detail popup — large, near-fullscreen, footer pinned to bottom. */
.shift-detail-modal { max-width: 1100px; width: 92vw; max-height: 90vh; min-height: min(660px, 86vh); display: flex; flex-direction: column; }
.shift-detail-modal .modal-body { flex: 1 1 auto; overflow-y: auto; }
.shift-detail-modal .modal-footer { flex: 0 0 auto; }
.shift-detail-modal .addsh-row { padding: 20px 28px; gap: 18px; }
.shift-detail-modal .addsh-ic { font-size: 24px; width: 28px; flex-basis: 28px; }
.shift-detail-modal .addsh-f select, .shift-detail-modal .addsh-f input { font-size: 16px; }
.shift-detail-modal .shift-av { width: 42px; height: 42px; flex-basis: 42px; font-size: 14px; }
/* Large note/admin-note textareas in the shift card + add-shift modal. */
.shift-ta { width: 100%; min-height: 92px; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 15px; line-height: 1.45; font-family: inherit; resize: vertical; background: #fff; color: var(--ink); box-sizing: border-box; }
.shift-ta:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(255,107,26,0.15); }
/* Edit/Done button sits on the dark navy header — needs light treatment to be visible. */
.shift-edit-btn { background: rgba(255,255,255,0.16); color: #fff; border: 1px solid rgba(255,255,255,0.5); font-weight: 600; }
.shift-edit-btn:hover { background: rgba(255,255,255,0.3); color: #fff; }
@media (max-width: 760px) {
  .shift-detail-modal { width: 100%; max-width: 100%; max-height: none; min-height: 100vh; }
}

/* Single "unassigned" row schedule — tall day columns so each day reads as a column. */
.sb-grid--row .sb-cell--row { min-height: 60vh; padding: 6px; gap: 6px; }
.sb-grid--row .sb-entry-block { font-size: 12px; padding: 7px 20px 7px 9px; }
.sb-entry-block { position: relative; border-radius: 5px; padding: 4px 18px 4px 6px; color: #fff; font-size: 11px; line-height: 1.2; cursor: grab; box-shadow: 0 1px 3px rgba(0,0,0,0.15); user-select: none; transition: transform 0.06s, opacity 0.1s; }
.sb-entry-block:hover { transform: translateY(-1px); box-shadow: 0 3px 8px rgba(0,0,0,0.22); }
.sb-entry-block:active { cursor: grabbing; opacity: 0.85; }
.sb-entry-x { position: absolute; top: 1px; right: 2px; background: rgba(0,0,0,0.25); border: none; color: #fff; width: 15px; height: 15px; border-radius: 50%; font-size: 11px; line-height: 1; cursor: pointer; padding: 0; display: flex; align-items: center; justify-content: center; }
.sb-entry-x:hover { background: rgba(0,0,0,0.55); }
.sb-eb-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-eb-sub { opacity: 0.85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 10px; }
/* Crew avatar circles on a shift block — one per assigned painter (initials). */
.sb-eb-crew { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 4px; }
/* Crew "pill" — elongates to fit a first name; tiny font. */
.sb-av { min-width: 18px; max-width: 84px; height: 17px; padding: 0 6px; border-radius: 9px; background: rgba(255,255,255,0.92); color: #1f2937; font-size: 9px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; line-height: 1; flex: 0 0 auto; box-shadow: 0 0 0 1px rgba(0,0,0,0.12); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Unassigned stays a small round badge (just the red ✕). */
.sb-av--un { width: 18px; min-width: 18px; padding: 0; border-radius: 50%; background: rgba(255,255,255,0.3); color: #fff; box-shadow: 0 0 0 1px rgba(255,255,255,0.5); }
.sb-side { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 14px; position: sticky; top: 14px; max-height: calc(100vh - 60px); overflow-y: auto; }
.sb-side h3 { margin: 0 0 4px; font-size: 14px; color: var(--navy); }
.sb-side p.small { margin: 0 0 12px; }
#scheduleJobSearch { width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.sb-unsched { background: #fff; border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 6px; padding: 8px 10px; margin-bottom: 6px; cursor: grab; font-size: 12.5px; }
.sb-unsched:hover { box-shadow: 0 2px 6px rgba(0,0,0,0.08); }
.sb-unsched:active { cursor: grabbing; }
.sb-unsched-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.sb-unsched-head strong { color: var(--navy); }
.sb-stage-pill { color: #fff; font-size: 10px; padding: 1px 7px; border-radius: 10px; }
@media (max-width: 1024px) { .sb-wrap { grid-template-columns: 1fr; } .sb-side { position: static; max-height: none; } }

/* ---- Schedule: mobile list view (one day at a time, stacked cards) ---- */
/* In list mode the board is just a flow of cards on the page, not a scroll box. */
.sb-board--list { max-height: none; overflow: visible; border: none; background: transparent; border-radius: 0; }
.sb-mlist { padding: 2px 0 10px; }
.sb-mpills { display: flex; gap: 4px; padding: 7px 5px 12px; }
.sb-mpill { flex: 1 1 0; min-width: 0; border: 1px solid var(--border); background: #fff; border-radius: 9px; padding: 6px 1px 5px; display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative; cursor: pointer; color: var(--navy); }
.sb-mpill .dow { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0; color: var(--muted); }
.sb-mpill .dom { font-size: 15px; font-weight: 700; line-height: 1; }
.sb-mpill .cnt { position: absolute; top: -6px; right: -4px; background: var(--accent); color: #fff; font-size: 9.5px; font-weight: 700; border-radius: 8px; min-width: 16px; height: 16px; line-height: 16px; text-align: center; padding: 0 2px; box-shadow: 0 0 0 1.5px #fff; }
.sb-mpill.today { border-color: var(--accent); }
.sb-mpill.sel { background: var(--navy); color: #fff; border-color: var(--navy); }
.sb-mpill.sel .dow { color: #cbd5e1; }
.sb-mday-label { font-weight: 700; color: var(--navy); padding: 2px 4px 10px; font-size: 15px; }
.sb-mcard { position: relative; background: #fff; border: 1px solid var(--border); border-radius: 10px; margin: 0 2px 9px; padding: 11px 12px 11px 18px; box-shadow: 0 1px 2px rgba(0,0,0,0.06); cursor: pointer; overflow: hidden; }
.sb-mcard:active { background: #f9fafb; }
.sb-mcard-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 7px; background: var(--bar, #9ca3af); }
.sb-mcard-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.sb-mcard-title { font-weight: 700; font-size: 15px; color: var(--navy); line-height: 1.25; }
.sb-mcard-x { flex: 0 0 auto; border: none; background: #f3f4f6; color: #6b7280; width: 30px; height: 30px; border-radius: 8px; font-size: 19px; line-height: 1; cursor: pointer; }
.sb-mcard-x:active { background: #fee2e2; color: #b91c1c; }
.sb-mcard-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.sb-mcard-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 9px; font-size: 12px; }
.sb-mcard-stage { color: #fff; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.sb-mcard-worker { color: var(--navy); font-weight: 600; }
.sb-mcard-code { color: var(--muted); font-size: 11px; }

/* Settings sub-nav */
.settings-subnav { display: flex; gap: 4px; margin: -4px 0 18px; border-bottom: 2px solid var(--border); flex-wrap: wrap; }
.settings-subnav button { background: none; border: none; padding: 10px 16px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: color 0.15s, border-color 0.15s; }
.settings-subnav button:hover { color: var(--navy); }
.settings-subnav button.active { color: var(--accent); border-bottom-color: var(--accent); }
.settings-section { display: none; }
.settings-section.active { display: block; }

/* Messaging tab */
.msg-grid { display: grid; grid-template-columns: 1fr 320px; gap: 14px; align-items: start; }
@media (max-width: 1024px) { .msg-grid { grid-template-columns: 1fr; } }
.msg-thread { display: flex; flex-direction: column; gap: 8px; max-height: 360px; overflow-y: auto; padding: 6px; background: #fff; border: 1px solid var(--border); border-radius: 6px; }
.msg-bubble { padding: 8px 12px; border-radius: 10px; font-size: 13px; max-width: 85%; }
.msg-outbound { background: #dbeafe; align-self: flex-end; border-bottom-right-radius: 2px; }
.msg-inbound  { background: #f1f5f9; align-self: flex-start; border-bottom-left-radius: 2px; }
.ai-reply-panel { margin-top: 8px; padding: 8px 10px; border-left: 3px solid #a855f7; background: #faf5ff; border-radius: 6px; font-size: 12px; }
.ai-reply-panel .ai-reply-header { display: flex; gap: 6px; align-items: center; }
.ai-reply-panel button.btn { font-size: 11px; max-width: 100%; text-align: left; white-space: normal; line-height: 1.3; }

/* Insights cards on the Dashboard home */
.insights-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.insight-card { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; }
.insight-card.insight-alert { border-left: 4px solid var(--amber); background: #fffbeb; }
.insight-card.insight-alert.insight-red { border-left-color: var(--red); background: #fef2f2; }
.insight-card.insight-tip { background: #eff6ff; border-left: 4px solid var(--blue); }
.insight-card.insight-green { border-left: 4px solid var(--green); }
.insight-card.insight-amber { border-left: 4px solid var(--amber); }
.insight-card.insight-red { border-left: 4px solid var(--red); }
.insight-label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
.insight-value { font-size: 26px; font-weight: 800; color: var(--navy); margin: 4px 0 2px; line-height: 1.1; }
.insight-list { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.insight-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.insight-row:last-child { border-bottom: none; }
.insight-row.clickable { cursor: pointer; }
.insight-row.clickable:hover { background: #f9fafb; margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: 4px; }
.insight-bar { height: 5px; background: #e5e7eb; border-radius: 3px; margin-top: 4px; overflow: hidden; }
.insight-bar-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }

/* Sortable column headers (any <table class="data">) */
table.data thead th { cursor: pointer; user-select: none; position: relative; padding-right: 18px; }
table.data thead th:hover { background: rgba(0,0,0,0.04); }
table.data thead th::after { content: ''; position: absolute; right: 6px; top: 50%; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; opacity: 0.25; transform: translateY(-50%); }
table.data thead th.sort-asc::after { border-bottom: 5px solid var(--navy); opacity: 1; }
table.data thead th.sort-desc::after { border-top: 5px solid var(--navy); opacity: 1; }

/* Margin % bar (profit area on job modal) */
.margin-bar-wrap { position: relative; height: 28px; background: #e5e7eb; border-radius: 6px; overflow: hidden; margin-top: 6px; }
.margin-bar { height: 100%; border-radius: 6px 0 0 6px; transition: width 0.3s ease, background 0.2s ease; }
.margin-bar-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; color: #1a1a1a; font-size: 14px; letter-spacing: 0.3px; text-shadow: 0 0 6px rgba(255,255,255,0.85); }

/* ==================== MOBILE / TABLET ==================== */

/* Table scroll wrappers - any table inside a card stays horizontally scrollable */
.card-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { min-width: 100%; }

/* TABLET + LARGER PHONES (<= 1024px) */
@media (max-width: 1024px) {
  main { padding: 16px 12px; }
  header.top { padding: 10px 14px; }
  .brand-logo-img { height: 36px; padding: 3px 8px; }
  .brand-text .sub { font-size: 10px; }
  nav.tabs { top: 60px; padding: 0 8px; }
  nav.tabs button { padding: 12px 14px; font-size: 13px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi { padding: 12px; }
  .kpi-value { font-size: 22px; }
  table.data th, table.data td { padding: 9px 10px; font-size: 12.5px; }
}

/* PHONES (<= 768px) */
@media (max-width: 768px) {
  body { font-size: 14px; }
  /* Header: shrink + hide date, keep logo + user + signout */
  header.top { padding: 8px 12px; }
  .brand-logo-img { height: 32px; padding: 2px 6px; border-radius: 6px; }
  .brand-text { display: none; }
  .header-right { gap: 8px; font-size: 12px; }
  .header-right .date { display: none; }
  #userBadge { display: none; }
  .header-right .btn { padding: 7px 10px; font-size: 12px; }

  /* Tabs: on phones keep a single swipeable row (wrapping 18 tabs would eat the
     whole screen), so override the desktop wrap back to a horizontal scroll. */
  nav.tabs { top: 50px; padding: 0 8px; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  nav.tabs button { padding: 12px 12px; font-size: 13px; min-height: 44px; }

  main { padding: 12px 10px; }
  h2.page-title { font-size: 18px; }
  .page-sub { font-size: 12px; margin-bottom: 14px; }

  /* KPIs full-width-stacked on phones */
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
  .kpi { padding: 10px 12px; border-radius: 8px; }
  .kpi-label { font-size: 10px; }
  .kpi-value { font-size: 19px; }
  .kpi-sub { font-size: 11px; }

  /* Cards: tighter spacing, but keep clean */
  .card { margin-bottom: 14px; border-radius: 8px; }
  .card-header { padding: 11px 14px; flex-wrap: wrap; gap: 6px; }
  .card-header h3 { font-size: 13px; }
  .card-body { padding: 12px 14px; }

  /* Tables stay in their card - horizontal scroll inside .card-body */
  table.data th, table.data td { padding: 8px 10px; font-size: 12.5px; white-space: nowrap; }
  /* First column often a strong label - allow wrapping there */
  table.data td:first-child { white-space: normal; }

  /* Forms collapse to single column (already 768px in old rule, keep) */
  .form-grid { grid-template-columns: 1fr; gap: 11px; }
  label { font-size: 11px; }
  input[type="text"], input[type="number"], input[type="date"], input[type="email"],
  input[type="tel"], input[type="password"], select, textarea {
    padding: 11px 12px; font-size: 16px;  /* 16px prevents iOS zoom-on-focus */
  }
  .btn { padding: 11px 16px; font-size: 14px; min-height: 42px; }
  .btn.sm, .btn.small { padding: 7px 11px; font-size: 12px; min-height: 34px; }

  /* Modals: near-full-screen on phones */
  .modal-bg { padding: 0; align-items: stretch; }
  .modal { max-width: 100%; height: 100vh; border-radius: 0; display: flex; flex-direction: column; }
  .modal-header { padding: 14px 14px; position: sticky; top: 0; z-index: 5; }
  .modal-header h3 { font-size: 15px; }
  .modal-body { padding: 14px; max-height: none; flex: 1; }
  .modal-footer { padding: 10px 12px; flex-wrap: wrap; gap: 6px; position: sticky; bottom: 0; z-index: 5; }
  .modal-footer .btn { flex: 1 1 auto; min-width: 100px; }
  .modal-footer .btn[style*="margin-right:auto"] { flex-basis: 100%; }

  /* Kanban: stack columns vertically */
  .kanban { grid-template-columns: 1fr; gap: 10px; overflow-x: visible; }
  .kcol { min-height: 0; }

  /* Hub tiles: 2-col on phones */
  .hub-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .hub-tile { padding: 14px 8px; }
  .hub-icon { width: 40px; height: 40px; font-size: 18px; }

  /* Insights cards: 1-col */
  .insights-grid { grid-template-columns: 1fr; gap: 8px; }
  .insight-card { padding: 10px 12px; }
  .insight-value { font-size: 22px; }

  /* Settings sub-nav: horizontal scroll */
  .settings-subnav { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .settings-subnav button { padding: 10px 14px; flex: 0 0 auto; min-height: 42px; }

  /* Messaging grid stacks (was at 1024px, keep) */
  .msg-grid { grid-template-columns: 1fr; }
  .msg-thread { max-height: 50vh; }

  /* Schedule board: full width; hide the drag-only "Active jobs" sidebar on phones.
     Plain block (not grid) so the board is exactly viewport-wide and card content
     wraps instead of stretching the day strip off-screen. */
  .sb-wrap { display: block; }
  .sb-board { max-height: 60vh; }
  .sb-side { display: none; }
  /* Declutter the desktop-only colour legend on phone. The search box + hits
     stay toggleable (their own inline display:none hides them until 🔍 is tapped). */
  #scheduleLegend { display: none; }
  /* On a phone the toolbar's right-hand group wraps, and when the search is
     opened it takes its own full-width row (so it's properly tappable instead of
     a tiny squeezed box). 16px font stops iOS zooming in on focus. */
  #schedToolbarRight { display: flex; flex-wrap: wrap; width: 100%; margin-left: 0; justify-content: flex-end; }
  #scheduleGridSearch { flex: 1 1 100%; min-width: 0 !important; order: -1; font-size: 16px; padding: 10px 12px; }
  .sb-day-head strong { font-size: 14px; }
  .sb-day-head { font-size: 11px; padding: 6px 6px; }
  .sb-worker-cell { padding: 6px 8px; font-size: 11.5px; }

  /* Toolbar: stack search + filters on phone */
  .toolbar { gap: 8px; }
  .toolbar input, .toolbar select { flex: 1 1 100%; padding: 11px 12px; font-size: 15px; }

  /* SMS Cycle Tester table: stays in scroll wrapper */
  #cycleStagesBody td { font-size: 12px; }
  #cycleConvo { max-height: 50vh; font-size: 12.5px; }

  /* Scope blocks - tighter */
  .scope-block { padding: 8px; }
  .scope-block textarea { font-size: 13px; }

  /* Larger margin bar label so it stays readable */
  .margin-bar-label { font-size: 13px; }
}

/* TINY PHONES (<= 420px) */
@media (max-width: 420px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .hub-grid { grid-template-columns: 1fr; }
  .modal-footer .btn { flex-basis: 100%; }
  nav.tabs button { padding: 12px 10px; font-size: 12.5px; }
  .brand-logo-img { height: 28px; padding: 2px 5px; }
  h2.page-title { font-size: 16px; }
}

/* ============================================================
   STREAKS PAGE - stat strip, records wall, crew, hot feed, heatmap
   ============================================================ */

.streak-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 12px 0 16px;
}
.streak-stat {
  position: relative;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 10px;
  color: #fff;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.streak-stat:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,0.12); }
.streak-stat[data-tone="gold"]   { background: linear-gradient(135deg,#f59e0b 0%,#d97706 100%); }
.streak-stat[data-tone="navy"]   { background: linear-gradient(135deg,#1e3a8a 0%,#1e40af 100%); }
.streak-stat[data-tone="red"]    { background: linear-gradient(135deg,#dc2626 0%,#991b1b 100%); }
.streak-stat[data-tone="purple"] { background: linear-gradient(135deg,#7c3aed 0%,#5b21b6 100%); }
.streak-stat-icon {
  font-size: 30px;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.2));
  flex-shrink: 0;
}
.streak-stat-body { min-width: 0; flex: 1; }
.streak-stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  opacity: 0.85;
  font-weight: 600;
}
.streak-stat-value {
  font-size: 22px;
  font-weight: 800;
  margin: 2px 0;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.streak-stat-sub {
  font-size: 12px;
  opacity: 0.85;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Wall of Records */
.streak-records {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.streak-record {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  background: linear-gradient(135deg,#fef3c7 0%,#fde68a 100%);
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.streak-record:hover { transform: translateY(-1px); }
.streak-record-emoji { font-size: 28px; flex-shrink: 0; }
.streak-record-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.4px; color: #78350f; font-weight: 600; }
.streak-record-value { font-size: 18px; font-weight: 800; color: #1f2937; }
.streak-record-detail { font-size: 11.5px; color: #57534e; }

/* Two-column container */
.streak-twocol {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.streak-twocol .card { margin: 0; }

/* Hot Right Now feed */
.streak-hot-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.streak-hot-row:last-child { border-bottom: 0; }
.streak-hot-row:hover { background: #f9fafb; }
.streak-hot-emoji { font-size: 22px; }
.streak-hot-text { flex: 1; font-size: 13px; }

/* Animated flame for active streaks 7+ */
@keyframes streak-flicker {
  0%, 100% { transform: scale(1) rotate(-1deg); }
  50%      { transform: scale(1.08) rotate(1deg); }
}
.streak-flame-anim { display: inline-block; animation: streak-flicker 1.6s ease-in-out infinite; }

/* Contribution-grid heatmap (60 cells, 10 cols x 6 rows) */
.heatmap-wrap { padding: 6px 0; }
.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 3px;
  max-width: 320px;
}
.heatmap-cell {
  aspect-ratio: 1 / 1;
  border-radius: 2px;
  background: #ebedf0;
}
.heatmap-cell[data-level="1"] { background: #c6e48b; }
.heatmap-cell[data-level="2"] { background: #7bc96f; }
.heatmap-cell[data-level="3"] { background: #239a3b; }
.heatmap-cell[data-level="4"] { background: #196127; }
.heatmap-cell[data-level="-1"]{ background: #fecaca; }
.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  color: var(--muted);
}
.heatmap-legend .heatmap-cell { width: 12px; height: 12px; }

/* ===== Takeoff clip drop zone + gallery (quote modal) ===== */
.takeoff-dropzone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 10px;
  background: #fafbfd;
  outline: none;
  min-height: 60px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.takeoff-dropzone:focus,
.takeoff-dropzone:focus-within {
  border-color: var(--accent);
  background: #fff8f4;
}
.takeoff-dropzone.uploading {
  opacity: 0.7;
  cursor: progress;
}
.takeoff-dropzone-hint {
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 8px;
}
.takeoff-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}
.takeoff-thumb {
  position: relative;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  overflow: hidden;
}
.takeoff-thumb img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  display: block;
  border-radius: 4px;
  background: #f3f4f6;
}
.takeoff-thumb-meta {
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 4px;
  padding: 0 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.takeoff-thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 16px;
  line-height: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.takeoff-thumb-remove:hover { background: var(--red); }

/* ===== HERO money cards (top of streaks page) ===== */
.streak-money-hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 12px 0;
}
.money-hero-card {
  position: relative;
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 22px 24px;
  border-radius: 12px;
  color: #fff;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
}
.money-hero-card[data-tone="green"]   { background: linear-gradient(135deg,#16a34a 0%,#15803d 100%); }
.money-hero-card[data-tone="emerald"] { background: linear-gradient(135deg,#059669 0%,#047857 100%); }
.money-hero-icon { font-size: 52px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.25)); flex-shrink: 0; }
.money-hero-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.8px; opacity: 0.9; font-weight: 600; }
.money-hero-value { font-size: 34px; font-weight: 800; line-height: 1.1; margin: 4px 0 2px; }
.money-hero-sub   { font-size: 13px; opacity: 0.92; }

/* ===== Money Talks grid - 3 columns of leaderboards ===== */
.money-talks-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.money-talks-col   { min-width: 0; }
.money-talks-title { margin: 0 0 2px; font-size: 14px; color: var(--ink); }
.money-talks-sub   { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.money-talks-table { font-size: 12.5px; width: 100%; }
.money-talks-table td, .money-talks-table th { padding: 5px 6px; }
.money-talks-table td.num, .money-talks-table th.num { text-align: right; white-space: nowrap; }
.money-talks-table tbody tr:nth-child(1) { background: linear-gradient(90deg,#fef3c7 0%,#fffbeb 100%); }

/* Worker drill-down money tiles */
.worker-money-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 8px;
}
.worker-money-tile {
  padding: 12px 14px;
  border-radius: 8px;
}

/* Streaks page responsive */
@media (max-width: 1024px) {
  .streak-stats { grid-template-columns: repeat(2, 1fr); }
  .streak-twocol { grid-template-columns: 1fr; }
  .streak-money-hero { grid-template-columns: 1fr; }
  .money-talks-grid { grid-template-columns: 1fr; gap: 20px; }
  .worker-money-grid { grid-template-columns: 1fr; }
  .money-hero-value { font-size: 28px; }
}
@media (max-width: 480px) {
  .streak-stats { grid-template-columns: 1fr; }
  .streak-stat-value { font-size: 18px; }
  .money-hero-icon { font-size: 38px; }
  .money-hero-value { font-size: 24px; }
}
