/* ===== REMI CRM — Navy / Teal / Slate Palette ===== */
:root {
  --navy: #0D2B4B;
  --navy-light: #1A3D5C;
  --teal: #1D9E75;
  --teal-light: #25C590;
  --slate: #334155;
  --slate-light: #64748B;
  --bg: #F1F5F9;
  --card: #FFFFFF;
  --border: #E2E8F0;
  --text: #1E293B;
  --text-muted: #94A3B8;
  --amber: #F59E0B;
  --green: #10B981;
  --red: #EF4444;
  --grey: #6B7280;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--teal); text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 0.875rem; }

/* ===== LOGIN ===== */
.login-wrapper {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
}
.login-box {
  background: var(--card); border-radius: 12px; padding: 2.5rem; width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-box h1 { font-size: 1.5rem; color: var(--navy); margin-bottom: 0.25rem; }
.login-box .subtitle { color: var(--text-muted); margin-bottom: 1.5rem; font-size: 0.875rem; }
.login-box label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--slate); margin-bottom: 0.25rem; }
.login-box input {
  width: 100%; padding: 0.6rem 0.75rem; border: 1px solid var(--border); border-radius: 6px;
  margin-bottom: 1rem; font-size: 0.9rem;
}
.login-box input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(29,158,117,0.15); }
.btn-primary {
  width: 100%; padding: 0.7rem; background: var(--teal); color: #fff; border: none;
  border-radius: 6px; font-weight: 600; font-size: 0.9rem; transition: background 0.2s;
}
.btn-primary:hover { background: var(--teal-light); }
.login-error { color: var(--red); font-size: 0.8rem; margin-bottom: 0.75rem; display: none; }

/* ===== LAYOUT ===== */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; background: var(--navy); color: #fff; display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
}
.sidebar-brand { padding: 1.25rem 1.25rem 0.75rem; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-brand h2 { font-size: 1.1rem; font-weight: 700; letter-spacing: 0.5px; }
.sidebar-brand span { font-size: 0.7rem; color: rgba(255,255,255,0.5); text-transform: uppercase; letter-spacing: 1px; }
.sidebar-nav { flex: 1; padding: 0.75rem 0; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem 1.25rem; color: rgba(255,255,255,0.7);
  font-size: 0.85rem; cursor: pointer; transition: all 0.15s; border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: rgba(29,158,117,0.2); color: var(--teal-light); border-left-color: var(--teal); }
.nav-item .icon { width: 18px; text-align: center; font-size: 1rem; }
.nav-section { padding: 0.5rem 1.25rem 0.25rem; font-size: 0.65rem; text-transform: uppercase; letter-spacing: 1px; color: rgba(255,255,255,0.35); margin-top: 0.5rem; }
.sidebar-footer { padding: 1rem 1.25rem; border-top: 1px solid rgba(255,255,255,0.1); font-size: 0.8rem; }
.sidebar-footer .user-name { font-weight: 600; }
.sidebar-footer .user-role { font-size: 0.7rem; color: rgba(255,255,255,0.5); text-transform: capitalize; }
.logout-btn {
  margin-top: 0.5rem; background: rgba(255,255,255,0.1); border: none; color: rgba(255,255,255,0.7);
  padding: 0.4rem 0.75rem; border-radius: 4px; font-size: 0.75rem; cursor: pointer; width: 100%;
}
.logout-btn:hover { background: rgba(255,255,255,0.2); color: #fff; }

/* ===== SIDEBAR TOGGLE / COLLAPSE ===== */
.sidebar { transition: width 0.2s ease; }
.sidebar-toggle {
  position: absolute; top: 0.7rem; right: 0.6rem; z-index: 10;
  width: 28px; height: 28px; border: none; border-radius: 4px;
  background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.8);
  font-size: 1rem; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.18); color: #fff; }

/* Collapsed state — only show icons */
.sidebar.collapsed { width: 56px; }
.sidebar.collapsed .sidebar-brand h2 { font-size: 0.9rem; text-align: center; }
.sidebar.collapsed .sidebar-brand span,
.sidebar.collapsed .nav-item span:not(.icon),
.sidebar.collapsed .nav-section,
.sidebar.collapsed .sidebar-footer .user-name,
.sidebar.collapsed .sidebar-footer .user-role,
.sidebar.collapsed .logout-btn { display: none; }
.sidebar.collapsed .nav-item {
  padding: 0.6rem 0; justify-content: center; font-size: 0; gap: 0;
}
.sidebar.collapsed .nav-item .icon { font-size: 1.2rem; width: auto; }
.sidebar.collapsed .sidebar-footer { padding: 0.5rem; text-align: center; }
.sidebar.collapsed .sidebar-brand { padding: 1.25rem 0.25rem 0.5rem; text-align: center; }
.sidebar.collapsed .sidebar-toggle { right: 50%; transform: translateX(50%); top: 0.4rem; }

/* When sidebar collapsed, main content shifts to give more room */
.app-layout.sidebar-collapsed .main-content { margin-left: 56px; }

.main-content { margin-left: 240px; flex: 1; padding: 1.5rem 2rem; min-height: 100vh; transition: margin-left 0.2s ease; }

/* ===== HEADER ===== */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.5rem; color: var(--navy); }
.header-actions { display: flex; gap: 0.5rem; }
.btn {
  padding: 0.5rem 1rem; border-radius: 6px; font-size: 0.8rem; font-weight: 600;
  border: 1px solid var(--border); background: var(--card); color: var(--text); transition: all 0.15s;
}
.btn:hover { border-color: var(--slate-light); }
.btn-teal { background: var(--teal); color: #fff; border-color: var(--teal); }
.btn-teal:hover { background: var(--teal-light); border-color: var(--teal-light); }
.btn-navy { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-navy:hover { background: var(--navy-light); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.75rem; }

/* ===== STATS STRIP ===== */
.stats-strip { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--card); border-radius: 8px; padding: 1rem 1.25rem; border: 1px solid var(--border);
}
.stat-card .stat-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 0.25rem; }
.stat-card .stat-value { font-size: 1.5rem; font-weight: 700; }
.stat-card .stat-value.teal { color: var(--teal); }
.stat-card .stat-value.navy { color: var(--navy); }
.stat-card .stat-value.amber { color: var(--amber); }
.stat-card .stat-value.green { color: var(--green); }
.stat-card .stat-value.grey { color: var(--grey); }

/* ===== TABLE ===== */
.table-card { background: var(--card); border-radius: 8px; border: 1px solid var(--border); overflow: hidden; }
.table-toolbar {
  padding: 0.75rem 1rem; display: flex; align-items: center; gap: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.table-toolbar input[type="text"] {
  padding: 0.4rem 0.75rem; border: 1px solid var(--border); border-radius: 6px; font-size: 0.8rem; width: 240px;
}
.table-toolbar input:focus { outline: none; border-color: var(--teal); }
.view-toggle { display: flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; margin-left: auto; flex-shrink: 0; }
.view-toggle button {
  padding: 0.35rem 0.7rem; border: none; background: var(--card); font-size: 0.75rem; color: var(--slate-light);
  white-space: nowrap; flex-shrink: 0;
}
.view-toggle button.active { background: var(--navy); color: #fff; }

/* P&L Budget — editable cells */
td.pl-edit:hover { background: rgba(29,158,117,0.12) !important; outline: 1px dashed var(--teal); }

table { width: 100%; border-collapse: collapse; font-size: 0.825rem; }
thead { background: var(--bg); }
th { padding: 0.6rem 1rem; text-align: left; font-weight: 600; color: var(--slate); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; cursor: pointer; user-select: none; }
th:hover { color: var(--navy); }
td { padding: 0.6rem 1rem; border-top: 1px solid var(--border); white-space: nowrap; }
tr:hover td { background: rgba(29,158,117,0.04); }
tr.clickable { cursor: pointer; }

/* Status badges */
.badge {
  display: inline-block; padding: 0.2rem 0.6rem; border-radius: 12px; font-size: 0.7rem;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px;
}
.badge-on_resly { background: rgba(29,158,117,0.15); color: var(--teal); }
.badge-leased { background: rgba(37,99,235,0.12); color: #2563EB; }
.badge-sold_under_contract { background: rgba(245,158,11,0.15); color: #B45309; }
.badge-vacant { background: rgba(245,158,11,0.15); color: #D97706; }
.badge-staff_other { background: rgba(107,114,128,0.15); color: var(--grey); }

/* Tags */
.tag {
  display: inline-block; padding: 0.15rem 0.5rem; border-radius: 10px; font-size: 0.65rem;
  font-weight: 600; margin-right: 0.25rem; margin-bottom: 0.15rem;
}

/* ===== SIDE PANEL ===== */
.side-panel-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4);
  z-index: 200; display: none; opacity: 0; transition: opacity 0.2s;
}
.side-panel-overlay.open { display: block; opacity: 1; }
.side-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 520px; background: var(--card);
  z-index: 201; transform: translateX(100%); transition: transform 0.25s ease;
  overflow-y: auto; box-shadow: -4px 0 20px rgba(0,0,0,0.1);
}
.side-panel.open { transform: translateX(0); }
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); position: sticky; top: 0;
  background: var(--card); z-index: 1;
}
.panel-header h2 { font-size: 1.1rem; color: var(--navy); }
.panel-close { background: none; border: none; font-size: 1.25rem; color: var(--slate-light); cursor: pointer; }
.panel-body { padding: 1.25rem 1.5rem; }
.panel-section { margin-bottom: 1.5rem; }
.panel-section h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 0.75rem; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.detail-item label { font-size: 0.7rem; color: var(--text-muted); display: block; }
.detail-item span { font-size: 0.875rem; font-weight: 500; }

/* Status override form */
.status-form { display: flex; flex-direction: column; gap: 0.5rem; }
.status-form select, .status-form textarea {
  padding: 0.5rem; border: 1px solid var(--border); border-radius: 6px; font-size: 0.85rem;
}
.status-form textarea { resize: vertical; min-height: 60px; }

/* Activity log */
.activity-item { padding: 0.5rem 0; border-bottom: 1px solid var(--border); font-size: 0.8rem; }
.activity-item .activity-time { color: var(--text-muted); font-size: 0.7rem; }

/* ===== GRID / CARD VIEW ===== */
.apt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; padding: 1rem; }
.apt-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 1.25rem;
  cursor: pointer; transition: all 0.15s; min-height: 160px; display: flex; flex-direction: column;
}
.apt-card:hover { border-color: var(--teal); box-shadow: 0 2px 8px rgba(29,158,117,0.15); }
.apt-card .unit-num { font-size: 1.3rem; font-weight: 700; color: var(--navy); }
.apt-card .apt-type { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.apt-card .apt-meta { font-size: 0.85rem; color: var(--slate); margin-bottom: 0.15rem; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center; padding: 3rem; color: var(--text-muted);
}
.empty-state .icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.empty-state h3 { font-size: 1rem; color: var(--slate); margin-bottom: 0.25rem; }
.empty-state p { font-size: 0.85rem; }

/* ===== RESLY BANNER ===== */
.warning-banner {
  background: #FEF3C7; border: 1px solid #F59E0B; border-radius: 8px;
  padding: 0.75rem 1rem; margin-bottom: 1rem; font-size: 0.85rem; color: #92400E;
  display: flex; align-items: center; gap: 0.5rem;
}

/* ===== UTILITY ===== */
.hidden { display: none !important; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.font-mono { font-family: 'SF Mono', 'Fira Code', monospace; }
.mt-1 { margin-top: 0.5rem; }
.mb-1 { margin-bottom: 0.5rem; }

/* Filter tabs */
.filter-tabs { display: flex; gap: 0.25rem; flex-wrap: wrap; padding: 0.5rem 1rem; border-bottom: 1px solid var(--border); }
.filter-tab {
  padding: 0.3rem 0.7rem; border-radius: 16px; font-size: 0.7rem; font-weight: 600;
  border: 1px solid var(--border); background: var(--card); color: var(--slate); cursor: pointer;
}
.filter-tab.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.filter-tab:hover:not(.active) { border-color: var(--slate-light); }

/* ===== KANBAN BOARD ===== */
.kanban-board {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.75rem;
  padding: 1rem; overflow-x: auto; min-height: 400px;
}
.kanban-column {
  background: var(--bg); border-radius: 8px; padding: 0.5rem;
  min-width: 200px; display: flex; flex-direction: column;
}
.kanban-column-header {
  padding: 0.5rem 0.6rem; font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--slate); display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 0.5rem;
}
.kanban-column-header .count {
  background: var(--border); border-radius: 10px; padding: 0.1rem 0.5rem;
  font-size: 0.7rem; color: var(--slate-light);
}
.kanban-cards { flex: 1; display: flex; flex-direction: column; gap: 0.5rem; }
.kanban-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 6px;
  padding: 0.75rem; cursor: pointer; transition: all 0.15s;
}
.kanban-card:hover { border-color: var(--teal); box-shadow: 0 2px 6px rgba(29,158,117,0.12); }
.kanban-card.dragging { opacity: 0.4; cursor: grabbing; }
.kanban-card[draggable="true"] { cursor: grab; }
.kanban-column.drop-target { background: rgba(29,158,117,0.15); border: 2px dashed var(--teal); }

/* Resly booking match pulse */
@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 0 2px rgba(16,185,129,0.25); }
  50% { box-shadow: 0 0 0 4px rgba(16,185,129,0.5); }
}
.kanban-card.has-booking { animation: pulse-green 2s ease-in-out infinite; }
.kanban-card .lead-name { font-weight: 600; font-size: 0.85rem; color: var(--navy); }
.kanban-card .lead-type { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.15rem; }
.kanban-card .lead-value {
  font-size: 0.8rem; font-weight: 600; color: var(--teal); margin-top: 0.3rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
}
.kanban-card .lead-meta {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 0.4rem; font-size: 0.7rem; color: var(--text-muted);
}
.kanban-card .lead-likelihood {
  background: var(--bg); border-radius: 4px; padding: 0.1rem 0.4rem;
  font-weight: 600; font-size: 0.65rem;
}
.kanban-card .lead-apartments { font-size: 0.7rem; color: var(--slate-light); margin-top: 0.2rem; }

/* Stage move buttons in card */
.stage-arrows { display: flex; gap: 0.2rem; margin-top: 0.4rem; }
.stage-arrows button {
  background: var(--bg); border: 1px solid var(--border); border-radius: 4px;
  padding: 0.15rem 0.4rem; font-size: 0.65rem; cursor: pointer; color: var(--slate);
}
.stage-arrows button:hover { background: var(--teal); color: #fff; border-color: var(--teal); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(15, 23, 42, 0.55);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
.modal-box {
  background: var(--card); border-radius: 10px; padding: 1.5rem; width: 480px;
  max-height: 80vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  z-index: 1001;
}
/* Wider modal used by P&L upload, Revenue classification, Unclear lines */
.modal {
  background: #fff; border-radius: 10px;
  width: 96vw; max-width: 1400px; height: 92vh;
  display: flex; flex-direction: column;
  box-shadow: 0 30px 80px rgba(0,0,0,0.4);
  z-index: 1001;
  overflow: hidden;
}
.modal .modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.5rem; border-bottom: 1px solid var(--border);
  background: var(--navy); color: #fff;
}
.modal .modal-header h3 {
  margin: 0; font-size: 1.05rem; font-weight: 600; color: #fff;
}
.modal .modal-close {
  background: none; border: none; color: #fff; font-size: 1.6rem;
  line-height: 1; cursor: pointer; padding: 0 0.5rem;
  opacity: 0.8;
}
.modal .modal-close:hover { opacity: 1; }
.modal .modal-body {
  padding: 1rem 1.5rem; overflow-y: auto; flex: 1;
}
.modal-box h2 { font-size: 1.1rem; color: var(--navy); margin-bottom: 1rem; }
.modal-box label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--slate); margin-bottom: 0.2rem; margin-top: 0.6rem; }
.modal-box input, .modal-box select, .modal-box textarea {
  width: 100%; padding: 0.5rem; border: 1px solid var(--border); border-radius: 6px; font-size: 0.85rem;
}
.modal-box textarea { resize: vertical; min-height: 60px; }
.modal-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }

/* Slider */
input[type="range"] { width: 100%; accent-color: var(--teal); }

/* ===== KPI DASHBOARD ===== */
.kpi-section-title {
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--text-muted); font-weight: 700;
  margin: 1.5rem 0 0.75rem; padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--border);
}
.kpi-section-title:first-child { margin-top: 0; }

.kpi-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 0.5rem;
}
.kpi-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.kpi-grid.cols-5 { grid-template-columns: repeat(5, 1fr); }
.kpi-grid.cols-6 { grid-template-columns: repeat(6, 1fr); }

.kpi-card {
  background: var(--card); border-radius: 10px; padding: 1.1rem 1.25rem;
  border: 1px solid var(--border); position: relative; overflow: hidden;
  transition: all 0.2s;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(13,43,75,0.08); }
.kpi-card .kpi-label {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted); margin-bottom: 0.4rem; font-weight: 600;
}
.kpi-card .kpi-value {
  font-size: 1.6rem; font-weight: 700; color: var(--navy); line-height: 1.1;
  font-family: 'SF Mono', 'Fira Code', monospace;
}
.kpi-card .kpi-value.large { font-size: 2rem; }
.kpi-card .kpi-value.teal { color: var(--teal); }
.kpi-card .kpi-value.green { color: var(--green); }
.kpi-card .kpi-value.amber { color: var(--amber); }
.kpi-card .kpi-value.red { color: var(--red); }
.kpi-card .kpi-sub {
  font-size: 0.72rem; color: var(--text-muted); margin-top: 0.35rem;
  display: flex; align-items: center; gap: 0.3rem;
}
.kpi-card .kpi-sub.up { color: var(--green); }
.kpi-card .kpi-sub.down { color: var(--red); }
.kpi-card.feature {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  color: #fff; border: none;
}
.kpi-card.feature .kpi-label { color: rgba(255,255,255,0.6); }
.kpi-card.feature .kpi-value { color: #fff; }
.kpi-card.feature .kpi-sub { color: rgba(255,255,255,0.7); }
.kpi-card.feature.teal {
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-light) 100%);
}

/* Progress bar in KPI card */
.kpi-progress {
  height: 6px; background: var(--border); border-radius: 3px;
  margin-top: 0.6rem; overflow: hidden;
}
.kpi-progress-bar {
  height: 100%; background: var(--teal); border-radius: 3px; transition: width 0.4s;
}
.kpi-progress-bar.amber { background: var(--amber); }
.kpi-progress-bar.red { background: var(--red); }

/* Dashboard mini-tables */
.dashboard-card {
  background: var(--card); border-radius: 10px; padding: 1.25rem;
  border: 1px solid var(--border);
}
.dashboard-card h3 {
  font-size: 0.85rem; color: var(--navy); margin-bottom: 0.75rem;
  font-weight: 700;
}
.dashboard-card .stage-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 0; border-bottom: 1px solid var(--border); font-size: 0.85rem;
}
.dashboard-card .stage-row:last-child { border-bottom: none; }

/* ===== CHAT WIDGET ===== */
.chat-fab {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 250;
  width: 56px; height: 56px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-light) 100%);
  color: #fff; font-size: 1.5rem; cursor: pointer;
  box-shadow: 0 6px 20px rgba(29,158,117,0.4);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
}
.chat-fab:hover { transform: scale(1.05); box-shadow: 0 8px 24px rgba(29,158,117,0.55); }
.chat-fab.open { background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%); box-shadow: 0 6px 20px rgba(13,43,75,0.4); }

.chat-window {
  position: fixed; bottom: 5.5rem; right: 1.5rem; z-index: 249;
  width: 480px; max-width: calc(100vw - 3rem); height: 640px; max-height: calc(100vh - 8rem);
  min-width: 360px; min-height: 400px;
  background: var(--card); border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  display: none; flex-direction: column; overflow: hidden;
  border: 1px solid var(--border);
  resize: both;          /* drag from bottom-right corner to resize */
}
.chat-window.open { display: flex; }
.chat-window.expanded {
  width: min(900px, calc(100vw - 3rem));
  height: min(800px, calc(100vh - 8rem));
}
.chat-window.maximised {
  width: calc(100vw - 3rem);
  height: calc(100vh - 8rem);
  bottom: 1.5rem; right: 1.5rem;
}
.chat-window.fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
  border-radius: 0;
  resize: none;
}
/* Hide the FAB when chat is fullscreen so the close hint is the X button in header */
body.chat-fullscreen .chat-fab { display: none; }

.chat-resize-handle {
  position: absolute; top: 4px; left: 4px; width: 14px; height: 14px;
  cursor: nwse-resize; opacity: 0.5;
}
.chat-resize-handle:hover { opacity: 1; }
.chat-size-btn {
  background: rgba(255,255,255,0.15); border: none; color: rgba(255,255,255,0.85);
  padding: 0.3rem 0.5rem; border-radius: 4px; font-size: 0.85rem; cursor: pointer; margin-right: 0.3rem;
  font-family: inherit;
}
.chat-size-btn:hover { background: rgba(255,255,255,0.25); color: #fff; }

.chat-header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  color: #fff; padding: 0.85rem 1rem;
  display: flex; align-items: center; justify-content: space-between;
}
.chat-header h3 { font-size: 0.95rem; font-weight: 700; margin: 0; }
.chat-header .subtitle { font-size: 0.7rem; color: rgba(255,255,255,0.7); }
.chat-clear-btn {
  background: rgba(255,255,255,0.15); border: none; color: rgba(255,255,255,0.85);
  padding: 0.3rem 0.6rem; border-radius: 4px; font-size: 0.7rem; cursor: pointer;
}
.chat-clear-btn:hover { background: rgba(255,255,255,0.25); color: #fff; }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 1rem; background: var(--bg);
  display: flex; flex-direction: column; gap: 0.6rem;
}
.chat-msg { max-width: 85%; padding: 0.6rem 0.85rem; border-radius: 12px; font-size: 0.85rem; line-height: 1.5; word-wrap: break-word; }
.chat-msg.user { align-self: flex-end; background: var(--teal); color: #fff; border-bottom-right-radius: 3px; }
.chat-msg.assistant { align-self: flex-start; background: var(--card); color: var(--text); border: 1px solid var(--border); border-bottom-left-radius: 3px; }
.chat-msg.assistant table { font-size: 0.75rem; margin: 0.4rem 0; border-collapse: collapse; }
.chat-msg.assistant th, .chat-msg.assistant td { border: 1px solid var(--border); padding: 0.3rem 0.5rem; text-align: left; }
.chat-msg.assistant th { background: var(--bg); font-weight: 600; }
.chat-msg.assistant code { background: var(--bg); padding: 0.1rem 0.3rem; border-radius: 3px; font-size: 0.8rem; }
.chat-msg.thinking {
  align-self: flex-start; color: var(--text-muted); font-style: italic;
  display: flex; align-items: center; gap: 0.3rem;
}
.chat-msg.thinking::after {
  content: '●●●'; letter-spacing: 0.2rem;
  animation: chat-pulse 1.5s ease-in-out infinite;
}
@keyframes chat-pulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }
.chat-msg.error { align-self: stretch; background: #FEE2E2; color: #991B1B; border: 1px solid #FCA5A5; }

.chat-input-row {
  border-top: 1px solid var(--border); padding: 0.6rem; display: flex; gap: 0.5rem; background: var(--card);
}
.chat-input-row textarea {
  flex: 1; resize: none; border: 1px solid var(--border); border-radius: 6px;
  padding: 0.5rem 0.75rem; font-size: 0.85rem; font-family: inherit;
  max-height: 100px;
}
.chat-input-row textarea:focus { outline: none; border-color: var(--teal); }
.chat-input-row button {
  background: var(--teal); color: #fff; border: none; border-radius: 6px;
  padding: 0 1rem; font-size: 0.85rem; font-weight: 600; cursor: pointer;
}
.chat-input-row button:hover { background: var(--teal-light); }
.chat-input-row button:disabled { background: var(--text-muted); cursor: not-allowed; }

.chat-suggestions {
  padding: 0.5rem 0.75rem 0; display: flex; flex-wrap: wrap; gap: 0.3rem;
  border-top: 1px solid var(--border); background: var(--card);
}
.chat-suggestion {
  background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
  padding: 0.25rem 0.6rem; font-size: 0.7rem; color: var(--slate); cursor: pointer;
}
.chat-suggestion:hover { border-color: var(--teal); color: var(--teal); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--slate-light); }
