/* AgentSplit — dashboard styles. Inspired by AgentApply's dark-mode glass aesthetic. */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* HTML `hidden` attribute must always win. Without this, any rule that sets
 * `display` on an element (.modal { display: flex }, .user-chip { display:
 * inline-flex }) overrides the browser's default [hidden]→display:none.
 */
[hidden] { display: none !important; }

.skip-to-content {
  position: absolute; top: -100%; left: 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--primary); color: #fff; font-weight: 600;
  border-radius: 0 0 8px 8px; z-index: 10000;
  text-decoration: none; transition: top 0.2s;
}
.skip-to-content:focus { top: 0; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

:root {
  /* VireoAgents brand palette — kept aligned to vireoagents.com so the family
   * reads as one product line. AgentSplit's accent (the `verb` color) is the
   * AgentApply lineage indigo since both are billing-side / personal-finance. */
  --brand: #7C3AED;           /* VireoAgents umbrella violet */
  --brand-light: #A78BFA;
  --brand-dark: #6D28D9;
  --bg: #09090B;              /* zinc-950 — same as vireoagents */
  --surface: #18181B;
  --surface2: #27272A;
  --border: #3F3F46;
  --text: #FAFAFA;
  --text-dim: #A1A1AA;
  --primary: #6366f1;         /* AgentSplit's own accent (sibling of AgentApply) */
  --primary-hover: #818cf8;
  --success: #22c55e;
  --warning: #eab308;
  --danger: #ef4444;
  --info: #3b82f6;
  --glow: rgba(99, 102, 241, 0.25);
  --topbar-bg: rgba(24, 24, 27, 0.7);
}

/* Light theme — matches AgentApply tokens. Primary/success/warning/danger
 * are intentionally identical across themes (brand consistency); only
 * surface/text/border swap.
 */
[data-theme="light"] {
  --bg: #FAFAFA;
  --surface: #FFFFFF;
  --surface2: #F4F4F5;
  --border: #E4E4E7;
  --text: #09090B;
  --text-dim: #71717A;
  --glow: rgba(99, 102, 241, 0.15);
  --topbar-bg: rgba(255, 255, 255, 0.75);
}

/* Theme toggle button — fixed top-right, sits above topbar */
.theme-toggle {
  position: fixed; top: 0.75rem; right: 1rem; z-index: 1100;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-dim); cursor: pointer;
  padding: 0.45rem; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; line-height: 0;
  transition: color 0.15s, border-color 0.15s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--primary); }

body {
  background: var(--bg);
  color: var(--text);
  /* Inter is the VireoAgents-family typeface. system-ui fallback for first
   * paint while the webfont fetches. */
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--topbar-bg);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 100;
}
.topbar-inner {
  max-width: 1200px; margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex; align-items: center; gap: 1rem;
}
.brand {
  display: flex; align-items: center; gap: 0.5rem;
  font-weight: 700; font-size: 1.15rem; letter-spacing: -0.01em;
  color: var(--text); text-decoration: none;
}
.brand-mark { color: var(--brand); }
.brand-word { color: var(--text); font-weight: 500; }
/* The "verb" half pops with the AgentSplit accent — same pattern vireoagents
 * uses (AgentApply, AgentMatch, AgentSplit). */
.brand-verb { color: var(--primary); font-weight: 700; }
.brand-sub {
  color: var(--text-dim); font-size: 0.8rem;
  text-decoration: none; transition: color 0.15s;
}
.brand-sub:hover { color: var(--brand-light); }
.brand-sub strong { color: var(--brand-light); font-weight: 600; }
.user-chip {
  margin-left: auto;
  padding: 0.3rem 0.4rem 0.3rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.85rem;
  display: inline-flex; align-items: center; gap: 0.6rem;
}
.user-chip .btn.small.ghost {
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  border-radius: 999px;
}
.user-name-btn {
  background: transparent; border: 0; color: var(--text);
  font: inherit; cursor: pointer; padding: 0; text-align: left;
}
.user-name-btn:hover { color: var(--primary-hover); text-decoration: underline; }

.member-name-editable { cursor: pointer; border-bottom: 1px dashed transparent; }
.member-name-editable:hover { color: var(--primary-hover); border-bottom-color: var(--primary-hover); }

.trip-title-editable { cursor: pointer; }
.trip-title-editable:hover { color: var(--primary-hover); }
.trip-title-editable::after { content: ' ✎'; font-size: 0.7em; color: var(--text-dim); opacity: 0.5; }
.trip-title-editable:hover::after { opacity: 1; color: var(--primary-hover); }

.profile-popover {
  position: absolute; top: 3.2rem; right: 1.5rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 0.75rem 1rem; min-width: 260px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  z-index: 200; font-size: 0.85rem;
}
.profile-row { display: flex; justify-content: space-between; gap: 1rem; padding: 0.3rem 0; }
.profile-row + .profile-row { border-top: 1px solid var(--border); }
.profile-label { color: var(--text-dim); }

main { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem; }

.view { animation: fadeIn 0.25s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2rem;
  max-width: 480px; margin: 4rem auto;
  box-shadow: 0 8px 40px rgba(0,0,0,0.3);
}
.card h1 { font-size: 1.8rem; margin-bottom: 0.5rem; line-height: 1.2; letter-spacing: -0.02em; font-weight: 700; }
.lede { color: var(--text-dim); margin-bottom: 1.5rem; }

/* Hero card on the login view — uses the VireoAgents pattern: tiny tagline
 * above the headline, gradient text on the headline, footer with link back. */
.hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
}
.hero-card h1 {
  background: linear-gradient(135deg, var(--text) 0%, var(--brand-light) 50%, var(--brand) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.tagline {
  display: inline-block;
  font-size: 0.7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--brand-light);
  background: rgba(124, 58, 237, 0.12);
  padding: 0.25rem 0.6rem; border-radius: 999px;
  margin-bottom: 0.9rem;
}
.hero-footer {
  max-width: 480px; margin: 1rem auto 4rem;
  text-align: center;
  font-size: 0.78rem; color: var(--text-dim);
  line-height: 1.55;
}
.hero-footer a { color: var(--brand-light); text-decoration: none; font-weight: 600; }
.hero-footer a:hover { text-decoration: underline; }
.muted { color: var(--text-dim); }
.small { font-size: 0.85rem; }

.form { display: flex; flex-direction: column; gap: 0.75rem; }
.form label { display: flex; flex-direction: column; gap: 0.25rem; font-weight: 500; font-size: 0.95rem; }
.form input, .form select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  font-size: 0.95rem;
}
.form input:focus, .form select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--glow); }

.btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem; font-weight: 500;
  cursor: pointer; transition: all 0.15s;
}
.btn:hover:not(:disabled) { border-color: var(--primary); background: var(--surface); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn.ghost { background: transparent; }
.btn.small { padding: 0.35rem 0.7rem; font-size: 0.85rem; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-action { color: var(--text-dim); }
.btn.danger-action:hover:not(:disabled) { color: var(--danger); border-color: var(--danger); background: transparent; }

.row-between { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.row-right { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.5rem; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.panel h3 { margin-bottom: 0.75rem; font-size: 1rem; font-weight: 600; }

.grid.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 720px) { .grid.two-col { grid-template-columns: 1fr; } }

.trips-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.trip-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem; cursor: pointer; transition: all 0.15s;
}
.trip-card:hover { border-color: var(--primary); transform: translateY(-2px); }

.status-chip {
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: var(--surface2); color: var(--text-dim);
}
.status-chip.draft       { background: rgba(139, 143, 163, 0.15); color: var(--text-dim); }
.status-chip.collecting  { background: rgba(59, 130, 246, 0.18); color: var(--info); }
.status-chip.ready       { background: rgba(34, 197, 94, 0.18); color: var(--success); }
.status-chip.pushed      { background: rgba(99, 102, 241, 0.18); color: var(--primary-hover); }

/* View-mode toggle + hide-personal — sits between the summary and the tables */
.view-controls {
  display: flex; align-items: center; justify-content: space-between;
  margin: 0.75rem 0 0.5rem; gap: 1rem; flex-wrap: wrap;
}
.view-mode-toggle {
  display: inline-flex; background: var(--surface2); border-radius: 8px; padding: 2px;
}
.vm-btn {
  background: transparent; border: 0; color: var(--text-dim);
  padding: 0.35rem 0.8rem; border-radius: 6px; font: inherit; cursor: pointer;
  font-size: 0.85rem;
}
.vm-btn.active { background: var(--primary); color: #fff; }
.vm-btn:not(.active):hover { color: var(--text); }
.view-controls-right { display: inline-flex; align-items: center; gap: 0.75rem; }
.hide-personal {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.85rem; color: var(--text-dim); cursor: pointer;
}
.hide-personal input { accent-color: var(--primary); }

/* Lock / visibility toggle on personal rows — only shown on rows you own.
 * Locked = only you (the payer) see this row when others view the trip.
 */
.lock-btn {
  background: none; border: 0; cursor: pointer;
  color: var(--text-dim); padding: 0.15rem 0.3rem; border-radius: 4px;
  font-size: 0.9rem;
}
.lock-btn:hover { color: var(--primary-hover); background: rgba(99,102,241,0.1); }
.lock-btn.is-private { color: var(--warning); }
.lock-btn.is-private:hover { color: var(--warning); }
.expenses-table tr.is-private td:first-child::before {
  content: '🔒 '; font-size: 0.75em; opacity: 0.8;
}

/* Sectioned tables — Shared (prominent) and Personal (de-emphasized) */
.section-block { margin-top: 1rem; }
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.4rem 0.2rem; border-bottom: 1px solid var(--border);
  margin-bottom: 0.25rem;
}
.section-title {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-size: 0.95rem; font-weight: 600; color: var(--text);
}
.section-icon       { color: var(--success); font-size: 1.05rem; }
.section-icon.dim   { color: var(--text-dim); }
.section-meta       { color: var(--text-dim); font-weight: 400; font-size: 0.85rem; }
.section-toggle {
  background: none; border: 0; color: var(--text-dim);
  font-size: 0.85rem; cursor: pointer; padding: 0 0.3rem;
  width: 1.4rem;
}
.section-toggle:hover { color: var(--text); }
#personalBlock.collapsed table { display: none; }
#personalBlock {
  opacity: 0.85;  /* gentle de-emphasis — these don't affect settlement */
}
#personalBlock table tr td { font-size: 0.82rem; color: var(--text-dim); }
#personalBlock table tr td:nth-child(2) { color: var(--text); }

/* Hidden-from-view rows — shown only when the user clicks "Show hidden".
 * Distinct strikethrough/dim treatment so they're obviously not in normal view. */
.expenses-table tr.row-hidden td { opacity: 0.6; }
.expenses-table tr.row-hidden td:nth-child(2) { text-decoration: line-through; }
.expenses-table tr.hidden-footer-row td {
  background: var(--surface2);
  text-align: center;
  padding: 0.6rem;
  border-top: 1px dashed var(--border);
  border-bottom: 0;
}

/* Sortable column headers */
.expenses-table.sortable th { cursor: pointer; user-select: none; position: relative; }
.expenses-table.sortable th:hover { color: var(--text); }
.expenses-table.sortable th.sort-asc::after  { content: ' ▲'; font-size: 0.7em; color: var(--primary-hover); }
.expenses-table.sortable th.sort-desc::after { content: ' ▼'; font-size: 0.7em; color: var(--primary-hover); }
.expenses-table.sortable th[data-sort="receipts"],
.expenses-table.sortable th[data-sort="actions"] { cursor: default; }
.expenses-table.sortable th[data-sort="receipts"]:hover,
.expenses-table.sortable th[data-sort="actions"]:hover { color: var(--text-dim); }

.expenses-table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
.expenses-table th, .expenses-table td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  text-align: left; font-size: 0.85rem;
}
.expenses-table th { color: var(--text-dim); font-weight: 500; }
.expenses-table tr.personal { opacity: 0.7; }
.expenses-table .badge { padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.7rem; }
/* Per-user color coding — each row carries `--user-color` from the payer's
 * stable color (see colorForUser in app.js). Used for a 3px left stripe and
 * the small avatar dot in the "Paid by" cell.
 */
.expenses-table tr[data-id] {
  border-left: 3px solid transparent;
}
.expenses-table tr[data-id][style*="--user-color"] {
  border-left-color: var(--user-color);
}
.user-dot {
  display: inline-block; width: 0.55rem; height: 0.55rem;
  border-radius: 50%; vertical-align: middle;
  margin-right: 0.35rem;
}
/* Group divider — separates "mine" from "others" in mine_first sort mode.
 * Just a horizontal rule with a small "Others" label centered on it. */
.expenses-table tr.group-divider-row td {
  padding: 0.6rem 0 0.35rem; border-bottom: 0;
  background: transparent;
}
.expenses-table tr.group-divider-row {
  border-left: none !important;
}
.group-divider-row td {
  display: flex; align-items: center; gap: 0.5rem;
}
.group-divider-line {
  flex: 1; height: 1px; background: var(--border);
}
.group-divider-label {
  color: var(--text-dim); font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.08em;
}

/* Rows that have comments — subtle blue wash so you can spot active threads
 * at a glance. Combined with the per-user left stripe via a 2nd background. */
.expenses-table tr.has-comments {
  background:
    linear-gradient(90deg, rgba(99, 102, 241, 0.07) 0%, rgba(99, 102, 241, 0.02) 60%, transparent 100%);
}
.expenses-table tr.has-comments .comment-btn {
  color: var(--primary-hover); font-weight: 600;
  animation: comment-pulse 2.4s ease-in-out infinite;
}
@keyframes comment-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.08); }
}

/* "Jump to discussion" chip — appears in view-controls when any row has comments */
.discussion-chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid var(--primary);
  color: var(--text);
  padding: 0.3rem 0.7rem; border-radius: 999px;
  font-size: 0.78rem; font: inherit; cursor: pointer;
  font-weight: 500;
}
.discussion-chip:hover { background: rgba(99, 102, 241, 0.20); }

/* Refund badge on credit rows */
.refund-tag {
  display: inline-block; padding: 0.05rem 0.35rem;
  background: rgba(34, 197, 94, 0.18); color: var(--success);
  border-radius: 999px; font-size: 0.65rem; font-weight: 600;
}
.expenses-table tr.is-refund td.amt { color: var(--success); }

.you-tag {
  display: inline-block; padding: 0.05rem 0.4rem;
  background: rgba(99, 102, 241, 0.18); color: var(--primary-hover);
  border-radius: 999px; font-size: 0.7rem; font-weight: 600;
  margin-left: 0.25rem; letter-spacing: 0.02em;
}

.expenses-table .badge.shared { background: rgba(34,197,94,0.18); color: var(--success); }
.expenses-table .badge.personal { background: rgba(139,143,163,0.18); color: var(--text-dim); }
.expenses-table .badge.custom  { background: rgba(99,102,241,0.18); color: var(--primary-hover); }

/* The badge is a clickable button that opens a tiny menu. */
.share-btn {
  background: none; border: 0; padding: 0; font: inherit; cursor: pointer;
}
.share-btn .badge { padding: 0.15rem 0.55rem; }
.share-btn:hover .badge { filter: brightness(1.15); }

/* Dropdown menu — absolute-positioned, populated by JS, click-outside closes */
.share-menu {
  position: absolute; z-index: 500;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.3rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  min-width: 200px; font-size: 0.85rem;
}
.share-menu button {
  display: block; width: 100%; text-align: left;
  background: none; border: 0; color: var(--text);
  padding: 0.45rem 0.7rem; border-radius: 6px;
  font: inherit; cursor: pointer;
}
.share-menu button:hover { background: var(--surface2); color: var(--primary-hover); }
.share-menu .menu-sep { height: 1px; background: var(--border); margin: 0.25rem 0; }
.share-menu .menu-label { color: var(--text-dim); font-size: 0.75rem; padding: 0.3rem 0.7rem; line-height: 1.4; }
.share-menu .menu-sub {
  color: var(--text-dim); font-size: 0.72rem; font-weight: 400;
  margin-top: 0.15rem; line-height: 1.3;
}
.share-menu button:hover .menu-sub { color: var(--text-dim); }

/* Custom-split modal — member rows */
.split-member-row {
  display: grid; grid-template-columns: 1fr 80px 24px;
  gap: 0.5rem; align-items: center; padding: 0.3rem 0;
}
.split-member-row input[type=number] {
  text-align: right; padding: 0.4rem 0.5rem;
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; font: inherit;
}
.split-member-row .pct-suffix { color: var(--text-dim); font-size: 0.85rem; text-align: center; }
.split-sum-ok { color: var(--success); }
.split-sum-bad { color: var(--danger); }
.expenses-table .amt { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }

.summary {
  display: flex; gap: 1.5rem; padding: 0.75rem 0;
  flex-wrap: wrap;
}
.summary .stat { display: flex; flex-direction: column; }
.summary .stat .lab { color: var(--text-dim); font-size: 0.8rem; }
.summary .stat .val { font-size: 1.1rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.summary .stat .val.pos { color: var(--success); }
.summary .stat .val.neg { color: var(--danger); }

.settle-options { display: flex; flex-direction: column; gap: 0.5rem; }
.settle-option {
  display: flex; gap: 0.75rem; align-items: flex-start;
  padding: 0.75rem; border: 1px solid var(--border); border-radius: 10px;
  cursor: pointer; transition: all 0.15s; background: var(--surface);
}
.settle-option:hover:not(.disabled) { border-color: var(--primary); background: var(--surface2); }
.settle-option.disabled { opacity: 0.5; cursor: not-allowed; }
.settle-option .opt-icon { font-size: 1.4rem; line-height: 1; }
.settle-option .opt-title { font-weight: 600; }
.settle-option .opt-desc { color: var(--text-dim); font-size: 0.85rem; margin-top: 0.2rem; }
.settle-option .opt-flag { color: var(--warning); font-size: 0.8rem; margin-top: 0.3rem; }

/* Auth tabs on the landing screen */
.auth-tabs { display: flex; gap: 0.25rem; margin: 1rem 0 0.75rem; border-bottom: 1px solid var(--border); }
.auth-tab {
  background: transparent; border: 0; color: var(--text-dim);
  padding: 0.55rem 0.9rem; font: inherit; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.auth-tab.active { color: var(--text); border-bottom-color: var(--primary); }
.auth-tab:hover:not(.active) { color: var(--text); }
.auth-legacy { margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }
.auth-legacy summary { cursor: pointer; }

/* Onboarding */
.onboarding-card { max-width: 560px; }
.onboarding-steps { list-style: none; padding: 0.5rem 0; margin: 0.75rem 0 1.25rem; }
.onboarding-steps li { padding: 0.4rem 0; border-bottom: 1px solid var(--border); }
.onboarding-steps li:last-child { border-bottom: 0; }

/* New-trip wizard */
.wizard-progress { display: flex; gap: 0.5rem; margin-bottom: 1rem; font-size: 0.85rem; }
.wizard-step {
  flex: 1; padding: 0.4rem 0.6rem; border-radius: 6px;
  background: var(--surface2); color: var(--text-dim); text-align: center;
}
.wizard-step.active { background: var(--primary); color: #fff; font-weight: 500; }
.wizard-step.done { background: rgba(99, 102, 241, 0.25); color: var(--primary-hover); }

.invitees-list { display: flex; flex-direction: column; gap: 0.5rem; margin: 0.5rem 0; }
.invitee-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 0.4rem; align-items: center; }
.invitee-row input { padding: 0.5rem 0.6rem; }
.invitee-row .remove-invitee {
  background: transparent; border: 0; color: var(--text-dim);
  font-size: 1.1rem; cursor: pointer; padding: 0.2rem 0.5rem; border-radius: 6px;
}
.invitee-row .remove-invitee:hover { color: var(--danger); background: rgba(239,68,68,0.1); }

/* Claim-account banner for share-mode guests — invites them to set a password
 * so they can sign back in later without the share link. */
.claim-account-banner {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0.9rem; margin-bottom: 0.9rem;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid var(--primary);
  border-radius: 8px;
  font-size: 0.85rem;
}
.claim-account-banner > span { flex: 1; }

/* Single-member-trip warning — shown above the panels when a trip has no
 * one to split with. Without another member, "shared" expenses collapse to
 * 100% payer and the dashboard looks broken. The banner makes the fix obvious.
 */
.lone-trip-notice {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0.9rem; margin-bottom: 0.9rem;
  background: rgba(234, 179, 8, 0.12);
  border: 1px solid var(--warning);
  border-radius: 8px;
  color: var(--text); font-size: 0.85rem;
}
.lone-trip-notice > span { flex: 1; }

/* Inline refine notice — shown above the trip panels while Phase B
 * (background LLM refinement) is in flight. Non-blocking; user can still
 * read/scroll the partially-classified rows underneath.
 */
/* Activity panel — last N audit_log events scoped to this trip */
.activity-list { display: flex; flex-direction: column; gap: 0.25rem; max-height: 220px; overflow-y: auto; }
.activity-row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.3rem 0.4rem; font-size: 0.8rem;
  border-radius: 4px;
}
.activity-row:hover { background: var(--surface2); }
.activity-row .activity-actor { font-weight: 600; }
.activity-row .activity-when { color: var(--text-dim); margin-left: auto; font-size: 0.72rem; white-space: nowrap; }
.activity-list .muted { padding: 0.5rem 0.2rem; }

/* Trip lifecycle banner — "all members done, ready to settle" / "settled" */
.lifecycle-banner {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 0.9rem; margin-bottom: 0.9rem;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid var(--success);
  border-radius: 8px;
  font-size: 0.85rem;
}
.lifecycle-banner.settled {
  background: rgba(99, 102, 241, 0.12); border-color: var(--primary);
}

.refine-notice {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.55rem 0.9rem; margin-bottom: 0.9rem;
  background: rgba(99, 102, 241, 0.10);
  border: 1px solid var(--primary);
  border-radius: 8px;
  color: var(--text); font-size: 0.85rem;
}
.refine-notice .spinner-inline { color: var(--primary-hover); font-family: monospace; }

/* Rows whose category is still ambiguous (awaiting LLM refinement).
 * Subtle pulse so the user knows "something will change here". */
.expenses-table tr.pending-classify { opacity: 0.65; }
.expenses-table tr.pending-classify td:nth-child(2) { animation: pending-pulse 1.6s ease-in-out infinite; }
@keyframes pending-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

/* Indeterminate progress bar — used during long uploads (~60s classify) */
.progress-bar {
  position: relative; height: 4px; border-radius: 999px;
  background: var(--surface2); overflow: hidden; margin: 0.6rem 0 0.3rem;
}
.progress-bar::before {
  content: ''; position: absolute; top: 0; left: -40%;
  width: 40%; height: 100%;
  background: linear-gradient(90deg, transparent 0%, var(--primary) 50%, transparent 100%);
  animation: progress-slide 1.6s ease-in-out infinite;
}
@keyframes progress-slide {
  0%   { left: -40%; }
  100% { left: 100%; }
}
.progress-msg {
  display: flex; align-items: center; gap: 0.5rem;
  color: var(--text-dim); font-size: 0.85rem;
  min-height: 1.25rem;
}
.progress-msg .spinner {
  display: inline-block; font-family: monospace; color: var(--primary-hover);
}
.progress-file { color: var(--text); font-weight: 500; }

/* Receipts */
.receipts-list { display: flex; flex-direction: column; gap: 0.4rem; }
.receipts-list:empty::after { content: 'No receipts yet.'; color: var(--text-dim); font-size: 0.85rem; }
.receipt-row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.4rem 0.6rem; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 8px;
}
.receipt-row .file-icon { font-size: 1.1rem; }
.receipt-row a { color: var(--primary-hover); text-decoration: none; }
.receipt-row a:hover { text-decoration: underline; }
.receipt-row .size { color: var(--text-dim); font-size: 0.75rem; margin-left: auto; }
.receipt-row .btn-del {
  background: transparent; border: 0; color: var(--text-dim); cursor: pointer; padding: 0.2rem 0.4rem;
}
.receipt-row .btn-del:hover { color: var(--danger); }

.attach-btn,
.comment-btn {
  background: transparent; border: 0; color: var(--text-dim); cursor: pointer;
  font-size: 0.95rem; padding: 0.2rem 0.4rem; border-radius: 4px;
}
.attach-btn:hover,
.comment-btn:hover { color: var(--primary-hover); background: rgba(99,102,241,0.1); }
.attach-btn.has,
.comment-btn.has { color: var(--primary-hover); }

/* Comments thread inside the modal */
.comment-entry {
  padding: 0.5rem 0.6rem; margin-bottom: 0.4rem;
  background: var(--surface2); border-radius: 6px;
  border-left: 3px solid var(--primary);
}
.comment-entry .comment-head {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.78rem; margin-bottom: 0.25rem;
}
.comment-entry .comment-body { font-size: 0.85rem; white-space: pre-wrap; word-break: break-word; }
.comment-entry .btn-del { padding: 0 0.3rem; }

/* POS-split suggestion banner */
.pos-split-banner {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0.9rem; margin: 0 0 0.75rem;
  background: rgba(59, 130, 246, 0.10);
  border: 1px solid var(--info);
  border-radius: 8px;
  font-size: 0.85rem;
}
.pos-split-banner > span:first-child { flex: 1; }

/* Share-links list — one row per invitee, read-only input + Copy button. */
.share-link-row {
  display: grid; grid-template-columns: 1fr auto; gap: 0.4rem;
  align-items: center; margin-bottom: 0.6rem;
}
.share-link-row .who {
  grid-column: 1 / -1; font-weight: 600; font-size: 0.9rem;
  color: var(--text); margin-bottom: 0.15rem;
}
.share-link-row input {
  padding: 0.4rem 0.55rem;
  background: var(--bg); border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 6px; font: inherit; font-size: 0.78rem;
  min-width: 0;  /* allow shrinking inside the grid */
  text-overflow: ellipsis;
}
.share-link-row .row-actions { display: inline-flex; gap: 0.3rem; }
.share-link-row .copy-btn,
.share-link-row .email-btn { white-space: nowrap; }
.share-link-row .email-btn {
  text-decoration: none;  /* it's an <a> styled as a button */
}

/* Toasts — non-blocking inline notifications. Stack bottom-right, auto-dismiss. */
#toastContainer {
  position: fixed; bottom: 1rem; right: 1rem;
  z-index: 2000;
  display: flex; flex-direction: column; gap: 0.5rem;
  pointer-events: none;
  max-width: min(420px, calc(100vw - 2rem));
}
.toast {
  pointer-events: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  font-size: 0.85rem;
  display: flex; align-items: flex-start; gap: 0.5rem;
  animation: toast-in 0.18s ease-out;
}
.toast.success { border-left-color: var(--success); }
.toast.warn    { border-left-color: var(--warning); }
.toast.error   { border-left-color: var(--danger); }
.toast .toast-icon { font-size: 1rem; line-height: 1.2; }
.toast .toast-msg  { flex: 1; line-height: 1.35; }
.toast .toast-close {
  background: none; border: 0; color: var(--text-dim); cursor: pointer;
  padding: 0 0.2rem; line-height: 1;
}
.toast .toast-close:hover { color: var(--text); }
.toast.leaving { animation: toast-out 0.18s ease-in forwards; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(8px); } }

.modal[hidden] { display: none !important; }
.view[hidden] { display: none !important; }
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-inner { margin: 0; max-width: 480px; width: 90%; }

/* Site footer — mirrors vireoagents.com pattern. Renders at the bottom of
 * every view (login, dashboard, trip). Visible regardless of auth state. */
.site-footer {
  max-width: 1200px; margin: 4rem auto 0; padding: 3rem 1.5rem 2rem;
  border-top: 1px solid var(--border);
  color: var(--text-dim); font-size: 0.85rem;
}
.footer-grid {
  display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 2.5rem;
  margin-bottom: 2rem;
}
.footer-brand {
  font-size: 1.1rem; font-weight: 700; color: var(--text);
  margin-bottom: 0.5rem; letter-spacing: -0.01em;
}
.footer-brand-desc { color: var(--text-dim); line-height: 1.55; max-width: 36ch; }
.footer-brand-desc a { color: var(--brand-light); text-decoration: none; font-weight: 600; }
.footer-brand-desc a:hover { text-decoration: underline; }
.footer-col h4 {
  font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-dim); margin-bottom: 0.9rem;
}
.footer-col ul { list-style: none; padding: 0; margin: 0; }
.footer-col li { margin-bottom: 0.45rem; }
.footer-col a {
  color: var(--text-dim); text-decoration: none; font-size: 0.85rem;
  transition: color 0.15s;
}
.footer-col a:hover { color: var(--text); }
.footer-bottom {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 1.5rem; border-top: 1px solid var(--border);
  font-size: 0.75rem; color: var(--text-dim);
}
@media (max-width: 720px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-bottom { flex-direction: column; gap: 0.4rem; text-align: center; }
}
@media (max-width: 480px) {
  .footer-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
