:root {
  color-scheme: light;
  --bg: #f5f6f9;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --surface-3: #eceef4;
  --text: #1b1d28;
  --text-strong: #0f1119;
  --muted: #686d7f;
  --muted-2: #8b91a5;
  --border: #e3e5ee;
  --border-strong: #d2d5e2;
  --primary: #4f46e5;
  --primary-strong: #4338ca;
  --primary-soft: #eef2ff;
  --success: #15803d;
  --success-soft: #e9f9ef;
  --warning: #b45309;
  --warning-soft: #fff7e6;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --info: #0369a1;
  --info-soft: #e8f4fd;
  --neutral: #5b6270;
  --neutral-soft: #eef0f4;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 12px 32px rgba(16, 24, 40, 0.10);
  --shadow-lg: 0 24px 64px rgba(16, 24, 40, 0.18);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --sidebar-width: 276px;
  --topbar-height: 68px;
  --font: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0f16;
  --surface: #151825;
  --surface-2: #1a1e2c;
  --surface-3: #222738;
  --text: #e7e9f2;
  --text-strong: #ffffff;
  --muted: #a2a7bc;
  --muted-2: #7c8299;
  --border: #272b3d;
  --border-strong: #323950;
  --primary: #6366f1;
  --primary-strong: #818cf8;
  --primary-soft: #1e1b4b;
  --success: #22c55e;
  --success-soft: #052e14;
  --warning: #f59e0b;
  --warning-soft: #301c04;
  --danger: #f87171;
  --danger-soft: #3c0d0d;
  --info: #38bdf8;
  --info-soft: #082f49;
  --neutral: #a8adbf;
  --neutral-soft: #252b3c;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.24);
  --shadow: 0 12px 32px rgba(0,0,0,0.30);
  --shadow-lg: 0 24px 64px rgba(0,0,0,0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.no-scroll {
  overflow: hidden;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
}

svg {
  display: block;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
}

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

/* ---------- Primary controls ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.08s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible,
.icon-btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-strong);
  border-color: var(--primary-strong);
}

.btn-outline {
  border-color: var(--border);
  background: var(--surface);
}

.btn-outline:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}

.btn-outline-danger {
  background: transparent;
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 50%, var(--border));
}

.btn-outline-danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

.btn-outline-danger .icon {
  stroke: currentColor;
}

.btn-sm {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 7px;
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-lg {
  min-height: 44px;
  padding: 0 18px;
  font-size: 14px;
  border-radius: 10px;
}

.btn-block {
  width: 100%;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

/* ---------- Auth ---------- */
.auth-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  background: var(--surface);
}

.auth-art {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.22), transparent 32%),
    radial-gradient(circle at 80% 20%, rgba(236, 72, 153, 0.15), transparent 28%),
    linear-gradient(145deg, #12142a 0%, #1d1b3b 38%, #15162c 100%);
  color: #f8fafc;
  padding: 60px;
  display: flex;
  align-items: center;
}

.auth-art-inner {
  max-width: 560px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 56px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35);
}

.brand-name {
  font-weight: 700;
  font-size: 20px;
  color: #fff;
}

.auth-art h1 {
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1.05;
  letter-spacing: -0.035em;
  margin: 0 0 20px;
  max-width: 540px;
}

.auth-art h1.is-slogan-swap {
  animation: auth-slogan-in 0.55s ease;
}

@keyframes auth-slogan-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.auth-art p {
  color: #c8cbe0;
  font-size: 16px;
  line-height: 1.7;
  margin: 0 0 32px;
  max-width: 520px;
}

.auth-feature-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 16px;
  max-width: 540px;
}

.auth-feature-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  color: #e8eaf4;
  font-size: 16px;
  line-height: 1.55;
  font-weight: 500;
}

.auth-feature-list li::before {
  content: "✓";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border-radius: 6px;
  background: var(--primary, #4f46e5);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
  margin-top: 2px;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.4);
}

.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 48px 24px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
}

.auth-card.is-wide {
  max-width: 720px;
}

.guide-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.lang-switcher {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.lang-switcher-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
}

.lang-switcher-btn:hover {
  color: var(--text-strong);
}

.lang-switcher-btn.is-active {
  background: var(--surface);
  color: var(--text-strong);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.auth-card h2 {
  margin: 0 0 8px;
  font-size: 26px;
  letter-spacing: -0.02em;
  color: var(--text-strong);
}

.auth-card .auth-subtitle {
  color: var(--muted);
  margin: 0 0 24px;
}

.auth-form {
  display: grid;
  gap: 16px;
}

.captcha-image {
  display: block;
  width: 220px;
  max-width: 100%;
  height: auto;
  margin: 0 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border, #1e293b);
  background: #0f172a;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted-2);
  font-size: 12px;
  margin: 20px 0;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--border);
}

.social-btn {
  background: var(--surface);
  border-color: var(--border);
}

.auth-alt {
  text-align: center;
  color: var(--muted);
  margin-top: 20px;
  font-size: 13px;
}

.auth-legal {
  margin-top: 32px;
  color: var(--muted-2);
  font-size: 12px;
  text-align: center;
  max-width: 400px;
}

/* ---------- App shell ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-shell.is-hidden,
.auth-view.is-hidden {
  display: none !important;
}

.sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
}

.sidebar-brand {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.sidebar-brand-text strong {
  font-size: 15px;
  color: var(--text-strong);
}

.sidebar-brand-text span {
  font-size: 11px;
  color: var(--muted-2);
}

.workspace-switcher {
  margin: 16px 16px 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  width: calc(100% - 32px);
  padding: 10px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.workspace-switcher:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
}

.workspace-avatar,
.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  background: linear-gradient(135deg, #e0e7ff, #ede9fe);
  color: #4338ca;
  flex: 0 0 auto;
}

.workspace-meta,
.user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  line-height: 1.25;
}

.workspace-meta strong,
.user-meta strong {
  font-size: 13px;
  color: var(--text-strong);
}

.user-name-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}

.user-name-row #sidebarUserName {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plan-badge-pro,
.plan-badge-team {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.4;
}

.plan-badge-pro {
  background: #fff;
  color: #2563eb;
}

.plan-badge-team {
  background: #fff;
  color: #0f766e;
}

.plan-badges {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.workspace-meta span,
.user-meta > span {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace-chevron {
  color: var(--muted-2);
  font-size: 16px;
}

.sidebar-nav {
  padding: 4px 12px;
  display: grid;
  gap: 2px;
  overflow-y: auto;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 500;
  font-size: 13px;
  border: 1px solid transparent;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.nav-link:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.nav-link.active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: rgba(79, 70, 229, 0.14);
}

.nav-link .icon {
  width: 17px;
  height: 17px;
}

.nav-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  padding: 16px 10px 5px;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}

.user-chip {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
  transition: background 0.15s ease;
}

.user-chip:hover {
  background: var(--surface-2);
}

.user-more {
  color: var(--muted-2);
  font-weight: 700;
  letter-spacing: 2px;
}

.main-shell {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-search {
  width: min(360px, 34vw);
  height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--muted);
}

.topbar-search input {
  border: 0;
  background: transparent;
  color: var(--text);
  outline: 0;
  flex: 1;
  min-width: 0;
  font-size: 13px;
}

.topbar-search input::placeholder {
  color: var(--muted-2);
}

.topbar-search kbd {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
  background: var(--surface);
}

.mobile-menu-btn,
.sidebar-close {
  display: none;
}

.mobile-overlay {
  display: none;
}

.billing-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid rgba(180, 83, 9, 0.18);
}

.billing-banner.is-hidden {
  display: none;
}

.page-content {
  padding: 28px;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.page-header h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: -0.025em;
  color: var(--text-strong);
}

.page-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.page-desc {
  margin: 0;
  color: var(--muted);
  max-width: 680px;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

/* ---------- Cards and grids ---------- */
.grid {
  display: grid;
  gap: 16px;
}

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

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: -0.01em;
}

.member-title-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.member-seat-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.member-seat-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.member-seat-add {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  color: var(--text-strong);
}

.buy-seats-summary {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}

.buy-seats-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}

.buy-seats-row strong {
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
}

.payment-method-fieldset {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px 14px;
  margin: 0;
}

.payment-method-fieldset legend {
  padding: 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.payment-method-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
}

.payment-method-option input {
  accent-color: var(--accent, #2563eb);
}

.card-subtitle {
  margin: 3px 0 0;
  color: var(--muted-2);
  font-size: 12px;
}

.card-body {
  padding: 18px;
}

.card-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ---------- Metric cards ---------- */
.metric-card {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.metric-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.metric-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
  color: var(--primary);
}

.metric-icon.green {
  background: var(--success-soft);
  color: var(--success);
}

.metric-icon.red {
  background: var(--danger-soft);
  color: var(--danger);
}

.metric-icon.blue {
  background: var(--info-soft);
  color: var(--info);
}

.metric-value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-strong);
  font-family: var(--mono);
}

.metric-delta {
  font-size: 12px;
  font-weight: 600;
}

.delta-up {
  color: var(--success);
}

.delta-down {
  color: var(--danger);
}

/* ---------- Tables ---------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th,
.table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
}

.table th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-2);
  background: var(--surface-2);
}

.table tbody tr {
  transition: background 0.12s ease;
}

.table tbody tr:hover {
  background: var(--surface-2);
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

/* Larger selection checkboxes (transactions / CSV review) */
.table input[type="checkbox"].tx-row-check,
.table input[type="checkbox"].csv-rev-check,
.table input[type="checkbox"]#txSelectAll,
.table input[type="checkbox"]#csvReviewSelectAll {
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
  vertical-align: middle;
}

.table th:has(> input[type="checkbox"]),
.table td:has(> input[type="checkbox"].tx-row-check),
.table td:has(> input[type="checkbox"].csv-rev-check) {
  width: 44px;
  text-align: center;
  vertical-align: middle;
}

.table tr.tx-selectable-row,
.table tr.csv-review-row {
  cursor: pointer;
}

.table .tx-row-num-col,
.table .tx-row-num {
  width: 2.5rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.table tr.tx-selectable-row.is-selected,
.table tr.csv-review-row.is-selected {
  background: color-mix(in srgb, var(--primary) 14%, var(--surface));
}

.table tr.tx-selectable-row.is-selected:hover,
.table tr.csv-review-row.is-selected:hover {
  background: color-mix(in srgb, var(--primary) 20%, var(--surface));
}

.cell-main {
  font-weight: 600;
  color: var(--text-strong);
}

.cell-sub {
  font-size: 12px;
  color: var(--muted);
}

.text-right {
  text-align: right;
}

.amount-positive {
  color: var(--success);
  font-weight: 700;
  font-family: var(--mono);
}

.amount-negative {
  color: var(--text-strong);
  font-weight: 700;
  font-family: var(--mono);
}

.table-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  border: 1px solid transparent;
}

.badge-success {
  background: var(--success-soft);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge-info {
  background: var(--info-soft);
  color: var(--info);
}

.badge-neutral {
  background: var(--neutral-soft);
  color: var(--neutral);
}

.badge-primary {
  background: var(--primary-soft);
  color: var(--primary);
}

.type-income {
  color: var(--success);
  background: var(--success-soft);
}

.type-expense {
  color: var(--danger);
  background: var(--danger-soft);
}

.type-transfer {
  color: var(--info);
  background: var(--info-soft);
}

/* ---------- Forms ---------- */
.form-grid {
  display: grid;
  gap: 14px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label,
.field .label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.field .hint {
  font-size: 11px;
  color: var(--muted-2);
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
  outline: 0;
}

.textarea {
  min-height: 84px;
  resize: vertical;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrap .icon {
  position: absolute;
  left: 11px;
  color: var(--muted-2);
  pointer-events: none;
}

.input-wrap .input {
  padding-left: 36px;
}

.select-wrap {
  position: relative;
}

.select-wrap .select {
  appearance: none;
  padding-right: 32px;
}

.select-wrap::after {
  content: "⌄";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-2);
  pointer-events: none;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-3);
  border-radius: 10px;
  gap: 2px;
}

.segmented button {
  padding: 6px 12px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.segmented button.active {
  background: var(--surface);
  color: var(--text-strong);
  box-shadow: var(--shadow-sm);
}

/* ---------- Filters ---------- */
.filters {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.filters-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filters-row .input,
.filters-row .select {
  width: auto;
  min-width: 130px;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 220px;
  display: flex;
  align-items: center;
}

.search-input-wrap .icon {
  position: absolute;
  left: 11px;
  color: var(--muted-2);
  pointer-events: none;
}

.search-input-wrap .input {
  padding-left: 36px;
}

/* ---------- Tabs ---------- */
.tab-list {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tab {
  padding: 9px 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  background: transparent;
  white-space: nowrap;
  margin-bottom: -1px;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ---------- Progress ---------- */
.progress {
  height: 8px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
  width: 100%;
}

.progress-bar {
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
  transition: width 0.4s ease;
}

.progress-bar.warning {
  background: var(--warning);
}

.progress-bar.danger {
  background: var(--danger);
}

.progress-bar.success {
  background: var(--success);
}

/* ---------- Donut ---------- */
.donut-wrap {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
}

.donut {
  width: 190px;
  height: 190px;
  border-radius: 50%;
  position: relative;
  flex: 0 0 auto;
}

.donut-hole {
  position: absolute;
  inset: 28px;
  background: var(--surface);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.donut-hole strong {
  font-size: 22px;
  font-family: var(--mono);
  letter-spacing: -0.04em;
  color: var(--text-strong);
}

.donut-hole span {
  font-size: 11px;
  color: var(--muted);
}

.legend {
  display: grid;
  gap: 8px;
  flex: 1;
  min-width: 160px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  flex: 0 0 auto;
}

.legend-label {
  flex: 1;
  color: var(--text);
}

.legend-value {
  font-weight: 700;
  color: var(--text-strong);
  font-family: var(--mono);
}

/* ---------- Charts ---------- */
.chart-wrap {
  width: 100%;
}

.line-chart {
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart-x {
  display: flex;
  justify-content: space-between;
  color: var(--muted-2);
  font-size: 11px;
  margin-top: 8px;
}

.chart-legend-row {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--muted);
  font-size: 12px;
}

.chart-legend-row .legend-dot {
  width: 14px;
  height: 4px;
  border-radius: 999px;
}

/* ---------- Lists ---------- */
.list {
  display: grid;
  gap: 8px;
}

.workspace-group-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: background 0.12s ease, border-color 0.12s ease;
}

.list-item:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.tx-icon {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--neutral-soft);
  color: var(--muted);
  flex: 0 0 auto;
}

.tx-icon.green {
  background: var(--success-soft);
  color: var(--success);
}

.tx-icon.red {
  background: var(--danger-soft);
  color: var(--danger);
}

.tx-icon.blue {
  background: var(--info-soft);
  color: var(--info);
}

.tx-icon.amber {
  background: color-mix(in srgb, #d4a017 22%, var(--surface-2));
  color: #d4a017;
}

.tx-main {
  min-width: 0;
  flex: 1;
}

.tx-main strong {
  display: block;
  font-size: 13px;
  color: var(--text-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tx-main span {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.tx-amount {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 13px;
}

/* ---------- Empty / error states ---------- */
.empty-state {
  padding: 44px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
}

.empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 15px;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.empty-state h3 {
  margin: 0;
  font-size: 16px;
  color: var(--text-strong);
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  max-width: 360px;
}

/* ---------- Quick actions ---------- */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.quick-action {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
}

.quick-action:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.quick-action .icon {
  color: var(--primary);
}

/* ---------- Plan cards ---------- */
.plan-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.plan-card {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  position: relative;
}

.plan-card.featured {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary), var(--shadow);
}

.plan-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.plan-name {
  font-weight: 800;
  color: var(--text-strong);
  font-size: 16px;
}

.plan-price {
  font-size: 30px;
  font-family: var(--mono);
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text-strong);
}

.plan-price > span:not(.plan-price-list) {
  font-family: var(--font);
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0;
}

.plan-price-list {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: line-through;
  letter-spacing: -0.02em;
  margin-right: 4px;
}

.offer-banner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--radius, 12px);
  background: color-mix(in srgb, var(--success, #2f9e44) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--success, #2f9e44) 35%, transparent);
  color: var(--text-strong);
}

.offer-banner svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--success, #2f9e44);
}

.offer-banner strong {
  display: block;
  font-size: 14px;
  margin-bottom: 2px;
}

.offer-banner p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}

.star-rating {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.star-btn {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: #d4a017;
  font-size: 18px;
  cursor: pointer;
  text-align: left;
}

.star-btn:hover {
  border-color: color-mix(in srgb, #d4a017 50%, var(--border));
  background: color-mix(in srgb, #d4a017 10%, var(--surface));
}

.plan-features {
  list-style: none;
  padding: 0;
  margin: 18px 0;
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.plan-features li::before {
  content: "✓";
  color: var(--success);
  font-weight: 700;
  margin-right: 7px;
}

/* ---------- Modal ---------- */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-root.open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 12, 24, 0.58);
  backdrop-filter: blur(2px);
  animation: fadeIn 0.16s ease;
}

.modal {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.18s ease;
}

.modal-lg {
  max-width: 760px;
}

.modal-sm {
  max-width: 420px;
}

.modal-xl {
  max-width: 980px;
}

/* Near-fullscreen — for dense tables like CSV import review */
.modal-root:has(.modal-full) {
  padding: 8px;
  align-items: stretch;
}

.modal-full {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius-md, 10px);
}

.modal-full .modal-header,
.modal-full .modal-footer {
  flex: 0 0 auto;
}

.modal-full .modal-body {
  flex: 1 1 auto;
  overflow: auto;
  min-height: 0;
}

.modal-full .table-wrap {
  overflow: auto;
}

.modal-full .csv-rev-merchant {
  min-width: 160px;
}

.modal-full .csv-rev-category-wrap,
.modal-full .csv-rev-account-wrap,
.modal-full td .select-wrap {
  min-width: 140px;
}

.modal-full .csv-rev-amount {
  min-width: 110px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
}

.modal-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  color: var(--text-strong);
  letter-spacing: -0.01em;
}

.modal-desc {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  position: sticky;
  bottom: 0;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}

.modal-close:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* ---------- Toast ---------- */
.toast-root {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 140;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}

.toast {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideInToast 0.2s ease;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.toast-success {
  border-left: 3px solid var(--success);
}

.toast-danger {
  border-left: 3px solid var(--danger);
}

.toast-info {
  border-left: 3px solid var(--info);
}

/* ---------- Settings ---------- */
.settings-layout {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 18px;
}

.settings-nav {
  display: grid;
  gap: 2px;
  align-self: start;
  position: sticky;
  top: calc(var(--topbar-height) + 20px);
}

.settings-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
}

.settings-link:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.settings-link.active {
  background: var(--primary-soft);
  color: var(--primary);
}

/* ---------- One time secret ---------- */
.secret-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  background: var(--surface-2);
  border-radius: 10px;
  border: 1px dashed var(--border-strong);
  margin: 14px 0;
}

.secret-box code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-strong);
  word-break: break-all;
  flex: 1;
}

/* ---------- Import wizard ---------- */
.wizard-steps {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted-2);
}

.wizard-step .step-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-3);
  color: var(--muted);
}

.wizard-step.active .step-dot {
  background: var(--primary);
  color: #fff;
}

.wizard-step.active {
  color: var(--text-strong);
}

.wizard-step.done .step-dot {
  background: var(--success-soft);
  color: var(--success);
}

.upload-drop {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 42px 20px;
  text-align: center;
  color: var(--muted);
  background: var(--surface-2);
}

/* ---------- Misc ---------- */
.muted {
  color: var(--muted);
}

.mono {
  font-family: var(--mono);
}

.mt-16 {
  margin-top: 16px;
}

.mb-16 {
  margin-bottom: 16px;
}

.gap-8 {
  gap: 8px;
}

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

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.w-full {
  width: 100%;
}

.is-hidden {
  display: none !important;
}

/* ---------- Animations ---------- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes slideInToast {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .topbar-search {
    width: 280px;
  }
}

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    width: min(320px, 86vw);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(10, 12, 24, 0.5);
    z-index: 25;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
  }

  .mobile-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-menu-btn,
  .sidebar-close {
    display: inline-flex;
  }

  .topbar {
    padding: 0 14px;
  }

  .topbar-search {
    width: min(320px, 50vw);
  }

  .page-content {
    padding: 18px 14px;
  }

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

  .settings-layout {
    grid-template-columns: 1fr;
  }

  .settings-nav {
    position: static;
    flex-direction: row;
    overflow-x: auto;
    display: flex;
  }
}

@media (max-width: 640px) {
  .auth-view {
    grid-template-columns: 1fr;
  }

  .auth-art {
    display: none;
  }

  .auth-panel {
    padding: 32px 20px;
  }

  .grid-2,
  .grid-3,
  .grid-4,
  .form-row,
  .form-row-3 {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
  }

  .page-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .topbar-search {
    width: 42vw;
  }

  .topbar-create {
    padding: 0 9px;
  }

  .topbar-create .btn-text {
    display: none;
  }

  .topbar-right {
    gap: 6px;
  }

  .topbar-left {
    gap: 6px;
  }

  .modal {
    max-width: 100%;
  }

  .donut-wrap {
    justify-content: center;
  }
}

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

/* Auto-import plan lock */
.auto-import-locked {
  opacity: 0.72;
  filter: grayscale(0.35);
  position: relative;
}
.auto-import-locked .is-disabled,
.card-body.is-disabled {
  pointer-events: none;
  user-select: none;
}
.auto-import-lock-banner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid var(--border, #d0d5dd);
  border-radius: 12px;
  background: var(--surface-2, #f8fafc);
}
.auto-import-lock-icon {
  display: inline-flex;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
}
.auto-import-lock-icon svg {
  width: 22px;
  height: 22px;
}
