/* ===== Design Tokens: Light (default) ===== */
:root {
  --bg-primary: #f6f5f2;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-elevated: #f0f0ec;
  --border-color: rgba(20,20,15,0.10);
  --accent-primary: #a3790f;
  --accent-secondary: #1d4e42;
  --text-primary: #17181c;
  --text-secondary: #565f6b;
  --text-muted: #8b93a0;
  --success: #15803d;
  --warning: #b45309;
  --danger: #b91c1c;
  --info: #1d4ed8;
  --sidebar-w: 240px;
  --header-h: 60px;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.08);

  --badge-new-bg: rgba(29,78,216,.10); --badge-new-text: #1d4ed8;
  --badge-needs_review-bg: rgba(180,83,9,.12); --badge-needs_review-text: #92400e;
  --badge-more_info_requested-bg: rgba(180,83,9,.12); --badge-more_info_requested-text: #92400e;
  --badge-approved-bg: rgba(163,121,15,.14); --badge-approved-text: #8a660c;
  --badge-assigned-bg: rgba(163,121,15,.14); --badge-assigned-text: #8a660c;
  --badge-vendor_accepted-bg: rgba(21,128,61,.12); --badge-vendor_accepted-text: #15803d;
  --badge-vendor_declined-bg: rgba(185,28,28,.12); --badge-vendor_declined-text: #b91c1c;
  --badge-scheduled-bg: rgba(29,78,216,.10); --badge-scheduled-text: #1d4ed8;
  --badge-in_progress-bg: rgba(180,83,9,.12); --badge-in_progress-text: #92400e;
  --badge-quote_uploaded-bg: rgba(29,78,66,.14); --badge-quote_uploaded-text: #1d4e42;
  --badge-completed-bg: rgba(21,128,61,.12); --badge-completed-text: #15803d;
  --badge-cancelled-bg: rgba(20,20,15,.08); --badge-cancelled-text: #565f6b;
  --badge-pending-bg: rgba(180,83,9,.10); --badge-pending-text: #92400e;
  --badge-active-bg: rgba(21,128,61,.10); --badge-active-text: #15803d;
  --badge-inactive-bg: rgba(20,20,15,.08); --badge-inactive-text: #565f6b;
  --badge-low-bg: rgba(21,128,61,.10); --badge-low-text: #15803d;
  --badge-medium-bg: rgba(29,78,216,.10); --badge-medium-text: #1d4ed8;
  --badge-high-bg: rgba(180,83,9,.12); --badge-high-text: #92400e;
  --badge-emergency-bg: rgba(185,28,28,.12); --badge-emergency-text: #b91c1c;

  --role-agent-bg: rgba(163,121,15,.14); --role-agent-text: #8a660c;
  --role-client-bg: rgba(29,78,216,.10); --role-client-text: #1d4ed8;
  --role-vendor-bg: rgba(29,78,66,.14); --role-vendor-text: #1d4e42;
}

/* ===== Design Tokens: Dark (opt-in via toggle) ===== */
/* NewGenIT.ai brand palette (matches www.newgenit.ai's own dark theme tokens) */
[data-theme="dark"] {
  --bg-primary: #020d0f;
  --bg-secondary: #061819;
  --bg-card: #0b2427;
  --bg-elevated: #0f2c2f;
  --border-color: rgba(63,222,233,0.15);
  --accent-primary: #3fdee9;
  --accent-secondary: #0a8f93;
  --text-primary: #ffffff;
  --text-secondary: #c8d1d2;
  --text-muted: #6f7d80;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);

  --badge-new-bg: rgba(59,130,246,.15); --badge-new-text: #60a5fa;
  --badge-needs_review-bg: rgba(245,158,11,.15); --badge-needs_review-text: #fbbf24;
  --badge-more_info_requested-bg: rgba(245,158,11,.15); --badge-more_info_requested-text: #fbbf24;
  --badge-approved-bg: rgba(63,222,233,.15); --badge-approved-text: #3fdee9;
  --badge-assigned-bg: rgba(63,222,233,.15); --badge-assigned-text: #3fdee9;
  --badge-vendor_accepted-bg: rgba(34,197,94,.15); --badge-vendor_accepted-text: #4ade80;
  --badge-vendor_declined-bg: rgba(239,68,68,.15); --badge-vendor_declined-text: #f87171;
  --badge-scheduled-bg: rgba(59,130,246,.15); --badge-scheduled-text: #60a5fa;
  --badge-in_progress-bg: rgba(245,158,11,.15); --badge-in_progress-text: #fbbf24;
  --badge-quote_uploaded-bg: rgba(10,143,147,.3); --badge-quote_uploaded-text: #3fdee9;
  --badge-completed-bg: rgba(34,197,94,.15); --badge-completed-text: #4ade80;
  --badge-cancelled-bg: rgba(74,85,104,.2); --badge-cancelled-text: #8892a4;
  --badge-pending-bg: rgba(245,158,11,.12); --badge-pending-text: #fbbf24;
  --badge-active-bg: rgba(34,197,94,.12); --badge-active-text: #4ade80;
  --badge-inactive-bg: rgba(74,85,104,.2); --badge-inactive-text: #8892a4;
  --badge-low-bg: rgba(34,197,94,.12); --badge-low-text: #4ade80;
  --badge-medium-bg: rgba(59,130,246,.12); --badge-medium-text: #60a5fa;
  --badge-high-bg: rgba(245,158,11,.15); --badge-high-text: #fbbf24;
  --badge-emergency-bg: rgba(239,68,68,.15); --badge-emergency-text: #f87171;

  --role-agent-bg: rgba(63,222,233,.15); --role-agent-text: #3fdee9;
  --role-client-bg: rgba(59,130,246,.15); --role-client-text: #60a5fa;
  --role-vendor-bg: rgba(10,143,147,.35); --role-vendor-text: #3fdee9;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: 'Inter', 'Space Grotesk', system-ui, -apple-system, sans-serif; background: var(--bg-primary); color: var(--text-primary); min-height: 100vh; display: flex; flex-direction: column; transition: background .15s, color .15s; }
a { color: var(--accent-primary); text-decoration: none; }
a:hover { opacity: .85; }

/* ===== Layout ===== */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--bg-secondary); border-right: 1px solid var(--border-color); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; overflow-y: auto; z-index: 100; transition: transform .3s; }
.main-wrap { margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; flex: 1; min-width: 0; }
.topbar { height: var(--header-h); background: var(--bg-secondary); border-bottom: 1px solid var(--border-color); display: flex; align-items: center; padding: 0 1.5rem; gap: 1rem; position: sticky; top: 0; z-index: 50; }
.page-content { padding: 2rem 1.75rem; flex: 1; }

/* ===== Sidebar ===== */
.sidebar-brand { padding: 1.25rem 1.25rem 1rem; display: flex; align-items: center; gap: .75rem; border-bottom: 1px solid var(--border-color); }
.sidebar-brand-icon { width: 36px; height: 36px; background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary)); border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; color: #fff; }
.sidebar-brand-text { font-weight: 700; font-size: .95rem; color: var(--text-primary); line-height: 1.2; }
.sidebar-brand-sub { font-size: .72rem; color: var(--text-muted); font-weight: 400; }
.sidebar-section { padding: 1.25rem 1rem .5rem; }
.sidebar-section-label { font-size: .68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted); margin-bottom: .5rem; padding: 0 .25rem; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a { display: flex; align-items: center; gap: .65rem; padding: .6rem .75rem; border-radius: 8px; color: var(--text-secondary); font-size: .88rem; font-weight: 500; transition: background .15s, color .15s; }
.sidebar-nav a:hover, .sidebar-nav a.active { background: var(--role-agent-bg); color: var(--accent-primary); }
.sidebar-nav a svg { width: 17px; height: 17px; flex-shrink: 0; }

.nav-group-toggle { width: 100%; display: flex; align-items: center; gap: .65rem; padding: .6rem .75rem; border-radius: 8px; background: none; border: none; color: var(--text-secondary); font-size: .88rem; font-weight: 500; font-family: inherit; cursor: pointer; text-align: left; transition: background .15s, color .15s; }
.nav-group-toggle:hover, .nav-group-toggle.active { background: var(--role-agent-bg); color: var(--accent-primary); }
.nav-group-toggle svg.icon { width: 17px; height: 17px; flex-shrink: 0; }
.nav-group-toggle .chevron { width: 14px; height: 14px; flex-shrink: 0; margin-left: auto; transition: transform .15s; }
.nav-group.open .nav-group-toggle .chevron { transform: rotate(180deg); }
.nav-submenu { max-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 1px; padding-left: 2.15rem; transition: max-height .2s ease; }
.nav-group.open .nav-submenu { max-height: 240px; }
.nav-submenu a { display: block; padding: .45rem .6rem; border-radius: 6px; color: var(--text-muted); font-size: .82rem; font-weight: 500; transition: background .15s, color .15s; }
.nav-submenu a:hover, .nav-submenu a.active { background: var(--role-agent-bg); color: var(--accent-primary); }
.sidebar-footer { margin-top: auto; padding: 1rem; border-top: 1px solid var(--border-color); }
.sidebar-user { display: flex; align-items: center; gap: .65rem; }
.sidebar-avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg,var(--accent-primary),var(--accent-secondary)); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; color: #fff; flex-shrink: 0; }
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: .85rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: .72rem; color: var(--text-muted); }

/* ===== Topbar ===== */
.hamburger { display: none; background: none; border: none; cursor: pointer; padding: .35rem; color: var(--text-primary); }
.hamburger span { display: block; width: 22px; height: 2px; background: currentColor; margin: 4px 0; border-radius: 2px; transition: .25s; }
.topbar-title { font-weight: 700; font-size: 1rem; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: .75rem; margin-left: auto; }

/* ===== Theme toggle ===== */
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 8px; background: var(--bg-elevated); border: 1px solid var(--border-color); color: var(--text-primary); cursor: pointer; flex-shrink: 0; }
.icon-btn:hover { opacity: .85; }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn .icon-moon { display: none; }
[data-theme="dark"] .icon-btn .icon-sun { display: none; }
[data-theme="dark"] .icon-btn .icon-moon { display: block; }

/* ===== Role badge ===== */
.role-badge { font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: .2rem .6rem; border-radius: 20px; }
.role-badge.agent { background: var(--role-agent-bg); color: var(--role-agent-text); }
.role-badge.client { background: var(--role-client-bg); color: var(--role-client-text); }
.role-badge.vendor { background: var(--role-vendor-bg); color: var(--role-vendor-text); }

/* ===== Impersonation banner ===== */
.impersonation-banner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; background: var(--warning); color: #1a1200; padding: .5rem 1.5rem; font-size: .82rem; font-weight: 600; position: sticky; top: 0; z-index: 60; }
.impersonation-banner .btn-secondary { background: rgba(0,0,0,.15); color: #1a1200; border: none; }

/* ===== Notification bell ===== */
.notif-bell-wrap { position: relative; }
.notif-badge { position: absolute; top: -4px; right: -4px; background: var(--danger); color: #fff; font-size: .62rem; font-weight: 700; min-width: 16px; height: 16px; border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 0 3px; }
.notif-dropdown { position: absolute; top: calc(100% + 8px); right: 0; width: 320px; max-height: 420px; overflow-y: auto; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 200; }
.notif-dropdown[hidden] { display: none; }
.notif-dropdown-header { display: flex; align-items: center; justify-content: space-between; padding: .75rem 1rem; border-bottom: 1px solid var(--border-color); font-size: .82rem; font-weight: 700; color: var(--text-primary); }
.notif-mark-all { background: none; border: none; color: var(--accent-primary); font-size: .75rem; font-weight: 600; cursor: pointer; padding: 0; }
.notif-empty { padding: 2rem 1rem; text-align: center; font-size: .82rem; color: var(--text-muted); }
.notif-list { display: flex; flex-direction: column; }
.notif-item { display: block; padding: .75rem 1rem; border-bottom: 1px solid var(--border-color); color: var(--text-primary); }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg-elevated); opacity: 1; }
.notif-item.unread { background: var(--role-agent-bg); }
.notif-item-title { font-size: .82rem; font-weight: 600; margin-bottom: .15rem; }
.notif-item-body { font-size: .78rem; color: var(--text-secondary); margin-bottom: .25rem; }
.notif-item-time { font-size: .7rem; color: var(--text-muted); }

/* ===== Notification preference toggles ===== */
.pref-toggle { display: flex; align-items: center; gap: .65rem; padding: .65rem 0; border-bottom: 1px solid var(--border-color); font-size: .88rem; color: var(--text-primary); cursor: pointer; }
.pref-toggle:last-of-type { border-bottom: none; }
.pref-toggle input { width: auto; accent-color: var(--accent-primary); }

/* ===== Satisfaction rating stars ===== */
.star-form { display: inline-flex; gap: .1rem; }
.star-form button { background: none; border: none; cursor: pointer; padding: 0; font-size: 1.1rem; color: var(--border-color); line-height: 1; }
.star-form button:hover { color: var(--warning); }
.star-display span { font-size: 1.1rem; color: var(--border-color); }
.star-display span.filled { color: var(--warning); }

/* ===== Client properties ===== */
.property-list { display: flex; flex-direction: column; gap: .6rem; }
.property-item { background: var(--bg-elevated); border: 1px solid var(--border-color); border-radius: 8px; padding: .65rem .85rem; }
.property-item-label { font-size: .82rem; font-weight: 700; color: var(--text-primary); margin-bottom: .2rem; }
.property-item-address { font-size: .82rem; color: var(--text-secondary); }
.property-images { display: flex; gap: .5rem; margin-top: .5rem; flex-wrap: wrap; }
.property-image { position: relative; width: 280px; height: 210px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border-color); flex-shrink: 0; padding: 0; margin: 0; background: none; font: inherit; cursor: zoom-in; transition: opacity .15s, border-color .15s; }
.property-image:hover { opacity: .88; border-color: var(--accent-primary); }
.property-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.property-image-label { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,.55); color: #fff; font-size: .65rem; font-weight: 600; text-align: center; padding: .15rem 0; letter-spacing: .03em; text-transform: uppercase; }
.property-coordinates { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-top: .4rem; font-size: .74rem; }
.property-coordinates-value { color: var(--text-muted); font-family: 'Consolas', monospace; }
.property-coordinates a { color: var(--accent-primary); font-weight: 600; }
.property-coordinates a:hover { text-decoration: underline; }
@media(max-width:768px) {
  .property-image { width: 240px; height: 180px; }
}

.pc-lightbox-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 500;
  align-items: center; justify-content: center; padding: 2rem; overflow: hidden;
}
.pc-lightbox-overlay.open { display: flex; flex-direction: column; }
.pc-lightbox-img-wrap { max-width: min(90vw, 1100px); max-height: 80vh; overflow: auto; border-radius: 8px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.pc-lightbox-img { display: block; max-width: min(90vw, 1100px); max-height: 80vh; object-fit: contain; cursor: zoom-in; transition: width .15s ease; }
.pc-lightbox-img.zoomed { max-width: none; max-height: none; cursor: zoom-out; }
.pc-lightbox-label { color: #fff; font-size: .85rem; font-weight: 600; text-align: center; margin-top: .75rem; letter-spacing: .03em; text-transform: uppercase; opacity: .85; }
.pc-lightbox-hint { color: rgba(255,255,255,.6); font-size: .72rem; text-align: center; margin-top: .3rem; }
.pc-lightbox-close {
  position: absolute; top: 1.25rem; right: 1.5rem; background: rgba(255,255,255,.12); border: none; color: #fff;
  width: 40px; height: 40px; border-radius: 50%; font-size: 1.6rem; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center; z-index: 1;
}
.pc-lightbox-close:hover { background: rgba(255,255,255,.22); }
.pc-lightbox-zoom-controls { position: absolute; top: 1.25rem; left: 1.5rem; display: flex; gap: .5rem; z-index: 1; }
.pc-lightbox-zoom-btn {
  background: rgba(255,255,255,.12); border: none; color: #fff; width: 40px; height: 40px; border-radius: 50%;
  font-size: 1.2rem; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.pc-lightbox-zoom-btn:hover { background: rgba(255,255,255,.22); }

/* ===== Vendor capacity toggle ===== */
.capacity-card { margin-bottom: 1.5rem; }
.capacity-card-body { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.capacity-label { font-size: .75rem; color: var(--text-muted); margin-bottom: .3rem; }
.capacity-status { display: flex; align-items: center; gap: .5rem; font-size: .95rem; font-weight: 700; }
.capacity-status.on { color: var(--success); }
.capacity-status.off { color: var(--text-muted); }
.capacity-dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; }

/* ===== Vendor tier badge ===== */
.tier-badge { display: inline-flex; align-items: center; gap: .25rem; font-size: .68rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: .2rem .55rem; border-radius: 20px; vertical-align: middle; }
.tier-badge.preferred { background: var(--role-agent-bg); color: var(--accent-primary); }
.tier-badge.standard { background: var(--role-client-bg); color: var(--role-client-text); }
.tier-badge.backup { background: var(--badge-cancelled-bg); color: var(--badge-cancelled-text); }

.suggestion-card { display: flex; align-items: center; gap: .75rem; width: 100%; text-align: left; background: var(--bg-elevated); border: 1px solid var(--border-color); border-radius: var(--radius); padding: .65rem .85rem; cursor: pointer; font-family: inherit; transition: border-color .15s, background .15s; }
.suggestion-card:hover { border-color: var(--accent-primary); }
.suggestion-card.selected { border-color: var(--accent-primary); background: var(--role-agent-bg); }
.suggestion-rank { font-weight: 800; font-size: .82rem; color: var(--accent-primary); flex-shrink: 0; width: 1.6rem; }
.suggestion-name { font-weight: 600; font-size: .85rem; color: var(--text-primary); flex-shrink: 0; }
.suggestion-stats { font-size: .78rem; color: var(--text-secondary); margin-left: auto; white-space: nowrap; }
@media(max-width:768px) {
  .suggestion-card { flex-wrap: wrap; }
  .suggestion-stats { margin-left: 0; width: 100%; }
}

/* ===== Cards ===== */
.card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius); }
.card-body { padding: 1.5rem; }

/* ===== Stats grid ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(160px,1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius); padding: 1.25rem; }
.stat-label { font-size: .75rem; color: var(--text-secondary); margin-bottom: .4rem; font-weight: 500; }
.stat-value { font-size: 2rem; font-weight: 800; line-height: 1; color: var(--text-primary); }
.stat-value.accent { color: var(--accent-primary); }
.stat-value.warning { color: var(--warning); }
.stat-value.danger { color: var(--danger); }
.stat-value.success { color: var(--success); }
.stat-sub { font-size: .75rem; color: var(--text-muted); margin-top: .3rem; }
.success-text { color: var(--success); font-weight: 700; }
.warning-text { color: var(--warning); font-weight: 700; }
.danger-text { color: var(--danger); font-weight: 700; }

/* ===== Alert banner ===== */
.alert-banner { display: flex; gap: .85rem; align-items: flex-start; background: var(--badge-emergency-bg); border: 1px solid var(--danger); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1.5rem; }
.alert-banner-icon { font-size: 1.2rem; line-height: 1; color: var(--danger); }
.alert-banner-title { font-size: .88rem; font-weight: 700; color: var(--text-primary); margin-bottom: .4rem; }
.alert-banner-list { display: flex; flex-direction: column; gap: .25rem; }
.alert-banner-list a { font-size: .8rem; color: var(--text-secondary); }
.alert-banner-list a:hover { color: var(--danger); }

/* ===== Kanban board ===== */
.kanban-board { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: .5rem; align-items: flex-start; }
.kanban-column { flex: 0 0 260px; background: var(--bg-elevated); border: 1px solid var(--border-color); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 220px); }
.kanban-column-header { padding: .85rem 1rem; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; justify-content: space-between; }
.kanban-column-title { font-size: .82rem; font-weight: 700; color: var(--text-primary); }
.kanban-column-count { font-size: .72rem; font-weight: 700; color: var(--text-muted); background: var(--bg-card); border-radius: 20px; padding: .1rem .5rem; }
.kanban-column-body { padding: .75rem; display: flex; flex-direction: column; gap: .6rem; overflow-y: auto; flex: 1; min-height: 80px; }
.kanban-column-body.drag-over { background: var(--role-agent-bg); border-radius: 8px; }
.kanban-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 8px; padding: .75rem .85rem; cursor: grab; transition: box-shadow .15s, transform .1s; }
.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging { opacity: .4; }
.kanban-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.kanban-card-title { font-size: .85rem; font-weight: 600; color: var(--text-primary); margin-bottom: .35rem; display: block; }
.kanban-card-meta { font-size: .72rem; color: var(--text-muted); display: flex; justify-content: space-between; gap: .5rem; }
.kanban-card-urgency { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: .35rem; }
.view-toggle { display: inline-flex; border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; }
.view-toggle a { padding: .45rem .9rem; font-size: .82rem; font-weight: 600; color: var(--text-secondary); background: var(--bg-elevated); }
.view-toggle a.active { background: var(--accent-primary); color: #fff; }
.view-toggle a:hover { opacity: .9; }

/* ===== Calendar ===== */
.calendar { border: 1px solid var(--border-color); border-radius: var(--radius); overflow: hidden; background: var(--bg-card); }
.calendar-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--bg-elevated); border-bottom: 1px solid var(--border-color); }
.calendar-weekdays div { padding: .6rem; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); text-align: center; }
.calendar-week { display: grid; grid-template-columns: repeat(7, 1fr); }
.calendar-cell { min-height: 100px; border-right: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color); padding: .4rem; display: flex; flex-direction: column; gap: .25rem; }
.calendar-cell:nth-child(7n) { border-right: none; }
.calendar-cell.empty { background: var(--bg-elevated); }
.calendar-cell.today { background: var(--role-agent-bg); }
.calendar-date { font-size: .78rem; font-weight: 700; color: var(--text-secondary); margin-bottom: .2rem; }
.calendar-cell.today .calendar-date { color: var(--accent-primary); }
.calendar-event { display: block; font-size: .7rem; font-weight: 600; padding: .2rem .4rem; border-radius: 5px; background: var(--role-agent-bg); color: var(--accent-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.calendar-event:hover { opacity: .85; }
.calendar-event.proposed { border: 1px dashed var(--accent-primary); background: transparent; }
.calendar-event.declined { border: 1px dashed var(--danger); background: transparent; color: var(--danger); text-decoration: line-through; }
@media(max-width:768px) {
  .calendar-cell { min-height: 60px; font-size: .8rem; }
  .calendar-event { font-size: .62rem; }
}

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border-color); }
table { width: 100%; border-collapse: collapse; }
th { background: var(--bg-elevated); text-align: left; padding: .75rem 1rem; font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); border-bottom: 1px solid var(--border-color); }
td { padding: .75rem 1rem; font-size: .88rem; color: var(--text-secondary); border-bottom: 1px solid var(--border-color); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-elevated); }
td a { color: var(--text-primary); font-weight: 500; }
td a:hover { color: var(--accent-primary); }

/* ===== Status badges (service request lifecycle) ===== */
.badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: .25rem .65rem; border-radius: 20px; white-space: nowrap; }
.doc-status { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; font-weight: 600; }
.doc-status::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.doc-status.none { color: var(--text-muted); }
.doc-status.green { color: var(--success); }
.doc-status.yellow { color: var(--warning); }
.doc-status.red { color: var(--danger); font-weight: 700; }
.badge.new { background: var(--badge-new-bg); color: var(--badge-new-text); }
.badge.needs_review { background: var(--badge-needs_review-bg); color: var(--badge-needs_review-text); }
.badge.more_info_requested { background: var(--badge-more_info_requested-bg); color: var(--badge-more_info_requested-text); }
.badge.approved { background: var(--badge-approved-bg); color: var(--badge-approved-text); }
.badge.collecting_quotes { background: var(--badge-quote_uploaded-bg); color: var(--badge-quote_uploaded-text); }
.badge.assigned { background: var(--badge-assigned-bg); color: var(--badge-assigned-text); }
.badge.vendor_accepted { background: var(--badge-vendor_accepted-bg); color: var(--badge-vendor_accepted-text); }
.badge.vendor_declined { background: var(--badge-vendor_declined-bg); color: var(--badge-vendor_declined-text); }
.badge.scheduled { background: var(--badge-scheduled-bg); color: var(--badge-scheduled-text); }
.badge.in_progress { background: var(--badge-in_progress-bg); color: var(--badge-in_progress-text); }
.badge.quote_uploaded { background: var(--badge-quote_uploaded-bg); color: var(--badge-quote_uploaded-text); }
.badge.completed { background: var(--badge-completed-bg); color: var(--badge-completed-text); }
.badge.cancelled { background: var(--badge-cancelled-bg); color: var(--badge-cancelled-text); }
.badge.pending { background: var(--badge-pending-bg); color: var(--badge-pending-text); }
.badge.active { background: var(--badge-active-bg); color: var(--badge-active-text); }
.badge.inactive { background: var(--badge-inactive-bg); color: var(--badge-inactive-text); }
.badge.low { background: var(--badge-low-bg); color: var(--badge-low-text); }
.badge.medium { background: var(--badge-medium-bg); color: var(--badge-medium-text); }
.badge.high { background: var(--badge-high-bg); color: var(--badge-high-text); }
.badge.emergency { background: var(--badge-emergency-bg); color: var(--badge-emergency-text); }

.badge-select { font-size: .72rem; font-weight: 700; letter-spacing: .04em; padding: .25rem 1.6rem .25rem .65rem; border-radius: 20px; border: none; cursor: pointer; appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M3 4.5l3 3 3-3z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .5rem center; background-size: 10px; }
.badge-select.new { background-color: var(--badge-new-bg); color: var(--badge-new-text); }
.badge-select.approved { background-color: var(--badge-approved-bg); color: var(--badge-approved-text); }
.badge-select.assigned { background-color: var(--badge-assigned-bg); color: var(--badge-assigned-text); }
.badge-select.scheduled { background-color: var(--badge-scheduled-bg); color: var(--badge-scheduled-text); }
.badge-select.in_progress { background-color: var(--badge-in_progress-bg); color: var(--badge-in_progress-text); }
.badge-select.quote_uploaded { background-color: var(--badge-quote_uploaded-bg); color: var(--badge-quote_uploaded-text); }
.badge-select.completed { background-color: var(--badge-completed-bg); color: var(--badge-completed-text); }
.badge-select.cancelled { background-color: var(--badge-cancelled-bg); color: var(--badge-cancelled-text); }
.badge-select.pending { background-color: var(--badge-pending-bg); color: var(--badge-pending-text); }
.badge-select.active { background-color: var(--badge-active-bg); color: var(--badge-active-text); }
.badge-select.inactive { background-color: var(--badge-inactive-bg); color: var(--badge-inactive-text); }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; gap: .45rem; padding: .55rem 1.1rem; border-radius: 8px; font-size: .88rem; font-weight: 600; cursor: pointer; border: none; transition: opacity .15s, transform .1s; white-space: nowrap; text-decoration: none; }
.btn:hover { opacity: .88; transform: translateY(-1px); }
.btn-primary { background: var(--accent-primary); color: #fff; }
.btn-secondary { background: var(--bg-elevated); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-danger { background: var(--badge-vendor_declined-bg); color: var(--badge-vendor_declined-text); border: 1px solid var(--badge-vendor_declined-text); }
.btn-success { background: var(--badge-completed-bg); color: var(--badge-completed-text); border: 1px solid var(--badge-completed-text); }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }

/* ===== Forms ===== */
.form-group { margin-bottom: 1.25rem; }
label { display: block; font-size: .83rem; font-weight: 600; color: var(--text-secondary); margin-bottom: .4rem; }
input, select, textarea { width: 100%; background: var(--bg-elevated); border: 1px solid var(--border-color); border-radius: 8px; color: var(--text-primary); font-size: .9rem; padding: .65rem .85rem; font-family: inherit; transition: border-color .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-primary); }
textarea { resize: vertical; min-height: 90px; }
select option { background: var(--bg-secondary); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-error { background: var(--badge-vendor_declined-bg); border: 1px solid var(--badge-vendor_declined-text); color: var(--badge-vendor_declined-text); padding: .75rem 1rem; border-radius: 8px; font-size: .88rem; margin-bottom: 1.25rem; }
.form-success { background: var(--badge-completed-bg); border: 1px solid var(--badge-completed-text); color: var(--badge-completed-text); padding: .75rem 1rem; border-radius: 8px; font-size: .88rem; margin-bottom: 1.25rem; }

.toggle-switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-switch .toggle-track { position: absolute; inset: 0; background: var(--bg-elevated); border: 1px solid var(--border-color); border-radius: 24px; cursor: pointer; transition: background .15s; }
.toggle-switch .toggle-track::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 2px; background: var(--text-muted); border-radius: 50%; transition: transform .15s, background .15s; }
.toggle-switch input:checked + .toggle-track { background: var(--role-agent-bg); border-color: var(--accent-primary); }
.toggle-switch input:checked + .toggle-track::before { transform: translateX(18px); background: var(--accent-primary); }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 300; align-items: center; justify-content: center; padding: 1rem; }
.modal { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; width: 100%; max-width: 380px; }

/* ===== Page header ===== */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.75rem; flex-wrap: wrap; gap: 1rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 800; }
.page-sub { font-size: .85rem; color: var(--text-muted); margin-top: .2rem; }

/* ===== Bulk action bar ===== */
.bulk-bar { display: flex; align-items: center; gap: .75rem; background: var(--role-agent-bg); border: 1px solid var(--accent-primary); border-radius: var(--radius); padding: .65rem 1rem; margin-bottom: 1rem; font-size: .85rem; font-weight: 600; color: var(--text-primary); }
.bulk-bar[hidden] { display: none; }
.bulk-bar select { width: auto; min-width: 160px; }

/* ===== Quick filters (saved views) ===== */
.quick-filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.quick-filter { font-size: .8rem; font-weight: 600; padding: .4rem .85rem; border-radius: 20px; background: var(--bg-elevated); border: 1px solid var(--border-color); color: var(--text-secondary); }
.quick-filter:hover { opacity: .85; }
.quick-filter.active { background: var(--accent-primary); border-color: var(--accent-primary); color: #fff; }

/* ===== Filter bar ===== */
.filter-bar { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: 1.5rem; align-items: center; }
.filter-bar input, .filter-bar select { width: auto; min-width: 140px; }

/* ===== Charts ===== */
.charts-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1.5rem; margin-bottom: 1.5rem; }

/* ===== Detail layout ===== */
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; }
.detail-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.detail-field label { font-size: .75rem; color: var(--text-muted); margin-bottom: .2rem; }
.detail-field .val { font-size: .95rem; color: var(--text-primary); font-weight: 500; }

/* ===== Timeline / activity feed ===== */
.activity-feed { display: flex; flex-direction: column; gap: .75rem; }
.activity-item { display: flex; gap: .75rem; align-items: flex-start; font-size: .85rem; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-primary); margin-top: .35rem; flex-shrink: 0; }
.photo-gallery { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .4rem; }
.photo-gallery img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border-color); }
.activity-time { font-size: .75rem; color: var(--text-muted); }

/* ===== Internal notes ===== */
.internal-notes-card { border-color: var(--warning); }
.internal-notes-list { display: flex; flex-direction: column; gap: .6rem; }
.internal-note { background: var(--badge-pending-bg); border: 1px solid var(--warning); border-radius: 8px; padding: .65rem .85rem; }
.internal-note-meta { font-size: .7rem; color: var(--text-muted); margin-bottom: .3rem; }
.internal-note-body { font-size: .85rem; color: var(--text-primary); white-space: pre-wrap; }

/* ===== Thread composer & mentions ===== */
.thread-composer { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border-color); }
.thread-composer textarea { min-height: 70px; }
.thread-composer-actions { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-top: .6rem; }
.thread-composer-actions select { width: auto; min-width: 160px; }
.thread-mention-tag { display: inline-block; font-size: .72rem; font-weight: 700; color: var(--accent-primary); background: var(--role-agent-bg); padding: .1rem .5rem; border-radius: 10px; margin-bottom: .35rem; }

/* ===== Request thread ===== */
.thread { display: flex; flex-direction: column; gap: 1rem; max-height: 420px; overflow-y: auto; padding-right: .4rem; }
.thread-msg { background: var(--bg-elevated); border: 1px solid var(--border-color); border-radius: var(--radius); padding: .9rem 1.1rem; max-width: 80%; }
.thread-msg.me { align-self: flex-end; background: var(--role-agent-bg); border-color: var(--accent-primary); }
.thread-msg-meta { font-size: .72rem; color: var(--text-muted); margin-bottom: .35rem; }
.thread-msg-body { font-size: .88rem; color: var(--text-primary); }

/* ===== Auth / public pages ===== */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg-primary); padding: 2rem; position: relative; }
.auth-wrap .icon-btn { position: absolute; top: 1.5rem; right: 1.5rem; }
.auth-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 16px; padding: 2.5rem; width: 100%; max-width: 460px; box-shadow: var(--shadow); }
.auth-logo { text-align: center; margin-bottom: 2rem; }
.auth-logo-icon { width: 52px; height: 52px; background: linear-gradient(135deg,var(--accent-primary),var(--accent-secondary)); border-radius: 13px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; margin: 0 auto 1rem; color: #fff; }
.auth-title { font-size: 1.5rem; font-weight: 800; text-align: center; margin-bottom: .4rem; }
.auth-sub { text-align: center; font-size: .88rem; color: var(--text-secondary); margin-bottom: 2rem; }
.auth-links { text-align: center; margin-top: 1.5rem; font-size: .85rem; color: var(--text-secondary); }

/* ===== Landing / join hero ===== */
.hero { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 3rem 1.5rem; background: radial-gradient(circle at 50% 0%, var(--role-agent-bg), transparent 60%); position: relative; }
.hero h1 { font-size: 2.4rem; font-weight: 800; max-width: 720px; margin-bottom: 1rem; }
.hero p { font-size: 1.05rem; color: var(--text-secondary); max-width: 560px; margin-bottom: 2rem; }
.hero-actions { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; }
.hero .icon-btn { position: absolute; top: 1.5rem; right: 1.5rem; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; max-width: 640px; width: 100%; margin-top: 1.5rem; }
.choice-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius); padding: 1.75rem; text-align: left; transition: border-color .15s, transform .15s; }
.choice-card:hover { border-color: var(--accent-primary); transform: translateY(-2px); }
.choice-card h3 { font-size: 1.1rem; margin-bottom: .5rem; color: var(--text-primary); }
.choice-card p { font-size: .85rem; color: var(--text-secondary); margin-bottom: 1rem; }

/* ===== Portal nav (client/vendor/admin) ===== */
.portal-nav { height: var(--header-h); background: var(--bg-secondary); border-bottom: 1px solid var(--border-color); display: flex; align-items: center; padding: 0 1.5rem; gap: 1rem; position: sticky; top: 0; z-index: 50; }
.portal-nav .brand { font-weight: 700; flex: 1; }
.portal-content { padding: 2rem 1.75rem; flex: 1; max-width: 960px; margin: 0 auto; width: 100%; }

/* ===== Empty state ===== */
.empty-state { text-align: center; padding: 3rem 1.5rem; color: var(--text-muted); }
.empty-state h3 { color: var(--text-secondary); margin-bottom: .5rem; }

/* ===== Overlay sidebar for mobile ===== */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 99; }
.app-footer { text-align: center; padding: 1.25rem 1rem; font-size: .78rem; color: var(--text-muted); border-top: 1px solid var(--border-color); }
.app-footer a { color: var(--text-secondary); font-weight: 600; }
.app-footer a:hover { color: var(--accent-primary); }
body:has(.sidebar) .app-footer { margin-left: var(--sidebar-w); }
@media(max-width:768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .main-wrap { margin-left: 0; }
  body:has(.sidebar) .app-footer { margin-left: 0; }
  .hamburger { display: block; }
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .charts-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .choice-grid { grid-template-columns: 1fr; }
  .page-content { padding: 1.25rem 1rem; }
  .hero h1 { font-size: 1.8rem; }
}

/* ===== Global support chatbot widget ===== */
#pc-chat-root { position: fixed; right: 22px; bottom: 22px; z-index: 9999; font-family: 'Inter', Arial, sans-serif; }
#pc-chat-toggle {
  width: 60px; height: 60px; border-radius: 50%; border: none; cursor: pointer;
  background: #0d3f8f; box-shadow: 0 6px 20px rgba(13,63,143,.45), 0 2px 6px rgba(0,0,0,.25);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s ease, box-shadow .15s ease;
}
#pc-chat-toggle:hover { transform: scale(1.06); box-shadow: 0 8px 26px rgba(13,63,143,.55), 0 2px 8px rgba(0,0,0,.3); }
#pc-chat-toggle.pc-chat-toggle-open { transform: scale(.96); }

#pc-chat-panel {
  position: absolute; right: 0; bottom: 74px; width: 360px; max-width: calc(100vw - 32px);
  height: 500px; max-height: calc(100vh - 120px);
  background: #12131a; border: 1px solid rgba(255,255,255,.08); border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0,0,0,.4); display: flex; flex-direction: column; overflow: hidden;
}
/* An ID selector with `display` beats the browser's built-in [hidden] rule
   (also an attribute selector, but lower specificity), so [hidden] alone
   would never actually hide this panel — this rule restores that behavior. */
#pc-chat-panel[hidden] { display: none; }
#pc-chat-header {
  background: linear-gradient(135deg, #1565c0, #0d3f8f); color: #fff; padding: .9rem 1rem;
  display: flex; align-items: flex-start; justify-content: space-between; flex-shrink: 0;
}
#pc-chat-title { font-weight: 700; font-size: .95rem; }
#pc-chat-subtitle { font-size: .74rem; opacity: .95; margin-top: .15rem; line-height: 1.4; }
#pc-chat-report { font-weight: 800; color: #ffd54a; text-decoration: underline; text-underline-offset: 2px; }
#pc-chat-close { background: none; border: none; color: #fff; font-size: 1.4rem; line-height: 1; cursor: pointer; padding: 0 .2rem; opacity: .85; }
#pc-chat-close:hover { opacity: 1; }

#pc-chat-messages { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .6rem; background: #0b0c10; }
.pc-chat-msg { display: flex; }
.pc-chat-msg-user { justify-content: flex-end; }
.pc-chat-msg-bot { justify-content: flex-start; }
.pc-chat-bubble { max-width: 82%; padding: .55rem .75rem; border-radius: 12px; font-size: .85rem; line-height: 1.4; white-space: pre-wrap; word-break: break-word; }
.pc-chat-msg-user .pc-chat-bubble { background: #1565c0; color: #fff; border-bottom-right-radius: 3px; }
.pc-chat-msg-bot .pc-chat-bubble { background: #1b1d27; color: #e8e9ee; border: 1px solid rgba(255,255,255,.07); border-bottom-left-radius: 3px; }

.pc-chat-typing .pc-chat-bubble { display: flex; gap: 4px; padding: .7rem .8rem; }
.pc-chat-typing .pc-chat-bubble span { width: 6px; height: 6px; border-radius: 50%; background: #7d8190; animation: pcChatBounce 1.2s infinite ease-in-out; }
.pc-chat-typing .pc-chat-bubble span:nth-child(2) { animation-delay: .15s; }
.pc-chat-typing .pc-chat-bubble span:nth-child(3) { animation-delay: .3s; }
@keyframes pcChatBounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

#pc-chat-privacy-notice { flex-shrink: 0; padding: .5rem .8rem; font-size: .68rem; line-height: 1.35; color: #9aa0ad; background: #0f1015; border-top: 1px solid rgba(255,255,255,.06); }
#pc-chat-form { display: flex; gap: .5rem; padding: .7rem; border-top: 1px solid rgba(255,255,255,.08); background: #12131a; flex-shrink: 0; }
#pc-chat-input { flex: 1; background: #1b1d27; border: 1px solid rgba(255,255,255,.1); border-radius: 8px; color: #fff; padding: .55rem .7rem; font-size: .85rem; font-family: inherit; }
#pc-chat-input:focus { outline: none; border-color: #1565c0; }
#pc-chat-input::placeholder { color: #6b6f7c; }
#pc-chat-send { width: 38px; height: 38px; flex-shrink: 0; border-radius: 8px; border: none; background: #1565c0; color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }
#pc-chat-send:hover { background: #1c73d4; }

@media (max-width: 480px) {
  #pc-chat-root { right: 14px; bottom: 14px; }
  #pc-chat-panel { width: calc(100vw - 28px); }
}
