/* Brixa — modern bento UI. Light grey canvas, rounded bento cards with
   soft depth, one dark "ink" featured card in the mix, monochrome brand
   accent, Inter + Space Grotesk. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Space+Grotesk:wght@500;600;700&display=swap');

* { box-sizing: border-box; }
:root {
  --bg: #eef0f3;
  --panel: #ffffff;
  --ink: #101216;
  --muted: #6f7480;
  --line: #e3e6eb;
  --line-soft: #eef0f3;
  --accent: #101216;          /* primary buttons: ink */
  --accent-ink: #ffffff;
  --brand: #101216;           /* the mark: ink on light surfaces… */
  --brand-on-dark: #ffffff;   /* …and white on the dark ones */
  --violet: #7c6cf6;
  --violet-soft: #edeafd;
  --green: #22a06b;
  --green-soft: #e3f5ec;
  --blue: #2f6bff;
  --blue-soft: #e8eeff;
  --amber: #c47b0a;
  --amber-soft: #fdf2dc;
  --red: #e0442e;
  --red-soft: #fdeae6;
  --radius: 20px;
  --shadow: 0 1px 2px rgba(16, 18, 22, 0.04), 0 8px 24px -12px rgba(16, 18, 22, 0.12);
  --shadow-hover: 0 2px 4px rgba(16, 18, 22, 0.05), 0 16px 32px -12px rgba(16, 18, 22, 0.18);
  --display: "Space Grotesk", "Inter", sans-serif;
}
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.55 "Inter", -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased; }
a { color: inherit; }

/* Layout: floating dark sidebar + content */
.layout { display: flex; min-height: 100vh; gap: 0; }
.sidebar { width: 224px; flex: 0 0 224px; background: #0e1013; color: #b9bcc4; padding: 22px 14px;
  display: flex; flex-direction: column; gap: 3px; margin: 14px 0 14px 14px; border-radius: 24px;
  position: sticky; top: 14px; height: calc(100vh - 28px); }
.sidebar .brand { display: flex; align-items: center; gap: 10px; color: #ffffff; font-family: var(--display);
  font-weight: 700; font-size: 17px; letter-spacing: -0.3px; padding: 2px 10px 20px; }
.sidebar .brand .mark { width: 30px; height: 30px; display: block; }
.sidebar a.nav { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 12px;
  text-decoration: none; color: #8d919c; font-weight: 500; font-size: 13.5px; transition: background 0.15s, color 0.15s; }
.sidebar a.nav .ico { width: 18px; text-align: center; opacity: 0.9; }
.sidebar a.nav:hover { background: #191c21; color: #e8e9ec; }
.sidebar a.nav.active { background: #1d2026; color: #ffffff; }
.sidebar a.nav.active .ico { color: var(--brand-on-dark); }
.sidebar .spacer { flex: 1; }
.sidebar .whoami { font-size: 12px; color: #6f7480; padding: 12px 12px 2px; border-top: 1px solid #1d2026; }
.sidebar .whoami a { color: #8d919c; }
.content { flex: 1; padding: 34px 36px 70px; max-width: 1280px; min-width: 0; }

h1 { font-family: var(--display); font-size: 28px; letter-spacing: -0.8px; margin: 0 0 4px; font-weight: 700; }
.sub { color: var(--muted); margin: 0 0 24px; font-size: 13.5px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; }

/* Bento cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 24px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card h2 { font-family: var(--display); font-size: 16px; margin: 0 0 14px; letter-spacing: -0.3px; font-weight: 600; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow); transition: transform 0.15s, box-shadow 0.15s; position: relative; overflow: hidden; }
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.stat::before { content: ""; position: absolute; right: -22px; top: -22px; width: 74px; height: 74px; border-radius: 50%;
  background: var(--stat-color, var(--line-soft)); opacity: 0.16; }
.stat .label { font-size: 12px; color: var(--muted); margin-bottom: 8px; font-weight: 500; }
/* Money values must never clip in a narrow column, so the size flexes. */
.stat .value { font-family: var(--display); font-size: clamp(19px, 1.75vw, 28px); font-weight: 700;
  letter-spacing: -1px; line-height: 1.15; }
.stat.dark { background: #101216; border-color: #101216; color: #ffffff; }
.stat.dark .label { color: #9aa0ab; }
.stat.dark .value { color: var(--brand-on-dark); }
.stat.dark::before { background: var(--brand-on-dark); opacity: 0.12; }

table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted);
  font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 12px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.list tr:last-child td { border-bottom: none; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: #f7f8fa; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Status pills */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; padding: 4px 11px;
  border-radius: 999px; background: #f0f1f4; color: #4c505a; white-space: nowrap; }
.badge::before { content: "●"; font-size: 7px; line-height: 1; }
.badge.enquiry, .badge.draft, .badge.logged, .badge.task, .badge.todo { background: #f0f1f4; color: #4c505a; }
.badge.site_visit, .badge.quote_sent, .badge.sent { background: var(--blue-soft); color: var(--blue); }
.badge.contract, .badge.confirmed { background: var(--violet-soft); color: var(--violet); }
.badge.in_progress { background: var(--amber-soft); color: var(--amber); }
.badge.completed, .badge.delivered, .badge.received, .badge.approved { background: var(--green-soft); color: var(--green); }
.badge.completed::before, .badge.delivered::before, .badge.approved::before, .badge.received::before,
.badge.sent::before, .badge.quote_sent::before { content: "✓"; font-size: 10px; }
.badge.on_hold { background: #fdeef6; color: #c0398f; }
.badge.lost, .badge.cancelled, .badge.failed, .badge.declined { background: var(--red-soft); color: var(--red); }
.badge.paid { background: var(--green-soft); color: var(--green); }
.badge.paid::before { content: "✓"; font-size: 10px; }
.badge.overdue { background: var(--red-soft); color: var(--red); }
.badge.overdue::before { content: "⚠"; font-size: 10px; }

button, .btn { font: inherit; font-weight: 600; font-size: 13.5px; border: 1px solid var(--line); background: var(--panel);
  color: var(--ink); padding: 10px 16px; border-radius: 12px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 7px; transition: transform 0.12s, box-shadow 0.12s, background 0.12s; box-shadow: var(--shadow); }
button:hover, .btn:hover { background: #f7f8fa; transform: translateY(-1px); box-shadow: var(--shadow-hover); }
button:active, .btn:active { transform: translateY(0); }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.primary:hover, .btn.primary:hover { background: #23262d; }
button.green, .btn.green { background: var(--brand); color: #ffffff; border-color: var(--brand); }
button.green:hover, .btn.green:hover { background: #b9e844; }
button.danger { color: var(--red); }
button.small, .btn.small { padding: 5px 12px; font-size: 12.5px; border-radius: 9px; box-shadow: none; }
button:disabled { opacity: 0.5; cursor: default; }

/* Create chips */
.chips { display: flex; gap: 9px; flex-wrap: wrap; margin-bottom: 22px; }
.chip { display: inline-flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line);
  color: var(--ink); font-weight: 600; font-size: 13px; padding: 9px 16px; border-radius: 999px; cursor: pointer;
  box-shadow: var(--shadow); transition: transform 0.12s, box-shadow 0.12s; }
.chip:hover { transform: translateY(-1px); box-shadow: var(--shadow-hover); }

input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 13px; width: 100%; transition: border 0.12s, box-shadow 0.12s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #101216; box-shadow: 0 0 0 3px rgba(16, 18, 22, 0.08); }
label { display: block; font-size: 12px; font-weight: 600; color: #4c505a; margin: 0 0 5px; }
.field { margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 14px; }

/* Two-column project layout */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.rail .card { padding: 18px 20px; }
.rail h3 { font-family: var(--display); font-size: 14px; margin: 0 0 12px; letter-spacing: -0.2px; }
.rail .kv { font-size: 13px; margin-bottom: 8px; display: flex; gap: 8px; }
.rail .kv .k { color: var(--muted); width: 84px; flex: none; }
.avatar { width: 40px; height: 40px; border-radius: 14px; background: linear-gradient(135deg, #7c6cf6, #a78bfa); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex: none; }

/* Stage progress */
.stagebar { display: flex; gap: 4px; margin-top: 12px; }
.stagebar span { height: 8px; flex: 1; border-radius: 5px; background: var(--line); }
.stagebar span.on { background: var(--brand); }

/* Modal */
.modal-back { position: fixed; inset: 0; background: rgba(14, 16, 19, 0.55); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; z-index: 50; }
.modal { background: #fff; border-radius: 22px; padding: 26px; width: 100%; max-width: 600px; max-height: 88vh;
  overflow: auto; box-shadow: 0 24px 64px -16px rgba(14, 16, 19, 0.4); }
.modal h2 { font-family: var(--display); margin: 0 0 16px; font-size: 19px; letter-spacing: -0.4px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* Tabs — segmented pill. Works with <button> (in-page) and <a class="segbtn"> (links). */
.tabs { display: inline-flex; gap: 2px; background: #e6e8ec; border-radius: 999px; padding: 4px; margin-bottom: 18px; flex-wrap: wrap; }
.tabs button, .tabs a.segbtn { border: none; background: none; box-shadow: none; padding: 8px 16px; font-weight: 600;
  font-size: 13px; color: var(--muted); border-radius: 999px; text-decoration: none; display: inline-flex;
  align-items: center; cursor: pointer; font-family: inherit; }
.tabs button:hover, .tabs a.segbtn:hover { background: #dcdfe4; transform: none; box-shadow: none; }
.tabs button.active, .tabs a.segbtn.active { color: var(--ink); background: #ffffff; box-shadow: 0 1px 3px rgba(16,18,22,0.12); }
/* Inner sub-nav (e.g. Money → Budget/Quotes/Orders/Costs) */
.tabs.inner { background: transparent; padding: 0; gap: 6px; margin-bottom: 16px; }
.tabs.inner button { border: 1px solid var(--line); background: var(--panel); padding: 6px 14px; font-size: 12.5px; }
.tabs.inner button.active { background: #101216; color: #fff; border-color: #101216; box-shadow: none; }

/* Toast */
#toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: #101216; color: #ffffff;
  padding: 12px 22px; border-radius: 14px; font-weight: 600; font-size: 13.5px; z-index: 100;
  box-shadow: 0 12px 32px rgba(0,0,0,0.3); animation: toastin 0.2s ease; }
#toast.error { background: var(--red); }
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Auth screens */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(1200px 600px at 70% -10%, #dfe3ff 0%, var(--bg) 55%); }
.auth-card { background: #fff; border: 1px solid var(--line); border-radius: 24px; padding: 36px; width: 100%;
  max-width: 400px; box-shadow: var(--shadow-hover); }
.auth-card .brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-size: 20px;
  font-weight: 700; letter-spacing: -0.4px; margin-bottom: 4px; }
.auth-card .brand .mark { width: 32px; height: 32px; display: block; }

/* Gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)); gap: 14px; }
.gallery .item { border: 1px solid var(--line); border-radius: 18px; overflow: hidden; background: #fff;
  box-shadow: var(--shadow); transition: transform 0.15s, box-shadow 0.15s; }
.gallery .item:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.gallery .thumb { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; background: var(--line-soft); }
.gallery .thumb.doc { display: flex; align-items: center; justify-content: center; font-size: 36px; color: #b3b7c0; text-decoration: none; }
.gallery .meta { padding: 10px 12px; font-size: 12.5px; }
.gallery .meta .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gallery .meta .k { color: var(--muted); display: flex; justify-content: space-between; align-items: center; margin-top: 3px; }

/* Quote document */
.qdoc-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line);
  padding-bottom: 18px; margin-bottom: 18px; flex-wrap: wrap; }
.qdoc-title { font-family: var(--display); font-size: 23px; font-weight: 700; letter-spacing: -0.6px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.qsection { background: #f4f5f7; font-weight: 700; }
.qsection td { padding: 9px 10px !important; }
.qtotals td { border-bottom: none !important; padding: 5px 10px !important; }
.qtotals .grand { font-family: var(--display); font-size: 17px; font-weight: 700; }

/* Gantt-lite schedule */
.gantt-wrap { overflow-x: auto; padding-bottom: 6px; }
.gantt { display: grid; align-items: stretch; min-width: 100%; }
.gantt .glabel { grid-column: 1; padding: 8px 10px 8px 2px; border-bottom: 1px solid var(--line-soft); font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: sticky; left: 0; background: var(--panel); z-index: 2; }
.gantt .gday { border-left: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); min-height: 36px; }
.gantt .gday.weekend { background: #f5f6f8; }
.gantt .gday.today { background: #f5fbe6; }
.gantt .ghead { font-size: 10.5px; color: var(--muted); text-align: center; padding: 3px 0 5px; border-left: 1px solid var(--line-soft); }
.gantt .ghead.today { color: #6a9412; font-weight: 700; }
.gantt .gmonth { font-family: var(--display); font-size: 11px; font-weight: 600; color: #4c505a; padding: 2px 4px;
  border-left: 1px solid var(--line-soft); overflow: hidden; white-space: nowrap; }
.gantt-bar { border-radius: 9px; margin: 4px 2px; padding: 4px 9px; font-size: 12px; font-weight: 600; color: #101216;
  display: flex; align-items: center; gap: 6px; cursor: pointer; overflow: hidden; white-space: nowrap; z-index: 1;
  min-height: 26px; box-shadow: 0 1px 2px rgba(16,18,22,0.12); transition: filter 0.12s, transform 0.12s; }
.gantt-bar:hover { filter: brightness(0.96); transform: translateY(-1px); }
.gantt-bar.done { opacity: 0.5; text-decoration: line-through; }
.gantt-bar .who { background: rgba(255,255,255,0.85); border-radius: 999px; font-size: 10px; padding: 1px 6px; flex: none; font-weight: 700; }
.swatches { display: flex; gap: 8px; margin: 4px 0 2px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: transform 0.1s; }
.swatch:hover { transform: scale(1.1); }
.swatch.selected { border-color: #101216; }

/* Week board */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 12px; }
.week .day { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 12px; min-height: 150px; box-shadow: var(--shadow); }
.week .day.today { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand), var(--shadow); }
.week .day h4 { margin: 0 0 10px; font-size: 12px; color: var(--muted); font-weight: 600; }
.week .day.today h4 { color: var(--brand); }
.week .chipitem { border-radius: 11px; padding: 7px 9px; font-size: 12px; margin-bottom: 7px; cursor: pointer;
  background: #f0f1f4; transition: transform 0.12s; box-shadow: 0 1px 2px rgba(16,18,22,0.08); }
.week .chipitem:hover { transform: translateY(-1px); }
.week .chipitem .p { color: #4c505a; font-size: 11px; opacity: 0.8; }
.week .chipitem.done { opacity: 0.5; text-decoration: line-through; }

/* Timesheet grid — team down the side, the week across */
.tswrap { overflow-x: auto; }
table.ts th.today { color: #6a9412; }
table.ts td.tscell { cursor: pointer; min-width: 62px; }
table.ts td.tscell:hover { background: #f5fbe6; }
table.ts td.tscell.today { background: #fafcf3; }
table.ts td.tscell .hours { font-weight: 700; font-family: var(--display); }
table.ts td.tscell .add { color: #c3c7cf; font-weight: 700; }
table.ts td.tscell:hover .add { color: #6a9412; }
table.ts tr:last-child td { background: #fafbfc; }

/* Site diary */
.diary-entry { border-left: 3px solid var(--brand); padding-left: 16px; margin-bottom: 22px; }
.diary-entry .head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 6px; }
.diary-entry .date { font-family: var(--display); font-weight: 700; font-size: 15px; }
.diary-entry .field-row { font-size: 13px; margin-bottom: 6px; }
.diary-entry .field-row .k { color: var(--muted); font-weight: 600; margin-right: 6px; }
.diary-entry .issues { background: var(--red-soft); color: #8f2a1b; border-radius: 10px; padding: 8px 12px; font-size: 13px; margin: 8px 0; }
.diary-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin-top: 10px; }
.diary-photos a { position: relative; display: block; }
.diary-photos img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 12px; background: var(--line-soft); display: block; }
.diary-photos button { position: absolute; top: 5px; right: 5px; padding: 2px 7px; font-size: 11px; border-radius: 8px; opacity: 0.9; }

.empty { color: var(--muted); text-align: center; padding: 32px 10px; }
.muted { color: var(--muted); }
.right { text-align: right; }
.mt0 { margin-top: 0; }

@media (max-width: 980px) { .split { grid-template-columns: 1fr; } .rail { order: -1; } }
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { width: auto; flex: none; flex-direction: row; align-items: center; overflow-x: auto;
    padding: 10px; margin: 10px; height: auto; position: static; border-radius: 18px; }
  .sidebar .brand { padding: 2px 10px; }
  .sidebar .whoami { border: none; white-space: nowrap; padding: 0 10px; }
  .content { padding: 6px 16px 40px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .week { grid-template-columns: 1fr 1fr; }
}

/* ── WhatsApp-style chat (project → Messages → Chat) ───────────────────────── */
.chip.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip.active .muted { color: rgba(255, 255, 255, 0.65); }
.wa-thread { background: #e9e4dc; border-radius: 14px; padding: 16px 14px; max-height: 460px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px; }
.wa-bubble { max-width: 78%; padding: 8px 11px 5px; border-radius: 12px; font-size: 13.5px; line-height: 1.45;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08); word-break: break-word; }
.wa-bubble.in { align-self: flex-start; background: #ffffff; border-top-left-radius: 4px; }
.wa-bubble.out { align-self: flex-end; background: #d7f7c8; border-top-right-radius: 4px; }
.wa-bubble img { display: block; max-width: 100%; border-radius: 9px; margin: 2px 0 6px; }
.wa-bubble .wa-meta { font-size: 10.5px; color: #7a7f74; text-align: right; margin-top: 3px; }
.wa-compose { display: flex; gap: 8px; margin-top: 12px; align-items: center; }
.wa-compose input[name="text"] { flex: 1; border-radius: 99px; }

/* ── Welcome tour ──────────────────────────────────────────────────────────── */
.tour-back { position: fixed; inset: 0; background: rgba(12, 14, 18, 0.55); z-index: 900; }
.tour-spot { position: relative; z-index: 901; box-shadow: 0 0 0 4px #ffffff, 0 0 0 9px rgba(255, 255, 255, 0.35); border-radius: 12px; }
.tour-card { position: fixed; z-index: 902; width: 300px; max-width: calc(100vw - 20px); background: var(--panel);
  border-radius: 16px; padding: 18px 18px 14px; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35); }
.tour-card h3 { margin: 0 0 6px; font-size: 15.5px; }
.tour-card p { margin: 0 0 14px; font-size: 13px; line-height: 1.5; color: var(--muted); }
.tour-actions { display: flex; align-items: center; gap: 10px; }
.tour-actions .tour-skip { background: transparent; border: none; color: var(--muted); font-size: 12.5px; padding: 6px 2px; }
.tour-dots { flex: 1; display: flex; gap: 5px; justify-content: center; }
.tour-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.tour-dots i.on { background: var(--accent); }

/* ── Assistant chat ────────────────────────────────────────────────────────── */
#assistBtn { position: fixed; right: 18px; bottom: 18px; z-index: 850; width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent); color: #ffffff; font-size: 22px; border: none; box-shadow: 0 8px 24px rgba(0,0,0,.3);
  cursor: pointer; transition: transform .12s; }
#assistBtn:hover { transform: scale(1.06); }
#assistPanel { position: fixed; right: 18px; bottom: 80px; z-index: 851; width: 340px; max-width: calc(100vw - 24px);
  height: 460px; max-height: calc(100vh - 110px); background: var(--panel); border-radius: 18px;
  box-shadow: 0 18px 60px rgba(0,0,0,.35); display: none; flex-direction: column; overflow: hidden; }
#assistPanel.open { display: flex; }
.ap-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.ap-head .grow { flex: 1; }
.ap-head button { background: transparent; border: none; font-size: 14px; color: var(--muted); padding: 4px; cursor: pointer; }
.ap-msgs { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 8px; background: var(--bg); }
.ap-bubble { max-width: 85%; padding: 8px 11px; border-radius: 12px; font-size: 13px; line-height: 1.5; word-break: break-word; }
.ap-bubble.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.ap-bubble.bot { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.ap-actions { display: flex; flex-direction: column; gap: 4px; margin-top: 7px; }
.ap-actions span { background: var(--green-soft); color: var(--green); border-radius: 8px; padding: 3px 8px; font-size: 11.5px; font-weight: 600; }
.ap-typing { color: var(--muted); letter-spacing: 2px; }
.ap-compose { display: flex; gap: 7px; padding: 10px; border-top: 1px solid var(--line); }
.ap-compose input { flex: 1; border-radius: 99px; font-size: 13px; }
.ap-compose button { border-radius: 50%; width: 38px; height: 38px; padding: 0; flex: none; }

/* ── Global search ─────────────────────────────────────────────────────────── */
.searchwrap { position: relative; margin: 2px 10px 10px; }
.searchwrap input { width: 100%; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14);
  color: #fff; border-radius: 99px; padding: 8px 14px; font-size: 12.5px; }
.searchwrap input::placeholder { color: rgba(255,255,255,.45); }
.searchwrap input:focus { outline: none; border-color: rgba(255,255,255,.55); background: rgba(255,255,255,.12); }
#searchResults { position: absolute; top: calc(100% + 8px); left: 0; z-index: 700; width: 340px; max-width: 84vw;
  max-height: 60vh; overflow-y: auto; background: var(--panel); border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0,0,0,.35); padding: 6px; }
.sr-hit { display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; border-radius: 9px;
  text-decoration: none; color: var(--ink); }
.sr-hit:hover { background: var(--bg); }
.sr-type { flex: none; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  background: var(--brand); color: #ffffff; border-radius: 6px; padding: 3px 6px; margin-top: 1px; min-width: 52px; text-align: center; }
.sr-text { display: flex; flex-direction: column; min-width: 0; }
.sr-text strong { font-size: 13px; line-height: 1.35; }
.sr-text span { font-size: 11.5px; color: var(--muted); }
.sr-empty { padding: 14px; font-size: 12.5px; color: var(--muted); }
@media (max-width: 900px) { .searchwrap { min-width: 160px; flex: 1; margin: 0 6px; } }

/* ── Project priority on schedule items (set in Schedule → Planner) ────────── */
.chipitem.prio-1 { border-left: 4px solid var(--red); }
.chipitem.prio-2 { border-left: 4px solid var(--amber); }
.chipitem.prio-3 { border-left: 4px solid var(--green); }

/* ── Brixa: company line under the brand, and the "inside a company" bar ──── */
.sidebar .brand { flex-direction: column; align-items: flex-start; gap: 6px; }
.sidebar .brand .lockup { display: flex; align-items: center; gap: 10px; }
.sidebar .brand .company { font-family: "Inter", sans-serif; font-weight: 500; font-size: 12px; color: #8d919c; letter-spacing: 0; padding-left: 2px; }
.imp-bar { position: sticky; top: 0; z-index: 60; display: flex; align-items: center; gap: 12px; padding: 8px 16px;
  background: #101216; color: #e8e9ec; font-size: 13px; border-bottom: 1px solid #2a2e36; }
.imp-bar strong { color: #fff; }
.imp-bar .grow { flex: 1; }
.imp-bar button { background: #fff; color: #101216; border: 0; font-weight: 600; font-size: 12.5px; padding: 6px 12px; border-radius: 999px; cursor: pointer; }
/* Only on desktop, where the sidebar is a full-height column: the bar pushes it
   down and shortens it. On a phone the sidebar is a short horizontal strip with
   height:auto, and forcing a viewport height on it turned the whole screen into
   a black block. */
@media (min-width: 761px) {
  body.impersonating .sidebar { top: 52px; height: calc(100vh - 66px); }
}
@media (max-width: 900px) { .sidebar .brand { flex-direction: row; align-items: center; } .sidebar .brand .company { display: none; } }

/* ── Language picker, at the foot of the sidebar ───────────────────────────── */
/* Small and quiet: it is chosen once and then forgotten, so it must not compete
   with the navigation above it. */
.sidebar .whoami select {
  width: auto; margin: 6px 0 2px; padding: 3px 22px 3px 8px; font-size: 12px; font-weight: 600;
  color: #b9bcc4; background: #191c21 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238d919c' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 8px center;
  border: 1px solid #262a31; border-radius: 8px; appearance: none; cursor: pointer;
}
.sidebar .whoami select:hover { color: #e8e9ec; border-color: #343943; }
.sidebar .whoami select:focus { outline: none; border-color: #4a5058; box-shadow: none; }

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE — everything below this line is inside one media query, so the
   desktop app is byte-for-byte what it was. Under 760px Brixa stops being a
   narrow desktop and becomes its own thing: a dark pill at the bottom with
   four places and a "+", and pages made of cards instead of tables.
   ═══════════════════════════════════════════════════════════════════════════ */
/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE — every rule below hangs off `body.m`, a class only the mobile shell
   adds (mobile.js → mountMobileShell). Deliberately not a media query: the
   layout is chosen once in JavaScript, and if the stylesheet disagreed with
   that choice — a phone turned sideways, an iPad in split view, a window
   dragged narrower — you got the mobile markup with the desktop stylesheet,
   which is no layout at all. A desktop session never gets the class, so none
   of this can reach it.
   ═══════════════════════════════════════════════════════════════════════════ */
/* The scroll area. The bottom padding clears the tab bar plus the home bar. */
body.m .m-content { padding: 10px 16px calc(130px + env(safe-area-inset-bottom)); max-width: 100%; }
body.m { background: var(--bg); }
body.m .imp-bar { position: static; }
body.m .m-content h1 { font-size: 27px; letter-spacing: -0.9px; margin: 0 0 3px; }
body.m .m-content .kicker { font-size: 13px; color: var(--muted); font-weight: 500; margin: 8px 0 1px; }
body.m .m-sect { font-size: 11.5px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
    color: var(--muted); margin: 22px 2px 9px; }/* ── Tab bar ─────────────────────────────────────────────────────────── */
body.m .m-tabbar { position: fixed; left: 14px; right: 14px; bottom: calc(16px + env(safe-area-inset-bottom));
    height: 62px; z-index: 60; background: rgba(14, 16, 19, 0.94); -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px); border-radius: 999px; display: grid;
    grid-template-columns: 1fr 1fr 74px 1fr 1fr; align-items: center;
    box-shadow: 0 10px 30px -8px rgba(10, 11, 13, 0.55); }
body.m .m-tabbar a, body.m .m-tabbar button { background: none; border: 0; box-shadow: none; padding: 0; cursor: pointer;
    color: #7e838d; text-decoration: none; display: grid; justify-items: center; gap: 3px;
    transition: color 0.15s; font-weight: 600; }
body.m .m-tabbar a:hover, body.m .m-tabbar button:hover { background: none; transform: none; box-shadow: none; color: #c9ccd2; }
body.m .m-tabbar .ico { font-size: 17px; line-height: 1; }
body.m .m-tabbar .lbl { font-size: 9.5px; letter-spacing: 0.01em; }
body.m .m-tabbar a.on { color: #ffffff; }
body.m .m-fab { justify-self: center; width: 58px; height: 58px; border-radius: 50%; background: #ffffff;
    display: grid !important; place-items: center; border: 0; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
    transform: translateY(-11px); font-size: 26px; line-height: 1; color: #101216; font-weight: 300; }
body.m .m-fab:hover { background: #fff; transform: translateY(-13px); }/* ── The "+" sheet ───────────────────────────────────────────────────── */
body.m .m-scrim { position: fixed; inset: 0; background: rgba(12, 14, 17, 0.5); -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px); z-index: 70; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
body.m .m-scrim.on { opacity: 1; pointer-events: auto; }
body.m .m-sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 71; background: var(--panel);
    border-radius: 26px 26px 0 0; padding: 10px 14px calc(26px + env(safe-area-inset-bottom));
    transform: translateY(102%); transition: transform 0.26s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 0 -10px 40px -10px rgba(0, 0, 0, 0.3); max-height: 88vh; overflow-y: auto; }
body.m .m-sheet.on { transform: translateY(0); }
body.m .m-grab { width: 38px; height: 4px; border-radius: 3px; background: #d3d7de; margin: 5px auto 12px; }
body.m .m-sheet h3 { font-family: var(--display); font-size: 15px; margin: 0 0 10px 4px; }/* The assistant first: a sentence beats four buttons for anyone in a hurry. */
body.m .m-ask { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--line);
    border-radius: 999px; padding: 6px 6px 6px 17px; margin: 0 0 6px; cursor: pointer; width: 100%; }
body.m .m-ask span { flex: 1; text-align: left; color: #8e939e; font-size: 14.5px; }
body.m .m-ask b { width: 42px; height: 42px; border-radius: 50%; background: var(--ink); color: #fff; flex: none;
    display: grid; place-items: center; font-size: 15px; }
body.m .m-or { text-align: center; font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
    color: #a4a9b3; margin: 8px 0 2px; }
body.m .m-big { display: flex; align-items: center; gap: 13px; width: 100%; text-align: left; font: inherit;
    background: none; border: 0; border-bottom: 1px solid var(--line-soft); border-radius: 0; box-shadow: none;
    padding: 12px 4px; color: var(--ink); }
body.m .m-big:hover { background: none; transform: none; box-shadow: none; }
body.m .m-big:last-of-type { border-bottom: 0; }
body.m .m-big .ic { flex: none; width: 44px; height: 44px; border-radius: 15px; background: var(--ink); color: #fff;
    display: grid; place-items: center; font-size: 19px; }
body.m .m-big .tx { min-width: 0; }
body.m .m-big .tt { font-weight: 600; font-size: 16px; letter-spacing: -0.2px; display: block; }
body.m .m-big .ss { font-size: 12.5px; color: var(--muted); display: block; }/* ── Cards, tiles, rows ──────────────────────────────────────────────── */
body.m .m-alert { display: flex; align-items: center; gap: 11px; width: 100%; text-align: left; font: inherit;
    background: var(--red-soft); border: 1px solid #f6cfc6; border-radius: 16px; padding: 13px 14px;
    margin-bottom: 12px; color: var(--red); box-shadow: none; text-decoration: none; }
body.m .m-alert:hover { background: var(--red-soft); transform: none; box-shadow: none; }
body.m .m-alert .tt { font-weight: 700; font-size: 14.5px; }
body.m .m-alert .amt { font-family: var(--display); font-weight: 700; font-size: 19px; letter-spacing: -0.5px; margin-left: auto; }
body.m .m-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
body.m .m-tiles.three { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
body.m .m-tile { background: var(--panel); border: 1px solid var(--line); border-radius: 17px; padding: 13px 14px;
    box-shadow: var(--shadow); display: block; text-decoration: none; color: inherit; }
body.m .m-tile .l { font-size: 12px; color: var(--muted); font-weight: 500; margin-bottom: 4px; }
body.m .m-tile .v { font-family: var(--display); font-size: 21px; font-weight: 700; letter-spacing: -0.9px;
    font-variant-numeric: tabular-nums; }
body.m .m-tiles.three .m-tile { padding: 12px 11px; }
body.m .m-tiles.three .v { font-size: 17px; letter-spacing: -0.6px; }
body.m .m-tiles.three .l { font-size: 11px; }
body.m .m-tile.ink { background: var(--ink); border-color: var(--ink); color: #fff; }
body.m .m-tile.ink .l { color: #9aa0ab; }
body.m .m-tile.bad .v { color: var(--red); }
body.m .m-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 15px 16px; box-shadow: var(--shadow); margin-bottom: 12px; }
body.m .m-card.flush { padding: 15px 16px 6px; }
body.m .m-card h3 { font-family: var(--display); font-size: 14px; font-weight: 600; letter-spacing: -0.2px; margin: 0 0 11px; }
body.m .m-row { display: flex; align-items: center; gap: 12px; padding: 10px 0;
    border-bottom: 1px solid var(--line-soft); text-decoration: none; color: inherit; }
body.m .m-row:last-child { border-bottom: 0; }
body.m .m-row .body { flex: 1; min-width: 0; }
body.m .m-row .t { font-weight: 600; font-size: 14.5px; letter-spacing: -0.1px; }
body.m .m-row .s { font-size: 12.5px; color: var(--muted); }
body.m .m-row .amt { font-family: var(--display); font-weight: 700; font-size: 15px; letter-spacing: -0.3px;
    white-space: nowrap; font-variant-numeric: tabular-nums; }
body.m .m-row .chev { color: #b7bcc6; flex: none; font-size: 15px; }
body.m .m-dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }/* Ticking a task off is the most-pressed thing on the phone, so it is the
     biggest target on the row. */
body.m .m-tick { flex: none; width: 42px; height: 42px; border-radius: 14px; border: 2px solid var(--line);
    background: #fff; padding: 0; box-shadow: none; display: grid; place-items: center;
    font-size: 17px; color: transparent; transition: background 0.15s, border-color 0.15s; }
body.m .m-tick:hover { background: #fff; transform: none; box-shadow: none; }
body.m .m-tick[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #fff; }
body.m .m-task[data-done="1"] .t { text-decoration: line-through; color: var(--muted); }
body.m .m-time { font-family: var(--display); font-weight: 700; font-size: 14px; letter-spacing: -0.3px; flex: none; }/* Project cards */
body.m .m-pcard { display: block; width: 100%; text-align: left; font: inherit; color: inherit; text-decoration: none;
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 15px;
    box-shadow: var(--shadow); margin-bottom: 10px; }
body.m .m-pcard .top { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 11px; }
body.m .m-pcard .name { font-weight: 700; font-size: 15.5px; letter-spacing: -0.25px; line-height: 1.3; display: block; }
body.m .m-pcard .client { font-size: 12.5px; color: var(--muted); margin-top: 1px; display: block; }
body.m .m-bar { height: 7px; border-radius: 4px; background: var(--line-soft); overflow: hidden; }
body.m .m-bar i { display: block; height: 100%; border-radius: 4px; background: var(--ink); }
body.m .m-bar i.over { background: var(--red); }
body.m .m-money-line { display: flex; justify-content: space-between; align-items: baseline; font-size: 12.5px;
    color: var(--muted); margin-top: 7px; font-variant-numeric: tabular-nums; }
body.m .m-money-line b { color: var(--ink); font-weight: 700; }/* Horizontal filter chips: one line, always, however many there are. */
body.m .m-chips { display: flex; gap: 7px; overflow-x: auto; padding: 2px 16px 12px; margin: 0 -16px;
    scrollbar-width: none; -webkit-overflow-scrolling: touch; }
body.m .m-chips::-webkit-scrollbar { height: 0; }
body.m .m-chips button { flex: none; font-size: 13.5px; font-weight: 600; background: var(--panel);
    border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 9px 15px; box-shadow: none; }
body.m .m-chips button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }/* Project page: the six tabs become a grid you can see all of at once. */
body.m .m-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin-bottom: 16px; }
body.m .m-grid a { background: var(--panel); border: 1px solid var(--line); border-radius: 17px; padding: 11px 3px 9px;
    display: grid; justify-items: center; gap: 5px; box-shadow: var(--shadow); text-decoration: none; color: inherit; }
body.m .m-grid .ico { font-size: 19px; line-height: 1; }
body.m .m-grid .lbl { font-size: 10.5px; font-weight: 600; color: var(--muted); letter-spacing: -0.1px; }
body.m .m-empty { color: var(--muted); text-align: center; padding: 26px 10px; font-size: 13.5px; }/* ── Anything still rendered as a table becomes a stack of cards ─────── *//* Pages we have not given a bespoke mobile view yet still have to be usable,
     so every list table collapses: the header row goes, each row becomes a
     card, and the first cell is its title. */
body.m .m-content table.list, body.m .m-content table.list tbody, body.m .m-content table.list tr, body.m .m-content table.list td { display: block; width: 100%; }
body.m .m-content table.list tr:has(th) { display: none; }
body.m .m-content table.list tr { background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
    padding: 12px 14px; margin-bottom: 10px; }
body.m .m-content table.list td { border: 0; padding: 2px 0; font-size: 13px; }
body.m .m-content table.list td:first-child { font-size: 15px; font-weight: 600; letter-spacing: -0.15px; padding-bottom: 4px; }
body.m .m-content table.list td.num { text-align: left; font-family: var(--display); font-weight: 700; }
body.m .m-content table.list td:empty { display: none; }

/* Forms and modals: a dialog on a phone belongs at the bottom, thumb-first. */
body.m .m-content .grid2, body.m .m-content .grid3 { grid-template-columns: 1fr; }
body.m .modal-back { padding: 0; align-items: flex-end; }
body.m .modal { border-radius: 22px 22px 0 0; max-height: 92vh; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); }
body.m .modal .actions { position: sticky; bottom: 0; background: #fff; padding-top: 12px; margin-top: 16px; }
body.m .modal .actions button { flex: 1; justify-content: center; padding: 14px; font-size: 15px; }
body.m input, body.m select, body.m textarea { font-size: 16px; }   /* under 16px iOS zooms the page in */

/* The assistant becomes the whole screen — it is a conversation, not a widget. */
body.m #assistBtn { display: none; }
body.m #assistPanel { right: 0; left: 0; bottom: 0; top: 0; width: auto; max-width: none; border-radius: 0;
    z-index: 80; height: 100%; }
body.m #assistPanel .ap-head { padding: 14px 16px; padding-top: calc(14px + env(safe-area-inset-top)); }
body.m .ap-bubble { font-size: 14.5px; max-width: 88%; }
body.m .ap-compose { padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); }
body.m .ap-compose button { width: 44px; height: 44px; }
body.m #toast { bottom: calc(96px + env(safe-area-inset-bottom)); left: 16px; right: 16px; transform: none;
    border-radius: 16px; padding: 15px 17px; animation-name: m-toastin; }
@keyframes m-toastin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
