/**
 * FinFunnel by Plotkai - Fintech Design System
 * Mobile-First, Zero-Vertical-Scroll Layout with Horizontal Card Carousels
 */

:root {
  --bg-main: #090d16;
  --bg-card: rgba(18, 26, 43, 0.75);
  --bg-card-hover: rgba(26, 37, 61, 0.85);
  --bg-input: rgba(13, 19, 33, 0.9);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.6);
  
  --primary-blue: #38bdf8;
  --primary-indigo: #6366f1;
  --primary-purple: #a855f7;
  
  --earn-accent: #38bdf8;
  --earn-bg: rgba(56, 189, 248, 0.08);
  --earn-border: rgba(56, 189, 248, 0.25);
  
  --spend-accent: #f43f5e;
  --spend-bg: rgba(244, 63, 94, 0.08);
  --spend-border: rgba(244, 63, 94, 0.25);
  
  --emerald-accent: #10b981;
  --emerald-bg: rgba(16, 185, 129, 0.12);
  --emerald-border: rgba(16, 185, 129, 0.3);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', 'Segoe UI', Roboto, sans-serif;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.25);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden; /* Avoid page-level vertical jumping */
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* App Viewport Container */
.app-viewport {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  width: 100%;
  max-width: 600px; /* Perfect for mobile, centered on tablets/desktops */
  margin: 0 auto;
  position: relative;
  background: radial-gradient(circle at 50% 0%, rgba(99, 102, 241, 0.12) 0%, transparent 50%),
              radial-gradient(circle at 50% 100%, rgba(244, 63, 94, 0.08) 0%, transparent 40%),
              var(--bg-main);
  border-left: 1px solid rgba(255, 255, 255, 0.04);
  border-right: 1px solid rgba(255, 255, 255, 0.04);
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.6);
}

@media (min-width: 800px) {
  .app-viewport {
    max-width: 720px;
  }
}

/* Header Bar */
.app-header {
  height: 56px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(12px);
  z-index: 10;
  flex-shrink: 0;
}

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

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  background: linear-gradient(135deg, #ffffff 40%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-author {
  font-size: 11px;
  font-weight: 500;
  color: var(--primary-blue);
  opacity: 0.9;
}

/* Buttons & Icons */
.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-icon:hover, .btn-icon:active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.btn-icon.accent-glow {
  border-color: rgba(99, 102, 241, 0.3);
  color: var(--primary-blue);
}
.btn-icon.accent-glow:hover {
  border-color: var(--primary-blue);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
}

/* Header Period Selector & Dropdown */
.period-selector-wrapper {
  position: relative;
}

.period-icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  width: auto;
  height: 34px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: var(--primary-blue);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
}
.period-icon-btn:hover {
  background: rgba(99, 102, 241, 0.22);
  border-color: var(--primary-blue);
}

.period-badge-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
}

.period-badge-text {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.2px;
}

.period-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 160px;
  background: #0f172a;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 50;
  animation: dropdownFadeIn 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}
.period-dropdown-menu.open {
  display: flex;
}

@keyframes dropdownFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.period-option-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}
.period-option-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}
.period-option-btn.active {
  background: rgba(56, 189, 248, 0.15);
  color: var(--primary-blue);
}

.period-opt-badge {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
}
.period-option-btn.active .period-opt-badge {
  background: var(--primary-blue);
  color: #090d16;
}

/* Main Split Screen */
.main-flow-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Halves: Upper & Lower */
.flow-half-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 14px 4px 14px;
  overflow: hidden;
  position: relative;
}

.flow-half-section.earnings-half {
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.04) 0%, transparent 100%);
}

.flow-half-section.spendings-half {
  background: linear-gradient(0deg, rgba(244, 63, 94, 0.04) 0%, transparent 100%);
}

/* Section Header Row */
.section-meta-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.section-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-icon-pill {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}
.earnings-half .section-icon-pill {
  background: rgba(56, 189, 248, 0.15);
  color: var(--earn-accent);
}
.spendings-half .section-icon-pill {
  background: rgba(244, 63, 94, 0.15);
  color: var(--spend-accent);
}

.section-title-text {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
}

.section-summary-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.total-pill-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.1;
}

.total-pill-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.total-pill-amount {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.3px;
}
.earnings-half .total-pill-amount {
  color: var(--earn-accent);
}
.spendings-half .total-pill-amount {
  color: var(--spend-accent);
}

/* Horizontal Inline Card Carousel */
.cards-horizontal-scroll {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 2px 6px 2px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.cards-horizontal-scroll::-webkit-scrollbar {
  height: 3px;
}
.cards-horizontal-scroll::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 4px;
}
.cards-horizontal-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}

/* Sleek Summary Block Card (Compact Height) */
.finance-card {
  width: 210px;
  min-width: 210px;
  max-width: 210px;
  height: 100%;
  max-height: 132px; /* Super compact summary block */
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 8px 10px;
  scroll-snap-align: start;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s, background 0.2s;
  position: relative;
  user-select: none;
}

.finance-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px -4px rgba(0, 0, 0, 0.5);
}

.earning-card {
  border-left: 3px solid var(--earn-accent);
}
.spending-card {
  border-left: 3px solid var(--spend-accent);
}

.card-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.card-badge {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--earn-bg);
  color: var(--earn-accent);
  border: 1px solid var(--earn-border);
}
.card-badge.spend-badge {
  background: var(--spend-bg);
  color: var(--spend-accent);
  border-color: var(--spend-border);
}

.card-cycle-pill {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}
.card-cycle-pill.pct-pill {
  background: rgba(244, 63, 94, 0.15);
  color: var(--spend-accent);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.btn-card-edit {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  padding: 0;
  color: var(--text-secondary);
}
.finance-card:hover .btn-card-edit {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.1);
}

.card-title-text {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 3px;
}

.card-main-amount {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.3px;
  margin-top: 1px;
}
.earning-card .card-main-amount {
  color: var(--earn-accent);
}
.spending-card .card-main-amount {
  color: var(--spend-accent);
}

.card-bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  gap: 4px;
}

.card-tag-pills {
  display: flex;
  flex-wrap: nowrap;
  gap: 3px;
  overflow: hidden;
}

.tag-pill {
  font-size: 8.5px;
  font-weight: 600;
  color: var(--earn-accent);
  background: rgba(56, 189, 248, 0.1);
  padding: 1px 5px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(56, 189, 248, 0.2);
  white-space: nowrap;
}
.tag-pill.spend-tag-pill {
  color: var(--spend-accent);
  background: rgba(244, 63, 94, 0.1);
  border-color: rgba(244, 63, 94, 0.2);
}

.card-norm-sub {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Add Block Card */
.finance-card.add-card-block {
  border: 1px dashed rgba(56, 189, 248, 0.35);
  background: rgba(56, 189, 248, 0.03);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.finance-card.add-card-block:hover {
  background: rgba(56, 189, 248, 0.08);
  border-color: var(--earn-accent);
  transform: scale(1.02);
}

.finance-card.spend-add-block {
  border-color: rgba(244, 63, 94, 0.35);
  background: rgba(244, 63, 94, 0.03);
}
.finance-card.spend-add-block:hover {
  background: rgba(244, 63, 94, 0.08);
  border-color: var(--spend-accent);
}

.add-card-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}

.add-icon-circle {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: rgba(56, 189, 248, 0.15);
  color: var(--earn-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}
.finance-card.add-card-block:hover .add-icon-circle {
  transform: rotate(90deg) scale(1.1);
}

.spend-add-circle {
  background: rgba(244, 63, 94, 0.15);
  color: var(--spend-accent);
}

.add-card-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-primary);
}
.add-card-sub {
  font-size: 9px;
  color: var(--text-muted);
}

/* Center Flow Funnel Node */
.center-flow-bridge {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 16px;
  position: relative;
  flex-shrink: 0;
  z-index: 5;
}

.funnel-svg-connector {
  position: absolute;
  top: -24px;
  bottom: -24px;
  left: 0;
  right: 0;
  width: 100%;
  height: calc(100% + 48px);
  pointer-events: none;
  z-index: 1;
}

.settlement-card {
  position: relative;
  z-index: 2;
  background: rgba(18, 26, 43, 0.9);
  backdrop-filter: blur(20px);
  border: 1px solid var(--emerald-border);
  border-radius: var(--radius-md);
  padding: 8px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.5), 0 0 15px rgba(16, 185, 129, 0.15);
  transition: all 0.2s;
}

.settlement-card:hover {
  border-color: rgba(16, 185, 129, 0.5);
  box-shadow: 0 10px 28px -4px rgba(0, 0, 0, 0.6), 0 0 20px rgba(16, 185, 129, 0.25);
}

.settlement-icon-circle {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: var(--emerald-bg);
  border: 1px solid var(--emerald-border);
  color: var(--emerald-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.settlement-info {
  display: flex;
  flex-direction: column;
}

.settlement-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.settlement-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-secondary);
}

.status-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
}
.status-badge.surplus {
  background: var(--emerald-bg);
  color: var(--emerald-accent);
  border: 1px solid var(--emerald-border);
}
.status-badge.neutral {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
}
.status-badge.deficit {
  background: rgba(244, 63, 94, 0.15);
  color: #f43f5e;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.settlement-amount {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.5px;
  color: var(--emerald-accent);
  line-height: 1.1;
  margin-top: 1px;
}
.settlement-amount.negative {
  color: #f43f5e;
}

.settlement-savings-rate {
  font-size: 10px;
  font-weight: 600;
  color: var(--emerald-accent);
  margin-top: 1px;
}
.settlement-savings-rate.negative {
  color: #f43f5e;
}

/* Center Edit Modal */
.app-modal.center-card-modal {
  max-width: 480px;
}

.edit-modal-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px;
}

.modal-field {
  height: 38px;
  font-size: 13px;
}

.modal-type-toggle {
  margin-bottom: 2px;
}
.modal-type-toggle .type-toggle-btn {
  padding: 6px 0;
  font-size: 11px;
}

.input-with-suffix {
  position: relative;
  display: flex;
  align-items: center;
}
.input-with-suffix .input-suffix {
  position: absolute;
  right: 12px;
  font-weight: 700;
  color: var(--text-muted);
  pointer-events: none;
}

.modal-preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-top: 4px;
}

.preview-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.preview-val {
  font-size: 13px;
  font-weight: 800;
  color: var(--primary-blue);
}

/* Edit Modal Footer */
.edit-modal-footer {
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-subtle);
  background: rgba(13, 19, 32, 0.5);
}

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

.btn-action-outline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-action-outline:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}
.btn-action-outline.text-danger {
  color: #f87171;
  border-color: rgba(244, 63, 94, 0.25);
}
.btn-action-outline.text-danger:hover {
  background: rgba(244, 63, 94, 0.15);
  border-color: #f43f5e;
}
.btn-action-outline.btn-confirm-delete {
  background: #f43f5e !important;
  color: #fff !important;
  border-color: #f43f5e !important;
  font-weight: 700;
  animation: pulseDelete 0.6s infinite alternate;
}

@keyframes pulseDelete {
  from { box-shadow: 0 0 0 rgba(244, 63, 94, 0.4); }
  to { box-shadow: 0 0 10px rgba(244, 63, 94, 0.8); }
}

.btn-primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 16px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: none;
  background: linear-gradient(135deg, #38bdf8 0%, #6366f1 100%);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
  transition: all 0.2s;
}
.btn-primary-action:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.5);
}

.btn-primary-action:active {
  transform: translateY(0);
}

/* Modals & Drawers */
.drawer-overlay, .modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.drawer-overlay.open, .modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* Hamburger Side Drawer */
.side-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 290px;
  max-width: 85vw;
  background: #0d1320;
  border-right: 1px solid var(--border-subtle);
  z-index: 101;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 10px 0 30px rgba(0, 0, 0, 0.6);
}
.side-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  height: 56px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.drawer-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.drawer-menu-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}
.menu-item:hover {
  background: rgba(255, 255, 255, 0.05);
}
.menu-item.text-danger {
  color: #f87171;
}
.menu-item.text-danger:hover {
  background: rgba(244, 63, 94, 0.1);
}

.menu-item-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.menu-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 6px 0;
}

.drawer-currency-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
}
.drawer-currency-row label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}
.currency-select-input {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--primary-blue);
  font-weight: 700;
  padding: 4px 8px;
  outline: none;
}

.drawer-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border-subtle);
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

/* Analytics Center Modal */
.app-modal {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translate(-50%, 100%);
  width: 100%;
  max-width: 580px;
  max-height: 88vh;
  background: #0f172a;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  z-index: 102;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.8);
}
.app-modal.open {
  transform: translate(-50%, 0);
}

@media (min-width: 640px) {
  .app-modal {
    bottom: auto;
    top: 50%;
    transform: translate(-50%, -45%) scale(0.95);
    border-radius: var(--radius-lg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    opacity: 0;
    pointer-events: none;
  }
  .app-modal.open {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    pointer-events: auto;
  }
}

.modal-header {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title-box {
  display: flex;
  flex-direction: column;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-subtitle {
  font-size: 11px;
  color: var(--text-muted);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Charts & SVG Styling */
.donut-chart-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
@media (min-width: 480px) {
  .donut-chart-wrapper {
    flex-direction: row;
    justify-content: space-around;
  }
}

.donut-svg-container {
  position: relative;
  width: 200px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.donut-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.donut-segment {
  cursor: pointer;
  transition: stroke-width 0.2s, opacity 0.2s;
}
.donut-segment:hover {
  stroke-width: 32;
  opacity: 0.9;
}

.donut-center-info {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  pointer-events: none;
}
.center-sub {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.center-main {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
}

.chart-legend-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-width: 240px;
}

.chart-legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
}

.legend-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.legend-label {
  font-weight: 600;
  color: var(--text-secondary);
}

.legend-right {
  display: flex;
  align-items: center;
  gap: 6px;
}
.legend-val {
  font-weight: 700;
  color: var(--text-primary);
}
.legend-pct {
  color: var(--text-muted);
  font-size: 10px;
}

/* Bar Chart Styling */
.bar-chart-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bar-chart-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.bar-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
}
.bar-label {
  font-weight: 600;
  color: var(--text-secondary);
}
.bar-value {
  font-weight: 700;
  color: var(--text-primary);
}

.bar-track {
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Master Analytics Summary Grid */
.analytics-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.summary-metric-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.metric-title {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}
.metric-val {
  font-size: 14px;
  font-weight: 800;
  margin: 3px 0 1px 0;
}
.metric-sub {
  font-size: 9.5px;
  color: var(--text-muted);
}

.section-subheading {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.analytics-sub-section {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
}

.chart-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

/* Utility Colors & Classes */
.text-cyan { color: var(--primary-blue); }
.text-rose { color: var(--spend-accent); }
.text-emerald { color: var(--emerald-accent); }
.text-danger { color: #f87171; }
.hidden { display: none !important; }

/* App Toast */
.app-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(30, 41, 59, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(12px);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  z-index: 999;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}
.app-toast.show {
  transform: translateX(-50%) translateY(0);
}
