* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #F5F7FA;
  --bg2: #ffffff;
  --bg3: #f0f2f5;
  --border: #e2e5eb;
  --text: #1a1d27;
  --text2: #6b7084;
  --accent: #2563eb;
  --accent-light: #dbeafe;
  --green: #16a34a;
  --green-light: #dcfce7;
  --yellow: #d97706;
  --yellow-light: #fef3c7;
  --red: #dc2626;
  --red-light: #fee2e2;
  --orange: #ea580c;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.08);
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  min-height: 100vh; -webkit-font-smoothing: antialiased;
}

#app { min-height: 100vh; display: flex; flex-direction: column; }
.app-content { flex: 1; padding: 24px 32px; padding-bottom: 32px; overflow-x: hidden; box-sizing: border-box; background: var(--bg); }
.page { display: none; }
.page.active { display: block; }

/* Header */
.header { background: var(--bg2); border-bottom: 1px solid var(--border); padding: 12px 16px; 
  display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow); }
.header h1 { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.header .user-info { font-size: 13px; color: var(--text2); display: flex; align-items: center; gap: 8px; }

/* Sidebar */
.sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 240px; background: #142334;
  border-right: none; display: flex; flex-direction: column; z-index: 100; }

/* Top bar — logo + avatar */
.sidebar-top-bar { display: flex; align-items: center; padding: 14px 14px 10px; gap: 10px; }
.sidebar-app-icon { width: 32px; height: 32px; background: rgba(255,255,255,0.1); border-radius: 8px; display: flex;
  align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.sidebar-top-spacer { flex: 1; }
.sidebar-avatar { width: 28px; height: 28px; border-radius: 50%; background: #0967D2; color: #fff;
  font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* Company name */
.sidebar-company { padding: 4px 16px 12px; font-size: 13px; font-weight: 600; color: #fff; }

/* Nav */
.sidebar-nav { flex: 1; padding: 4px 8px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.sidebar-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 6px;
  border: none; background: none; color: #8191A2; font-size: 14px; font-weight: 500;
  cursor: pointer; width: 100%; text-align: left; transition: background 0.15s, color 0.15s; position: relative; }
.sidebar-item:hover { background: rgba(255,255,255,0.08); color: #C3D0DE; }
.sidebar-item.active { background: rgba(255,255,255,0.10); color: #fff; }
.sidebar-icon { font-size: 20px; flex-shrink: 0; width: 22px; text-align: center; line-height: 1; }

/* Footer */
.sidebar-footer { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,0.1); display: flex; flex-direction: column; gap: 8px; }
.sidebar-username { font-size: 13px; font-weight: 600; color: #C3D0DE; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-logout { background: none; border: none; color: #8191A2; font-size: 13px; font-weight: 400;
  cursor: pointer; text-align: left; padding: 0; }
.sidebar-logout:hover { color: #C3D0DE; }

/* Hamburger (mobile only) */
.hamburger { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text);
  padding: 4px 8px; border-radius: 6px; flex-shrink: 0; line-height: 1; }
.hamburger:hover { background: var(--bg3); }
.header-left { display: flex; align-items: center; gap: 8px; }

/* Sidebar backdrop (mobile) */
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 99; }

/* Cards */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }

/* Stats */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid rgba(20,35,52,.12); border-radius: 10px; padding: 16px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--cc-primary, #0967D2); }
.stat-label { font-size: 13px; color: var(--cc-muted, #8191a2); margin-top: 4px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: var(--radius); border: none; font-size: 15px;
  font-weight: 600; cursor: pointer; width: 100%; transition: all 0.15s; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-success { background: var(--green); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 8px 14px; font-size: 13px; width: auto; border-radius: 8px; }
.btn-ghost { background: none; border: none; color: var(--accent); padding: 8px; width: auto; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Voice FAB */
.voice-fab { position: fixed; bottom: 24px; right: 20px; width: 60px; height: 60px; border-radius: 50%;
  background: var(--accent); border: none; color: #fff; font-size: 26px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4); z-index: 200; transition: all 0.2s; 
  display: flex; align-items: center; justify-content: center; }
.voice-fab:active { transform: scale(0.9); }
.voice-fab.recording { background: var(--red); animation: pulse 1.5s infinite; }
.voice-fab.recording::after { content: ''; position: absolute; width: 100%; height: 100%; border-radius: 50%;
  border: 2px solid var(--red); animation: ripple 1s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5); } 70% { box-shadow: 0 0 0 16px rgba(220, 38, 38, 0); } }
@keyframes ripple { 0% { transform: scale(1); opacity: 0.6; } 100% { transform: scale(1.8); opacity: 0; } }

/* Voice Sheet */
.voice-sheet-wrapper { position: fixed; inset: 0; z-index: 150; display: flex; align-items: flex-end; justify-content: center; }
.voice-sheet-wrapper.hidden { display: none; }
.voice-sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,0.3); }
.voice-sheet-panel { position: relative; background: var(--bg2); border-radius: 16px 16px 0 0; width: 100%; max-width: 640px;
  max-height: 75vh; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 20px 100px;
  animation: slideUp 0.3s ease; box-shadow: 0 -4px 20px rgba(0,0,0,0.1); }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-handle { display: flex; justify-content: center; padding: 8px 0 12px; cursor: pointer; }
.handle-bar { width: 36px; height: 4px; background: var(--border); border-radius: 2px; }
.sheet-actions { position: sticky; bottom: 0; background: var(--bg2); padding: 12px 0 8px; display: flex; gap: 8px;
  border-top: 1px solid var(--bg3); margin-top: 8px; }

/* Forms */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; }
input, select, textarea { background: var(--bg); border: 1.5px solid var(--border); border-radius: 8px;
  padding: 11px 12px; color: var(--text); font-size: 15px; width: 100%; font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
textarea { resize: vertical; min-height: 70px; }

/* Transcript */
.transcript-box { background: var(--bg3); border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 14px; min-height: 60px; font-size: 15px; line-height: 1.5; }
.transcript-box.empty { color: var(--text2); font-style: italic; }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-active { background: var(--accent-light); color: var(--accent); }
.badge-on_hold { background: var(--yellow-light); color: var(--yellow); }
.badge-completed { background: var(--green-light); color: var(--green); }
.badge-invoiced { background: #f3e8ff; color: #7c3aed; }
.badge-draft { background: var(--bg3); color: var(--text2); }
.badge-sent { background: var(--accent-light); color: var(--accent); }
.badge-paid { background: var(--green-light); color: var(--green); }

/* Project cards */
.project-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; margin-bottom: 10px; cursor: pointer; box-shadow: var(--shadow); transition: box-shadow 0.15s; }
.project-card:active { box-shadow: var(--shadow-lg); }
.project-card .title { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.project-card .client { font-size: 13px; color: var(--text2); }
.project-card .meta { display: flex; gap: 12px; margin-top: 8px; font-size: 12px; color: var(--text2); flex-wrap: wrap; }

/* === PROJECT LIST — COMPANYCAM STYLE === */

/* Page header */
.projects-title { font-size: 36px; font-weight: 800; color: #142334; margin-bottom: 8px; }
.btn-create { display: inline-flex; align-items: center; gap: 6px; padding: 0 16px; border-radius: 8px;
  background: #0967D2; color: #fff; font-size: 15px; font-weight: 400; border: none; cursor: pointer; transition: background 0.15s; margin-left: auto; flex-shrink: 0; height: 40px; }
.btn-create:hover { background: #0552B5; }
.btn-create:active { transform: scale(0.98); }

/* Search bar */
.project-search-row { display: flex; gap: 16px; margin-bottom: 16px; align-items: center; }
.search-input-wrap { position: relative; width: 400px; max-width: 100%; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 16px; pointer-events: none; color: #9CA3AF; }
.search-input { padding: 0 12px 0 36px !important; border-radius: 8px !important; background: #fff !important;
  border: 1px solid #D1D5DB !important; font-size: 14px !important; height: 40px !important; box-sizing: border-box !important; }
.search-input::placeholder { color: #9CA3AF; }

/* CompanyCam shared UI components */
.cc-card { background: #fff; border: 1px solid rgba(20,35,52,.12); border-radius: 10px; padding: 16px 20px; }
.cc-section-label { font-size: 12px; font-weight: 700; color: #4D5A68; letter-spacing: 0.5px; text-transform: uppercase; }
.section-title { font-size: 18px; font-weight: 700; color: #142334; }
.search-action-row { display: flex; align-items: center; gap: 12px; }

/* Shared list rows (invoices, inventory, etc.) */
.cc-list-row { display: flex; align-items: center; gap: 14px; padding: 16px; background: #fff;
  border: 1px solid rgba(20,35,52,.08); border-radius: 10px; margin-bottom: 8px; cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s; }
.cc-list-row:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); border-color: rgba(20,35,52,.16); }
.cc-list-row-icon { width: 40px; height: 40px; border-radius: 8px; background: rgba(9,103,210,.08);
  color: #0967D2; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.cc-list-row-info { flex: 1; min-width: 0; }
.cc-list-row-title { font-size: 15px; font-weight: 700; color: #142334; }
.cc-list-row-sub { font-size: 13px; color: #4D5A68; margin-top: 2px; }
.cc-list-row-meta { font-size: 12px; color: #8191a2; margin-top: 2px; }

/* Page tab row — Projects / Project Groups */
.page-tab-row { display: flex; gap: 24px; margin-bottom: 16px; border-bottom: 1px solid var(--cc-border); }
.page-tab { padding: 8px 0 10px; font-size: 15px; font-weight: 600; color: var(--cc-muted); background: none; border: none;
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color 0.15s; }
.page-tab:hover { color: var(--cc-dark); }
.page-tab.active { color: var(--cc-dark); border-bottom-color: var(--cc-dark); }

/* Recent user initials (plain text, no avatar circle) */
.project-stat-initials { font-size: 14px; font-weight: 600; color: #111827; }

/* Filter tabs — CompanyCam exact style: gray container, white active pill */
.filter-tabs { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.filter-tab-group { display: inline-flex; align-items: center; background: #EBEFF5; border-radius: 8px; padding: 4px; height: 40px; box-sizing: border-box; }
.filter-tab { padding: 0 12px; font-size: 12px; font-weight: 600; color: #142334; background: none; border: none;
  border-radius: 8px; cursor: pointer; white-space: nowrap; transition: background 0.15s; height: 32px; display: inline-flex; align-items: center; }
.filter-tab:hover { background: rgba(255,255,255,0.6); }
.filter-tab.active { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.filter-icon-btn { width: 40px; height: 40px; background: #EBEFF5; border: 2px solid transparent; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: #64748B; font-size: 18px; transition: background 0.15s; }
.filter-icon-btn:hover { background: #DCE2EB; }
/* Hide old pill filter styles */
.filter-chip { display: none; }

/* Project row — CSS grid with fixed columns like CompanyCam */
.project-row { display: grid; grid-template-columns: 1fr 400px; gap: 48px; align-items: center; padding: 16px;
  background: #fff; border: 1px solid rgba(20,35,52,0.12); border-radius: 10px; cursor: pointer; transition: background 0.12s, box-shadow 0.15s;
  min-width: 0; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.05); min-height: 128px; }
.project-row:hover { background: #F9FAFB; box-shadow: 0 2px 6px rgba(0,0,0,0.08); }
.projects-card-wrap { display: flex; flex-direction: column; gap: 10px; max-width: 100%; }

/* Thumbnail */
.project-thumb { width: 80px; height: 80px; border-radius: 8px; overflow: hidden; flex-shrink: 0;
  background: var(--bg3); position: relative; }
.project-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.project-thumb-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 700; color: #4B6A8A; background: #DFE6ED; border-radius: 8px; }

/* Project info (middle-left) */
.project-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.project-row-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.project-row-title { font-size: 17px; font-weight: 600; color: #111827; }
.project-row-subtitle { font-size: 13px; color: #6B7280; }
.project-row-client { font-size: 13px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.label-pill { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 20px;
  font-size: 10px; font-weight: 600; border: 1px solid transparent; white-space: nowrap; }

/* Stats columns (fixed middle zone) — paired with vertical divider */
.project-stats { display: flex; flex-shrink: 0; align-items: stretch; min-width: 180px; }
.project-stat-col { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-width: 80px; padding: 0 20px; }
.project-stat-col + .project-stat-col { border-left: 1px solid #E5E7EB; }
.project-stat-header { font-size: 10px; color: #9CA3AF; font-weight: 600; }
.project-stat-value { font-size: 18px; font-weight: 700; color: #111827; }
.project-stat-avatar { width: 32px; height: 32px; border-radius: 50%; background: #9CA3AF; color: #fff;
  font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }

/* Left column: thumb + title + stats */
.project-row-info { display: flex; align-items: center; gap: 16px; min-width: 0; }

/* Right column: photos (fixed grid column, never shifts) */
.project-photos-zone { display: flex; align-items: center; justify-content: flex-end; }
.project-photos-strip { display: flex; gap: 8px; }
.project-photos-strip img { width: 80px; height: 80px; border-radius: 8px; object-fit: cover; display: block; flex-shrink: 0; }
.project-no-photos { font-size: 13px; color: #9CA3AF; font-style: italic; text-align: right; }
.proj-menu-item { padding: 10px 16px; font-size: 14px; cursor: pointer; border-radius: 6px; transition: background 0.12s; }
.proj-menu-item:hover { background: var(--bg3); }
.proj-menu-danger { color: var(--red); }

/* Badges — subtler */
.badge { font-size: 10px; padding: 2px 8px; }

/* Medium: stacked layout + hide sidebar like CompanyCam ~850px */
@media (max-width: 1024px) {
  /* Stack project rows */
  .project-row { grid-template-columns: 1fr; gap: 8px; min-height: auto; }
  .project-row-info { flex-wrap: wrap; }
  .project-stats { border-top: 1px solid #E5E7EB; padding-top: 8px; margin-top: 4px; }
  .project-stat-col:first-child { padding-left: 0; }
  .project-photos-strip { flex-wrap: wrap; gap: 6px; }
  .project-photos-strip img { width: 80px; height: 80px; }
  .project-no-photos { font-size: 12px; }
  .project-photos-zone { justify-content: flex-start; }
}

/* Hide sidebar, show hamburger */
@media (max-width: 900px) {
  .sidebar { display: none !important; }
  .sidebar.open { display: flex !important; }
  .header { margin-left: 0 !important; width: 100% !important; }
  .app-content { margin-left: 0 !important; width: 100% !important; padding: 16px; }
  .hamburger { display: flex !important; }
  .projects-title { font-size: 24px; margin-bottom: 10px; }
  .search-input-wrap { flex: 1; width: auto; max-width: none; }
  .btn-create { padding: 0 14px; font-size: 13px; height: 36px; }
  .project-thumb { width: 56px; height: 56px; }
}

/* Mobile: match CompanyCam — hide stats, show photos full-width below */
@media (max-width: 600px) {
  .project-stats { display: none; }
  .project-thumb { width: 48px; height: 48px; }
  .project-row-title { font-size: 15px; font-weight: 700; }
  .project-row { padding: 14px; gap: 6px; }
  .project-row-info { flex-wrap: nowrap; gap: 12px; }
  .project-photos-zone { width: 100%; }
  .project-photos-strip { width: 100%; }
  .project-photos-strip img { flex: 1; min-width: 0; height: 80px; border-radius: 8px; }
  .project-no-photos { font-size: 11px; }
  .filter-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .filter-tabs::-webkit-scrollbar { display: none; }
  .filter-tab-group { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; flex-wrap: nowrap; }
  .filter-tab-group::-webkit-scrollbar { display: none; }
  .filter-tab { padding: 0 8px; font-size: 11px; flex-shrink: 0; }
  .filter-icon-btn { width: 34px; height: 34px; flex-shrink: 0; }
}

/* Expandable sections */
.section { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; box-shadow: var(--shadow); overflow: hidden; }
.section-header { padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; font-weight: 600; font-size: 15px; }
.section-header:hover { background: var(--bg3); }
.section-header .count { font-size: 12px; color: var(--text2); font-weight: 400; }
.section-header .chevron { transition: transform 0.2s; font-size: 14px; color: var(--text2); }
.section-header.expanded .chevron { transform: rotate(90deg); }
.section-body { display: none; padding: 0 16px 14px; }
.section-body.open { display: block; }

/* List items */
.list-item { padding: 10px 0; border-bottom: 1px solid var(--bg3); display: flex; flex-direction: column; gap: 4px; }
.list-item:last-child { border-bottom: none; }
.list-item .primary { font-size: 14px; font-weight: 500; }
.list-item .secondary { font-size: 12px; color: var(--text2); }
.list-item .amount { font-weight: 600; color: var(--accent); }

/* Activity feed */
.activity-item { padding: 12px 0; border-bottom: 1px solid rgba(20,35,52,.08); display: flex; gap: 12px; align-items: flex-start; }
.activity-item:last-child { border-bottom: none; }
.activity-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.activity-icon.time { background: rgba(9,103,210,.1); color: #0967D2; }
.activity-icon.material { background: rgba(245,158,11,.1); color: #D97706; }
.activity-icon.note { background: rgba(16,185,129,.1); color: #059669; }
.activity-content { flex: 1; min-width: 0; }
.activity-content .text { font-size: 13px; color: #142334; }
.activity-content .meta { font-size: 11px; color: #8191a2; margin-top: 2px; }

/* Invoice */
.invoice-preview { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.invoice-preview table { width: 100%; border-collapse: collapse; margin: 16px 0; }
.invoice-preview th { text-align: left; padding: 8px; border-bottom: 2px solid var(--border); font-size: 12px; text-transform: uppercase; color: var(--text2); }
.invoice-preview td { padding: 8px; border-bottom: 1px solid var(--bg3); font-size: 14px; }
.invoice-preview .totals td { font-weight: 600; border-bottom: none; }

/* Login */
.login-page { display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px; gap: 20px; background: var(--bg); }
.login-page .logo { font-size: 56px; }
.login-page h1 { font-size: 28px; font-weight: 700; }
.login-page .subtitle { color: var(--text2); text-align: center; font-size: 15px; }
.login-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 16px; padding: 24px; width: 100%; max-width: 380px; box-shadow: var(--shadow-lg); }
.login-toggle { font-size: 14px; color: var(--accent); cursor: pointer; text-align: center; }

/* Tabs / Filters (legacy — kept for non-project pages) */
.filter-bar { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; padding-bottom: 4px; }
.filter-btn { padding: 6px 14px; border-radius: 20px; border: 1.5px solid var(--border); background: var(--bg2);
  font-size: 13px; font-weight: 500; color: var(--text2); cursor: pointer; white-space: nowrap; }
.filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Client list */
.client-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; box-shadow: var(--shadow); }
.client-card:active { background: var(--bg3); }

/* Loading */
.loading { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 20px; color: var(--text2); }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty */
.empty-state { text-align: center; padding: 40px 16px; color: var(--text2); }
.empty-state .icon { font-size: 40px; margin-bottom: 8px; }

/* Utils */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--text2); }
.text-center { text-align: center; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.font-bold { font-weight: 700; }

/* Status dropdown */
.status-dropdown { border: none; appearance: none; -webkit-appearance: none; cursor: pointer; text-transform: uppercase; letter-spacing: 0.5px; }
.status-dropdown.status-active { background: var(--accent-light); color: var(--accent); }
.status-dropdown.status-completed { background: var(--green-light); color: var(--green); }
.status-dropdown.status-invoiced { background: #f3e8ff; color: #7c3aed; }
.status-dropdown:focus { outline: 2px solid var(--accent); }

/* Inventory dropdown */
.inv-dropdown { position: absolute; top: 100%; left: 0; right: 0; background: var(--bg2); border: 1.5px solid var(--accent);
  border-radius: 0 0 8px 8px; z-index: 50; max-height: 200px; overflow-y: auto; box-shadow: var(--shadow-lg); }
.inv-dd-item { padding: 10px 12px; cursor: pointer; display: flex; justify-content: space-between; align-items: center;
  font-size: 14px; border-bottom: 1px solid var(--bg3); }
.inv-dd-item:hover, .inv-dd-item:active { background: var(--accent-light); }
.inv-dd-item:last-child { border-bottom: none; }

/* Team */
.team-member { padding: 12px 0; border-bottom: 1px solid var(--bg3); }
.team-member:last-child { border-bottom: none; }
.team-member .primary { font-size: 15px; font-weight: 600; }
.team-member .secondary { font-size: 12px; color: var(--text2); margin-top: 2px; }
.team-member.team-inactive { opacity: 0.5; }
.team-role-select { padding: 4px 8px; font-size: 12px; font-weight: 600; border-radius: 20px; width: auto; min-width: 70px; text-align: center; }
.join-code-banner { background: var(--accent-light); border: 1.5px solid var(--accent); border-radius: var(--radius); padding: 12px 16px; text-align: center; }
.join-code-value { font-size: 28px; font-weight: 700; color: var(--accent); letter-spacing: 3px; font-family: monospace; margin-top: 4px; }

/* Photos */
.photo-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 480px) { .photo-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 600px) { .photo-grid { grid-template-columns: repeat(4, 1fr); } }
.photo-thumb { position: relative; border-radius: 8px; overflow: hidden; cursor: pointer;
  aspect-ratio: 1; background: var(--bg3); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.2s; }
.photo-thumb:active img { transform: scale(1.05); }
.photo-caption { position: absolute; bottom: 0; left: 0; right: 0; background: linear-gradient(transparent, rgba(0,0,0,0.7));
  color: #fff; font-size: 11px; padding: 16px 6px 4px; line-height: 1.3; }
.photo-delete-btn { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px;
  background: rgba(0,0,0,0.6); color: #fff; border: none; border-radius: 50%;
  font-size: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.2s; }
.photo-thumb:hover .photo-delete-btn { opacity: 1; }
@media (hover: none) { .photo-delete-btn { opacity: 1; } }
.photo-upload-bar { height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.photo-upload-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s ease; width: 0; }

/* === PROJECT DETAIL REDESIGN — COMPANYCAM STYLE === */

/* CompanyCam color variables — scoped to .pd but also used globally */
:root { --cc-primary: #0967D2; --cc-dark: #142334; --cc-text: #142334; --cc-subtle: #4D5A68;
  --cc-muted: #8191A2; --cc-bg2: #F5F7FA; --cc-bg3: #EBEFF5;
  --cc-border: rgba(20,35,52,0.12); --cc-border-input: rgba(20,35,52,0.2); }

/* Project detail layout */
.pd-layout { display: flex; gap: 32px; }
.pd-main { flex: 1; min-width: 0; }
.pd-sidebar { width: 340px; flex-shrink: 0; padding: 0 0 0 24px; border-left: 1px solid var(--cc-border); }

/* Breadcrumb */
/* Header top row — breadcrumb left, actions right */
.pd-header-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.pd-breadcrumb { display: inline-block; font-size: 14px; font-weight: 600; color: var(--cc-primary); cursor: pointer;
  text-decoration: none; }
.pd-breadcrumb:hover { text-decoration: underline; }
.pd-header-actions { display: flex; align-items: center; gap: 16px; }
.pd-action-btn { background: none; border: none; cursor: pointer; font-size: 14px; color: var(--cc-subtle);
  display: flex; align-items: center; gap: 4px; padding: 4px 8px; border-radius: 6px; transition: background 0.15s; }
.pd-action-btn:hover { background: var(--cc-bg3); color: var(--cc-dark); }
.pd-action-btn i { font-size: 20px; }
.pd-action-btn span { font-size: 13px; font-weight: 500; }
.pd-action-overflow { font-size: 20px; }

/* Header — thumbnail + info */
.pd-header { display: flex; gap: 20px; align-items: flex-start; margin-bottom: 20px; }
.pd-header-thumb { width: 160px; height: 120px; border-radius: 8px; overflow: hidden; flex-shrink: 0; background: var(--cc-bg3); }
.pd-header-thumb img { width: 100%; height: 100%; object-fit: cover; }
.pd-header-info { flex: 1; min-width: 0; }

.pd-title { font-size: 36px; font-weight: 800; color: var(--cc-dark); line-height: 1.15; }
.pd-address { font-size: 14px; color: var(--cc-primary); cursor: pointer; }
.pd-address:hover { text-decoration: underline; }
.pd-label-link { font-size: 13px; color: var(--cc-primary); cursor: pointer; margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.pd-label-link:hover { text-decoration: underline; }
.pd-label-link i { font-size: 15px; }
.pd-client { font-size: 14px; color: var(--cc-subtle); }
.pd-status-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }

/* Tab bar — CompanyCam style (white background like CC) */
.pd-tab-bar { display: flex; gap: 24px; border-bottom: 1px solid var(--cc-border); position: sticky; top: 52px;
  background: #fff; z-index: 20; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.pd-tab-bar::-webkit-scrollbar { display: none; }
.pd-tab { padding: 24px 0 12px; font-size: 16px; font-weight: 600; color: var(--cc-muted); background: none; border: none;
  cursor: pointer; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color 0.15s; }
.pd-tab:hover { color: var(--cc-dark); }
.pd-tab.active { color: var(--cc-dark); border-bottom-color: var(--cc-dark); }

/* Tab content panels */
.pd-tab-content { display: none; padding-top: 16px; }
.pd-tab-content.active { display: block; }

/* Photo toolbar — compact row */
.pd-photo-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 0;
  border-bottom: 1px solid var(--cc-border); margin-bottom: 16px; }
.pd-photo-toolbar-left { font-size: 14px; color: var(--cc-muted); }
.pd-photo-toolbar-right { display: flex; gap: 8px; align-items: center; }
.pd-toolbar-btn { height: 40px; padding: 0 16px; border-radius: 8px; font-size: 14px; font-weight: 500;
  border: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: background 0.15s; }
.pd-toolbar-btn-secondary { background: var(--cc-bg3); color: var(--cc-dark); }
.pd-toolbar-btn-secondary:hover { background: #DCE2EB; }
.pd-toolbar-btn-primary { background: var(--cc-primary); color: #fff; font-size: 15px; }
.pd-toolbar-btn-primary:hover { background: #0552B5; }

/* Photo grid — drag target */
.pd-photo-grid-wrap { min-height: 100px; transition: background 0.2s; border-radius: 8px; }
.pd-photo-grid-wrap.dragover { background: rgba(9,103,210,0.06); outline: 2px dashed var(--cc-primary); outline-offset: -2px; }

/* Photo date headers — with checkbox like CompanyCam */
.pd-photo-date { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--cc-dark);
  padding: 16px 0 10px; border-bottom: 1px solid var(--cc-border); margin-bottom: 10px; }
.pd-photo-date:first-child { padding-top: 0; }
.pd-photo-date input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--cc-primary); cursor: pointer; flex-shrink: 0; }

/* Filter toolbar — Start Date / End Date / Users / Groups / View */
.pd-filter-bar { display: flex; align-items: center; gap: 8px; padding: 8px 0; flex-wrap: wrap; }
.pd-filter-pill { height: 34px; padding: 0 12px; border-radius: 6px; font-size: 13px; font-weight: 500;
  border: 1px solid var(--cc-border-input); background: #fff; color: var(--cc-dark); cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px; transition: background 0.15s; white-space: nowrap; }
.pd-filter-pill:hover { background: var(--cc-bg3); }
.pd-filter-pill select { border: none; background: none; font: inherit; color: inherit; cursor: pointer; padding: 0; }
.pd-filter-spacer { flex: 1; }

/* "No more photos" end message */
.pd-photos-end { text-align: center; padding: 16px 0; font-size: 13px; color: var(--cc-muted); }

/* Photo grid — responsive, compact like CompanyCam (~5 per row) */
.pd-photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; margin-bottom: 20px; }

/* Photo item wrapper (card + meta below) */
.pd-photo-item { display: flex; flex-direction: column; }

/* Photo card */
.pd-photo-card { position: relative; border-radius: 8px; overflow: hidden; cursor: pointer; background: var(--cc-bg3); }
.pd-photo-card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; transition: transform 0.2s; }
.pd-photo-card:hover img { transform: scale(1.03); }

/* Photo avatar badge — CompanyCam style (bottom-left of thumbnail) */
.pd-photo-avatar { position: absolute; bottom: 6px; left: 6px; width: 24px; height: 24px;
  background: #26A69A; color: #fff; border-radius: 50%; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; letter-spacing: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3); pointer-events: none; }

/* Photo overlay — hidden (metadata goes below now) */
.pd-photo-overlay { display: none; }

/* Photo metadata below image — CompanyCam style */
.pd-photo-meta { padding: 4px 2px 0; font-size: 11px; color: var(--cc-muted); line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }

/* Photo caption below */
.pd-photo-caption { font-size: 13px; color: var(--cc-muted); padding: 6px 2px 0; line-height: 1.3; }

/* Photo delete */
.pd-photo-delete { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px;
  background: rgba(0,0,0,0.6); color: #fff; border: none; border-radius: 50%;
  font-size: 13px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.2s; }
.pd-photo-card:hover .pd-photo-delete { opacity: 1; }
@media (hover: none) { .pd-photo-delete { opacity: 1; } }

/* No more photos */
.pd-photos-end { text-align: center; padding: 24px; color: var(--cc-muted); font-size: 14px; }

/* Empty state for photo tab */
.empty-state-illustration { text-align: center; padding: 48px 16px; color: var(--cc-muted); }
.empty-state-illustration .icon { font-size: 56px; margin-bottom: 12px; }
.empty-state-illustration p { font-size: 14px; }

/* Chat-style notes */
.note-chat { display: flex; flex-direction: column; gap: 12px; padding-bottom: 70px; }
.note-bubble { display: flex; gap: 10px; align-items: flex-start; }
.note-avatar { width: 32px; height: 32px; border-radius: 50%; background: rgba(9,103,210,0.12); color: var(--cc-primary);
  font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.note-bubble .note-body { background: #fff; border: 1px solid var(--cc-border); border-radius: 0 12px 12px 12px;
  padding: 10px 14px; max-width: 85%; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.note-bubble .note-meta { font-size: 11px; color: var(--cc-muted); margin-bottom: 3px; }
.note-bubble .note-text { font-size: 14px; line-height: 1.5; color: var(--cc-dark); }

/* Note input bar */
.note-input-bar { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; display: flex; gap: 8px;
  border-top: 1px solid var(--cc-border); }
.note-input-bar input { flex: 1; }
.note-input-bar button { flex-shrink: 0; width: auto; padding: 10px 16px; }

/* Time & Materials summary bar */
.tm-summary-bar { display: flex; gap: 16px; padding: 14px 16px; background: var(--cc-bg3); border-radius: 10px;
  margin-bottom: 16px; flex-wrap: wrap; }
.tm-summary-bar .tm-stat { font-size: 14px; color: var(--cc-subtle); }
.tm-summary-bar .tm-stat strong { color: var(--cc-primary); }

/* T&M list items */
.tm-list-item { padding: 12px 0; border-bottom: 1px solid var(--cc-border); display: flex; justify-content: space-between; align-items: center; }
.tm-list-item:last-child { border-bottom: none; }
.tm-list-item .tm-primary { font-size: 14px; font-weight: 500; color: var(--cc-dark); }
.tm-list-item .tm-secondary { font-size: 12px; color: var(--cc-muted); margin-top: 2px; }
.tm-list-item .tm-amount { font-weight: 600; color: var(--cc-primary); font-size: 14px; white-space: nowrap; }

/* Activity timeline */
.activity-timeline { position: relative; padding-left: 28px; }
.activity-timeline::before { content: ''; position: absolute; left: 11px; top: 8px; bottom: 8px; width: 2px; background: var(--cc-border); }
.timeline-item { position: relative; padding: 8px 0; }
.timeline-item .timeline-icon { position: absolute; left: -28px; top: 10px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; border: 2px solid var(--cc-border); display: flex; align-items: center; justify-content: center; font-size: 12px; }
.timeline-item .timeline-text { font-size: 13px; color: var(--cc-dark); }
.timeline-item .timeline-meta { font-size: 11px; color: var(--cc-muted); margin-top: 2px; }

/* Sidebar cards — CompanyCam section style */
.pd-sidebar-section { padding: 20px 0; border-bottom: 1px solid var(--cc-border); }
.pd-sidebar-section:first-child { padding-top: 0; }
.pd-sidebar-section:last-child { border-bottom: none; }
.pd-sidebar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.pd-sidebar-title { font-size: 15px; font-weight: 700; color: var(--cc-dark); }
.pd-sidebar-add { width: 28px; height: 28px; border-radius: 50%; background: none; border: 1.5px solid var(--cc-border);
  cursor: pointer; font-size: 18px; color: var(--cc-subtle); display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s; line-height: 1; }
.pd-sidebar-add:hover { background: var(--cc-bg3); color: var(--cc-primary); }
.pd-sidebar-toggle { cursor: pointer; user-select: none; }
.pd-sidebar-toggle:hover { opacity: 0.8; }
.pd-sidebar-chevron { font-size: 14px; color: var(--cc-muted); transition: transform 0.2s; }
.pd-sidebar-body { transition: all 0.2s; }
.pd-sidebar-body.collapsed { display: none; }
.pd-sidebar-add:hover { background: #DCE2EB; }

/* Sidebar info */
.pd-info-row { font-size: 13px; padding: 4px 0; display: flex; gap: 8px; }
.pd-info-label { color: var(--cc-muted); min-width: 70px; flex-shrink: 0; }
.pd-info-value { color: var(--cc-dark); }

/* Sidebar stats — 2x2 grid */
.pd-stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pd-stat-cell { text-align: center; padding: 10px 8px; background: var(--cc-bg2); border-radius: 8px; }
.pd-stat-val { font-size: 20px; font-weight: 700; color: var(--cc-primary); }
.pd-stat-lbl { font-size: 11px; color: var(--cc-muted); margin-top: 2px; }

/* Sidebar quick actions */
.pd-quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pd-quick-btn { padding: 10px 8px; font-size: 13px; font-weight: 600; border-radius: 8px;
  background: var(--cc-bg3); border: none; cursor: pointer; color: var(--cc-dark); transition: all 0.15s; }
.pd-quick-btn:hover { background: #DCE2EB; color: var(--cc-primary); }

/* Project user avatar — CompanyCam style (outlined, gray) */
.pd-user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--cc-bg3);
  color: var(--cc-dark); font-size: 12px; font-weight: 700; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; border: 1px solid var(--cc-border); }

/* Sidebar conversation — CompanyCam style */
.pd-sidebar-notes { display: flex; flex-direction: column; gap: 16px; }
.pd-convo-msg { display: flex; flex-direction: column; }
.pd-convo-header { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-bottom: 4px; }
.pd-convo-name { font-size: 12px; font-weight: 600; color: var(--cc-dark); }
.pd-convo-avatar { width: 28px; height: 28px; border-radius: 50%; background: #26A69A;
  color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; }
.pd-convo-bubble { background: var(--cc-primary); color: #fff; padding: 10px 14px; border-radius: 12px 12px 4px 12px;
  font-size: 13px; line-height: 1.45; word-break: break-word; }
.pd-convo-date { font-size: 11px; color: var(--cc-muted); text-align: right; margin-top: 4px; }
.pd-convo-input-wrap { position: relative; margin-top: 8px; }
.pd-convo-input { width: 100%; padding: 10px 36px 10px 12px; border: 1px solid var(--cc-border-input); border-radius: 8px;
  font-size: 13px; background: #fff; }
.pd-convo-at-btn { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: none;
  color: var(--cc-primary); font-size: 16px; font-weight: 700; cursor: pointer; }

/* Sidebar action buttons */
.pd-sidebar-actions { display: flex; flex-direction: column; gap: 8px; }
.pd-sidebar-actions .btn { font-size: 13px; }

/* Desktop: offset content by sidebar width */
@media (min-width: 901px) {
  .header { margin-left: 240px; width: calc(100% - 240px); }
  .app-content { margin-left: 240px; width: calc(100% - 240px); }
  .hamburger { display: none; }
  .header .user-info { display: none; }
}

/* Mobile: sidebar slides in as overlay */
@media (max-width: 767px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
  }
}

/* Mobile: collapse project detail to single column */
@media (max-width: 900px) {
  .pd-layout { flex-direction: column; gap: 0; }
  .pd-sidebar { width: 100%; border-left: none; padding: 24px 0 0; border-top: 1px solid var(--cc-border); }
  .pd-header { gap: 14px; }
  .pd-header-thumb { width: 100px; height: 75px; }
  .pd-title { font-size: 24px; }
  .pd-photo-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .pd-tab-bar { top: 52px; }
  .pd-header-top { margin-bottom: 8px; }
  .pd-header-actions { gap: 8px; }
  .pd-action-btn span { display: none; }
  .pd-action-btn { padding: 4px; }
}

/* Small mobile: further compact */
@media (max-width: 480px) {
  .pd-title { font-size: 20px; }
  .pd-header-thumb { width: 80px; height: 60px; }
  .pd-filter-bar { gap: 6px; }
  .pd-filter-pill { font-size: 12px; padding: 6px 10px; }
  .pd-toolbar-btn-primary { font-size: 12px; padding: 6px 12px; }
  .pd-photo-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 4px; }
  .pd-photo-avatar { width: 20px; height: 20px; font-size: 9px; bottom: 4px; left: 4px; }
}

/* Generic Modal (overlay for forms) */
.voice-modal { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,0.5); display: none; align-items: flex-end; justify-content: center; }
.voice-modal.open { display: flex; }
.voice-modal .voice-sheet { background: var(--bg2); border-radius: 16px 16px 0 0; width: 100%; max-width: 500px; padding: 20px; max-height: 80vh; overflow-y: auto; }

/* Photo Lightbox (CompanyCam-style fullscreen overlay) */
.photo-lightbox { position: fixed; inset: 0; z-index: 250; background: rgba(0,0,0,0.92); display: none; align-items: center; justify-content: center; flex-direction: column; }
.photo-lightbox.open { display: flex; }
.photo-lightbox img { max-width: 94vw; max-height: 85vh; object-fit: contain; border-radius: 4px; user-select: none; -webkit-user-select: none; }
.lightbox-close { position: absolute; top: 12px; right: 16px; background: none; border: none; color: #fff; font-size: 36px; cursor: pointer; z-index: 251; line-height: 1; padding: 8px; opacity: 0.8; }
.lightbox-close:hover { opacity: 1; }
.lightbox-caption { color: rgba(255,255,255,0.85); font-size: 14px; margin-top: 12px; text-align: center; max-width: 80vw; }

/* Print */
@media print {
  .header, .sidebar, .voice-fab, .btn, .no-print { display: none !important; }
  body { background: #fff; }
  .invoice-preview { border: none; box-shadow: none; padding: 0; }
}
