/* ═══════════════════════════════════════════════════════════════
   AppFolio Portal — Main Stylesheet
   Clean dark SaaS design. No framework.
   ═══════════════════════════════════════════════════════════════ */

/* ── Variables ───────────────────────────────────────────────── */

:root {
  --bg:          #0f172a;
  --bg-raised:   #1e293b;
  --bg-hover:    #334155;
  --border:      #334155;
  --border-light:#475569;
  --text:        #f1f5f9;
  --text-muted:  #94a3b8;
  --text-dim:    #64748b;
  --accent:      #3b82f6;
  --accent-hover:#2563eb;
  --success:     #22c55e;
  --warning:     #f59e0b;
  --danger:      #ef4444;
  --sla-immediate: #ef4444;
  --sla-8h:      #f97316;
  --sla-24h:     #eab308;
  --sla-7d:      #22c55e;
  --sla-30d:     #3b82f6;
  --radius:      8px;
  --radius-lg:   12px;
  --shadow:      0 1px 3px rgba(0,0,0,.3);
  --sidebar-w:   260px;
  --topbar-h:    56px;
  --font:        'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Reset ───────────────────────────────────────────────────── */

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

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

img { max-width: 100%; }

/* ── Typography ──────────────────────────────────────────────── */

h1 { font-size: 1.4rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 600; }
h3 { font-size: 1.05rem; font-weight: 600; }

.text-muted  { color: var(--text-muted); }
.text-dim    { color: var(--text-dim); }
.text-danger { color: var(--danger); }
.text-success{ color: var(--success); }
.text-warning{ color: var(--warning); }

/* ── Layout: Sidebar + Main ──────────────────────────────────── */

.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w); height: 100vh;
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 100;
  transition: transform .25s ease;
}

.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex; flex-direction: column;
}

/* ── Sidebar internals ───────────────────────────────────────── */

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex; align-items: center; gap: 10px;
  font-size: 1.15rem; font-weight: 700; color: var(--text);
}
.logo svg { color: var(--accent); flex-shrink: 0; }

.sidebar-nav {
  flex: 1; padding: 12px 10px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
}

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: var(--radius);
  color: var(--text-muted); font-weight: 500; font-size: .93rem;
  transition: all .15s;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item.active svg { color: #fff; }
.nav-item svg { flex-shrink: 0; }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

.user-info { display: flex; align-items: center; gap: 10px; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; flex-shrink: 0;
}

.user-meta { display: flex; flex-direction: column; line-height: 1.3; }
.user-name { font-size: .85rem; font-weight: 600; }
.user-role { font-size: .72rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; }

.logout-btn {
  color: var(--text-dim); padding: 6px; border-radius: var(--radius);
  transition: all .15s;
}
.logout-btn:hover { color: var(--danger); background: rgba(239,68,68,.1); text-decoration: none; }

/* ── Top bar ─────────────────────────────────────────────────── */

.topbar {
  height: var(--topbar-h);
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  background: var(--bg-raised);
  position: sticky; top: 0; z-index: 50;
}

.page-title { flex: 1; font-size: 1.1rem; font-weight: 600; }

.menu-toggle {
  display: none;
  background: none; border: none; color: var(--text); cursor: pointer;
  padding: 4px;
}

.topbar-actions { position: relative; display: flex; align-items: center; gap: 12px; }

/* ── Notification bell ───────────────────────────────────────── */

.notif-bell {
  position: relative; background: none; border: none;
  color: var(--text-muted); cursor: pointer; padding: 6px; border-radius: var(--radius);
  transition: all .15s;
}
.notif-bell:hover { color: var(--text); background: var(--bg-hover); }

.notif-badge {
  position: absolute; top: 0; right: 0;
  background: var(--danger); color: #fff;
  font-size: .65rem; font-weight: 700;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}

.notif-panel {
  display: none; position: absolute; top: 42px; right: 0;
  width: 340px; max-height: 440px;
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  overflow: hidden; z-index: 200;
}
.notif-panel.open { display: block; }

.notif-panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: .9rem;
}
.notif-panel-header button {
  background: none; border: none; color: var(--accent);
  cursor: pointer; font-size: .8rem;
}

.notif-list { overflow-y: auto; max-height: 380px; }

.notif-item {
  display: block; padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background .1s; color: var(--text);
}
.notif-item:hover { background: var(--bg-hover); text-decoration: none; }
.notif-item.unread { border-left: 3px solid var(--accent); }
.notif-item-title { font-weight: 600; font-size: .85rem; }
.notif-item-body  { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }
.notif-item-time  { font-size: .72rem; color: var(--text-dim); margin-top: 4px; }

.notif-empty {
  padding: 32px 16px; text-align: center;
  color: var(--text-dim); font-size: .85rem;
}

/* ── Content area ────────────────────────────────────────────── */

.content { flex: 1; padding: 24px; max-width: 1400px; width: 100%; }

/* ── Flash messages ──────────────────────────────────────────── */

.flash {
  padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px;
  font-size: .88rem; font-weight: 500;
  animation: flashIn .3s ease;
}
.flash-error   { background: rgba(239,68,68,.15); color: #fca5a5; border: 1px solid rgba(239,68,68,.3); }
.flash-success { background: rgba(34,197,94,.15); color: #86efac; border: 1px solid rgba(34,197,94,.3); }
.flash-info    { background: rgba(59,130,246,.15); color: #93c5fd; border: 1px solid rgba(59,130,246,.3); }
.flash-warning { background: rgba(245,158,11,.15); color: #fcd34d; border: 1px solid rgba(245,158,11,.3); }

@keyframes flashIn { from { opacity: 0; transform: translateY(-8px); } }

/* ── Toast ───────────────────────────────────────────────────── */

.toast-container {
  position: fixed; top: 16px; right: 16px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}

.toast {
  padding: 12px 20px; border-radius: var(--radius);
  font-size: .85rem; font-weight: 500;
  background: var(--bg-raised); border: 1px solid var(--border);
  box-shadow: var(--shadow); color: var(--text);
  animation: toastIn .3s ease;
  max-width: 360px;
}
.toast.success { border-color: var(--success); }
.toast.error   { border-color: var(--danger); }

@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } }

/* ── Cards ───────────────────────────────────────────────────── */

.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

/* ── Stat cards ──────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px; margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex; flex-direction: column; gap: 4px;
}
.stat-card .stat-value {
  font-size: 2rem; font-weight: 700; line-height: 1.1;
}
.stat-card .stat-label {
  font-size: .82rem; color: var(--text-muted); font-weight: 500;
}
.stat-card.danger  .stat-value { color: var(--danger); }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.success .stat-value { color: var(--success); }
.stat-card.accent  .stat-value { color: var(--accent); }

/* ── Connection banner ───────────────────────────────────────── */

.conn-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px; margin-bottom: 20px;
  border-radius: var(--radius-lg);
  font-size: .88rem;
}
.conn-banner.ok     { background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.25); }
.conn-banner.warn   { background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.25); }
.conn-banner.danger { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.25); }
.conn-banner svg   { flex-shrink: 0; }

/* ── Buildings grid ──────────────────────────────────────────── */

.buildings-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px; margin-bottom: 24px;
}

.building-card {
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 6px;
  transition: all .15s; cursor: pointer;
}
.building-card:hover { border-color: var(--accent); transform: translateY(-1px); text-decoration: none; color: var(--text); }
.building-card .b-name { font-weight: 600; font-size: .95rem; }
.building-card .b-counts {
  display: flex; gap: 12px; font-size: .8rem; color: var(--text-muted);
}
.building-card .b-counts .overdue { color: var(--danger); font-weight: 600; }

/* ── SLA timeline ────────────────────────────────────────────── */

.sla-timeline { margin-bottom: 24px; }
.sla-timeline h3 { margin-bottom: 12px; }

.sla-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: var(--radius);
  border: 1px solid var(--border); margin-bottom: 6px;
  font-size: .88rem; transition: background .1s; color: var(--text);
}
.sla-item:hover { background: var(--bg-hover); text-decoration: none; }
.sla-item .sla-time { font-weight: 600; white-space: nowrap; min-width: 80px; }
.sla-item .sla-desc { flex: 1; }

/* ── Buttons ─────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius); border: none;
  font-family: var(--font); font-size: .88rem; font-weight: 600;
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { background: #16a34a; }
.btn-warning   { background: var(--warning); color: #1a1a2e; }
.btn-warning:hover { background: #d97706; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: #dc2626; }

.btn-ghost {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }

.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }

/* ── Forms ───────────────────────────────────────────────────── */

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; margin-bottom: 6px;
  font-size: .82rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .04em;
}

.form-input, .form-select {
  width: 100%; padding: 10px 14px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-family: var(--font); font-size: .9rem;
  transition: border-color .15s;
}
.form-input:focus, .form-select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.form-input::placeholder { color: var(--text-dim); }

.form-row { display: flex; gap: 12px; }
.form-row > * { flex: 1; }

/* ── SLA badges ──────────────────────────────────────────────── */

.sla-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px;
  font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
}
.sla-badge::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: currentColor;
}

.sla-immediate { color: var(--sla-immediate); background: rgba(239,68,68,.12); }
.sla-8h        { color: var(--sla-8h);  background: rgba(249,115,22,.12); }
.sla-24h       { color: var(--sla-24h); background: rgba(234,179,8,.12); }
.sla-7d        { color: var(--sla-7d);  background: rgba(34,197,94,.12); }
.sla-30d       { color: var(--sla-30d); background: rgba(59,130,246,.12); }
.sla-unset     { color: var(--text-dim); background: rgba(107,114,128,.12); }

/* ── Status badges ───────────────────────────────────────────── */

.status-badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em;
}
.status-open         { color: var(--accent); background: rgba(59,130,246,.12); }
.status-in_progress  { color: var(--warning); background: rgba(245,158,11,.12); }
.status-needs_vendor { color: var(--danger); background: rgba(239,68,68,.12); }
.status-completed    { color: var(--success); background: rgba(34,197,94,.12); }

/* ── Work order list ─────────────────────────────────────────── */

.wo-filters {
  display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px;
  align-items: center;
}
.wo-filters .form-input,
.wo-filters .form-select {
  width: auto; min-width: 150px; padding: 7px 12px; font-size: .84rem;
}

.wo-list { display: flex; flex-direction: column; gap: 8px; }

.wo-card {
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px 20px;
  transition: all .15s; display: flex; flex-direction: column; gap: 10px;
}
.wo-card:hover { border-color: var(--border-light); }
.wo-card.overdue { border-left: 3px solid var(--danger); }

.wo-card-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px;
}
.wo-card-title {
  font-size: .95rem; font-weight: 600; line-height: 1.4;
  flex: 1;
}
.wo-card-meta {
  font-size: .8rem; color: var(--text-muted);
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center;
}
.wo-card-meta span { display: inline-flex; align-items: center; gap: 4px; }

.wo-card-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
}

.wo-action {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 14px; border-radius: var(--radius); border: none;
  font-family: var(--font); font-size: .8rem; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.wo-action.completed   { background: rgba(34,197,94,.12); color: var(--success); }
.wo-action.completed:hover { background: var(--success); color: #fff; }
.wo-action.inprogress  { background: rgba(245,158,11,.12); color: var(--warning); }
.wo-action.inprogress:hover { background: var(--warning); color: #1a1a2e; }
.wo-action.getvendor   { background: rgba(239,68,68,.12); color: var(--danger); }
.wo-action.getvendor:hover { background: var(--danger); color: #fff; }

.wo-action.active {
  box-shadow: inset 0 0 0 2px currentColor;
}

.wo-action.notes-toggle {
  background: rgba(99,102,241,.12); color: var(--primary);
}
.wo-action.notes-toggle:hover { background: var(--primary); color: #fff; }
.wo-action.notes-toggle.open { background: var(--primary); color: #fff; }
.notes-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--primary); color: #fff;
  font-size: .7rem; font-weight: 700; margin-left: 4px;
}
.wo-action.notes-toggle.open .notes-count,
.wo-action.notes-toggle:hover .notes-count {
  background: rgba(255,255,255,.3);
}

/* ── Inline notes panel ──────────────────────────────────────── */
.wo-notes-panel {
  border-top: 1px solid var(--border);
  padding: 12px 0 0;
  margin-top: 10px;
}
.wo-notes-messages {
  max-height: 260px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 10px; padding: 4px 0;
}
.wo-note-bubble {
  display: flex; gap: 8px; align-items: flex-start;
  font-size: .85rem; line-height: 1.4;
}
.wo-note-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .65rem; font-weight: 700; flex-shrink: 0;
}
.wo-note-body {
  flex: 1; min-width: 0;
}
.wo-note-author {
  font-weight: 600; font-size: .8rem; color: var(--text);
}
.wo-note-time {
  font-size: .72rem; color: var(--text-dim); margin-left: 6px; font-weight: 400;
}
.wo-note-text {
  color: var(--text-muted); word-break: break-word;
}
.wo-note-text .mention {
  color: var(--primary); font-weight: 600;
}
.wo-note-img {
  max-width: 220px; max-height: 200px; border-radius: 8px;
  margin: 4px 0; cursor: pointer; display: block;
}
.wo-notes-preview {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0 2px 36px;
}
.wo-attach-btn {
  padding: 4px; flex-shrink: 0; color: var(--text-muted);
}
.wo-attach-btn:hover { color: var(--primary); }
.wo-notes-input-row {
  display: flex; gap: 8px; align-items: center;
}
.wo-notes-input-wrap {
  flex: 1; position: relative;
}
.wo-notes-input {
  width: 100%; padding: 8px 12px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font-family: var(--font); font-size: .85rem;
}
.wo-notes-input:focus { outline: none; border-color: var(--primary); }
.mention-dropdown {
  display: none; position: absolute; bottom: 100%; left: 0;
  background: var(--card-bg, #1e293b); border: 1px solid var(--border);
  border-radius: var(--radius); max-height: 160px; overflow-y: auto;
  width: 200px; z-index: 100; box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
.mention-dropdown.show { display: block; }
.mention-item {
  padding: 8px 12px; cursor: pointer; font-size: .85rem;
  color: var(--text);
}
.mention-item:hover, .mention-item.active {
  background: var(--primary); color: #fff;
}

/* ── Ticket detail ───────────────────────────────────────────── */

.ticket-header {
  margin-bottom: 24px;
}
.ticket-number { font-size: .82rem; color: var(--text-dim); font-weight: 600; }
.ticket-title  { font-size: 1.3rem; font-weight: 700; margin: 6px 0; line-height: 1.35; }
.ticket-meta {
  display: flex; flex-wrap: wrap; gap: 16px;
  font-size: .85rem; color: var(--text-muted);
  margin-top: 8px;
}
.ticket-meta span { display: inline-flex; align-items: center; gap: 5px; }

.ticket-actions {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border);
}

.ticket-sla-select {
  padding: 6px 12px; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-family: var(--font); font-size: .84rem;
}

.ticket-link {
  margin-left: auto;
}

/* ── Chat / Notes ────────────────────────────────────────────── */

.chat-section {
  margin-top: 24px;
}
.chat-section h3 { margin-bottom: 16px; }

.chat-messages {
  display: flex; flex-direction: column; gap: 4px;
  max-height: 500px; overflow-y: auto;
  padding: 16px; margin-bottom: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.chat-msg {
  display: flex; gap: 10px;
  max-width: 75%;
  animation: msgIn .2s ease;
}
.chat-msg.mine { align-self: flex-end; flex-direction: row-reverse; }

@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } }

.chat-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--bg-hover); color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: .68rem; font-weight: 700; flex-shrink: 0;
  margin-top: 4px;
}
.chat-msg.mine .chat-avatar { background: var(--accent); color: #fff; }

.chat-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: .88rem; line-height: 1.45;
  position: relative;
}
.chat-msg:not(.mine) .chat-bubble {
  background: var(--bg-hover); color: var(--text);
  border-top-left-radius: 4px;
}
.chat-msg.mine .chat-bubble {
  background: var(--accent); color: #fff;
  border-top-right-radius: 4px;
}

.chat-sender {
  font-size: .72rem; font-weight: 700;
  color: var(--accent); margin-bottom: 2px;
}
.chat-msg.mine .chat-sender { color: rgba(255,255,255,.7); }
.chat-msg.mine .chat-bubble strong { color: #fff; }

.chat-time {
  font-size: .68rem; color: var(--text-dim);
  margin-top: 3px;
}
.chat-msg.mine .chat-time { color: rgba(255,255,255,.5); text-align: right; }

.chat-reply-preview {
  font-size: .76rem; color: var(--text-dim);
  padding: 4px 8px; margin-bottom: 4px;
  border-left: 2px solid var(--accent);
  border-radius: 2px;
}
.chat-msg.mine .chat-reply-preview {
  color: rgba(255,255,255,.6);
  border-left-color: rgba(255,255,255,.4);
}

/* ── Chat message actions (edit / delete) ────────────────────── */

.chat-msg-content { position: relative; }

.chat-msg-actions {
  display: flex; gap: 2px;
  opacity: 0; transition: opacity .15s;
  margin-top: 2px;
}
.chat-msg:hover .chat-msg-actions { opacity: 1; }
.chat-msg.mine .chat-msg-actions { justify-content: flex-end; }

.chat-action-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-dim); padding: 2px 4px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
}
.chat-action-btn:hover { background: var(--bg-hover); color: var(--text); }
.chat-action-delete:hover { color: var(--danger); }
.chat-msg.mine .chat-action-btn { color: rgba(255,255,255,.5); }
.chat-msg.mine .chat-action-btn:hover { background: rgba(255,255,255,.15); color: #fff; }
.chat-msg.mine .chat-action-delete:hover { color: var(--danger); }

.chat-edited-tag {
  display: inline-block;
  font-size: .68rem; color: var(--text-dim);
  font-style: italic; margin-top: 2px;
}
.chat-msg.mine .chat-edited-tag { color: rgba(255,255,255,.5); }

/* ── Chat compose ────────────────────────────────────────────── */

.chat-compose {
  display: flex; gap: 10px; align-items: flex-end;
}

.chat-compose-wrap {
  flex: 1; position: relative;
}

.chat-reply-bar {
  display: none; padding: 8px 12px; margin-bottom: 6px;
  background: var(--bg-hover); border-radius: var(--radius);
  font-size: .8rem; color: var(--text-muted);
  align-items: center; justify-content: space-between;
}
.chat-reply-bar.active { display: flex; }
.chat-reply-bar button {
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 1rem; line-height: 1;
}

.chat-input {
  width: 100%; padding: 12px 16px;
  background: var(--bg-raised); color: var(--text);
  border: 1px solid var(--border); border-radius: 24px;
  font-family: var(--font); font-size: .9rem;
  resize: none; min-height: 44px; max-height: 120px;
  transition: border-color .15s;
}
.chat-input:focus { outline: none; border-color: var(--accent); }
.chat-input::placeholder { color: var(--text-dim); }

.chat-send {
  width: 44px; height: 44px;
  background: var(--accent); color: #fff;
  border: none; border-radius: 50%;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all .15s; flex-shrink: 0;
}
.chat-send:hover { background: var(--accent-hover); }
.chat-send:disabled { opacity: .4; cursor: not-allowed; }

/* ── Activity log ────────────────────────────────────────────── */

.activity-log { margin-top: 24px; }
.activity-log h3 { margin-bottom: 12px; }

.activity-item {
  display: flex; gap: 10px; padding: 8px 0;
  font-size: .82rem; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-dim); margin-top: 6px; flex-shrink: 0;
}
.activity-item.status-change .activity-dot { background: var(--warning); }
.activity-item.completed .activity-dot     { background: var(--success); }

/* ── Settings page ───────────────────────────────────────────── */

.settings-grid {
  display: grid; grid-template-columns: 1fr; gap: 24px;
}

.settings-section { }
.settings-section h2 {
  margin-bottom: 16px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.user-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.user-row:last-child { border-bottom: none; }
.user-row .role-badge {
  font-size: .72rem; font-weight: 600; text-transform: uppercase;
  padding: 2px 8px; border-radius: 12px;
}
.role-admin     { color: var(--danger); background: rgba(239,68,68,.12); }
.role-assistant { color: var(--warning); background: rgba(245,158,11,.12); }
.role-super     { color: var(--accent); background: rgba(59,130,246,.12); }

.assign-pills {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 6px;
}
.assign-pill {
  padding: 3px 10px; border-radius: 12px; font-size: .76rem;
  background: var(--bg-hover); color: var(--text-muted);
  cursor: pointer; border: 1px solid transparent; transition: all .15s;
}
.assign-pill.selected { background: var(--accent); color: #fff; border-color: var(--accent); }
.assign-pill:hover { border-color: var(--accent); }

/* ── AppFolio connection card ────────────────────────────────── */

.af-status {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px; font-size: .9rem;
}
.af-dot {
  width: 10px; height: 10px; border-radius: 50%;
}
.af-dot.online  { background: var(--success); box-shadow: 0 0 6px var(--success); }
.af-dot.offline { background: var(--danger); box-shadow: 0 0 6px var(--danger); }

/* ── Login page ──────────────────────────────────────────────── */

.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
}

.login-card {
  width: 100%; max-width: 400px;
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 40px 32px;
}

.login-logo {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-bottom: 32px; font-size: 1.4rem; font-weight: 700;
}
.login-logo svg { color: var(--accent); }

.login-card .btn { width: 100%; margin-top: 8px; }
.login-card .form-input { padding: 12px 16px; }

/* ── Scrollbar ───────────────────────────────────────────────── */

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

/* ── Empty state ─────────────────────────────────────────────── */

.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-dim);
}
.empty-state svg { margin-bottom: 16px; opacity: .4; }
.empty-state h3 { color: var(--text-muted); margin-bottom: 8px; }

/* ── Section header ──────────────────────────────────────────── */

.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}

/* ── Responsive ──────────────────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }

  .main { margin-left: 0; }

  .menu-toggle { display: block; }

  .content { padding: 16px; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  .buildings-grid { grid-template-columns: 1fr; }

  .wo-card-actions { flex-direction: column; }

  .wo-filters { flex-direction: column; align-items: stretch; }
  .wo-filters .form-input,
  .wo-filters .form-select { width: 100%; }

  .chat-msg { max-width: 88%; }

  .ticket-actions { flex-direction: column; align-items: stretch; }
  .ticket-link { margin-left: 0; }

  .notif-panel { width: calc(100vw - 32px); right: -60px; }

  .form-row { flex-direction: column; }
}

/* Sidebar overlay on mobile */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 99;
}
.sidebar-overlay.show { display: block; }

/* ── Utility ─────────────────────────────────────────────────── */

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.gap-1 { gap: 8px; }
.flex  { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }

/* ── Group Chat layout ───────────────────────────────────────── */

.gc-layout {
  display: flex;
  height: calc(100vh - var(--topbar-h) - 32px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg);
}

.gc-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.gc-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.gc-sidebar-header h3 { font-size: 1rem; margin: 0; }

.gc-channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.gc-channel-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  cursor: pointer;
  font-size: .88rem;
  color: var(--text-muted);
  transition: background .1s, color .1s;
}
.gc-channel-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.gc-channel-item.active {
  background: var(--accent);
  color: #fff;
}

.gc-channel-hash {
  font-weight: 700;
  font-size: 1rem;
  opacity: .5;
}
.gc-channel-item.active .gc-channel-hash { opacity: .8; }

.gc-channel-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Main area */
.gc-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.gc-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  gap: 8px;
}
.gc-empty-state svg { opacity: .4; }
.gc-empty-state h3 { color: var(--text-muted); margin: 0; }

.gc-channel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-raised);
}
.gc-channel-name {
  font-weight: 700;
  font-size: 1rem;
}
.gc-channel-members {
  font-size: .78rem;
  color: var(--text-dim);
  margin-left: 4px;
}
.gc-back-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

/* Messages area */
.gc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Compose area */
.gc-compose {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-raised);
}

.gc-compose-wrap {
  flex: 1;
  position: relative;
}

.gc-reply-bar {
  display: none;
  padding: 6px 10px;
  margin-bottom: 6px;
  background: var(--bg-hover);
  border-radius: var(--radius);
  font-size: .8rem;
  color: var(--text-muted);
  align-items: center;
  justify-content: space-between;
}
.gc-reply-bar.active { display: flex; }
.gc-reply-bar button {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.gc-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 24px;
  font-family: var(--font);
  font-size: .9rem;
  transition: border-color .15s;
}
.gc-input:focus { outline: none; border-color: var(--accent); }
.gc-input::placeholder { color: var(--text-dim); }

.gc-compose .mention-dropdown {
  bottom: 100%;
  left: 0;
}

/* Mobile responsive */
@media (max-width: 640px) {
  .gc-sidebar {
    width: 100%;
    position: absolute;
    inset: 0;
    z-index: 10;
  }
  .gc-sidebar.gc-sidebar-hidden { display: none; }
  .gc-main { display: none; }
  .gc-main.gc-main-active { display: flex; }
  .gc-back-btn { display: block; }
  .gc-layout { position: relative; }
}
