:root {
  --bg-primary: #080c14;
  --bg-card: rgba(16, 23, 38, 0.75);
  --bg-card-hover: rgba(24, 34, 56, 0.9);
  --border-color: rgba(79, 172, 254, 0.2);
  --border-hover: rgba(79, 172, 254, 0.45);
  --accent-cyan: #00f2fe;
  --accent-blue: #4facfe;
  --accent-green: #10b981;
  --accent-emerald: #059669;
  --accent-red: #ef4444;
  --accent-orange: #f59e0b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: radial-gradient(circle at 50% 0%, #111d33 0%, var(--bg-primary) 70%);
  color: var(--text-main);
  font-family: var(--font-family);
  min-height: 100vh;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 2.5rem;
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(8, 12, 20, 0.85);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.35rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-green));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.networth-pill {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 0.4rem 0.9rem;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent-green);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.sync-btn {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  color: #080c14;
  border: none;
  padding: 0.5rem 1.1rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.sync-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.back-portal-btn {
  text-decoration: none;
  color: var(--accent-cyan);
  background: rgba(0, 242, 254, 0.08);
  border: 1px solid rgba(0, 242, 254, 0.25);
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.back-portal-btn:hover {
  background: rgba(0, 242, 254, 0.18);
  border-color: var(--accent-cyan);
}

main {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

/* Tab Navigation */
.tab-nav {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 0.65rem 1.2rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  color: var(--accent-cyan);
  background: rgba(0, 242, 254, 0.1);
  border-bottom: 2px solid var(--accent-cyan);
}

/* Metric Cards */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
}

.metric-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.metric-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

.metric-val {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-main);
}

.metric-val.green {
  color: var(--accent-green);
}

.metric-val.cyan {
  color: var(--accent-cyan);
}

/* Sankey Diagram Section */
.sankey-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.75rem;
  margin-bottom: 2rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.section-title {
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sankey-container {
  width: 100%;
  overflow-x: auto;
  padding: 1rem 0;
}

/* Budget Grid */
.budget-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.budget-card {
  background: rgba(11, 17, 30, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1rem;
}

.budget-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.budget-bar-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.4rem;
}

.budget-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.budget-bar-fill.healthy {
  background: var(--accent-green);
}

.budget-bar-fill.warning {
  background: var(--accent-orange);
}

.budget-bar-fill.exceeded {
  background: var(--accent-red);
}

/* Accounts List */
.accounts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.account-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.acc-inst {
  font-size: 0.85rem;
  color: var(--accent-cyan);
  font-weight: 600;
}

.acc-name {
  font-size: 1.1rem;
  font-weight: 700;
  margin-top: 0.15rem;
}

.acc-mask {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.acc-bal {
  font-size: 1.35rem;
  font-weight: 700;
  text-align: right;
}

/* Table Styling */
.custom-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
}

.custom-table th {
  background: rgba(255, 255, 255, 0.03);
  padding: 0.9rem 1.25rem;
  text-align: left;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.custom-table td {
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.9rem;
}

.custom-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.pill-green {
  color: var(--accent-green);
  font-weight: 600;
}

.pill-red {
  color: var(--accent-red);
  font-weight: 600;
}

/* Alert Banners */
.active-alerts-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.alert-banner-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  border-radius: 8px;
  background: rgba(16, 23, 38, 0.9);
  border: 1px solid var(--border-color);
}

.alert-banner-item.warning {
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.08);
}

.alert-banner-item.critical {
  border-color: rgba(239, 68, 68, 0.5);
  background: rgba(239, 68, 68, 0.12);
}

.alert-banner-item.info {
  border-color: rgba(0, 242, 254, 0.4);
  background: rgba(0, 242, 254, 0.08);
}
