/* ── Reset & base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #1a1a2e;
  --surface:   #16213e;
  --surface2:  #0f3460;
  --accent:    #e94560;
  --accent2:   #533483;
  --text:      #e0e0e0;
  --text-dim:  #888;
  --elsa:      #7c6af5;
  --radius:    12px;
  --sidebar-w: 260px;
  --header-h:  56px;
  --input-h:   64px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  color: var(--text);
}

body { background: var(--bg); height: 100dvh; overflow: hidden; }

.hidden { display: none !important; }
.screen { width: 100%; height: 100dvh; }
.error { color: var(--accent); font-size: 0.85rem; margin-top: 8px; }

/* ── Login ─────────────────────────────────────────────────────────── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-box {
  width: 100%;
  max-width: 340px;
  padding: 40px 32px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.login-title {
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--elsa);
  text-align: center;
  letter-spacing: -1px;
}

.login-subtitle {
  text-align: center;
  color: var(--text-dim);
  margin-bottom: 28px;
  font-size: 0.9rem;
}

#login-form input {
  display: block;
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 12px;
  background: var(--bg);
  border: 1px solid var(--surface2);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

#login-form input:focus { border-color: var(--elsa); }

#login-form button {
  width: 100%;
  padding: 13px;
  background: var(--elsa);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

#login-form button:hover { opacity: 0.85; }

/* ── App layout ────────────────────────────────────────────────────── */
#app-screen {
  display: flex;
  height: 100dvh;
}

/* ── Sidebar ────────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid rgba(255,255,255,0.06);
  transition: transform 0.25s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: var(--header-h);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.app-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--elsa);
}

#room-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.room-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  border-radius: 8px;
  margin: 2px 8px;
  transition: background 0.15s;
}

.room-item:hover { background: var(--surface2); }
.room-item.active { background: var(--surface2); }

.room-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.room-icon.main { background: var(--elsa); }

.room-info { overflow: hidden; }
.room-item-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-item-preview {
  font-size: 0.8rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
}

/* ── Chat area ──────────────────────────────────────────────────────── */
#chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

#chat-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: var(--surface);
  flex-shrink: 0;
}

#chat-header-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

#room-name {
  font-weight: 600;
  font-size: 1rem;
}

#sidebar-toggle { display: none; }

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-behavior: smooth;
}

/* ── Message bubbles ────────────────────────────────────────────────── */
.msg-group {
  display: flex;
  flex-direction: column;
  max-width: 72%;
}

.msg-group.mine { align-self: flex-end; align-items: flex-end; }
.msg-group.theirs { align-self: flex-start; align-items: flex-start; }
.msg-group.elsa-group { align-self: flex-start; align-items: flex-start; }

.msg-meta {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-bottom: 3px;
  padding: 0 4px;
}

.bubble {
  padding: 9px 14px;
  border-radius: 18px;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
  max-width: 100%;
}

.msg-group.mine .bubble {
  background: var(--surface2);
  border-bottom-right-radius: 4px;
}

.msg-group.theirs .bubble {
  background: var(--surface);
  border-bottom-left-radius: 4px;
}

.msg-group.elsa-group .bubble {
  background: linear-gradient(135deg, #2d1f6e, #1a1a4e);
  border: 1px solid var(--elsa);
  border-bottom-left-radius: 4px;
  color: #d8d4ff;
}

.msg-time {
  font-size: 0.68rem;
  color: var(--text-dim);
  margin-top: 2px;
  padding: 0 4px;
}

.msg-group.mine .msg-time { text-align: right; }

/* Confirm button in Elsa messages */
.confirm-btn {
  margin-top: 8px;
  padding: 7px 16px;
  background: var(--accent);
  border: none;
  border-radius: 20px;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.confirm-btn:hover { opacity: 0.8; }
.confirm-btn.cancel { background: var(--surface2); }

/* Consolidated bill rows */
.bill-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.bill-row .bill-label {
  flex: 1;
  min-width: 0;
}
.bill-row .confirm-btn {
  margin-top: 0;
  flex-shrink: 0;
}
.overdue-tag {
  background: #c0392b;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 4px;
  vertical-align: middle;
}

/* ── Review notification bar ────────────────────────────────────────── */
#review-bar {
  flex-shrink: 0;
  background: linear-gradient(135deg, #1e1535, #111130);
  border-top: 1px solid rgba(124,106,245,0.4);
}
#review-bar-btn {
  width: 100%;
  padding: 14px 20px;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #c4b5fd;
  font-size: 0.95rem;
  font-weight: 600;
}
#review-bar-btn:hover { background: rgba(255,255,255,0.04); }
#review-bar-icon { font-size: 1.1rem; }
.review-bar-arrow { margin-left: auto; font-size: 1.2rem; color: var(--elsa); }

/* ── Review panel — wizard layout ───────────────────────────────────── */
#review-panel { padding: 0; }
#review-panel-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0 0 env(safe-area-inset-bottom);
}
.rv-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: var(--surface);
}
.rv-progress { font-size: 0.78rem; color: var(--text-dim); }
.rv-close-btn {
  background: none;
  border: none;
  color: #888;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.rv-close-btn:hover { background: rgba(255,255,255,0.07); color: #ccc; }

/* Bill card (non-wizard) */
.rv-card {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: var(--radius);
  padding: 20px;
}
.rv-card-title { font-size: 1.05rem; font-weight: 600; margin-bottom: 8px; }
.rv-card-amount { font-size: 1.5rem; font-weight: 700; color: #c4b5fd; margin-bottom: 16px; }
.rv-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.rv-btn {
  flex: 1;
  min-width: 120px;
  padding: 13px 20px;
  border: none;
  border-radius: 24px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.rv-btn:hover { opacity: 0.85; }
.rv-btn-pay { background: var(--elsa); color: #fff; }
.rv-btn-skip { background: var(--surface2); color: var(--text); }
.rv-footer {
  flex-shrink: 0;
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,0.06);
  background: var(--surface);
}
.rv-footer .rv-btn { flex: 1; }
.rv-done { text-align: center; padding: 40px; font-size: 1.2rem; color: #c4b5fd; }

/* Wizard container */
.rv-wizard {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Active (sticky) item at top */
.rv-active-item {
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 2px solid rgba(124,106,245,0.5);
  padding: 14px 20px;
  cursor: pointer;
  user-select: none;
}
.rv-active-item:hover { background: rgba(255,255,255,0.03); }
.rv-active-label {
  font-size: 0.72rem;
  color: var(--elsa);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 3px;
}
.rv-active-desc {
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rv-active-meta { font-size: 0.83rem; color: var(--text-dim); margin-top: 2px; }
.rv-expand-hint { font-size: 0.72rem; color: var(--text-dim); margin-top: 6px; }

/* Expanded left items list */
.rv-left-list {
  flex-shrink: 0;
  background: rgba(0,0,0,0.25);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  max-height: 220px;
  overflow-y: auto;
}
.rv-left-item {
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.rv-left-item.active { background: rgba(124,106,245,0.15); }
.rv-left-item:hover:not(.active) { background: rgba(255,255,255,0.03); }
.rv-left-item-text { font-size: 0.88rem; }
.rv-left-item-amount { font-size: 0.85rem; color: var(--text-dim); flex-shrink: 0; margin-left: 10px; }

/* Scrollable column (candidates + resolution + chat) */
.rv-scroll-col {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Candidates section label */
.rv-cands-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 14px 20px 8px;
}

/* Candidate rows */
.rv-cand-item {
  padding: 13px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  border-left: 3px solid transparent;
  transition: background 0.1s;
}
.rv-cand-item:hover { background: rgba(255,255,255,0.04); }
.rv-cand-item.suggested {
  background: rgba(124,106,245,0.1);
  border-left-color: var(--elsa);
}
.rv-cand-item.suggested:hover { background: rgba(124,106,245,0.18); }
.rv-cand-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}
.rv-cand-item.suggested .rv-cand-dot { background: var(--elsa); }
.rv-cand-body { flex: 1; min-width: 0; }
.rv-cand-desc {
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rv-cand-date { font-size: 0.78rem; color: var(--text-dim); }
.rv-cand-amount { font-size: 0.95rem; font-weight: 600; flex-shrink: 0; }

/* Envelope picker for uncategorized transactions */
.rv-envelope-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px 0;
  flex-wrap: wrap;
}
.rv-picker-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  white-space: nowrap;
}
.rv-picker-select {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.12);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.85rem;
}
.rv-picker-select:focus { outline: 1px solid var(--elsa); }
.rv-picker-input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.12);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.85rem;
}
.rv-picker-input:focus { outline: 1px solid var(--elsa); }
.rv-combo-wrap {
  flex: 1;
  min-width: 0;
  position: relative;
}
.rv-combo-wrap .rv-picker-input { width: 100%; box-sizing: border-box; }
.rv-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  max-height: 220px;
  overflow-y: auto;
  background: var(--surface2);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 0 0 8px 8px;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.rv-dd-item {
  padding: 7px 10px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text);
}
.rv-dd-item:hover, .rv-dd-item.rv-dd-sel { background: rgba(255,255,255,0.08); }
.rv-dd-rec { font-weight: 600; }
.rv-dd-badge { color: #f5a623; font-size: 0.75rem; }
.rv-dd-empty { padding: 10px; color: var(--text-dim); font-size: 0.8rem; font-style: italic; }

/* Resolution buttons */
.rv-resolve-btns {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  flex-wrap: wrap;
}

/* Unfunded charge impact */
.rv-impact {
  padding: 12px 20px;
}
.rv-impact-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #f59e0b;
  margin-bottom: 10px;
}
.rv-impact-item {
  font-size: 0.88rem;
  padding: 8px 12px;
  margin-bottom: 6px;
  background: rgba(245, 158, 11, 0.08);
  border-left: 3px solid #f59e0b;
  border-radius: 6px;
  line-height: 1.4;
  color: var(--text);
}

/* Wizard chat messages */
.rv-chat-divider {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-align: center;
  padding: 10px 0;
  letter-spacing: 0.05em;
}
.rv-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 16px 12px;
}
.rv-bubble {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  word-break: break-word;
}
.rv-bubble.user {
  align-self: flex-end;
  background: var(--elsa);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.rv-bubble.assistant {
  align-self: flex-start;
  background: var(--surface);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

/* Wizard chat input bar */
.rv-chat-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 14px;
  background: #12102a;
  border-top: 1px solid rgba(124,106,245,0.25);
}
.rv-chat-input {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 9px 14px;
  color: var(--text);
  font-size: 0.9rem;
  resize: none;
  outline: none;
  font-family: inherit;
  line-height: 1.4;
  max-height: 80px;
  overflow-y: auto;
}
.rv-chat-input::placeholder { color: var(--text-dim); }
.rv-chat-input:focus { border-color: rgba(124,106,245,0.4); }
.rv-chat-send {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--elsa);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.9rem;
}
.rv-chat-send:hover { opacity: 0.85; }

/* ── Input area ─────────────────────────────────────────────────────── */
#input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
  background: var(--surface);
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}

#message-input {
  flex: 1;
  resize: none;
  background: var(--bg);
  border: 1px solid var(--surface2);
  border-radius: 20px;
  padding: 10px 16px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  line-height: 1.4;
  max-height: 120px;
  overflow-y: auto;
  outline: none;
  transition: border-color 0.2s;
}

#message-input:focus { border-color: var(--elsa); }

#send-btn {
  padding: 10px 18px;
  background: var(--elsa);
  border: none;
  border-radius: 20px;
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: opacity 0.2s;
  flex-shrink: 0;
}

#send-btn:hover { opacity: 0.85; }
#send-btn:disabled { opacity: 0.4; cursor: default; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.icon-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.icon-btn:hover { color: var(--text); background: rgba(255,255,255,0.07); }

.text-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.15s;
}
.text-btn:hover { color: var(--text); }

/* ── Modal ───────────────────────────────────────────────────────────── */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  width: min(400px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal h2 { font-size: 1.1rem; margin-bottom: 4px; }
.modal label { font-size: 0.85rem; color: var(--text-dim); }

.modal input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--surface2);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
}
.modal input[type="text"]:focus { border-color: var(--elsa); }

#member-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
  padding: 4px 0;
}

.member-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  cursor: pointer;
}

.elsa-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.modal-actions button:last-child {
  padding: 9px 20px;
  background: var(--elsa);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.modal-actions button:last-child:hover { opacity: 0.85; }

/* ── Typing indicator ────────────────────────────────────────────────── */
.typing-indicator {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 8px 14px;
  background: linear-gradient(135deg, #2d1f6e, #1a1a4e);
  border: 1px solid var(--elsa);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--elsa);
  animation: bounce 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

/* ── Responsive / mobile ─────────────────────────────────────────────── */
@media (max-width: 600px) {
  #sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
  }

  #sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,0.5); }
  #sidebar-toggle { display: flex; }

  /* Push headers below iPhone status bar / notch */
  #chat-header {
    padding-top: env(safe-area-inset-top, 44px);
    height: calc(var(--header-h) + env(safe-area-inset-top, 44px));
    align-items: flex-end;
    padding-bottom: 0;
  }

  .sidebar-header {
    padding-top: env(safe-area-inset-top, 44px);
    height: calc(var(--header-h) + env(safe-area-inset-top, 44px));
    align-items: flex-end;
    padding-bottom: 0;
  }

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

/* ── Module nav ──────────────────────────────────────────────────────────── */
.module-nav-list {
  border-top: 1px solid rgba(255,255,255,0.07);
  padding: 0.5rem 0;
}

.module-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  cursor: pointer;
  border-radius: 8px;
  margin: 2px 8px;
  color: #aaa;
  transition: background 0.15s, color 0.15s;
}

.module-nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.module-nav-item.active { background: rgba(124,106,245,0.2); color: #c4b5fd; }

.module-nav-icon { font-size: 1.2rem; }

/* ── Module panels ───────────────────────────────────────────────────────── */
.module-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--bg);
}

/* ── Calendar ────────────────────────────────────────────────────────────── */
#calendar-panel {
  padding: 1rem;
  gap: 0;
}

.cal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.cal-back-btn {
  background: none;
  border: none;
  color: #888;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
}
.cal-back-btn:hover { background: rgba(255,255,255,0.07); color: #ccc; }

.cal-filter-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: #aaa;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.25rem 0.6rem;
  display: flex;
  align-items: center;
  gap: 4px;
}
.cal-filter-btn:hover { background: rgba(255,255,255,0.1); }
.cal-filter-btn.cal-filter-active { border-color: rgba(124,106,245,0.5); }

.cal-filter-chip {
  display: inline-block;
  border: 1px solid;
  border-radius: 12px;
  padding: 1px 7px;
  font-size: 0.75rem;
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.cal-month-label {
  font-size: 1rem;
  font-weight: 600;
  color: #e0e0e0;
}

.cal-nav-btn {
  background: none;
  border: none;
  color: #aaa;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 0.5rem;
  line-height: 1;
}
.cal-nav-btn:hover { color: #fff; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 1rem;
}

.cal-dow {
  text-align: center;
  font-size: 0.7rem;
  color: #666;
  padding: 0.25rem 0;
  font-weight: 600;
}

.cal-cell {
  min-height: 44px;
  padding: 4px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.cal-cell:hover { background: rgba(255,255,255,0.06); }
.cal-cell.empty { cursor: default; }
.cal-cell.today .cal-day-num { background: #7c6af5; color: #fff; border-radius: 50%; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; }
.cal-cell.selected { background: rgba(124,106,245,0.15); outline: 1px solid #7c6af5; }

.cal-day-num {
  font-size: 0.8rem;
  color: #ccc;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cal-dots {
  display: flex;
  gap: 2px;
  margin-top: 2px;
  flex-wrap: wrap;
  justify-content: center;
}

.cal-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

.dot-default, .occ-unconfirmed { background: #7c6af5; }
.occ-confirmed { background: #22c55e; }
.occ-cancelled { background: #666; }

/* ── Day detail ──────────────────────────────────────────────────────────── */
.cal-day-detail {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 0.75rem;
}

.cal-detail-header {
  font-size: 0.85rem;
  font-weight: 600;
  color: #c4b5fd;
  margin-bottom: 0.5rem;
}

.cal-empty {
  color: #555;
  font-size: 0.85rem;
}

.cal-event-row {
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.5rem;
  border-left: 3px solid #7c6af5;
}

.cal-event-row.occ-confirmed { border-left-color: #22c55e; opacity: 0.8; }
.cal-event-row.occ-cancelled { border-left-color: #555; opacity: 0.5; }

.cal-event-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: #e0e0e0;
}

.cal-event-time {
  font-size: 0.8rem;
  color: #aaa;
  margin-left: 0.4rem;
}

.cal-loc, .cal-event-members {
  font-size: 0.75rem;
  color: #888;
  margin-top: 2px;
}

.cal-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.cal-confirm-btn {
  padding: 0.25rem 0.75rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  background: rgba(124,106,245,0.25);
  color: #c4b5fd;
}

.cal-confirm-btn:hover { background: rgba(124,106,245,0.4); }
.cal-cancel-btn { background: rgba(100,100,100,0.2); color: #aaa; }
.cal-cancel-btn:hover { background: rgba(100,100,100,0.4); }

.cal-member-chip {
  display: inline-block;
  border: 1px solid;
  border-radius: 12px;
  padding: 1px 7px;
  font-size: 0.72rem;
  margin-right: 3px;
}

/* ── Filter modal ────────────────────────────────────────────────────────── */
.cal-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.cal-modal-overlay.hidden { display: none; }

.cal-modal {
  background: #1e1e2e;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: 1.25rem;
  min-width: 220px;
  max-width: 320px;
  width: 90vw;
}

.cal-modal-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #c4b5fd;
  margin-bottom: 0.75rem;
}

.cal-filter-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.cal-filter-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #ddd;
  cursor: pointer;
}

.cal-filter-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cal-modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.cal-modal-btn {
  padding: 0.35rem 0.9rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  background: #7c6af5;
  color: #fff;
}
.cal-modal-btn:hover { background: #6a59e0; }

.cal-modal-btn-secondary {
  padding: 0.35rem 0.9rem;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  background: none;
  color: #aaa;
}
.cal-modal-btn-secondary:hover { background: rgba(255,255,255,0.06); }

/* ── Finance ─────────────────────────────────────────────────────────────── */
#finance-panel {
  padding: 0;
  gap: 0;
}

.fin-panel-inner {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.fin-loading {
  padding: 2rem;
  color: #aaa;
}

.fin-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7c6af5;
  margin-bottom: 0.5rem;
}

.fin-empty {
  font-size: 0.85rem;
  color: #555;
  padding: 0.25rem 0;
}

/* Accounts */
.fin-accounts {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.fin-account {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem;
  background: rgba(255,255,255,0.04);
  border-radius: 6px;
}

.fin-account-name {
  flex: 1;
  color: #ddd;
}

.fin-account-role {
  font-size: 0.72rem;
  color: #666;
  background: rgba(255,255,255,0.06);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.fin-account-bal {
  font-weight: 600;
  color: #a3e6b8;
  min-width: 4rem;
  text-align: right;
}

/* Envelopes */
.fin-envelopes {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.fin-envelope {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.fin-env-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.83rem;
}

.fin-env-name {
  flex: 1;
  color: #ddd;
}

.fin-env-priority {
  font-size: 0.68rem;
  color: #555;
  background: rgba(255,255,255,0.05);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}
.fin-env-mode {
  font-size: 0.62rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.mode-auto { color: #2ecc71; background: rgba(46,204,113,0.12); }
.mode-scraped { color: #3498db; background: rgba(52,152,219,0.12); }
.mode-vendor { color: #9b59b6; background: rgba(155,89,182,0.12); }
.mode-elsa-pay { color: #2ecc71; background: rgba(46,204,113,0.12); }
.mode-manual { color: #e67e22; background: rgba(230,126,34,0.12); }
.mode-manual-pay { color: #e67e22; background: rgba(230,126,34,0.12); }

.fin-env-amount {
  font-size: 0.78rem;
  min-width: 7rem;
  text-align: right;
}

.fin-env-amount.funded { color: #6ee7b7; }
.fin-env-amount.short  { color: #f87171; }

.fin-progress-bar {
  height: 5px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
}

.fin-progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.fin-progress-fill.funded  { background: #34d399; }
.fin-progress-fill.partial { background: #fbbf24; }
.fin-progress-fill.low     { background: #f87171; }

.fin-env-shortfall {
  font-size: 0.72rem;
  color: #f87171;
}

.fin-env-weekly {
  font-size: 0.72rem;
  color: #93c5fd;
}
.fin-env-weekly.over {
  color: #f87171;
}

.fin-env-due {
  font-size: 0.72rem;
  color: #9ca3af;
}
.fin-env-due.soon {
  color: #fbbf24;
}
.fin-env-due.today {
  color: #f87171;
  font-weight: 600;
}
.fin-env-due.overdue {
  color: #f87171;
  font-weight: 600;
}
.fin-env-due.paid {
  color: #6ee7b7;
}

/* Bills */
.fin-bills {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.fin-bill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.6rem;
  background: rgba(255,255,255,0.04);
  border-radius: 6px;
  border-left: 3px solid transparent;
}

.fin-bill.soon   { border-left-color: #fbbf24; }
.fin-bill.urgent { border-left-color: #f87171; }

.fin-bill-info {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.fin-bill-name {
  font-size: 0.85rem;
  color: #ddd;
}

.fin-bill-due {
  font-size: 0.72rem;
  color: #888;
}

.fin-bill-amount {
  font-size: 0.85rem;
  font-weight: 600;
  color: #fbbf24;
}

/* Refresh */
.fin-refresh {
  display: flex;
  justify-content: center;
}

.fin-refresh-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.1);
  color: #888;
  font-size: 0.8rem;
  padding: 0.35rem 1rem;
  border-radius: 6px;
  cursor: pointer;
}

.fin-refresh-btn:hover { background: rgba(255,255,255,0.06); color: #ccc; }

.fin-scrape-alert {
  background: rgba(233, 69, 96, 0.18);
  border: 1px solid rgba(233, 69, 96, 0.4);
  color: #ffb4b4;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  font-size: 0.8rem;
  margin-bottom: 0.8rem;
  line-height: 1.5;
}
.fin-uncat-banner {
  background: rgba(255, 193, 7, 0.18);
  border: 1px solid rgba(255, 193, 7, 0.4);
  color: #ffe082;
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  cursor: pointer;
}
.fin-uncat-banner:hover { background: rgba(255, 193, 7, 0.25); }
.fin-uncat-btn {
  background: rgba(255, 193, 7, 0.35);
  border: 1px solid rgba(255, 193, 7, 0.5);
  color: #fff;
  padding: 0.35rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  white-space: nowrap;
}
.fin-uncat-btn:hover { background: rgba(255, 193, 7, 0.5); }
