:root {
  --bg-primary: #0a0a0b;
  --bg-secondary: #111113;
  --bg-tertiary: #18181b;
  --bg-hover: #1e1e22;
  --bg-active: #252529;
  --border: #27272a;
  --border-light: #2e2e33;
  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-tertiary: #71717a;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-dim: rgba(99,102,241,0.15);
  --green: #22c55e;
  --green-dim: rgba(34,197,94,0.15);
  --red: #ef4444;
  --red-dim: rgba(239,68,68,0.15);
  --yellow: #eab308;
  --yellow-dim: rgba(234,179,8,0.15);
  --blue: #3b82f6;
  --blue-dim: rgba(59,130,246,0.15);
  --radius: 8px;
  --radius-lg: 12px;
  --sidebar-w: 220px;
  --transition: 150ms ease;
}

* { margin:0; padding:0; box-sizing:border-box; }
body { font-family:'Inter',system-ui,sans-serif; background:var(--bg-primary); color:var(--text-primary); display:flex; height:100vh; overflow:hidden; font-size:14px; }

/* 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(--text-tertiary); }

/* Sidebar */
#sidebar { width:var(--sidebar-w); min-width:var(--sidebar-w); height:100vh; background:var(--bg-secondary); border-right:1px solid var(--border); display:flex; flex-direction:column; z-index:10; }
.sidebar-logo { padding:20px 16px; display:flex; align-items:center; gap:10px; border-bottom:1px solid var(--border); }
.logo-icon { font-size:20px; }
.logo-text { font-weight:600; font-size:15px; letter-spacing:-0.3px; }
.nav-items { flex:1; padding:8px; overflow-y:auto; display:flex; flex-direction:column; gap:2px; }
.nav-item { display:flex; align-items:center; gap:10px; padding:8px 12px; border-radius:var(--radius); color:var(--text-secondary); text-decoration:none; cursor:pointer; transition:all var(--transition); font-size:13px; font-weight:500; }
.nav-item i { width:18px; text-align:center; font-size:14px; }
.nav-item:hover { background:var(--bg-hover); color:var(--text-primary); }
.nav-item.active { background:var(--accent-dim); color:var(--accent-hover); }
.sidebar-footer { padding:12px 16px; border-top:1px solid var(--border); }
.agent-badge { display:flex; align-items:center; gap:8px; font-size:13px; color:var(--text-secondary); }
.status-dot { width:8px; height:8px; border-radius:50%; background:var(--green); box-shadow:0 0 6px rgba(34,197,94,0.4); }

/* Main Content */
#content { flex:1; overflow-y:auto; padding:0; height:100vh; }
.page { padding:32px; max-width:1400px; animation:fadeIn 200ms ease; }
@keyframes fadeIn { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:translateY(0)} }
.page-header { margin-bottom:24px; }
.page-header h1 { font-size:22px; font-weight:600; letter-spacing:-0.5px; margin-bottom:4px; }
.page-header p { color:var(--text-tertiary); font-size:13px; }

/* Cards */
.card { background:var(--bg-secondary); border:1px solid var(--border); border-radius:var(--radius-lg); padding:20px; }
.card-header { display:flex; justify-content:space-between; align-items:center; margin-bottom:16px; }
.card-title { font-weight:600; font-size:14px; }

/* Buttons */
.btn { padding:7px 14px; border-radius:var(--radius); border:1px solid var(--border); background:var(--bg-tertiary); color:var(--text-primary); cursor:pointer; font-size:13px; font-family:inherit; font-weight:500; transition:all var(--transition); display:inline-flex; align-items:center; gap:6px; }
.btn:hover { background:var(--bg-hover); border-color:var(--border-light); }
.btn-primary { background:var(--accent); border-color:var(--accent); color:white; }
.btn-primary:hover { background:var(--accent-hover); }
.btn-sm { padding:5px 10px; font-size:12px; }
.btn-danger { color:var(--red); }
.btn-danger:hover { background:var(--red-dim); }

/* Inputs */
input,textarea,select { background:var(--bg-tertiary); border:1px solid var(--border); border-radius:var(--radius); padding:8px 12px; color:var(--text-primary); font-family:inherit; font-size:13px; outline:none; transition:border var(--transition); width:100%; }
input:focus,textarea:focus { border-color:var(--accent); }
textarea { resize:vertical; min-height:80px; }

/* Badge */
.badge { display:inline-flex; align-items:center; padding:3px 8px; border-radius:99px; font-size:11px; font-weight:600; }
.badge-green { background:var(--green-dim); color:var(--green); }
.badge-red { background:var(--red-dim); color:var(--red); }
.badge-yellow { background:var(--yellow-dim); color:var(--yellow); }
.badge-blue { background:var(--blue-dim); color:var(--blue); }
.badge-gray { background:var(--bg-hover); color:var(--text-tertiary); }

/* Table */
.table { width:100%; border-collapse:collapse; }
.table th { text-align:left; padding:10px 12px; font-size:11px; font-weight:600; text-transform:uppercase; letter-spacing:0.5px; color:var(--text-tertiary); border-bottom:1px solid var(--border); }
.table td { padding:10px 12px; border-bottom:1px solid var(--border); font-size:13px; }
.table tr:last-child td { border-bottom:none; }
.table tr:hover td { background:var(--bg-hover); }

/* Modal */
#modal-overlay { position:fixed; inset:0; background:rgba(0,0,0,0.6); backdrop-filter:blur(4px); display:flex; align-items:center; justify-content:center; z-index:100; }
.hidden { display: none !important; }
#modal-overlay.hidden { display:none; }
#modal { background:var(--bg-secondary); border:1px solid var(--border); border-radius:var(--radius-lg); padding:24px; width:90%; max-width:480px; animation:fadeIn 150ms ease; }
.modal-title { font-size:16px; font-weight:600; margin-bottom:16px; }
.modal-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:20px; }
.form-group { margin-bottom:14px; }
.form-group label { display:block; font-size:12px; font-weight:500; color:var(--text-secondary); margin-bottom:4px; }

/* Chat Layout */
.chat-layout { display:flex; height:calc(100vh - 0px); position:relative; }
.chat-main { flex:1; display:flex; flex-direction:column; }
.chat-header-bar { padding:14px 20px; border-bottom:1px solid var(--border); background:var(--bg-secondary); display:flex; align-items:center; }
.chat-header-status { display:flex; align-items:center; gap:10px; font-weight:600; font-size:15px; }
.chat-header-status .status-dot { width:8px; height:8px; border-radius:50%; background:var(--green); box-shadow:0 0 6px rgba(34,197,94,0.4); }
.chat-messages { flex:1; overflow-y:auto; padding:20px; display:flex; flex-direction:column; gap:8px; scroll-behavior:smooth; }
.chat-msg { max-width:70%; display:flex; flex-direction:column; gap:2px; }
.chat-msg.user { align-self:flex-end; }
.chat-msg.agent { align-self:flex-start; }
.chat-msg-bubble { padding:10px 14px; border-radius:var(--radius-lg); font-size:13px; line-height:1.5; white-space:pre-wrap; word-wrap:break-word; }
.chat-msg.user .chat-msg-bubble { background:var(--accent); color:white; border-bottom-right-radius:4px; }
.chat-msg.agent .chat-msg-bubble { background:var(--bg-tertiary); border:1px solid var(--border); border-bottom-left-radius:4px; }
.chat-msg-time { font-size:10px; color:var(--text-tertiary); padding:0 4px; }
.chat-msg.user .chat-msg-time { text-align:right; }

/* Chat Empty State */
.chat-empty-state { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; color:var(--text-tertiary); gap:12px; }
.chat-empty-icon { font-size:48px; }
.chat-empty-text { font-size:15px; }

/* Chat Input Bar */
.chat-input-bar { display:flex; align-items:center; gap:8px; padding:12px 16px; border-top:1px solid var(--border); background:var(--bg-secondary); }
.chat-input-bar input[type="text"] { flex:1; border-radius:20px; padding:10px 16px; }
.chat-send-btn { border-radius:50%; width:38px; height:38px; padding:0; display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.chat-attach-btn { cursor:pointer; display:flex; align-items:center; justify-content:center; width:38px; height:38px; border-radius:50%; color:var(--text-tertiary); transition:all var(--transition); flex-shrink:0; }
.chat-attach-btn:hover { color:var(--text-primary); background:var(--bg-hover); }

/* Chat Typing Indicator */
.chat-typing { display:flex; align-items:center; gap:4px; padding:0 24px 8px; }
.chat-typing span { width:6px; height:6px; border-radius:50%; background:var(--text-tertiary); animation:chatBounce 1.4s infinite ease-in-out; }
.chat-typing span:nth-child(2) { animation-delay:0.2s; }
.chat-typing span:nth-child(3) { animation-delay:0.4s; }
.chat-typing .chat-typing-text { font-size:12px; color:var(--text-tertiary); margin-left:6px; animation:none; width:auto; height:auto; border-radius:0; background:none; }
@keyframes chatBounce { 0%,80%,100%{transform:translateY(0)} 40%{transform:translateY(-6px)} }

/* Chat Attachments */
.chat-attachment { margin-top:8px; }
.chat-attachment img.chat-img-preview { max-width:240px; max-height:180px; border-radius:var(--radius); }
.chat-attachment a { color:var(--accent-hover); text-decoration:none; }
.chat-attachment a:hover { text-decoration:underline; }
.chat-attachment i { margin-right:4px; }

/* Chat Drag & Drop Overlay */
.chat-drop-overlay { position:absolute; inset:0; background:rgba(99,102,241,0.12); border:2px dashed var(--accent); border-radius:var(--radius-lg); display:none; align-items:center; justify-content:center; z-index:20; }
.chat-drop-overlay.active { display:flex; }
.chat-drop-content { display:flex; flex-direction:column; align-items:center; gap:8px; color:var(--accent-hover); font-size:16px; }
.chat-drop-content i { font-size:32px; }

/* Board */
.board-columns { display:flex; gap:16px; height:calc(100vh - 140px); }
.board-col { flex:1; background:var(--bg-secondary); border:1px solid var(--border); border-radius:var(--radius-lg); display:flex; flex-direction:column; min-width:0; }
.board-col-header { padding:12px 16px; border-bottom:1px solid var(--border); display:flex; justify-content:space-between; align-items:center; }
.board-col-title { font-size:13px; font-weight:600; text-transform:uppercase; letter-spacing:0.5px; }
.board-col-count { font-size:11px; color:var(--text-tertiary); background:var(--bg-hover); padding:2px 8px; border-radius:99px; }
.board-col-body { flex:1; overflow-y:auto; padding:8px; display:flex; flex-direction:column; gap:8px; }
.board-card { background:var(--bg-tertiary); border:1px solid var(--border); border-radius:var(--radius); padding:12px; cursor:grab; transition:all var(--transition); }
.board-card:hover { border-color:var(--border-light); background:var(--bg-hover); }
.board-card.dragging { opacity:0.5; }
.board-card-title { font-size:13px; font-weight:500; margin-bottom:4px; }
.board-card-desc { font-size:12px; color:var(--text-tertiary); line-height:1.4; }
.board-card-priority { margin-top:6px; }
.board-col-body.drag-over { background:var(--accent-dim); border-radius:var(--radius); }

/* Skills Grid */
.skills-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(280px,1fr)); gap:12px; }
.skill-card { display:flex; align-items:center; gap:14px; }
.skill-icon { width:40px; height:40px; border-radius:var(--radius); background:var(--accent-dim); display:flex; align-items:center; justify-content:center; color:var(--accent-hover); font-size:16px; flex-shrink:0; }
.skill-info { flex:1; min-width:0; }
.skill-name { font-size:13px; font-weight:600; margin-bottom:2px; }
.skill-desc { font-size:12px; color:var(--text-tertiary); }
.skill-toggle { position:relative; width:36px; height:20px; flex-shrink:0; }
.skill-toggle input { display:none; }
.skill-toggle .slider { position:absolute; inset:0; background:var(--bg-hover); border:1px solid var(--border); border-radius:99px; cursor:pointer; transition:all var(--transition); }
.skill-toggle .slider::before { content:''; position:absolute; width:14px; height:14px; border-radius:50%; background:var(--text-tertiary); top:2px; left:2px; transition:all var(--transition); }
.skill-toggle input:checked + .slider { background:var(--accent-dim); border-color:var(--accent); }
.skill-toggle input:checked + .slider::before { transform:translateX(16px); background:var(--accent-hover); }

/* Memory */
.memory-layout { display:flex; gap:0; height:calc(100vh - 0px); margin:-32px; }
.memory-sidebar { width:260px; min-width:260px; border-right:1px solid var(--border); background:var(--bg-secondary); padding:16px; display:flex; flex-direction:column; }
.memory-files { flex:1; overflow-y:auto; margin-top:12px; display:flex; flex-direction:column; gap:2px; }
.memory-file { padding:8px 12px; border-radius:var(--radius); cursor:pointer; font-size:13px; color:var(--text-secondary); transition:all var(--transition); display:flex; align-items:center; gap:8px; }
.memory-file:hover { background:var(--bg-hover); color:var(--text-primary); }
.memory-file.active { background:var(--accent-dim); color:var(--accent-hover); }
.memory-file i { font-size:12px; }
.memory-content { flex:1; overflow-y:auto; padding:32px; }
.memory-content h1,.memory-content h2,.memory-content h3 { margin:20px 0 8px; }
.memory-content h1 { font-size:22px; }
.memory-content h2 { font-size:18px; color:var(--text-primary); }
.memory-content h3 { font-size:15px; color:var(--text-secondary); }
.memory-content p { margin:8px 0; color:var(--text-secondary); line-height:1.6; }
.memory-content ul,.memory-content ol { margin:8px 0 8px 20px; color:var(--text-secondary); }
.memory-content li { margin:4px 0; line-height:1.5; }
.memory-content code { background:var(--bg-tertiary); padding:2px 6px; border-radius:4px; font-size:12px; }
.memory-content pre { background:var(--bg-tertiary); border:1px solid var(--border); border-radius:var(--radius); padding:14px; overflow-x:auto; margin:12px 0; }
.memory-content pre code { background:none; padding:0; }
.memory-content strong { color:var(--text-primary); }
.memory-content hr { border:none; border-top:1px solid var(--border); margin:16px 0; }

/* Activity */
.activity-filters { display:flex; gap:6px; margin-bottom:16px; }
.filter-btn { padding:5px 12px; border-radius:99px; font-size:12px; font-weight:500; background:var(--bg-tertiary); border:1px solid var(--border); color:var(--text-secondary); cursor:pointer; transition:all var(--transition); }
.filter-btn:hover { background:var(--bg-hover); }
.filter-btn.active { background:var(--accent-dim); color:var(--accent-hover); border-color:var(--accent); }
.activity-item { display:flex; gap:12px; padding:12px 0; border-bottom:1px solid var(--border); }
.activity-item:last-child { border-bottom:none; }
.activity-icon { width:32px; height:32px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:12px; flex-shrink:0; }
.activity-icon.task { background:var(--blue-dim); color:var(--blue); }
.activity-icon.system { background:var(--green-dim); color:var(--green); }
.activity-icon.agent { background:var(--accent-dim); color:var(--accent-hover); }
.activity-icon.chat { background:var(--yellow-dim); color:var(--yellow); }
.activity-text { font-size:13px; line-height:1.4; }
.activity-time { font-size:11px; color:var(--text-tertiary); margin-top:2px; }

/* System Stats */
.stats-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(250px,1fr)); gap:12px; }
.stat-card { display:flex; align-items:center; gap:14px; }
.stat-icon { width:42px; height:42px; border-radius:var(--radius); display:flex; align-items:center; justify-content:center; font-size:18px; }
.stat-label { font-size:12px; color:var(--text-tertiary); margin-bottom:2px; }
.stat-value { font-size:15px; font-weight:600; }

/* Settings */
.settings-section { margin-bottom:32px; }
.settings-section-title { font-size:16px; font-weight:600; margin-bottom:12px; padding-bottom:8px; border-bottom:1px solid var(--border); }
.rule-item { display:flex; align-items:center; gap:10px; padding:10px 0; border-bottom:1px solid var(--border); }
.rule-item:last-child { border-bottom:none; }
.rule-text { flex:1; font-size:13px; }
.rule-actions { display:flex; gap:4px; }

/* Heartbeat */
.hb-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(200px,1fr)); gap:12px; margin-bottom:24px; }
.hb-stat { text-align:center; padding:16px; }
.hb-stat-value { font-size:24px; font-weight:700; margin-bottom:4px; }
.hb-stat-label { font-size:12px; color:var(--text-tertiary); }

/* Nav Section Label */
.nav-section-label { font-size:10px; font-weight:600; text-transform:uppercase; letter-spacing:1px; color:var(--text-tertiary); padding:16px 12px 4px; }

/* Project Pages */
.project-icon-lg { width:48px; height:48px; border-radius:var(--radius-lg); background:var(--accent-dim); display:flex; align-items:center; justify-content:center; color:var(--accent-hover); font-size:20px; flex-shrink:0; }
.project-tabs { display:flex; gap:4px; margin-bottom:20px; border-bottom:1px solid var(--border); padding-bottom:0; }
.project-tab { padding:8px 16px; font-size:13px; font-weight:500; color:var(--text-secondary); background:none; border:none; border-bottom:2px solid transparent; cursor:pointer; transition:all var(--transition); font-family:inherit; }
.project-tab:hover { color:var(--text-primary); }
.project-tab.active { color:var(--accent-hover); border-bottom-color:var(--accent); }
.project-tab-content.hidden { display:none; }
.research-file { margin-bottom:24px; }
.research-file-name { font-size:12px; font-weight:500; color:var(--text-tertiary); margin-bottom:8px; display:flex; align-items:center; gap:6px; }
.research-content { background:var(--bg-secondary); border:1px solid var(--border); border-radius:var(--radius-lg); padding:24px 28px; }
.research-content h1,.research-content h2,.research-content h3 { margin:20px 0 8px; }
.research-content h1 { font-size:22px; }
.research-content h2 { font-size:18px; color:var(--text-primary); }
.research-content h3 { font-size:15px; color:var(--text-secondary); }
.research-content p { margin:8px 0; color:var(--text-secondary); line-height:1.7; }
.research-content ul,.research-content ol { margin:8px 0 8px 20px; color:var(--text-secondary); }
.research-content li { margin:4px 0; line-height:1.6; }
.research-content a { color:var(--accent-hover); text-decoration:none; }
.research-content a:hover { text-decoration:underline; }
.research-content blockquote { border-left:3px solid var(--accent); padding:8px 16px; margin:12px 0; color:var(--text-secondary); background:var(--bg-tertiary); border-radius:0 var(--radius) var(--radius) 0; }
.research-content code { background:var(--bg-tertiary); padding:2px 6px; border-radius:4px; font-size:12px; }
.research-content strong { color:var(--text-primary); }
.research-empty { color:var(--text-tertiary); font-size:13px; padding:20px; display:flex; align-items:center; gap:8px; }
.project-notes-textarea { min-height:300px; font-size:14px; line-height:1.7; resize:vertical; }
.notes-status { font-size:12px; color:var(--green); margin-top:8px; height:16px; }

/* ====== FINANCE MODULE ====== */
.finance-tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--border); padding: 0 32px 8px; }
#fin-header { padding: 32px 32px 8px; }
#fin-header .page-header { margin-bottom: 0; }
#fin-content { padding: 0 32px 32px; max-width: 1400px; }
.fin-tab { background: none; border: none; color: var(--text-secondary); padding: 8px 16px; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 500; transition: all 0.15s; }
.fin-tab:hover { background: var(--card-bg); color: var(--text-primary); }
.fin-tab.active { background: var(--accent); color: #fff; }

.fin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-bottom: 20px; }
.fin-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.fin-card.compact { padding: 14px; }
.fin-card-header { font-weight: 600; font-size: 14px; margin-bottom: 10px; color: var(--text-primary); }
.fin-card-equity { font-size: 22px; font-weight: 700; margin-bottom: 12px; color: var(--text-primary); }
.fin-acct-row { display: flex; justify-content: space-between; font-size: 12px; padding: 4px 0; color: var(--text-secondary); }
.fin-acct-row.cc { color: var(--text-secondary); }
.fin-row { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 0; }
.fin-row.total { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 8px; font-weight: 600; }

.fin-pnl-entity { background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; padding: 20px; margin-bottom: 16px; }
.fin-pnl-entity h4 { margin-bottom: 12px; font-size: 16px; }
.fin-section-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); margin: 12px 0 6px; font-weight: 600; }
.fin-line { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; }
.fin-line.total { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 6px; font-weight: 600; }
.fin-line.net { border-top: 2px solid var(--border); margin-top: 8px; padding-top: 8px; font-weight: 700; font-size: 15px; }

.fin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.fin-table th { text-align: left; padding: 8px 12px; border-bottom: 2px solid var(--border); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); }
.fin-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.fin-table tr:hover td { background: var(--card-bg); }

.fin-cat-badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--card-bg); border: 1px solid var(--border); }
.fin-filter { margin-bottom: 12px; }
.fin-filter select { background: var(--card-bg); border: 1px solid var(--border); color: var(--text-primary); padding: 6px 12px; border-radius: 6px; font-size: 13px; }

.fin-meta { font-size: 12px; color: var(--text-secondary); margin-top: 20px; }
.positive { color: #4ade80; }
.negative { color: #f87171; }

/* Finance v2 */
.fin-top-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.fin-top-bar .finance-tabs { flex: 1; }
.fin-card-actions { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.btn-xs { font-size: 11px; padding: 4px 10px; border-radius: 5px; background: var(--card-bg); border: 1px solid var(--border); color: var(--text-secondary); cursor: pointer; transition: all 0.15s; }
.btn-xs:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-warn { border-color: #f59e0b; color: #f59e0b; }
.btn-warn:hover { background: #f59e0b; color: #000; }
.fin-month-select { margin-top: 16px; font-size: 13px; }
.fin-month-select select { background: var(--card-bg); border: 1px solid var(--border); color: var(--text-primary); padding: 4px 8px; border-radius: 4px; }

.fin-overview-header { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.fin-month-picker select { background: var(--card-bg); border: 1px solid var(--border); color: var(--text-primary); padding: 8px 14px; border-radius: 6px; font-size: 15px; font-weight: 600; }
.fin-meta-inline { font-size: 12px; color: var(--text-secondary); }

/* P&L Drilldown */
.fin-drilldown { cursor: pointer; border-radius: 4px; padding: 4px 8px !important; margin: 0 -8px; transition: background 0.15s; }
.fin-drilldown:hover { background: rgba(255,255,255,0.05); }
.fin-drilldown.selected { background: rgba(37,99,235,0.15); border-left: 3px solid var(--accent); }
.fin-pnl-layout { display: flex; gap: 24px; align-items: flex-start; flex-wrap: nowrap; }
.fin-pnl-left { flex: 0 0 440px; }
.fin-pnl-right { flex: 1; min-width: 300px; position: sticky; top: 20px; max-height: calc(100vh - 120px); overflow-y: auto; }
.fin-card-sync { font-size: 11px; color: var(--text-tertiary); font-weight: 400; margin-top: 2px; }
.fin-tab-badge { display: inline-flex; align-items: center; justify-content: center; background: #f59e0b; color: #000; font-size: 10px; font-weight: 700; width: 16px; height: 16px; border-radius: 50%; margin-left: 6px; }
.fin-accounts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.fin-account-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.fin-account-card.disconnected { border-color: #f59e0b; }
.fin-account-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.fin-account-name { font-weight: 600; font-size: 14px; }
.fin-account-status { font-size: 12px; }
.fin-account-status.connected { color: var(--text-tertiary); }
.fin-account-status.disconnected { color: #f59e0b; }
.fin-account-detail { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; color: var(--text-secondary); border-bottom: 1px solid var(--border); }
.fin-account-detail:last-of-type { border-bottom: none; }
.fin-account-error { font-size: 12px; color: #f59e0b; margin-top: 8px; padding: 6px 10px; background: rgba(245,158,11,0.08); border-radius: 6px; }
.fin-reconnect-btn { margin-top: 12px; display: inline-block; text-decoration: none; text-align: center; }
.fin-bf-badge { display: inline-block; font-size: 9px; font-weight: 700; background: rgba(139,92,246,0.15); color: #a78bfa; padding: 1px 5px; border-radius: 4px; margin-left: 6px; vertical-align: middle; }
.fin-drilldown-placeholder { color: var(--text-secondary); font-size: 13px; text-align: center; padding: 40px 20px; opacity: 0.5; border: 1px dashed var(--border); border-radius: 10px; }
.fin-drilldown-box { background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; padding: 20px; }
.fin-drilldown-box h4 { margin-bottom: 12px; font-size: 14px; }
@media (max-width: 900px) { .fin-pnl-layout { flex-direction: column; } .fin-pnl-left { flex: 1; min-width: 0; } .fin-pnl-right { position: static; max-height: none; } }
.fin-pnl-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.fin-pnl-header h3 { margin: 0; }
.fin-pnl-header select, .fin-period-sel input[type="date"] { background: var(--card-bg); border: 1px solid var(--border); color: var(--text-primary); padding: 6px 12px; border-radius: 6px; font-size: 14px; }
.fin-period-sel { display: flex; align-items: center; gap: 8px; }
.fin-sub-header-bar { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; padding: 0 32px; }
.fin-sub-header-bar h3 { margin: 0; font-size: 16px; font-weight: 600; white-space: nowrap; }


/* Finance Health Warnings */
.fin-health-warning {
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
}
.fin-health-title {
  font-weight: 600;
  color: #fbbf24;
  margin-bottom: 8px;
  font-size: 14px;
}
.fin-health-account {
  font-size: 13px;
  color: #e0e0e0;
  padding: 4px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.fin-health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.fin-health-dot.connected { background: #4ade80; }
.fin-health-dot.disconnected { background: #f87171; }
.fin-health-dot.error { background: #fbbf24; }
.fin-health-note {
  font-size: 12px;
  color: #888;
  margin-top: 8px;
  font-style: italic;
}
.fin-card-health-warn {
  background: rgba(251, 191, 36, 0.1);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 11px;
  color: #fbbf24;
  margin-bottom: 8px;
}
.fin-card.has-health-warning {
  border-color: rgba(251, 191, 36, 0.3);
}

/* P&L Subtotal line */
.fin-line.subtotal {
  border-top: 1px dashed #444;
  padding-top: 6px;
  margin-top: 4px;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 14px;
}

/* Transaction Filters */
.fin-filters {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.fin-filters select {
  background: #1a1a1a;
  color: #e0e0e0;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  min-width: 140px;
}
.fin-filters select:focus {
  outline: none;
  border-color: #2563eb;
}

/* Fix date column width */
.fin-table th:first-child,
.fin-table td:first-child {
  white-space: nowrap;
  min-width: 110px;
}

/* ── Login Page ── */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100vw;
  background: var(--bg-primary);
}
.login-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px;
  text-align: center;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.login-logo { font-size: 48px; margin-bottom: 16px; }
.login-title { font-size: 22px; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.login-subtitle { font-size: 14px; color: var(--text-tertiary); margin-bottom: 32px; }
.login-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 12px 28px;
  background: #fff;
  color: #333;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: box-shadow 0.2s, transform 0.1s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.login-btn:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.3); transform: translateY(-1px); }

/* ── User Info in Sidebar ── */
.user-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  margin-top: 8px;
  background: var(--bg-tertiary);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}
.user-info.hidden { display: none; }
.user-info-details {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-info-details i { color: var(--accent); font-size: 14px; }
.logout-btn {
  color: var(--text-tertiary);
  font-size: 14px;
  text-decoration: none;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}
.logout-btn:hover { color: var(--red); background: var(--red-dim); }

/* ====== Ranch Office v2 ====== */

/* Location sub-tabs */
.ro-location-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 20px;
}
.ro-location-tab {
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  background: none;
  font-family: inherit;
}
.ro-location-tab:hover { color: var(--text-primary); background: var(--bg-hover); }
.ro-location-tab.active { background: var(--accent); color: #fff; }

/* Floor tabs */
.ro-floor-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 16px;
}
.ro-floor-tab {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
  background: none;
  font-family: inherit;
}
.ro-floor-tab:hover { color: var(--text-primary); border-color: var(--border); }
.ro-floor-tab.active { color: var(--accent-hover); border-color: var(--accent); background: var(--accent-dim); }

/* Floor plan container */
.ro-floorplan-grid {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  min-height: 300px;
  position: relative;
}

/* SVG Floor Plan */
.ro-svg-floorplan {
  max-height: 500px;
  width: 100%;
}

.fp-office rect {
  transition: fill 0.2s ease, stroke-width 0.2s ease, filter 0.2s ease;
}

.fp-office:hover rect {
  filter: brightness(1.4);
  stroke-width: 2.5;
}

.fp-office:hover {
  filter: drop-shadow(0 0 6px rgba(255,255,255,0.1));
}

/* Tooltip */
.ro-tooltip {
  position: fixed;
  z-index: 1000;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 12px;
  max-width: 280px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  line-height: 1.5;
}
.ro-tooltip.visible { opacity: 1; }
.ro-tooltip .tt-name { font-weight: 600; font-size: 13px; color: var(--text-primary); }
.ro-tooltip .tt-company { color: var(--accent-hover); font-size: 12px; }
.ro-tooltip .tt-detail { color: var(--text-secondary); font-size: 11px; margin-top: 4px; }
.ro-tooltip .tt-vacant { color: var(--red); font-weight: 500; }

/* Task feed */
.ro-task-feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 500px;
  overflow-y: auto;
  padding-right: 4px;
}

.ro-task-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  border-left: 3px solid var(--text-tertiary);
  transition: all var(--transition);
}
.ro-task-card:hover { border-color: var(--border-light); background: var(--bg-tertiary); }

/* Task type colors */
.ro-task-card[data-type="lead"] { border-left-color: var(--blue); }
.ro-task-card[data-type="maintenance"] { border-left-color: var(--yellow); }
.ro-task-card[data-type="member-issue"] { border-left-color: var(--red); }
.ro-task-card[data-type="invoice"] { border-left-color: #f97316; }
.ro-task-card[data-type="follow-up"] { border-left-color: #a855f7; }
.ro-task-card[data-type="general"] { border-left-color: var(--text-tertiary); }

.ro-task-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.ro-task-title { font-weight: 600; font-size: 13px; color: var(--text-primary); }
.ro-task-desc { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; line-height: 1.4; }
.ro-task-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ro-task-member { font-size: 11px; color: var(--accent-hover); }
.ro-task-time { font-size: 11px; color: var(--text-tertiary); }

/* Task type badges */
.ro-type-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.ro-type-lead { background: var(--blue-dim); color: var(--blue); }
.ro-type-maintenance { background: var(--yellow-dim); color: var(--yellow); }
.ro-type-member-issue { background: var(--red-dim); color: var(--red); }
.ro-type-invoice { background: rgba(249,115,22,0.15); color: #fb923c; }
.ro-type-follow-up { background: rgba(168,85,247,0.15); color: #c084fc; }
.ro-type-general { background: var(--bg-tertiary); color: var(--text-tertiary); }

/* Priority */
.ro-pri-urgent { color: #ef4444; font-weight: 700; }
.ro-pri-high { color: #f97316; font-weight: 600; }
.ro-pri-medium { color: #eab308; }
.ro-pri-low { color: var(--text-tertiary); }

.ro-priority-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
}
.ro-priority-dot.urgent { background: #ef4444; box-shadow: 0 0 6px rgba(239,68,68,0.5); }
.ro-priority-dot.high { background: #f97316; box-shadow: 0 0 6px rgba(249,115,22,0.4); }
.ro-priority-dot.medium { background: #eab308; }
.ro-priority-dot.low { background: var(--text-tertiary); }

/* Task action buttons */
.ro-task-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.ro-action-btn {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.ro-action-btn:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-light); }
.ro-action-btn.done-btn { color: var(--green); border-color: rgba(34,197,94,0.3); }
.ro-action-btn.done-btn:hover { background: var(--green-dim); }

/* FAB for adding tasks */
.ro-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(99,102,241,0.4);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.ro-fab:hover { background: var(--accent-hover); transform: scale(1.08); }

/* Stats row for location */
.ro-stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.ro-stat-mini {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  text-align: center;
}
.ro-stat-mini .stat-num { font-size: 22px; font-weight: 700; }
.ro-stat-mini .stat-lbl { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }
