/* Perch.ai — Base Styles */

:root {
  --perch-primary: #2563eb;
  --perch-secondary: #7c3aed;
  --perch-bg: #f8fafc;
  --perch-surface: #ffffff;
  --perch-text: #1e293b;
  --perch-text-muted: #64748b;
  --perch-border: #e2e8f0;
  --perch-success: #22c55e;
  --perch-warning: #f59e0b;
  --perch-error: #ef4444;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--perch-bg);
  color: var(--perch-text);
  height: 100vh;
  overflow: hidden;
}

/* Loader */
.loader-tallyfor {
  width: 24px; height: 24px;
  border: 3px solid var(--perch-border);
  border-top-color: var(--perch-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Skeleton loading */
@keyframes skeleton-pulse { 0% { opacity: 0.6; } 50% { opacity: 0.3; } 100% { opacity: 0.6; } }
.skeleton { background: var(--perch-border); border-radius: 6px; animation: skeleton-pulse 1.5s ease-in-out infinite; }
.skeleton-card { height: 80px; border-radius: 8px; margin-bottom: 12px; }
.skeleton-row { height: 16px; margin-bottom: 10px; border-radius: 4px; }
.skeleton-row.w75 { width: 75%; }
.skeleton-row.w50 { width: 50%; }
.skeleton-row.w90 { width: 90%; }
.skeleton-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }

/* Navigation */
.perch-nav {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 20px; height: 48px;
  background: var(--perch-surface);
  border-bottom: 1px solid var(--perch-border);
}
.nav-brand { font-size: 18px; font-weight: 700; color: var(--perch-primary); }
.nav-links { display: flex; gap: 12px; }
.nav-links button {
  padding: 4px 14px; border: 1px solid var(--perch-border);
  border-radius: 6px; background: transparent; cursor: pointer;
  font-size: 13px; color: var(--perch-text);
}
.nav-links button:hover { background: var(--perch-bg); }

/* App shell */
.perch-app { display: flex; flex-direction: column; height: 100vh; }
.perch-main { max-width: 400px; margin: 0 auto; padding: 24px; }

/* Auth split layout */
.auth-split { display: flex; flex: 1; overflow: hidden; }
.auth-split-left {
  flex: 1; background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 50%, #3b82f6 100%);
  display: flex; align-items: center; justify-content: center; padding: 40px;
}
.auth-split-content { max-width: 480px; color: white; }
.auth-split-content img { margin-bottom: 24px; }
.auth-split-content h1 {
  font-size: 32px; font-weight: 800; line-height: 1.2; margin-bottom: 16px;
}
.auth-split-content > p {
  font-size: 16px; line-height: 1.6; opacity: 0.9; margin-bottom: 32px;
}
.auth-split-features { display: flex; flex-direction: column; gap: 14px; margin-bottom: 32px; }
.auth-feature {
  font-size: 15px; line-height: 1.4; opacity: 0.95;
}
.auth-split-free {
  font-size: 13px; opacity: 0.7; letter-spacing: 0.02em;
}
.auth-split-right {
  width: 480px; min-width: 400px; display: flex; align-items: center;
  justify-content: center; padding: 40px; background: var(--perch-bg);
}
.auth-split-right .auth-container { max-width: 380px; width: 100%; }
@media (max-width: 900px) {
  .auth-split { flex-direction: column; }
  .auth-split-left { display: none; }
  .auth-split-right { width: 100%; min-width: unset; flex: 1; }
}

/* === Workspace: side-by-side dashboard + chat === */
.workspace {
  display: flex; flex: 1; overflow: hidden;
}
.workspace-dashboard {
  flex: 1; min-width: 0; overflow-y: auto; overflow-x: hidden;
  padding: 20px 24px;
  border-right: 1px solid var(--perch-border);
  container-type: inline-size; container-name: dashboard;
}
.workspace-chat {
  width: 420px; min-width: 360px;
  display: flex; flex-direction: column;
  background: var(--perch-surface);
  overflow: hidden; height: 100%;
}
.workspace.chat-collapsed .workspace-dashboard { border-right: none; }
.chat-toggle {
  width: 36px; padding: 0; border: none; border-left: 1px solid var(--perch-border);
  background: var(--perch-surface); color: var(--perch-text-muted);
  cursor: pointer; font-size: 10px; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; transition: background 0.15s;
}
.chat-toggle:hover { background: var(--perch-bg); color: var(--perch-text); }
.chat-toggle-icon { width: 22px; height: 22px; opacity: 0.6; }
.chat-toggle:hover .chat-toggle-icon { opacity: 1; }

/* Auth */
.auth-container { max-width: 400px; margin: 80px auto; text-align: center; }
.auth-logo { height: 48px; margin-bottom: 8px; }
.auth-container p { color: var(--perch-text-muted); margin-bottom: 32px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form input {
  padding: 10px 14px; border: 1px solid var(--perch-border);
  border-radius: 6px; font-size: 14px;
}
.auth-form button {
  padding: 10px 14px; border: none; border-radius: 6px;
  background: var(--perch-primary); color: white;
  font-size: 14px; cursor: pointer;
}
.auth-form button:hover { opacity: 0.9; }
.auth-form a { color: var(--perch-primary); cursor: pointer; font-size: 13px; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; }
.auth-links a { font-size: 12px; }
.auth-field-error { color: var(--perch-error); font-size: 12px; margin-top: -4px; text-align: left; }
.input-error { border-color: var(--perch-error) !important; }
/* OAuth provider buttons */
.auth-providers {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;
}
.oauth-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 14px; border: none; border-radius: 6px;
  font-size: 14px; font-weight: 400; cursor: pointer; color: white;
}
.oauth-btn:hover { opacity: 0.85; }
.oauth-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.google-btn { background: #fff; color: #3c4043; border: 1px solid #dadce0; }
.google-btn:hover { background: #f7f8f8; color: #3c4043; opacity: 1; }
.apple-btn { background: #000; }
.microsoft-btn { background: #2f2f2f; }
.auth-error {
  background: #fef2f2; color: var(--perch-error); border: 1px solid #fecaca;
  padding: 8px 12px; border-radius: 6px; font-size: 13px; text-align: left;
}
.auth-success {
  background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0;
  padding: 12px; border-radius: 6px; font-size: 14px; text-align: center;
}
.auth-divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--perch-text-muted); font-size: 13px;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--perch-border);
}

/* === Agent Chat (right panel) === */
/* Agent status chips in chat sidebar */
/* Agent status chips in chat sidebar */
.chat-agents {
  padding: 10px 16px; border-bottom: 1px solid var(--perch-border);
  background: #f8fafc; flex-shrink: 0;
}
.chat-agents-header {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; user-select: none;
}
.chat-agents-header:hover { opacity: 0.7; }
.chat-agents-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--perch-text-muted); margin-bottom: 0;
}
.chat-agents-toggle {
  font-size: 10px; color: var(--perch-text-muted); transition: transform 0.15s;
}
.chat-agents-toggle.collapsed { transform: rotate(-90deg); }
.chat-agents-row { margin-top: 8px; }
.chat-agents-row.collapsed { display: none; }
.chat-agents-row {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.chat-agent-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 20px;
  font-size: 12px; color: var(--perch-text-muted);
  background: var(--perch-surface);
  border: 1px solid var(--perch-border);
}
.chat-agent-chip.chat-agent-active {
  background: #f0fdf4; color: #16a34a;
  border-color: #bbf7d0;
}
.chat-agent-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #d1d5db;
}
.chat-agent-active .chat-agent-dot {
  background: #22c55e;
}

.agent-chat-panel {
  display: flex; flex-direction: column; flex: 1; min-height: 0;
}
.chat-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; border-bottom: 1px solid var(--perch-border);
  background: var(--perch-surface); flex-shrink: 0;
}
.chat-header span { font-size: 14px; font-weight: 600; }
.chat-header button {
  padding: 4px 10px; border: 1px solid var(--perch-border);
  border-radius: 6px; background: transparent; cursor: pointer; font-size: 12px;
}

.message-list { flex: 1; overflow-y: auto; padding: 12px 16px; min-height: 0; }
.message-bubble { margin-bottom: 10px; max-width: 90%; }
.message-bubble.user { margin-left: auto; }
.message-bubble.assistant { margin-right: auto; }
.message-content {
  padding: 8px 12px; border-radius: 10px;
  font-size: 13px; line-height: 1.5;
}
.user .message-content { background: var(--perch-primary); color: white; }
.assistant .message-content { background: var(--perch-bg); border: 1px solid var(--perch-border); }

.chat-input-container {
  display: flex; gap: 6px; padding: 10px 12px;
  border-top: 1px solid var(--perch-border);
  background: var(--perch-surface); flex-shrink: 0;
}
.chat-input-container textarea {
  flex: 1; padding: 8px 12px; border: 1px solid var(--perch-border);
  border-radius: 8px; font-size: 13px; resize: none; min-height: 38px; max-height: 100px;
  font-family: inherit;
}
.chat-input-container button {
  padding: 8px 16px; border: none; border-radius: 8px;
  background: var(--perch-primary); color: white; cursor: pointer; font-size: 13px;
  align-self: flex-end;
}
.chat-input-container button:disabled { opacity: 0.5; cursor: not-allowed; }

/* === Pipeline Dashboard (left panel) === */
.pipeline-dashboard { }
.pipeline-dashboard h2 { font-size: 16px; margin: 0; }
.section-header {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 4px 0; margin-bottom: 12px; user-select: none;
}
.section-header:hover { opacity: 0.7; }
.section-toggle { font-size: 10px; color: var(--perch-text-muted); width: 14px; }

/* Active Agents */
.active-agents { margin-bottom: 16px; text-align: center; }
.agents-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1.5px; color: var(--perch-text-muted); margin-bottom: 8px;
}
.agents-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.agent-card {
  width: 80px; height: 80px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  border: 1px solid var(--perch-border); border-radius: 8px;
  background: var(--perch-bg); position: relative;
}
.agent-name {
  font-size: 10px; font-weight: 600; color: var(--perch-text-muted);
  text-align: center; line-height: 1.2;
}
.agent-dot {
  position: absolute; top: 6px; right: 6px;
  width: 7px; height: 7px; border-radius: 50%; background: #d1d5db;
}
.agent-card.agent-active {
  border-color: var(--perch-success); background: #f0fdf4;
}
.agent-card.agent-active .agent-name { color: var(--perch-text); }
.agent-card.agent-active .agent-dot { background: var(--perch-success); }
.agent-card.agent-add {
  border-style: dashed; cursor: pointer;
  font-size: 20px; font-weight: 600; color: var(--perch-text-muted);
}
.agent-card.agent-add:hover {
  border-color: var(--perch-primary); color: var(--perch-primary); background: #eff6ff;
}

/* Pipeline layout — stacked layers */
.pipeline-layout {
  display: flex; flex-direction: column; width: 100%; gap: 0;
  padding: 24px 0; min-width: 0;
}
.pipeline-layer {
  width: 100%; min-width: 0;
  border: 1px solid var(--perch-border); border-radius: 8px;
  padding: 16px; background: var(--perch-surface);
}
.pipeline-layer.layer-complete       { border-color: var(--perch-success); }
.pipeline-layer.layer-sources       { border-left: 3px solid var(--perch-primary); }
.pipeline-layer.layer-transactions  { border-left: 3px solid #f97316; }
.pipeline-layer.layer-trial-balance { border-left: 3px solid #8b5cf6; }
.pipeline-layer.layer-properties    { border-left: 3px solid #06b6d4; }
.pipeline-layer.layer-finance       { border-left: 3px solid var(--perch-warning); }
.pipeline-layer.layer-tax           { border-left: 3px solid var(--perch-success); }

.layer-header {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1.5px; color: var(--perch-text-muted); margin-bottom: 8px;
  cursor: pointer; display: flex; align-items: center; gap: 6px;
  user-select: none;
}
.layer-header:hover { color: var(--perch-text); }
.layer-toggle { font-size: 8px; }
.layer-collapsed { padding-bottom: 8px; }
.layer-collapsed .layer-header { margin-bottom: 0; }

/* Collapse / Expand All controls */
.collapse-controls { display: flex; justify-content: flex-start; margin-bottom: 8px; }
.collapse-btn {
  padding: 2px 10px; font-size: 11px; font-weight: 500;
  border: 1px solid var(--perch-border); border-radius: 4px;
  background: transparent; cursor: pointer; color: var(--perch-text-muted);
}
.collapse-btn:hover { background: var(--perch-bg); color: var(--perch-text); }
.layer-content { min-width: 0; overflow: visible; }
.layer-sources .layer-content     { display: flex; gap: 16px; }
.layer-trial-balance .layer-content { display: flex; gap: 16px; }
.layer-properties .layer-content {
  display: flex; gap: 16px;
}
.layer-properties .properties-grid {
  flex: 1; min-width: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px;
}
.layer-finance .layer-content    { display: flex; gap: 16px; }
.layer-tax .layer-content        { display: flex; gap: 16px; }

/* Connector between layers */
.pipeline-connector {
  display: flex; justify-content: center; padding: 4px 0;
}
.pipeline-connector::before {
  content: ''; display: block; width: 2px; height: 20px;
  background: var(--perch-border);
}

/* TB status card (fallback when no properties) */
.tb-status-card {
  display: flex; align-items: center; gap: 12px;
  font-size: 13px; color: var(--perch-text);
}
.tb-status-card .tb-badge, .tb-badge {
  font-size: 11px; padding: 2px 8px; border-radius: 4px;
  background: #f0fdf4; color: var(--perch-success); font-weight: 500;
}
.tb-empty {
  color: var(--perch-text-muted); font-style: italic; font-size: 13px;
}

/* Per-property TB cards */
.tb-props-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.tb-props-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px;
  min-width: 0; width: 100%;
}
.tb-props-grid:has(.tb-property-detail) {
  grid-template-columns: 1fr;
}
.tb-prop-card-wrap { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.tb-prop-card {
  padding: 12px 14px; border: 1px solid var(--perch-border); border-radius: 8px;
  background: var(--perch-surface); cursor: pointer; transition: all 0.15s ease;
}
.tb-prop-card:hover { border-color: #8b5cf6; }
.tb-prop-card.tb-prop-expanded { border-color: #8b5cf6; background: #faf5ff; }
.tb-prop-name { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.tb-prop-stats {
  display: flex; gap: 6px; font-size: 11px; color: var(--perch-text-muted);
}
.tb-prop-stats .pos { color: var(--perch-success); font-weight: 500; }
.tb-prop-stats .neg { color: var(--perch-error); font-weight: 500; }
.tb-portfolio-summary {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--perch-text-muted); padding-top: 4px;
}

/* TB detail panel (GL left + TB right) */
.tb-property-detail {
  margin-top: 8px; border: 1px solid #e9d5ff; border-radius: 8px;
  background: white; overflow: hidden; min-width: 0;
}
.tb-detail-columns {
  display: flex; gap: 0; min-width: 0; width: 100%;
}
.tb-detail-columns > .tb-gl-section {
  flex: 3; min-width: 0; border-right: 1px solid var(--perch-border);
  display: flex; flex-direction: column; max-height: 600px;
}
.tb-detail-columns > .tb-detail-section:last-child {
  flex: 2; min-width: 0;
  display: flex; flex-direction: column; max-height: 600px;
}
.tb-detail-section { padding: 12px 16px 0; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.tb-detail-section > .report-table-wrap { flex: 1; overflow-y: auto; overflow-x: auto; padding-bottom: 12px; }
.tb-detail-title {
  font-size: 13px; font-weight: 600; margin-bottom: 10px; color: var(--perch-text);
}
.tb-detail-empty {
  font-size: 12px; color: var(--perch-text-muted); font-style: italic; padding: 8px 0;
}

/* GL period filter bar */
.gl-period-bar {
  display: flex; align-items: center; gap: 4px; margin-bottom: 6px;
}
.gl-period-btn {
  padding: 3px 10px; border: 1px solid var(--perch-border); border-radius: 4px;
  background: transparent; cursor: pointer; font-size: 11px;
  color: var(--perch-text-muted);
}
.gl-period-btn:hover { background: var(--perch-bg); }
.gl-period-btn.active {
  background: #8b5cf6; color: white; border-color: #8b5cf6;
}
.gl-period-select {
  padding: 3px 6px; border: 1px solid var(--perch-border); border-radius: 4px;
  font-size: 11px; background: var(--perch-bg); cursor: pointer;
}

/* Sortable table headers */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: #8b5cf6; }
.sort-caret {
  display: inline-block; margin-left: 4px; font-size: 8px;
  color: var(--perch-text-muted); opacity: 0.3; transition: opacity 0.15s;
}
.sort-caret.active { opacity: 1; color: #8b5cf6; }

/* GL table */
.gl-table { font-size: 12px; }
.gl-table th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.gl-desc { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gl-total td { border-top: 2px solid var(--perch-border); }
.gl-account { font-size: 12px; }
.category-code {
  font-size: 10px; padding: 1px 5px; border-radius: 3px;
  background: #f3e8ff; color: #8b5cf6; font-weight: 500;
}

/* TB summary table */
.tb-summary-table { font-size: 12px; }
.tb-summary-table th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.tb-code { font-size: 11px; color: var(--perch-text-muted); }
.tb-section-header td { padding-top: 10px; }
.tb-type-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 6px; vertical-align: middle;
}
.tb-totals td { border-top: 2px solid var(--perch-border); }
.tb-balanced td { text-align: center; padding-top: 8px; }

/* Override layer-trial-balance content to allow column layout for detail expansion */
.layer-trial-balance .layer-content { display: flex; gap: 16px; }

/* Add source button */
.add-source-btn {
  width: 32px; min-width: 32px; display: flex; align-items: center; justify-content: center;
  border: 2px dashed var(--perch-border); border-radius: 8px;
  background: var(--perch-bg); color: var(--perch-text-muted);
  font-size: 20px; font-weight: 600; cursor: pointer;
  transition: all 0.15s ease; align-self: stretch;
}
.add-source-btn:hover {
  border-color: var(--perch-primary); color: var(--perch-primary);
  background: #eff6ff;
}

/* Modal dialog */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
.modal-card {
  background: var(--perch-surface); border-radius: 12px;
  padding: 24px; min-width: 320px; max-width: 420px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}
.modal-title {
  font-size: 16px; font-weight: 600; margin-bottom: 8px;
}
.modal-message {
  font-size: 13px; color: var(--perch-text-muted); margin-bottom: 20px;
  line-height: 1.5;
}
.modal-actions {
  display: flex; gap: 8px; justify-content: flex-end;
}
.onboarding-modal { text-align: center; max-width: 440px; }
.onboarding-option {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border: 1px solid var(--perch-border); border-radius: 8px;
  cursor: pointer; text-align: left; transition: all 0.15s;
}
.onboarding-option:hover { border-color: var(--perch-primary); background: #eff6ff; }

/* Add source dropdown menu */
.add-source-wrapper { position: relative; align-self: stretch; }
.add-source-wrapper .add-source-btn { height: 100%; }
.menu-backdrop {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 9;
}
.add-source-menu {
  position: absolute; top: 0; left: 40px; z-index: 10;
  background: var(--perch-surface); border: 1px solid var(--perch-border);
  border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  min-width: 180px; overflow: hidden;
}
.add-menu-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; cursor: pointer; font-size: 13px;
  color: var(--perch-text); transition: background 0.1s;
}
.add-menu-item:hover { background: var(--perch-bg); }
.add-menu-item + .add-menu-item { border-top: 1px solid var(--perch-border); }
.add-menu-badge {
  font-size: 10px; padding: 1px 6px; border-radius: 3px;
  background: #f0fdf4; color: var(--perch-success); font-weight: 500;
}

/* Slot timestamp */
.slot-timestamp {
  font-size: 10px; color: var(--perch-text-muted); margin-top: 4px;
  font-style: italic;
}

/* Card width overrides within pipeline context */
.layer-sources .slot-card      { flex: 1; width: auto; }
.layer-sources .slot-drop-zone { flex: 1; width: auto; }
.layer-finance .slot-card,
.layer-tax .slot-card           { width: 100%; }
.layer-finance .bookings-card   { width: 100%; }
.layer-properties .property-card { width: auto; }

.slot-card {
  position: relative;
  width: 160px; padding: 20px; text-align: center;
  border: 2px solid var(--perch-border); border-radius: 12px;
  background: var(--perch-surface);
  transition: all 0.15s ease;
}

/* Card kebab menu (⋮) */
.card-menu { position: absolute; top: 6px; right: 6px; z-index: 10; }
.card-menu-btn {
  background: none; border: none; cursor: pointer;
  font-size: 18px; line-height: 1; color: var(--perch-text-muted);
  padding: 2px 6px; border-radius: 4px;
  opacity: 0; transition: opacity 0.15s ease;
}
.slot-card:hover .card-menu-btn,
.slot-drop-zone:hover .card-menu-btn { opacity: 1; }
.card-menu-btn:hover { background: rgba(0,0,0,0.06); color: var(--perch-text); }
.card-menu-dropdown {
  position: absolute; top: 100%; right: 0;
  min-width: 140px; padding-top: 2px;
  text-align: left;
}
.card-menu-dropdown-inner {
  background: white; border: 1px solid var(--perch-border);
  border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  padding: 4px 0;
}
.card-menu-item {
  display: block; width: 100%; padding: 7px 14px;
  border: none; background: none; text-align: left;
  font-size: 13px; color: var(--perch-text); cursor: pointer;
  white-space: nowrap;
}
.card-menu-item:hover { background: #f3f4f6; }
.card-menu-danger { color: var(--perch-error); }
.card-menu-danger:hover { background: #fef2f2; }
.slot-card.slot-connected { border-color: var(--perch-success); }
.slot-card.slot-error { border-color: var(--perch-error); }
.slot-card.slot-connecting { border-color: var(--perch-warning); }
.slot-icon { font-size: 24px; font-weight: 700; color: var(--perch-primary); margin-bottom: 6px; }
.slot-label { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.slot-status { font-size: 11px; color: var(--perch-text-muted); }
.slot-provider { font-size: 10px; color: var(--perch-text-muted); margin-top: 4px; text-transform: capitalize; }

/* === Accounting Drop Zone (the "A" card) === */
.slot-drop-zone {
  width: 200px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center;
}
.slot-drop-zone.drop-idle {
  border: 2px dashed #5FA4F3; background: #E6F1FE;
}
.slot-drop-zone.drop-dragover {
  border: 2px dashed #489A40; background: #C9F6C8;
}
.slot-drop-zone.drop-ready {
  border: 2px dashed var(--perch-warning); background: #FFF8E6;
}
.drop-icon { color: #5FA4F3; margin-bottom: 4px; }
.drop-dragover .drop-icon { color: #489A40; }
.drop-text { font-size: 12px; color: var(--perch-text-muted); margin-top: 2px; }
.drop-or { font-size: 11px; color: var(--perch-text-muted); margin: 4px 0; }
.drop-browse {
  font-size: 12px; color: var(--perch-primary); cursor: pointer;
  text-decoration: underline;
}
.drop-browse:hover { color: #1d4ed8; }
.drop-hint { font-size: 10px; color: var(--perch-text-muted); margin-top: 6px; }
.drop-parsed-summary { font-size: 11px; color: var(--perch-text-muted); margin: 6px 0; line-height: 1.5; }
.drop-prop-name { font-size: 11px; padding-left: 6px; color: var(--perch-text); }
.drop-actions { display: flex; gap: 6px; margin-top: 6px; }
.drop-success { font-size: 11px; color: var(--perch-success); margin-top: 4px; }
.bank-acct-list { margin-top: 6px; font-size: 11px; }
.bank-acct-row {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 2px 0; color: var(--perch-text-muted);
}
.bank-acct-name { font-weight: 500; }
.bank-acct-txns { color: var(--perch-text-muted); white-space: nowrap; }

/* === Bookings Card (Uplisting) === */
.bookings-card {
  width: 160px; display: flex; flex-direction: column; align-items: center;
}
.uplisting-input {
  width: 100%; padding: 6px 8px; border: 1px solid var(--perch-border);
  border-radius: 6px; font-size: 11px; margin: 6px 0 4px;
  font-family: monospace;
}
.uplisting-input:focus { outline: none; border-color: var(--perch-primary); }
.uplisting-connect-btn {
  margin-top: 8px; padding: 6px 14px; border: 1px solid var(--perch-primary);
  border-radius: 6px; background: transparent; cursor: pointer;
  font-size: 11px; color: var(--perch-primary); transition: all 0.15s ease;
}
.uplisting-connect-btn:hover {
  background: var(--perch-primary); color: white;
}

/* Properties */
.property-summary { margin-top: 24px; }
.property-summary h3 { font-size: 14px; margin-bottom: 10px; }
.property-summary p { color: var(--perch-text-muted); font-size: 13px; }
.property-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.property-card {
  position: relative;
  padding: 14px; border: 1px solid var(--perch-border); border-radius: 8px;
  background: var(--perch-surface);
}
.property-card:hover .card-menu-btn { opacity: 1; }
.property-name { font-weight: 600; font-size: 14px; margin-bottom: 3px; }
.property-location { font-size: 12px; color: var(--perch-text-muted); margin-bottom: 6px; }
.property-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  font-size: 10px; padding: 2px 6px; border-radius: 4px;
  background: var(--perch-bg); color: var(--perch-text-muted);
  border: 1px solid var(--perch-border);
}
.property-card:hover {
  border-color: #06b6d4; background: #f0fdfa;
  transition: border-color 0.15s, background 0.15s;
}
.property-address {
  font-size: 12px; color: var(--perch-text-muted); margin-bottom: 2px;
}
.property-card-auto { border-color: var(--perch-warning); border-style: dashed; }
.property-auto-badge {
  font-size: 10px; color: var(--perch-warning); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px;
}

/* Property dedup review modal */
.dedup-modal { max-width: 560px; width: 90vw; max-height: 80vh; display: flex; flex-direction: column; }
.dedup-pairs-list { overflow-y: auto; flex: 1; min-height: 0; }
.dedup-subtitle { font-size: 13px; color: var(--perch-text-muted); margin-bottom: 16px; }
.dedup-pairs-list { display: flex; flex-direction: column; gap: 16px; margin-bottom: 16px; }
.dedup-pair {
  border: 1px solid var(--perch-border); border-radius: 10px;
  padding: 16px; background: var(--perch-bg);
}
.dedup-pair-header { margin-bottom: 12px; }
.dedup-pair-question { font-size: 14px; font-weight: 600; color: var(--perch-text); }
.dedup-pair-props { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.dedup-pair-vs {
  font-size: 13px; font-weight: 700; color: var(--perch-text-muted);
  flex-shrink: 0; padding: 0 4px;
}
.dedup-prop {
  flex: 1; padding: 10px 12px; background: var(--perch-surface);
  border: 1px solid var(--perch-border); border-radius: 8px;
}
.dedup-prop-name { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.dedup-prop-detail { font-size: 12px; color: var(--perch-text-muted); }
.dedup-source-badge {
  display: inline-block; margin-top: 6px; padding: 2px 8px;
  border-radius: 4px; font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.source-stessa     { background: #dbeafe; color: #1e40af; }
.source-uplisting  { background: #fce7f3; color: #9d174d; }
.source-ownerrez   { background: #fef3c7; color: #92400e; }
.source-hospitable { background: #d1fae5; color: #065f46; }
.source-manual     { background: #f3f4f6; color: #6b7280; }
.source-unknown    { background: #f3f4f6; color: #6b7280; }
.dedup-pair-actions { display: flex; gap: 8px; }
.dedup-btn-merge {
  padding: 6px 14px; border: none; border-radius: 6px;
  background: var(--perch-primary); color: white;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.dedup-btn-merge:hover { opacity: 0.9; }
.dedup-btn-dismiss {
  padding: 6px 14px; border: 1px solid var(--perch-border); border-radius: 6px;
  background: var(--perch-surface); color: var(--perch-text);
  font-size: 13px; cursor: pointer;
}
.dedup-btn-dismiss:hover { background: var(--perch-bg); }

/* Property add/edit form modal */
.prop-form-card { min-width: 360px; max-width: 460px; }
.prop-form-field { margin-bottom: 14px; }
.prop-form-label {
  display: block; font-size: 12px; font-weight: 500;
  color: var(--perch-text-muted); margin-bottom: 4px;
}
.prop-form-required { color: #dc2626; font-weight: 600;
}
.prop-form-input {
  width: 100%; padding: 8px 10px; font-size: 13px;
  border: 1px solid var(--perch-border); border-radius: 6px;
  background: var(--perch-bg); color: var(--perch-text);
  outline: none; box-sizing: border-box;
}
.prop-form-input:focus {
  border-color: #06b6d4; box-shadow: 0 0 0 2px rgba(6,182,212,0.15);
}
.prop-form-row { display: flex; gap: 10px; }
.prop-form-row .prop-form-field { flex: 1; }
.prop-form-cancel {
  padding: 8px 16px; border: 1px solid var(--perch-border); border-radius: 6px;
  background: var(--perch-surface); color: var(--perch-text); cursor: pointer;
  font-size: 13px;
}
.prop-form-cancel:hover { background: var(--perch-bg); }
.prop-form-save {
  padding: 8px 20px; border: none; border-radius: 6px;
  background: #06b6d4; color: #fff; cursor: pointer;
  font-size: 13px; font-weight: 500;
}
.prop-form-save:hover { background: #0891b2; }
.prop-form-save:disabled { opacity: 0.5; cursor: not-allowed; }
.prop-form-select {
  width: 100%; padding: 8px 10px; font-size: 13px;
  border: 1px solid var(--perch-border); border-radius: 6px;
  background: var(--perch-bg); color: var(--perch-text);
  outline: none; box-sizing: border-box; cursor: pointer;
}
.prop-form-select:focus {
  border-color: #06b6d4; box-shadow: 0 0 0 2px rgba(6,182,212,0.15);
}
.property-source { margin-top: 4px; }
.source-badge {
  font-size: 10px; padding: 2px 8px; border-radius: 4px;
  background: #eff6ff; color: #3b82f6; font-weight: 500;
  border: 1px solid #bfdbfe;
}

/* Chat welcome / onboarding */
.chat-welcome {
  text-align: center; padding: 32px 16px; color: var(--perch-text-muted);
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; flex: 1;
}
.welcome-logo { margin-bottom: 12px; opacity: 0.9; }
.chat-welcome h3 { font-size: 18px; color: var(--perch-text); margin-bottom: 6px; font-weight: 600; }
.chat-welcome p { max-width: 340px; line-height: 1.5; margin-bottom: 20px; font-size: 13px; }

/* Suggestion chips */
.suggestion-chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center; max-width: 340px;
}
.suggestion-chip {
  padding: 7px 14px; border: 1px solid var(--perch-border);
  border-radius: 20px; background: var(--perch-surface);
  cursor: pointer; font-size: 12px; color: var(--perch-text);
  transition: all 0.15s ease;
}
.suggestion-chip:hover {
  border-color: var(--perch-primary); color: var(--perch-primary);
  background: #eff6ff;
}

/* Markdown in chat */
.assistant .message-content h1,
.assistant .message-content h2,
.assistant .message-content h3 { margin: 6px 0 3px; }
.assistant .message-content h3 { font-size: 13px; }
.assistant .message-content p { margin: 3px 0; }
.assistant .message-content ul, .assistant .message-content ol { margin: 3px 0 3px 18px; }
.assistant .message-content li { margin: 2px 0; }
.assistant .message-content strong { font-weight: 600; }
.assistant .message-content code {
  background: var(--perch-bg); padding: 1px 4px; border-radius: 3px; font-size: 12px;
}
.assistant .message-content pre {
  background: var(--perch-bg); padding: 6px; border-radius: 6px;
  overflow-x: auto; margin: 6px 0;
}
.assistant .message-content pre code { background: none; padding: 0; }
.chat-feedback { display: flex; gap: 4px; margin-top: 2px; margin-left: 4px; }
.chat-feedback button {
  background: none; border: none; cursor: pointer; font-size: 14px;
  padding: 2px 4px; border-radius: 4px; opacity: 0.5; transition: opacity 0.15s;
}
.chat-feedback button:hover { opacity: 1; }
.chat-feedback-thanks { font-size: 11px; color: var(--perch-text-muted); margin-left: 4px; margin-top: 2px; }

/* Stessa buttons & error (shared) */
.stessa-error {
  background: #fef2f2; color: var(--perch-error); border: 1px solid #fecaca;
  padding: 4px 8px; border-radius: 4px; font-size: 11px; text-align: left;
}
.stessa-btn-primary {
  padding: 5px 12px; border: none; border-radius: 6px;
  background: var(--perch-primary); color: white; cursor: pointer; font-size: 11px;
}
.stessa-btn-primary:hover { opacity: 0.9; }
.stessa-btn-secondary {
  padding: 5px 12px; border: 1px solid var(--perch-border); border-radius: 6px;
  background: transparent; cursor: pointer; font-size: 11px; color: var(--perch-text);
}
.stessa-btn-secondary:hover { background: var(--perch-bg); }

/* === Integration connect buttons === */
.uplisting-connect-btn {
  display: inline-block; padding: 6px 14px; border: 1px solid var(--perch-primary);
  border-radius: 6px; background: transparent; color: var(--perch-primary);
  cursor: pointer; font-size: 12px; font-weight: 500; text-decoration: none;
  margin-top: 8px; white-space: nowrap;
}
.uplisting-connect-btn:hover { background: var(--perch-primary); color: white; }
.uplisting-input {
  width: 100%; padding: 5px 8px; border: 1px solid var(--perch-border);
  border-radius: 4px; font-size: 11px; margin-bottom: 6px; box-sizing: border-box;
}

/* === Reports === */
.report-panel { margin-top: 32px; }
.report-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.report-header h2 { font-size: 16px; }
.report-header-actions {
  display: flex; gap: 8px; align-items: center;
}
.report-txf-btn {
  padding: 4px 12px; border: 1px solid #14b8a6; border-radius: 6px;
  background: #f0fdfa; cursor: pointer; font-size: 11px; color: #14b8a6;
  font-weight: 600; transition: background 0.15s;
}
.report-txf-btn:hover { background: #ccfbf1; }
.report-refresh {
  padding: 4px 12px; border: 1px solid var(--perch-border); border-radius: 6px;
  background: transparent; cursor: pointer; font-size: 11px; color: var(--perch-text-muted);
}
.report-refresh:hover { background: var(--perch-bg); }
.report-refresh:disabled { opacity: 0.5; cursor: not-allowed; }

/* Tab bar */
.report-tabs {
  display: flex; gap: 0; border-bottom: 2px solid var(--perch-border);
  margin-bottom: 20px;
}
.report-tab {
  padding: 8px 20px; border: none; background: transparent;
  font-size: 13px; color: var(--perch-text-muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all 0.15s ease;
}
.report-tab:hover { color: var(--perch-text); }
.report-tab.active {
  color: var(--perch-primary); border-bottom-color: var(--perch-primary);
  font-weight: 600;
}

/* Loading / error / empty */
.report-loading {
  display: flex; align-items: center; gap: 10px;
  padding: 24px; color: var(--perch-text-muted); font-size: 13px;
}
.report-error {
  background: #fef2f2; color: var(--perch-error); border: 1px solid #fecaca;
  padding: 12px; border-radius: 6px; font-size: 13px;
}
.report-empty {
  padding: 24px; text-align: center; color: var(--perch-text-muted); font-size: 13px;
}

/* KPI cards */
.kpi-row { display: flex; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.kpi-card {
  flex: 1; min-width: 110px; padding: 16px;
  background: var(--perch-surface); border: 1px solid var(--perch-border);
  border-radius: 8px; text-align: center;
}
.kpi-value { font-size: 20px; font-weight: 700; color: var(--perch-text); }
.kpi-label { font-size: 11px; color: var(--perch-text-muted); margin-top: 4px; }
.kpi-sub { font-size: 10px; color: var(--perch-text-muted); margin-top: 2px; }

/* Tables */
.report-table-wrap { overflow-x: auto; }
.report-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.report-table th {
  text-align: left; padding: 8px 12px; font-weight: 600; font-size: 11px;
  color: var(--perch-text-muted); text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 2px solid var(--perch-border); background: var(--perch-bg);
}
.report-table td { padding: 8px 12px; border-bottom: 1px solid var(--perch-border); }
.report-table th.r, .report-table td.r { text-align: right; }
.report-table .neg { color: var(--perch-error); }
.report-table .pos { color: #16a34a; font-weight: 600; }
.report-table .total-row td {
  font-weight: 700; border-top: 2px solid var(--perch-text);
  background: var(--perch-bg);
}
.report-table .has-disc { background: #fffbeb; }
.report-table .prop-name-cell { font-weight: 500; }
.report-table .more-row { text-align: center; color: var(--perch-text-muted); font-style: italic; }

/* Source & status badges */
.source-tag {
  display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 3px;
  background: #eff6ff; color: var(--perch-primary); margin-right: 4px;
  text-transform: capitalize;
}
.matched-badge {
  display: inline-block; font-size: 9px; padding: 1px 6px; border-radius: 3px;
  background: #f0fdf4; color: var(--perch-success); margin-left: 8px;
  font-weight: 500; text-transform: uppercase;
}
.unmatched-badge {
  display: inline-block; font-size: 9px; padding: 1px 6px; border-radius: 3px;
  background: #fffbeb; color: var(--perch-warning); margin-left: 8px; font-weight: 500;
}
.sources { white-space: nowrap; }

/* Subtables */
.subtable-wrap { margin: 8px 0 16px 20px; }
.subtable-wrap h4 { font-size: 12px; margin-bottom: 6px; color: var(--perch-text-muted); }
.report-table.subtable { font-size: 12px; }
.report-table.subtable th { font-size: 10px; }
.desc-cell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Property detail cards (Properties tab) */
.property-detail-card {
  border: 1px solid var(--perch-border); border-radius: 8px;
  margin-bottom: 8px; background: var(--perch-surface); overflow: hidden;
}
.property-detail-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; cursor: pointer; transition: background 0.1s;
}
.property-detail-header:hover { background: var(--perch-bg); }
.property-detail-name {
  display: flex; align-items: center; gap: 4px; font-weight: 600; font-size: 14px;
}
.expand-arrow { font-size: 10px; width: 16px; color: var(--perch-text-muted); }
.property-location-sm {
  font-size: 12px; color: var(--perch-text-muted); font-weight: 400; margin-left: 8px;
}
.property-detail-stats {
  display: flex; gap: 16px; font-size: 12px; color: var(--perch-text-muted);
}
.property-detail-body {
  padding: 0 16px 16px; border-top: 1px solid var(--perch-border);
}

/* Reconciliation cards */
.recon-card {
  border: 1px solid var(--perch-border); border-radius: 8px;
  margin-bottom: 16px; background: var(--perch-surface); overflow: hidden;
}
.recon-header {
  padding: 12px 16px; font-weight: 600; font-size: 14px;
  border-bottom: 1px solid var(--perch-border);
  display: flex; align-items: center; gap: 8px;
}
.recon-body { display: grid; grid-template-columns: 1fr 1fr; }
.recon-col { padding: 16px; }
.recon-col:first-child { border-right: 1px solid var(--perch-border); }
.recon-col h4 { font-size: 12px; color: var(--perch-text-muted); margin-bottom: 10px; font-weight: 600; }
.recon-line {
  display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px;
}
.recon-line .r { font-weight: 500; font-family: monospace; }
.recon-total {
  border-top: 1px solid var(--perch-border); margin-top: 8px;
  padding-top: 8px; font-weight: 600;
}
.recon-breakdown { margin-top: 14px; }
.recon-breakdown-title {
  font-size: 10px; color: var(--perch-text-muted); text-transform: uppercase;
  letter-spacing: 0.5px; margin-bottom: 4px;
}
.recon-breakdown-header {
  display: grid; grid-template-columns: 1fr 60px 90px; gap: 8px;
  font-size: 10px; color: var(--perch-text-muted); text-transform: uppercase;
  letter-spacing: 0.5px; padding: 4px 0; border-bottom: 1px solid var(--perch-border);
  margin-bottom: 2px;
}
.recon-breakdown-line {
  display: grid; grid-template-columns: 1fr 60px 90px; gap: 8px;
  font-size: 11px; color: var(--perch-text-muted); padding: 2px 0;
}
.recon-verdict {
  padding: 10px 16px; border-top: 1px solid var(--perch-border);
  font-size: 12px; text-align: center; background: var(--perch-bg);
}
.recon-match { color: var(--perch-success); font-weight: 500; }
.recon-warning { color: var(--perch-warning); font-weight: 500; }
.recon-info { color: var(--perch-text-muted); }
.recon-neutral { color: var(--perch-text-muted); font-style: italic; }

/* Schedule E form */
.sched-e-card {
  border: 1px solid var(--perch-border); border-radius: 8px;
  margin-bottom: 16px; background: var(--perch-surface); overflow: hidden;
}
.sched-e-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--perch-border);
}
.sched-e-header h3 { font-size: 14px; }
.sched-e-header span { font-size: 12px; color: var(--perch-text-muted); }
.sched-e-form { padding: 20px 24px; }
.sched-e-title { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.sched-e-subtitle { font-size: 12px; color: var(--perch-text-muted); margin-bottom: 16px; }
.sched-e-line {
  display: flex; align-items: baseline; padding: 5px 0; font-size: 13px;
}
.sched-e-line.zero-line { opacity: 0.4; }
.sched-e-line-num { width: 60px; color: var(--perch-text-muted); font-size: 12px; flex-shrink: 0; }
.sched-e-line-label { flex: 0 0 auto; }
.sched-e-line-dots {
  flex: 1; border-bottom: 1px dotted var(--perch-border);
  margin: 0 8px; min-width: 20px;
}
.sched-e-line-amount {
  text-align: right; font-family: 'SF Mono', 'Menlo', monospace;
  min-width: 90px; flex-shrink: 0;
}
.income-line .sched-e-line-amount { color: #16a34a; }
.expense-line .sched-e-line-amount { color: var(--perch-text); }
.sched-e-separator { border-top: 2px solid var(--perch-text); margin: 12px 0; }
.total-line { font-weight: 600; }
.net-line { margin-top: 4px; }
.sched-e-line-amount.neg { color: var(--perch-error); }
.sched-e-line-amount.pos { color: #16a34a; }

/* === Property Report (Form 8825 columnar) === */
.pr-wrap { }
.pr-title {
  font-size: 15px; font-weight: 600; margin-bottom: 16px;
  color: var(--perch-text);
}
.pr-table { min-width: 600px; }
.pr-table th.r { min-width: 100px; }
.pr-line-num { width: 40px; color: var(--perch-text-muted); font-size: 12px; }
.pr-total { font-weight: 600; }
.pr-section-header td {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--perch-text-muted);
  padding: 12px 12px 6px; border-bottom: 1px solid var(--perch-border);
  background: var(--perch-bg);
}
.pr-subtotal td {
  font-weight: 600; border-top: 1px solid var(--perch-text);
  background: var(--perch-bg);
}
.pr-net-income td {
  font-weight: 700; border-top: 2px solid var(--perch-text);
  background: #f0fdf4; padding: 10px 12px;
}
.pr-footer {
  margin-top: 8px; font-size: 11px; color: var(--perch-text-muted);
  text-align: right;
}
.pr-table .zero-line { opacity: 0.4; }

/* === Income Statement === */
.is-wrap { }
.is-title {
  font-size: 15px; font-weight: 600; margin-bottom: 16px;
  color: var(--perch-text);
}
.is-property-selector {
  margin-bottom: 16px;
}
.is-property-selector select {
  padding: 8px 12px; border: 1px solid var(--perch-border);
  border-radius: 6px; font-size: 13px; background: var(--perch-surface);
  color: var(--perch-text); cursor: pointer; min-width: 200px;
}
.is-property-selector select:focus { outline: none; border-color: var(--perch-primary); }
.is-table { max-width: 500px; }
.is-section-header td {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--perch-text-muted);
  padding: 12px 12px 6px; border-bottom: 1px solid var(--perch-border);
  background: var(--perch-bg);
}
.is-subtotal td {
  font-weight: 600; border-top: 1px solid var(--perch-border);
  background: var(--perch-bg); padding: 8px 12px;
}
.is-net-income td {
  font-weight: 700; border-top: 2px solid var(--perch-text);
  background: #f0fdf4; padding: 10px 12px;
}

/* Monthly Income Statement */
.mis-wrap { padding: 16px 0; }
.mis-title { font-size: 18px; font-weight: 700; color: var(--perch-text); margin-bottom: 4px; }
.mis-subtitle { font-size: 13px; color: var(--perch-text-muted); margin-bottom: 16px; font-style: italic; }
.mis-table { width: 100%; }
.mis-table th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; }
.mis-table td, .mis-table th { padding: 6px 10px; }
.mis-table td:first-child { min-width: 160px; }
.mis-total { font-weight: 600; }
.mis-section-header td {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--perch-text-muted);
  padding: 12px 10px 6px; border-bottom: 1px solid var(--perch-border);
  background: var(--perch-bg);
}
.mis-subtotal td {
  font-weight: 600; border-top: 1px solid var(--perch-border);
  background: var(--perch-bg); padding: 8px 10px;
}
.mis-net-income td {
  font-weight: 700; border-top: 2px solid var(--perch-text);
  background: #f0fdf4; padding: 10px 10px;
}
.mis-footer { margin-top: 12px; font-size: 12px; color: var(--perch-text-muted); }

/* Monthly P&L by Property */
.mpbp-wrap { padding: 16px 0; }
.mpbp-title { font-size: 18px; font-weight: 700; color: var(--perch-text); margin-bottom: 4px; }
.mpbp-subtitle { font-size: 13px; color: var(--perch-text-muted); margin-bottom: 16px; font-style: italic; }
.mpbp-table { width: 100%; border-collapse: collapse; }
.mpbp-table th {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  white-space: nowrap; padding: 6px 10px; position: sticky; top: 0;
  background: var(--perch-surface); z-index: 1;
}
.mpbp-table td { padding: 5px 10px; white-space: nowrap; font-size: 13px; }
.mpbp-table td:first-child { min-width: 140px; }
.mpbp-prop-name { font-weight: 600; color: var(--perch-primary); }
.mpbp-ytd { font-weight: 600; background: #f8fafc; }
.mpbp-revenue td { border-top: 1px solid var(--perch-border); }
.mpbp-net td { border-bottom: 2px solid var(--perch-border); }
.mpbp-portfolio-spacer td { height: 8px; border: none; }
.mpbp-portfolio-rev td {
  border-top: 2px solid var(--perch-text); background: #f0fdf4;
  font-weight: 600; padding: 8px 10px;
}
.mpbp-portfolio-exp td { background: #f0fdf4; font-weight: 600; padding: 6px 10px; }
.mpbp-portfolio-net td {
  background: #f0fdf4; font-weight: 700; padding: 8px 10px;
  border-top: 1px solid var(--perch-border);
  border-bottom: 2px solid var(--perch-text);
}
.mpbp-footer { margin-top: 12px; font-size: 12px; color: var(--perch-text-muted); }

/* Chart of Accounts table */
.coa-wrap { padding: 16px 0; }
.coa-title { font-size: 18px; font-weight: 700; color: var(--perch-text); margin-bottom: 4px; }
.coa-subtitle { font-size: 13px; color: var(--perch-text-muted); margin-bottom: 16px; font-style: italic; }
.coa-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.coa-table th { text-align: left; padding: 8px 10px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--perch-text-muted); border-bottom: 2px solid var(--perch-border); white-space: nowrap; }
.coa-table td { padding: 6px 10px; border-bottom: 1px solid var(--perch-border); vertical-align: top; }
.coa-table tbody tr:hover { background: #f1f5f9; }
.coa-section-header td { padding: 10px 10px 6px; background: var(--perch-bg); border-bottom: 1px solid var(--perch-border); }
.coa-type-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }
.coa-code { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px; color: var(--perch-text-muted); white-space: nowrap; }
.coa-desc { color: var(--perch-text-muted); font-size: 12px; max-width: 280px; }
.coa-type-badge { display: inline-block; padding: 2px 8px; border: 1px solid; border-radius: 10px; font-size: 11px; white-space: nowrap; }
.coa-norm { font-size: 12px; color: var(--perch-text-muted); white-space: nowrap; }

/* Sharing / Invites */
.nav-home-btn.active { background: var(--perch-primary); color: white; border-radius: 6px; }
.nav-sharing-btn { margin-right: 8px; }
.nav-sharing-btn.active { background: var(--perch-primary); color: white; border-radius: 6px; }
.nav-site-link {
  padding: 4px 14px; font-size: 13px; color: var(--perch-text-muted);
  text-decoration: none; border: 1px solid var(--perch-border); border-radius: 6px;
}
.nav-site-link:hover { background: var(--perch-bg); color: var(--perch-primary); text-decoration: none; }

/* Account Switcher */
.account-switcher { display: flex; align-items: center; gap: 8px; margin-right: 8px; }
.account-select {
  padding: 4px 8px; border: 1px solid var(--perch-border); border-radius: 6px;
  background: var(--perch-surface); font-size: 13px; color: var(--perch-text);
  cursor: pointer; max-width: 220px;
}
.account-select:focus { outline: none; border-color: var(--perch-primary); }
.viewing-badge {
  font-size: 11px; color: var(--perch-primary); background: #dbeafe;
  padding: 2px 8px; border-radius: 4px; white-space: nowrap;
}

.invites-panel { padding: 24px; max-width: 600px; }
.invites-panel h3 { margin: 0 0 4px; font-size: 20px; }
.invites-logged-in {
  font-size: 13px; color: var(--perch-text-muted); margin-bottom: 16px;
}
.invite-upgrade {
  margin-top: 10px; padding: 12px; background: #eff6ff; border: 1px solid #bfdbfe;
  border-radius: 8px; text-align: center;
}
.invite-upgrade p { font-size: 13px; color: #1e40af; margin-bottom: 10px; }
.invite-upgrade-btn {
  padding: 8px 20px; background: var(--perch-primary); color: white; border: none;
  border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.shared-viewing-banner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: #eff6ff; border: 1px solid #bfdbfe;
  border-radius: 8px; margin-bottom: 12px; font-size: 13px;
}
.shared-switch-btn {
  padding: 4px 12px; border: 1px solid var(--perch-primary); border-radius: 6px;
  background: white; color: var(--perch-primary); font-size: 12px; cursor: pointer;
}
.shared-switch-btn:hover { background: var(--perch-primary); color: white; }
.invite-card.shared {
  display: flex; justify-content: space-between; align-items: center;
}
.invite-card.shared-active { border-color: var(--perch-primary); background: #f0f7ff; }
.shared-view-btn {
  padding: 4px 14px; border: 1px solid var(--perch-primary); border-radius: 6px;
  background: transparent; color: var(--perch-primary); font-size: 12px; cursor: pointer;
  white-space: nowrap;
}
.shared-view-btn:hover { background: var(--perch-primary); color: white; }
.invites-description { color: var(--perch-text-muted); font-size: 14px; margin: 0 0 20px; }

.invite-form { margin-bottom: 24px; padding: 16px; background: var(--perch-surface); border-radius: 8px; border: 1px solid var(--perch-border); }
.invite-form h4 { margin: 0 0 12px; font-size: 15px; }
.invite-form-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.invite-form-row input[type="email"] {
  flex: 1; min-width: 200px; padding: 8px 12px; border: 1px solid var(--perch-border);
  border-radius: 6px; font-size: 14px; background: white;
}
.invite-form-row input:focus { outline: none; border-color: var(--perch-primary); }
.invite-form-row select {
  padding: 8px 12px; border: 1px solid var(--perch-border); border-radius: 6px;
  font-size: 13px; background: white; cursor: pointer;
}
.invite-send-btn {
  padding: 8px 16px; background: var(--perch-primary); color: white; border: none;
  border-radius: 6px; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.invite-send-btn:hover { opacity: 0.9; }
.invite-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.invite-accountant-check {
  display: flex; align-items: center; gap: 6px; margin-top: 8px;
  font-size: 13px; color: var(--perch-text); cursor: pointer;
}
.invite-accountant-check input[type="checkbox"] { cursor: pointer; }
.invite-success { margin-top: 8px; color: #16a34a; font-size: 13px; }
.invite-error { margin-top: 8px; color: #dc2626; font-size: 13px; }

.invite-section { margin-bottom: 20px; }
.invite-section h4 { font-size: 15px; margin: 0 0 10px; color: var(--perch-text); }
.invite-section h5 { font-size: 13px; margin: 12px 0 8px; color: var(--perch-text-muted); }
.invite-empty { font-size: 13px; color: var(--perch-text-muted); font-style: italic; }

.invite-card {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border: 1px solid var(--perch-border); border-radius: 6px;
  margin-bottom: 6px; background: white;
}
.invite-card.received { border-left: 3px solid var(--perch-primary); }
.invite-card.pending { opacity: 0.7; }
.invite-card.shared { border-left: 3px solid #16a34a; }
.invite-card-info { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.invite-email { font-weight: 500; font-size: 14px; }
.invite-from { font-weight: 500; font-size: 14px; }
.invite-role {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 2px 8px; border-radius: 10px; background: #f1f5f9; color: var(--perch-text-muted);
}
.invite-status { font-size: 12px; color: var(--perch-text-muted); font-style: italic; }
.invite-accountant-badge {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 2px 8px; border-radius: 10px; background: #ede9fe; color: #7c3aed;
}
.invite-date { font-size: 12px; color: var(--perch-text-muted); }
.invite-card-actions { display: flex; gap: 6px; }
.invite-accept {
  padding: 4px 12px; background: var(--perch-primary); color: white; border: none;
  border-radius: 4px; font-size: 13px; cursor: pointer;
}
.invite-decline {
  padding: 4px 12px; background: white; color: var(--perch-text-muted); border: 1px solid var(--perch-border);
  border-radius: 4px; font-size: 13px; cursor: pointer;
}
.invite-revoke {
  padding: 4px 12px; background: white; color: #dc2626; border: 1px solid #fecaca;
  border-radius: 4px; font-size: 13px; cursor: pointer;
}
.invite-revoke:hover { background: #fef2f2; }

/* Nav Pricing Button */
.nav-pricing-btn { margin-right: 8px; }
.nav-pricing-btn.active { background: var(--perch-secondary); color: white; border-radius: 6px; }

/* ===== Billing / Pricing ===== */

.billing-panel { padding: 24px; max-width: 960px; }
.billing-header { text-align: center; margin-bottom: 24px; }
.billing-header h2 { font-size: 24px; margin: 0 0 6px; }
.billing-subtitle { color: var(--perch-text-muted); font-size: 14px; margin: 0; }

/* Period toggle */
.billing-period-toggle {
  display: flex; justify-content: center; gap: 0; margin-bottom: 28px;
  background: var(--perch-bg); border-radius: 8px; padding: 3px; width: fit-content;
  margin-left: auto; margin-right: auto;
}
.billing-period-toggle button {
  padding: 6px 20px; border: none; border-radius: 6px; background: transparent;
  cursor: pointer; font-size: 13px; color: var(--perch-text-muted); position: relative;
}
.billing-period-toggle button.active {
  background: var(--perch-surface); color: var(--perch-text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1); font-weight: 600;
}
.save-badge {
  font-size: 13px; background: var(--perch-success); color: white;
  padding: 4px 10px; border-radius: 6px; margin-left: 8px; font-weight: 700;
  letter-spacing: 0.02em;
}

/* Plans grid */
.plans-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
}

/* Plan card */
.plan-card {
  background: var(--perch-surface); border: 1px solid var(--perch-border);
  border-radius: 12px; padding: 24px 20px; display: flex; flex-direction: column;
  position: relative;
}
.plan-card.popular {
  border-color: var(--perch-primary); box-shadow: 0 0 0 1px var(--perch-primary);
}
.plan-card.current-plan { border-color: var(--perch-success); }
.popular-badge {
  position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  background: var(--perch-primary); color: white; font-size: 13px; font-weight: 700;
  padding: 4px 14px; border-radius: 6px; white-space: nowrap;
  letter-spacing: 0.02em;
}
.plan-name { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.plan-price { margin-bottom: 4px; }
.plan-amount { font-size: 28px; font-weight: 700; color: var(--perch-text); }
.plan-per { font-size: 13px; color: var(--perch-text-muted); }
.plan-props { font-size: 13px; color: var(--perch-text-muted); margin-bottom: 16px; }
.plan-features {
  list-style: none; padding: 0; margin: 0 0 20px; flex: 1;
}
.plan-features li {
  font-size: 13px; padding: 4px 0; position: relative; padding-left: 18px;
  color: var(--perch-text);
}
.plan-features li::before {
  content: "\2713"; position: absolute; left: 0; color: var(--perch-success); font-weight: 700;
}
.plan-action { margin-top: auto; }
.plan-btn {
  width: 100%; padding: 10px; border: none; border-radius: 8px;
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.plan-btn-subscribe {
  background: var(--perch-primary); color: white;
}
.plan-btn-subscribe:hover { opacity: 0.9; }
.plan-btn-subscribe:disabled { opacity: 0.5; cursor: not-allowed; }
.plan-btn-current {
  background: var(--perch-bg); color: var(--perch-text-muted);
  border: 1px solid var(--perch-border); cursor: default;
}

/* Current subscription bar */
.billing-current {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: #f0fdf4; border: 1px solid #bbf7d0;
  border-radius: 8px; margin-bottom: 20px;
}
.billing-current-info { font-size: 14px; }
.trial-badge {
  font-size: 11px; background: var(--perch-warning); color: white;
  padding: 2px 8px; border-radius: 4px; margin-left: 8px;
}
.billing-manage-btn {
  padding: 6px 16px; border: 1px solid var(--perch-border); border-radius: 6px;
  background: var(--perch-surface); cursor: pointer; font-size: 13px;
}
.billing-manage-btn:hover { background: var(--perch-bg); }

/* Footer */
.billing-footer {
  text-align: center; margin-top: 24px; padding-top: 16px;
  border-top: 1px solid var(--perch-border);
}
.billing-footer p { font-size: 13px; color: var(--perch-text-muted); margin: 4px 0; }

/* ===== CPA Tools / Tallyfor ===== */

.nav-cpa-btn { margin-right: 8px; }
.nav-cpa-btn.active { background: var(--perch-secondary); color: white; border-radius: 6px; }

.tallyfor-panel { padding: 24px; max-width: 600px; }
.tallyfor-header { margin-bottom: 24px; }
.tallyfor-header h2 { font-size: 24px; margin: 0 0 6px; }
.tallyfor-subtitle { color: var(--perch-text-muted); font-size: 14px; margin: 0; }

.tallyfor-connect-form { display: flex; flex-direction: column; gap: 10px; max-width: 400px; }
.tallyfor-connect-form label { font-size: 13px; font-weight: 600; color: var(--perch-text); }
.tallyfor-input {
  padding: 8px 12px; border: 1px solid var(--perch-border); border-radius: 6px;
  font-size: 14px; font-family: monospace;
}
.tallyfor-input:focus { outline: none; border-color: var(--perch-primary); }
.tallyfor-connect-btn {
  padding: 8px 20px; background: var(--perch-primary); color: white; border: none;
  border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer; width: fit-content;
}
.tallyfor-connect-btn:hover { opacity: 0.9; }
.tallyfor-connect-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.tallyfor-status-bar {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px; margin-bottom: 20px;
  font-size: 14px;
}
.tallyfor-status-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #9ca3af;
}
.tallyfor-status-dot.connected { background: var(--perch-success); }
.tallyfor-key-hint {
  margin-left: auto; font-size: 12px; color: var(--perch-text-muted); font-family: monospace;
}

.tallyfor-push-section { margin-bottom: 20px; }
.tallyfor-push-section h4 { font-size: 15px; margin: 0 0 6px; }
.tallyfor-push-desc { font-size: 13px; color: var(--perch-text-muted); margin: 0 0 12px; }
.tallyfor-push-btn {
  padding: 10px 24px; background: var(--perch-primary); color: white; border: none;
  border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.tallyfor-push-btn:hover { opacity: 0.9; }
.tallyfor-push-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.tallyfor-error { margin-top: 8px; color: #dc2626; font-size: 13px; }
.tallyfor-success { margin-top: 8px; color: #16a34a; font-size: 13px; }

/* Push progress stepper */
.push-progress { margin-top: 16px; display: flex; flex-direction: column; gap: 6px; }
.push-step {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--perch-text-muted);
  transition: color 0.3s ease;
}
.push-step.done { color: #16a34a; }
.push-step.active { color: var(--perch-primary); font-weight: 600; }
.push-step.failed { color: #dc2626; }
.step-indicator {
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; flex-shrink: 0;
  background: #f1f5f9; color: #94a3b8;
  transition: all 0.3s ease;
}
.push-step.done .step-indicator { background: #dcfce7; color: #16a34a; }
.push-step.active .step-indicator { background: #e0e7ff; color: var(--perch-primary); }
.push-step.failed .step-indicator { background: #fef2f2; color: #dc2626; }
.step-spinner {
  width: 12px; height: 12px; border: 2px solid #c7d2fe;
  border-top-color: var(--perch-primary); border-radius: 50%;
  animation: spin 0.8s linear infinite; display: block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.tallyfor-last-push { margin-bottom: 20px; }
.tallyfor-last-push h4 { font-size: 15px; margin: 0 0 8px; }
.tallyfor-push-info {
  display: flex; gap: 16px; font-size: 13px; color: var(--perch-text-muted);
}

.tallyfor-disconnect-section { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--perch-border); }
.tallyfor-disconnect-btn {
  padding: 6px 16px; background: white; color: #dc2626; border: 1px solid #fecaca;
  border-radius: 6px; font-size: 13px; cursor: pointer;
}
.tallyfor-disconnect-btn:hover { background: #fef2f2; }

/* Toast notifications */
.toast-notification {
  position: fixed; top: 20px; right: 20px; z-index: 10000;
  max-width: 480px; padding: 14px 40px 14px 16px;
  border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  font-size: 14px; cursor: pointer;
  animation: toast-slide-in 0.3s ease-out;
}
.toast-notification.error {
  background: #fef2f2; color: #991b1b; border: 1px solid #fecaca;
}
.toast-notification.success {
  background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0;
}
.toast-close {
  position: absolute; top: 10px; right: 14px;
  font-size: 18px; opacity: 0.5; cursor: pointer;
}
.toast-close:hover { opacity: 1; }
.toast-message { word-break: break-word; }
@keyframes toast-slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* === Inline Category Editing (GL Table) === */
.category-editable {
  cursor: pointer; padding: 2px 4px; border-radius: 3px;
  transition: background 0.15s;
}
.category-editable:hover {
  background: #e0e7ff; text-decoration: underline;
}
.category-editable::after {
  content: " \270E"; font-size: 10px; opacity: 0; transition: opacity 0.15s;
  color: var(--perch-text-muted);
}
.category-editable:hover::after { opacity: 1; }
.uncategorized-text { color: var(--perch-warning); font-style: italic; }
.category-select {
  padding: 3px 6px; border: 1px solid var(--perch-primary); border-radius: 4px;
  font-size: 12px; background: var(--perch-surface); color: var(--perch-text);
  cursor: pointer; min-width: 160px; max-width: 240px;
}
.category-select:focus { outline: none; box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2); }

/* Searchable category dropdown */
.cat-search-dropdown { position: relative; display: inline-block; }
.cat-search-panel {
  position: absolute; top: 0; left: 0; z-index: 100;
  min-width: 260px; background: white;
  border: 1px solid var(--perch-border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}
.cat-search-input {
  width: 100%; padding: 8px 10px; border: none;
  border-bottom: 1px solid var(--perch-border);
  border-radius: 8px 8px 0 0; font-size: 13px;
  outline: none;
}
.cat-search-input:focus { box-shadow: inset 0 -2px 0 var(--perch-primary); }
.cat-search-list {
  max-height: 260px; overflow-y: auto; padding: 4px 0;
}
.cat-search-group {
  padding: 6px 12px 2px; font-size: 11px; font-weight: 600;
  color: var(--perch-text-muted); text-transform: uppercase;
  letter-spacing: 0.5px;
}
.cat-search-item {
  padding: 6px 12px; font-size: 13px; cursor: pointer;
  white-space: nowrap;
}
.cat-search-item:hover { background: #f3f4f6; }
.cat-search-active { background: #e0e7ff; font-weight: 600; }

.uncategorized-row { background: #fffbeb; }
.uncategorized-row:hover { background: #fef3c7; }

/* ================================================================
   All Transactions — master table layer
   ================================================================ */
.layer-transactions .layer-content { display: block; }

/* Fullscreen mode */
.txn-fullscreen {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 1000;
  background: white; padding: 20px; overflow-y: auto;
}
.txn-fullscreen .txn-table-wrap { max-height: calc(100vh - 200px); }

/* Toolbar */
.txn-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.txn-toolbar-left { display: flex; gap: 8px; align-items: center; }
.txn-toolbar-right { display: flex; gap: 8px; align-items: center; }
.txn-fullscreen-btn {
  padding: 5px 12px; border: 1px solid var(--perch-border); border-radius: 6px;
  background: none; font-size: 12px; cursor: pointer; color: var(--perch-text-muted);
}
.txn-fullscreen-btn:hover { background: var(--perch-bg); color: var(--perch-text); }
.tb-fullscreen {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 1000;
  background: white; padding: 20px; overflow-y: auto;
}
.tb-fullscreen .layer-header { display: flex; align-items: center; }
.auto-classify-btn {
  padding: 5px 14px; border: none; border-radius: 6px;
  background: var(--perch-primary); color: white;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.auto-classify-btn:hover { opacity: 0.9; }
.auto-classify-btn.classifying { opacity: 0.7; cursor: not-allowed; }

/* Undo toast */
.undo-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 2000; display: flex; align-items: center; gap: 12px;
  padding: 10px 20px; background: #1f2937; color: white;
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  font-size: 14px; animation: undo-slide-up 0.2s ease-out;
}
@keyframes undo-slide-up {
  from { transform: translateX(-50%) translateY(20px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0); opacity: 1; }
}
.undo-btn {
  padding: 4px 12px; border: 1px solid rgba(255,255,255,0.3); border-radius: 4px;
  background: none; color: #60a5fa; font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.undo-btn:hover { background: rgba(255,255,255,0.1); color: white; }
.undo-toast-success { background: #065f46; }

/* Tab bar */
.txn-tab-bar { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--perch-border); }
.txn-tab {
  padding: 8px 16px; border: none; background: none;
  font-size: 13px; font-weight: 600; color: var(--perch-text-muted);
  cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.txn-tab.active { color: var(--perch-primary); border-bottom-color: var(--perch-primary); }
.txn-tab:hover { color: var(--perch-text); }
.txn-review-badge {
  display: inline-block; margin-left: 6px; padding: 1px 7px;
  background: var(--perch-error); color: white; border-radius: 10px;
  font-size: 11px; font-weight: 700;
}

/* Filter bar */
.txn-filter-bar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }
.txn-search {
  padding: 6px 10px; border: 1px solid var(--perch-border); border-radius: 6px;
  font-size: 13px; min-width: 180px; flex: 1;
}
.txn-search:focus { outline: none; box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2); }
.txn-filter-select {
  padding: 6px 10px; border: 1px solid var(--perch-border); border-radius: 6px;
  font-size: 13px; background: white;
}
.txn-clear-filters {
  padding: 6px 12px; border: 1px solid var(--perch-border); border-radius: 6px;
  background: none; font-size: 12px; color: var(--perch-text-muted); cursor: pointer;
}
.txn-clear-filters:hover { background: var(--perch-bg); }

/* Table */
.txn-table-wrap { max-height: 500px; overflow-y: auto; border: 1px solid var(--perch-border); border-radius: 8px; }
.txn-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.txn-table thead { position: sticky; top: 0; background: var(--perch-bg); z-index: 2; }
.txn-table th {
  padding: 8px 10px; text-align: left; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px; color: var(--perch-text-muted);
  border-bottom: 1px solid var(--perch-border);
}
.txn-sortable { cursor: pointer; }
.txn-sortable:hover { color: var(--perch-text); }
.txn-table td { padding: 7px 10px; border-bottom: 1px solid #f3f4f6; }
.txn-table tbody tr:hover { background: #f9fafb; }
.txn-row-selected { background: #e0e7ff !important; }
.txn-desc { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txn-amount { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.txn-neg { color: var(--perch-error); }
.txn-pos { color: var(--perch-success); }
.txn-account { font-size: 11px; color: var(--perch-text-muted); max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.txn-empty { padding: 40px 20px; text-align: center; color: var(--perch-text-muted); font-style: italic; }

/* Batch bar */
.txn-batch-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: #e0e7ff; border-radius: 8px 8px 0 0;
  font-size: 13px; font-weight: 500;
}
.txn-batch-btn {
  padding: 4px 10px; border: 1px solid var(--perch-primary); border-radius: 4px;
  background: white; color: var(--perch-primary); font-size: 12px; cursor: pointer;
}

/* Property selector (inline) */
.prop-editable {
  cursor: pointer; padding: 2px 4px; border-radius: 3px; transition: background 0.15s;
}
.prop-editable:hover { background: #fef3c7; text-decoration: underline; }
.prop-search-dropdown { position: relative; display: inline-block; }
.prop-search-panel {
  position: absolute; top: 0; left: 0; z-index: 100;
  min-width: 220px; background: white;
  border: 1px solid var(--perch-border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}
.prop-search-input {
  width: 100%; padding: 8px 10px; border: none;
  border-bottom: 1px solid var(--perch-border);
  border-radius: 8px 8px 0 0; font-size: 13px; outline: none;
}
.prop-search-input:focus { box-shadow: inset 0 -2px 0 var(--perch-primary); }
.prop-search-list { max-height: 200px; overflow-y: auto; padding: 4px 0; }
.prop-search-item {
  padding: 6px 12px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.prop-search-item:hover { background: #f3f4f6; }
.prop-search-active { background: #fef3c7; font-weight: 600; }

/* GL header with auto-classify button — fixed above scroll */
.tb-gl-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 8px;
  flex-shrink: 0;
}
.tb-gl-header .tb-detail-title { margin-bottom: 0; }

/* Sticky column headers inside scroll area */
.report-table-wrap .gl-table thead th,
.report-table-wrap .tb-summary-table thead th {
  position: sticky; top: 0; z-index: 1;
}

/* TB title — fixed above scroll */
.tb-detail-section > .tb-detail-title {
  flex-shrink: 0; margin-bottom: 6px;
}
.auto-classify-btn {
  margin-left: auto;
  padding: 4px 12px; font-size: 11px; font-weight: 600;
  border: 1px solid var(--perch-primary); border-radius: 6px;
  background: var(--perch-primary); color: white; cursor: pointer;
  white-space: nowrap;
}
.auto-classify-btn:hover { background: #1d4ed8; }
.auto-classify-btn:disabled { opacity: 0.7; cursor: not-allowed; }
.auto-classify-btn.classifying { animation: pulse-classify 2s ease-in-out infinite; min-width: 200px; }
@keyframes pulse-classify { 0%,100% { opacity: 0.7; } 50% { opacity: 1; } }

/* Multi-select checkboxes */
.gl-check { width: 28px; text-align: center; }
.gl-check input[type="checkbox"] { cursor: pointer; accent-color: var(--perch-primary); }
.selected-row { background: #eff6ff; }
.selected-row:hover { background: #dbeafe; }
.selection-info {
  display: flex; align-items: center; gap: 6px; font-size: 12px;
  color: var(--perch-primary); font-weight: 500;
}
.selection-clear {
  padding: 2px 8px; border: 1px solid var(--perch-border); border-radius: 4px;
  background: transparent; cursor: pointer; font-size: 11px;
}
.selection-clear:hover { background: var(--perch-bg); }

/* Toast notification */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; border-radius: 8px;
  font-size: 13px; font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: toast-in 0.3s ease-out;
}
.toast-success { background: #065f46; color: white; }
.toast-error { background: var(--perch-error); color: white; }
.toast-info { background: var(--perch-text); color: white; }
.toast-close {
  background: none; border: none; color: inherit; cursor: pointer;
  font-size: 18px; line-height: 1; opacity: 0.7; padding: 0 0 0 4px;
}
.toast-close:hover { opacity: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* Year picker */
.tb-year-picker {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.tb-year-picker label { font-size: 13px; font-weight: 600; color: var(--perch-text-muted); }
.tb-year-select {
  padding: 4px 8px; border: 1px solid var(--perch-border); border-radius: 6px;
  font-size: 13px; background: var(--perch-surface); color: var(--perch-text);
  cursor: pointer;
}
.tb-year-select:focus { outline: none; box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2); }

/* Categorization notification toast */
.cat-summary {
  font-size: 12px; color: var(--perch-text-muted); margin-top: 4px;
}
.cat-summary .cat-count { font-weight: 600; color: var(--perch-success); }
.cat-summary .cat-review { font-weight: 600; color: var(--perch-warning); }

/* API Keys Panel */
.api-keys-panel { padding: 24px; max-width: 700px; }
.api-keys-panel h3 { margin: 0 0 4px; font-size: 20px; }
.api-keys-description { font-size: 14px; color: var(--perch-text-muted); margin-bottom: 20px; line-height: 1.5; }
.api-keys-description code { background: var(--perch-bg); padding: 2px 6px; border-radius: 4px; font-size: 13px; }
.api-key-actions { display: flex; gap: 8px; margin-bottom: 20px; }
.api-key-generate {
  padding: 8px 18px; border: none; border-radius: 6px;
  background: var(--perch-primary); color: white; font-size: 13px;
  font-weight: 600; cursor: pointer;
}
.api-key-generate:disabled { opacity: 0.5; cursor: not-allowed; }
.api-key-generate.api-key-cpa { background: var(--perch-secondary); }
.api-key-new {
  padding: 16px; background: #f0fdf4; border: 1px solid #bbf7d0;
  border-radius: 8px; margin-bottom: 16px;
}
.api-key-new h4 { margin: 0 0 4px; font-size: 15px; color: #166534; }
.api-key-new p { font-size: 13px; color: #166534; margin-bottom: 10px; }
.api-key-value {
  display: flex; gap: 8px; align-items: center; padding: 8px 12px;
  background: white; border: 1px solid #bbf7d0; border-radius: 6px;
  margin-bottom: 8px;
}
.api-key-value code { flex: 1; font-size: 12px; word-break: break-all; color: #1e293b; }
.api-key-value button {
  padding: 4px 12px; border: 1px solid var(--perch-primary); border-radius: 4px;
  background: white; color: var(--perch-primary); font-size: 12px; cursor: pointer;
  white-space: nowrap;
}
.api-key-dismiss {
  padding: 4px 12px; border: none; background: none;
  color: #64748b; font-size: 12px; cursor: pointer;
}
.api-key-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; background: var(--perch-surface); border: 1px solid var(--perch-border);
  border-radius: 8px; margin-bottom: 8px;
}
.api-key-info { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.api-key-hint code { font-size: 12px; background: var(--perch-bg); padding: 2px 6px; border-radius: 4px; }
.api-key-type { font-size: 11px; color: var(--perch-text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.api-key-date { font-size: 11px; color: var(--perch-text-muted); }
.api-key-revoke {
  padding: 4px 12px; border: 1px solid var(--perch-error); border-radius: 4px;
  background: white; color: var(--perch-error); font-size: 12px; cursor: pointer;
}
.api-key-revoke:hover { background: var(--perch-error); color: white; }
.api-key-empty { font-size: 14px; color: var(--perch-text-muted); font-style: italic; margin: 16px 0; }
.api-key-error { color: var(--perch-error); font-size: 13px; margin-bottom: 12px; }
.api-key-docs { margin-top: 24px; }
.api-key-docs h4 { font-size: 14px; margin: 16px 0 8px; }
.api-key-code {
  background: #1e293b; color: #e2e8f0; padding: 12px 16px; border-radius: 8px;
  font-size: 12px; overflow-x: auto; white-space: pre;
}
.api-key-endpoints { font-size: 13px; line-height: 2; color: var(--perch-text-muted); }
.api-key-endpoints code { background: var(--perch-bg); padding: 2px 6px; border-radius: 4px; font-size: 12px; }

/* Responsive: stack on narrow screens */
@media (max-width: 768px) {
  .workspace { flex-direction: column; }
  .workspace-dashboard { border-right: none; border-bottom: 1px solid var(--perch-border); max-height: 40vh; }
  .workspace-chat { width: 100%; min-width: unset; flex: 1; }
  .plans-grid { grid-template-columns: 1fr; }
  .layer-sources .layer-content { flex-direction: column; }
  /* Touch targets: min 44px */
  .nav-links button, .oauth-btn, .chat-toggle, .suggestion-chip,
  .chat-input-container button, .auth-form button, .auth-form a,
  .auth-links a, .nav-home-btn, .nav-sharing-btn, .nav-pricing-btn,
  .nav-cpa-btn, .nav-admin-btn, .nav-site-link {
    min-height: 44px; min-width: 44px;
  }
  .auth-providers { grid-template-columns: 1fr; }
  .chat-agents-row { gap: 6px; }
  .perch-nav { padding: 8px 12px; }
  .nav-links { gap: 4px; }
  .nav-links button { padding: 8px 10px; font-size: 12px; }
}

/* ================================================================
   Admin Dashboard
   ================================================================ */

.admin-dropdown { position: relative; }
.nav-admin-btn.active { background: var(--perch-primary); color: white; border-radius: 6px; }
.nav-admin-btn { border-color: #ddd !important; }
.admin-dropdown-menu {
  position: absolute; top: 100%; right: 0; z-index: 1000;
  min-width: 160px; padding-top: 4px;
}
.admin-dropdown-menu-inner {
  background: white; border: 1px solid var(--perch-border);
  border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  padding: 4px 0;
}
.admin-menu-item {
  display: block; width: 100%; padding: 6px 12px;
  border: none !important; background: none; text-align: left;
  font-size: 13px; color: var(--perch-text);
  cursor: pointer; white-space: nowrap; border-radius: 0;
}
.admin-menu-item:hover { background: #f3f4f6 !important; }
.admin-menu-item:disabled { opacity: 0.5; cursor: not-allowed; }
.admin-menu-divider { height: 1px; background: var(--perch-border); margin: 2px 0; }

.admin-panel { padding: 24px; }
.admin-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px;
}
.admin-header h2 { font-size: 22px; font-weight: 700; }

.admin-error {
  background: #fef2f2; color: #dc2626; padding: 10px 14px;
  border-radius: 8px; margin-bottom: 16px; font-size: 13px;
}
.admin-loading {
  color: var(--perch-text-muted); font-size: 13px;
  padding: 12px 0; text-align: center;
}
.admin-empty { text-align: center; padding: 60px 20px; color: var(--perch-text-muted); }

/* Stat cards grid */
.admin-stats-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px; margin-bottom: 24px;
}
.admin-stat-card {
  background: var(--perch-surface); border: 1px solid var(--perch-border);
  border-radius: 10px; padding: 14px 16px; text-align: center;
}
.admin-stat-value { font-size: 28px; font-weight: 700; color: var(--perch-primary); }
.admin-stat-label { font-size: 12px; color: var(--perch-text-muted); margin-top: 2px; }
.admin-stat-sub { font-size: 11px; color: var(--perch-text-muted); margin-top: 4px; opacity: 0.7; }

/* Sections */
.admin-section { margin-bottom: 24px; }
.admin-section h3 { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.admin-section-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}

/* Two-column layout for adoption cards */
.admin-two-col {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.admin-card {
  background: var(--perch-surface); border: 1px solid var(--perch-border);
  border-radius: 10px; padding: 16px;
}
.admin-card h4 { font-size: 13px; font-weight: 600; margin-bottom: 10px; }

/* Search */
.admin-search-wrap {
  position: relative; display: inline-block;
}
.admin-search {
  padding: 6px 28px 6px 12px; border: 1px solid var(--perch-border);
  border-radius: 6px; font-size: 13px; width: 280px;
}
.admin-search-clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: none; background: none; cursor: pointer;
  font-size: 16px; color: var(--perch-text-muted); padding: 0 4px;
  line-height: 1;
}
.admin-search-clear:hover { color: var(--perch-text); }

/* Tables */
.admin-table-wrap { overflow-x: auto; }
.admin-table {
  width: 100%; border-collapse: collapse; font-size: 12px;
}
.admin-table th {
  text-align: left; padding: 6px 10px; font-weight: 600;
  border-bottom: 2px solid var(--perch-border);
  color: var(--perch-text-muted); font-size: 11px; text-transform: uppercase;
  white-space: nowrap;
}
.admin-table td {
  padding: 7px 10px; border-bottom: 1px solid var(--perch-border);
  white-space: nowrap;
}
.admin-td-num { text-align: right; font-variant-numeric: tabular-nums; }
.admin-td-email { font-weight: 500; }

/* Users table */
.admin-users-table { background: var(--perch-surface); border-radius: 10px; overflow: hidden; }
.admin-user-row:hover { background: #f1f5f9; }

/* Badges */
.admin-badges { display: flex; gap: 4px; flex-wrap: wrap; }
.admin-badge {
  display: inline-block; padding: 2px 7px; border-radius: 4px;
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  background: #e0e7ff; color: #3730a3;
}
.badge-bookings { background: #d1fae5; color: #065f46; }
.badge-banking  { background: #fef3c7; color: #92400e; }
.badge-accounting { background: #ede9fe; color: #5b21b6; }
.badge-cpa-tools  { background: #fce7f3; color: #9d174d; }

.admin-plan-badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 10px; font-weight: 600; text-transform: uppercase;
}
.plan-none     { background: #f1f5f9; color: #64748b; }
.plan-starter  { background: #dbeafe; color: #1e40af; }
.plan-operator { background: #d1fae5; color: #065f46; }
.plan-portfolio { background: #fef3c7; color: #92400e; }
.plan-pro      { background: #ede9fe; color: #5b21b6; }

.admin-status-badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 10px; font-weight: 600;
}
.status-active   { background: #d1fae5; color: #065f46; }
.status-in_trial { background: #dbeafe; color: #1e40af; }
.status-cancelled { background: #fef2f2; color: #dc2626; }
.status-none     { background: #f1f5f9; color: #64748b; }

/* Detail modal */
.admin-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 1000; display: flex; justify-content: center; align-items: flex-start;
  padding: 40px 20px; overflow-y: auto;
}
.admin-modal {
  background: var(--perch-surface); border-radius: 12px;
  width: 100%; max-width: 900px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.admin-modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--perch-border);
}
.admin-modal-header h3 { font-size: 16px; font-weight: 600; }
.admin-modal-close {
  background: none; border: none; font-size: 22px; cursor: pointer;
  color: var(--perch-text-muted); padding: 4px 8px;
}
.admin-modal-body { padding: 20px; max-height: 70vh; overflow-y: auto; }

.admin-detail-stats {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px; margin-bottom: 16px;
}
.admin-detail-stats .admin-stat-card { padding: 10px 12px; }
.admin-detail-stats .admin-stat-value { font-size: 22px; }

.admin-detail-meta {
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center;
  font-size: 12px; color: var(--perch-text-muted);
  margin-bottom: 20px; padding: 10px 14px;
  background: #f8fafc; border-radius: 8px;
}
.admin-plan-override {
  margin-top: 12px; padding: 12px; background: #f0fdf4;
  border: 1px solid #bbf7d0; border-radius: 8px;
}
.admin-plan-override h4 { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.admin-plan-select {
  padding: 5px 10px; border: 1px solid var(--perch-border); border-radius: 6px;
  font-size: 13px; background: white;
}
.admin-plan-btn {
  padding: 5px 14px; border: none; border-radius: 6px;
  background: var(--perch-primary); color: white;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.admin-plan-btn:hover { opacity: 0.9; }

.admin-delete-trigger {
  margin-left: auto; padding: 4px 12px; border: 1px solid #fca5a5;
  border-radius: 6px; background: #fef2f2; color: #dc2626;
  font-size: 11px; font-weight: 600; cursor: pointer;
}
.admin-delete-trigger:hover { background: #fee2e2; }

/* Delete confirmation modal */
.admin-delete-confirm {
  background: white; border-radius: 14px; padding: 28px 32px;
  max-width: 440px; width: 90%; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.admin-delete-icon { font-size: 36px; margin-bottom: 12px; }
.admin-delete-confirm h3 { font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.admin-delete-warning { font-size: 13px; color: #394450; line-height: 1.5; margin-bottom: 8px; }
.admin-delete-actions {
  display: flex; gap: 10px; justify-content: center; margin-top: 20px;
}
.admin-delete-cancel {
  padding: 8px 20px; border: 1px solid #d1d5db; border-radius: 8px;
  background: white; cursor: pointer; font-size: 13px; font-weight: 600;
}
.admin-delete-cancel:hover { background: #f3f4f6; }
.admin-delete-btn {
  padding: 8px 20px; border: none; border-radius: 8px;
  background: #dc2626; color: white; cursor: pointer;
  font-size: 13px; font-weight: 600;
}
.admin-delete-btn:hover { background: #b91c1c; }
.admin-delete-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.admin-detail-section { margin-bottom: 20px; }
.admin-detail-section h4 { font-size: 13px; font-weight: 600; margin-bottom: 8px; }

/* Tallyfor card in Tax layer */
.tallyfor-card.slot-connected { border-color: #0d9488; }
.tallyfor-card.slot-connected .slot-status { color: #0d9488; }
.tallyfor-icon svg { display: block; }

/* ===== Referral Panel ===== */
.referral-panel {
  padding: 24px; max-width: 720px;
}
.referral-header { margin-bottom: 24px; }
.referral-header h2 { font-size: 22px; font-weight: 700; color: var(--perch-text); }
.referral-subtitle { color: var(--perch-text-muted); font-size: 14px; margin-top: 4px; }
.referral-loading { display: flex; justify-content: center; padding: 40px; }

/* Stats row */
.referral-stats-row {
  display: flex; gap: 14px; margin-bottom: 24px;
}
.referral-stat-card {
  flex: 1; text-align: center; padding: 16px 12px;
  background: var(--perch-surface); border: 1px solid var(--perch-border);
  border-radius: 10px;
}
.referral-stat-value { font-size: 26px; font-weight: 700; color: var(--perch-primary); }
.referral-stat-label { font-size: 12px; color: var(--perch-text-muted); margin-top: 2px; }

/* Share link */
.referral-share-section { margin-bottom: 20px; }
.referral-share-section h3 { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.referral-link-row { display: flex; gap: 8px; }
.referral-link-input {
  flex: 1; padding: 8px 12px; border: 1px solid var(--perch-border);
  border-radius: 6px; font-size: 13px; color: var(--perch-text);
  background: #f8fafc; outline: none;
}
.referral-copy-btn {
  padding: 8px 18px; border: 1px solid var(--perch-primary);
  border-radius: 6px; background: var(--perch-primary); color: white;
  font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.referral-copy-btn:hover { opacity: 0.9; }
.referral-copy-btn.copied {
  background: var(--perch-success); border-color: var(--perch-success);
}

/* Email invite */
.referral-invite-section { margin-bottom: 24px; }
.referral-invite-section h3 { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.referral-invite-row { display: flex; gap: 8px; }
.referral-invite-input {
  flex: 1; padding: 8px 12px; border: 1px solid var(--perch-border);
  border-radius: 6px; font-size: 13px; outline: none;
}
.referral-invite-input:focus { border-color: var(--perch-primary); }
.referral-send-btn {
  padding: 8px 18px; border: 1px solid var(--perch-primary);
  border-radius: 6px; background: white; color: var(--perch-primary);
  font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.referral-send-btn:hover { background: #eef2ff; }
.referral-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* How it works */
.referral-how-it-works {
  padding: 18px; background: #eef2ff; border-radius: 10px; margin-bottom: 24px;
}
.referral-how-it-works h3 { font-size: 14px; font-weight: 600; margin-bottom: 12px; color: var(--perch-primary); }
.referral-steps { display: flex; flex-direction: column; gap: 10px; }
.referral-step { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.referral-step-num {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--perch-primary); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.referral-cap-note {
  margin-top: 12px; font-size: 13px; font-weight: 600;
  color: var(--perch-primary);
}

/* Referral table */
.referral-table-section { margin-bottom: 20px; }
.referral-table-section h3 { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.referral-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.referral-table th {
  text-align: left; padding: 8px 12px; font-weight: 600;
  border-bottom: 2px solid var(--perch-border); color: var(--perch-text-muted);
  font-size: 12px; text-transform: uppercase;
}
.referral-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--perch-border);
}
.referral-email { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }

/* Status badges */
.referral-status-badge {
  display: inline-block; padding: 2px 10px; border-radius: 12px;
  font-size: 12px; font-weight: 600;
}
.referral-status-badge.status-invited { background: #f1f5f9; color: #64748b; }
.referral-status-badge.status-signed-up { background: #dbeafe; color: #2563eb; }
.referral-status-badge.status-subscribed { background: #dcfce7; color: #16a34a; }
.referral-status-badge.status-churned { background: #fee2e2; color: #dc2626; }

/* Credits card */
.referral-credits-card {
  padding: 14px 18px; background: #dcfce7; border-radius: 10px;
  font-size: 14px; font-weight: 600; color: #16a34a;
}

/* Nav button active state */
.nav-referrals-btn.active {
  background: var(--perch-primary) !important;
  color: white !important;
  border-color: var(--perch-primary) !important;
}

/* Demo banner */
.demo-banner {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  padding: 10px 20px;
  background: #fef3c7; border-bottom: 1px solid #fbbf24;
  font-size: 14px; color: #92400e;
}
.demo-banner-btn {
  padding: 5px 16px; border: 1px solid #d97706; border-radius: 6px;
  background: #fffbeb; color: #92400e; font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.demo-banner-btn:hover {
  background: #fde68a;
}
.demo-loading {
  gap: 10px;
}

/* ===================================================================
   Full Year Tax Prep — Card + Wizard
   =================================================================== */

/* Dashboard card */
.full-year-card {
  padding: 16px 20px; border-radius: 10px; margin-bottom: 16px;
  background: var(--perch-surface); border: 1px solid var(--perch-border);
  transition: all 0.2s;
}
.full-year-card.full-year-prominent {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border-color: #f59e0b;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.15);
}
.full-year-card.full-year-complete {
  border-color: var(--perch-success);
  background: #f0fdf4;
}
.full-year-card-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 6px;
}
.full-year-card-icon { color: #d97706; flex-shrink: 0; }
.full-year-prominent .full-year-card-icon { color: #92400e; }
.full-year-card-title { font-size: 15px; font-weight: 700; }
.full-year-card-desc {
  font-size: 13px; color: var(--perch-text-muted); margin-bottom: 10px;
}
.full-year-progress-bar {
  height: 4px; background: var(--perch-border); border-radius: 2px;
  margin-bottom: 10px; overflow: hidden;
}
.full-year-progress-fill {
  height: 100%; background: var(--perch-primary); border-radius: 2px;
  transition: width 0.3s;
}
.full-year-cta {
  padding: 6px 18px; border: none; border-radius: 6px;
  background: var(--perch-primary); color: white;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.full-year-prominent .full-year-cta {
  background: #d97706;
}
.full-year-cta:hover { opacity: 0.9; }
.full-year-cta-purchase {
  background: #14b8a6;
}
.full-year-cta-purchase:hover { background: #0d9488; opacity: 1; }

/* Full-year checklist — horizontal */
.fy-checklist-row {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
  flex-wrap: wrap;
}
.fy-check-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: #6A7582;
}
.fy-check-item.fy-check-done { color: #16a34a; }
.fy-check-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%;
  font-size: 10px; font-weight: 700;
  background: #e5e7eb; color: #6A7582;
  flex-shrink: 0;
}
.fy-check-done .fy-check-icon {
  background: #dcfce7; color: #16a34a;
}
.fy-check-label { font-weight: 500; }
.fy-check-separator {
  width: 20px; height: 1px; background: #d1d5db;
}

/* Wizard panel */
.full-year-panel {
  max-width: 720px; margin: 0 auto; padding: 0 8px;
}
.fy-panel-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px;
}
.fy-panel-header h2 { font-size: 20px; font-weight: 700; }
.fy-close {
  width: 32px; height: 32px; border: none; border-radius: 6px;
  background: var(--perch-bg); font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* Step indicator */
.fy-steps {
  display: flex; gap: 4px; margin-bottom: 24px;
  padding: 12px 0; border-bottom: 1px solid var(--perch-border);
}
.fy-step {
  flex: 1; display: flex; align-items: center; gap: 6px;
  padding: 6px 8px; border-radius: 6px; font-size: 12px;
}
.fy-step-num {
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
  background: var(--perch-border); color: var(--perch-text-muted);
}
.fy-step-done .fy-step-num {
  background: var(--perch-success); color: white;
}
.fy-step-active .fy-step-num {
  background: var(--perch-primary); color: white;
}
.fy-step-label { font-weight: 500; }
.fy-step-active .fy-step-label { font-weight: 700; color: var(--perch-primary); }
.fy-step-done .fy-step-label { color: var(--perch-success); }

/* Step content */
.fy-step-content { padding: 8px 0; }
.fy-step-content h3 { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.fy-step-content p { font-size: 14px; color: var(--perch-text-muted); margin-bottom: 12px; }
.fy-option {
  padding: 14px 16px; border: 1px solid var(--perch-border);
  border-radius: 8px; margin-bottom: 12px;
}
.fy-option h4 { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.fy-hint { font-size: 12px !important; color: var(--perch-text-muted); }
.fy-btn {
  padding: 7px 18px; border: 1px solid var(--perch-border); border-radius: 6px;
  background: var(--perch-surface); font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.fy-btn:hover { background: var(--perch-bg); }
.fy-btn.fy-btn-primary {
  background: var(--perch-primary); color: white; border-color: var(--perch-primary);
}
.fy-btn.fy-btn-primary:hover { opacity: 0.9; }
.fy-btn-secondary {
  padding: 7px 18px; border: 1px solid var(--perch-border); border-radius: 6px;
  background: var(--perch-surface); font-size: 13px; cursor: pointer;
}
.fy-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.fy-file-label {
  display: inline-block; padding: 7px 18px; border: 1px dashed var(--perch-border);
  border-radius: 6px; font-size: 13px; cursor: pointer; margin-bottom: 8px;
}
.fy-file-label:hover { background: var(--perch-bg); }
.fy-file-ready {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; font-size: 13px; color: var(--perch-success);
}
.fy-connected-badge {
  display: inline-block; padding: 4px 12px; border-radius: 12px;
  background: #dcfce7; color: #16a34a; font-size: 13px; font-weight: 600;
}
.fy-success { color: var(--perch-success); font-size: 13px; margin-top: 8px; }
.fy-error { color: var(--perch-error); font-size: 13px; margin-top: 8px; }
.fy-nav {
  display: flex; gap: 10px; margin-top: 20px; padding-top: 16px;
  border-top: 1px solid var(--perch-border);
}
.fy-categorizing {
  display: flex; align-items: center; gap: 12px; padding: 16px 0;
}
.fy-property-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.fy-property-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; border: 1px solid var(--perch-border); border-radius: 6px;
  font-size: 13px;
}
.fy-property-check { color: var(--perch-success); font-weight: 700; }
.fy-empty { padding: 16px 0; }
.fy-review-summary {
  display: flex; gap: 20px; padding: 16px; background: var(--perch-bg);
  border-radius: 8px; margin-bottom: 12px;
}
.fy-stat { display: flex; flex-direction: column; }
.fy-stat-label { font-size: 12px; color: var(--perch-text-muted); text-transform: uppercase; }
.fy-stat-value { font-size: 20px; font-weight: 700; }
.fy-review-hint { font-style: italic; }
.fy-done-icon {
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--perch-success); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; margin: 16px 0;
}
.fy-done-actions { display: flex; gap: 10px; margin-top: 16px; }

/* Excluded transactions */
.excluded-summary {
  padding: 8px 12px; background: #fefce8; border: 1px solid #fde68a;
  border-radius: 6px; margin-bottom: 12px; font-size: 13px;
}
.excluded-count { color: #92400e; font-weight: 600; }
.excluded-details { margin-top: 8px; }
.excluded-details summary {
  cursor: pointer; color: var(--perch-primary); font-size: 12px;
}
.excluded-list {
  max-height: 300px; overflow-y: auto; margin-top: 6px;
  display: flex; flex-direction: column; gap: 4px;
}
.excluded-item {
  display: flex; align-items: center; gap: 8px; padding: 4px 8px;
  background: white; border-radius: 4px; font-size: 12px;
}
.excluded-date { width: 80px; color: var(--perch-text-muted); flex-shrink: 0; }
.excluded-desc { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.excluded-amt { width: 70px; text-align: right; flex-shrink: 0; }
.excluded-undo {
  padding: 2px 8px; border: 1px solid var(--perch-border); border-radius: 4px;
  background: white; font-size: 11px; cursor: pointer; flex-shrink: 0;
}
.excluded-undo:hover { background: var(--perch-bg); }

/* === Feature Gate Overlays === */

/* TB detail blur gate */
.tb-gate-overlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  backdrop-filter: blur(6px);
  background: rgba(255,255,255,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 5; border-radius: 8px;
}
.tb-gate-content {
  text-align: center; padding: 24px; max-width: 320px;
}
.tb-gate-icon { font-size: 28px; margin-bottom: 8px; }
.tb-gate-title {
  font-size: 15px; font-weight: 600; color: var(--perch-text);
  margin-bottom: 6px;
}
.tb-gate-subtitle {
  font-size: 12px; color: var(--perch-text-muted); line-height: 1.5;
  margin-bottom: 14px;
}
.tb-gate-btn {
  padding: 8px 24px; border: none; border-radius: 8px;
  background: var(--perch-primary); color: white;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.tb-gate-btn:hover { opacity: 0.9; }

/* Reports gate banner */
.reports-gate {
  text-align: center; padding: 48px 24px;
  background: var(--perch-bg); border: 1px solid var(--perch-border);
  border-radius: 12px; margin-top: 8px;
}
.reports-gate-icon { font-size: 36px; margin-bottom: 12px; }
.reports-gate-title {
  font-size: 18px; font-weight: 600; color: var(--perch-text);
  margin-bottom: 8px;
}
.reports-gate-msg {
  font-size: 14px; color: var(--perch-text-muted); line-height: 1.6;
  max-width: 440px; margin: 0 auto 20px;
}
.reports-gate-btn {
  padding: 10px 28px; border: none; border-radius: 8px;
  background: var(--perch-primary); color: white;
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.reports-gate-btn:hover { opacity: 0.9; }

/* Chat message limit */
.chat-limit-banner {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 12px 16px; border-top: 1px solid var(--perch-border);
  background: #fffbeb; font-size: 13px; color: #92400e;
}
.chat-limit-btn {
  padding: 6px 16px; border: none; border-radius: 6px;
  background: var(--perch-primary); color: white;
  font-size: 12px; font-weight: 600; cursor: pointer;
}
.chat-limit-btn:hover { opacity: 0.9; }
.chat-remaining {
  font-size: 10px; color: var(--perch-text-muted);
  padding: 2px 0; text-align: center; width: 100%;
  position: absolute; bottom: -14px; left: 0;
}
.chat-input-container { position: relative; }

/* Sync period picker */
.sync-period-select {
  width: 100%; padding: 5px 8px; font-size: 11px;
  border: 1px solid var(--perch-border); border-radius: 6px;
  background: var(--perch-bg); color: var(--perch-text);
  cursor: pointer; outline: none;
}
.sync-period-select:focus {
  border-color: var(--perch-primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}
.sync-range {
  font-size: 10px; color: var(--perch-text-muted); margin-top: 2px;
}

/* === Responsive TB — progressive: hide columns first, stack last === */

/* Step 1: Tight — hide account code */
@container dashboard (max-width: 1100px) {
  .col-acct-code { display: none; }
}

/* Step 2: Tighter — also hide debit/credit, keep balance */
@container dashboard (max-width: 900px) {
  .col-acct-code { display: none; }
  .col-dr-cr { display: none; }
  .gl-desc { max-width: 180px; }
}

/* Step 3: Narrowest — stack GL + TB vertically, restore all columns */
@container dashboard (max-width: 700px) {
  .tb-detail-columns { flex-direction: column; }
  .tb-detail-columns > .tb-gl-section { border-right: none; border-bottom: 1px solid var(--perch-border); }
  .col-acct-code { display: table-cell; }
  .col-dr-cr { display: table-cell; }
  .gl-desc { max-width: 240px; }
  .tb-detail-section { padding: 8px 10px; }
}
