/* ================================================================
   Ekonom — Mobile-first design system (Klarna-inspired)
   Violett palett, pill-nav, stora hero-siffror, mjuka radier.
   Desktop (>=1024px) får uppskalad layout via media queries.
   ================================================================ */

/* ===== Tokens ===== */
:root {
  /* Primitives — violet dark palette */
  --bg-sunken:  #0E0B1C;
  --bg-base:    #1A1530;
  --bg-surface: #241D42;
  --bg-raised:  #2E2555;
  --bg-hover:   #3A2F66;

  --text-primary:   #F4F2FA;
  --text-secondary: #C4B5FD;
  --text-tertiary:  #9D8DC8;
  --text-faint:     #6B5F8E;

  --border-subtle:  rgba(255,255,255,0.04);
  --border-default: rgba(255,255,255,0.06);
  --border-strong:  rgba(255,255,255,0.12);

  --accent:        #A78BFA;
  --accent-hover:  #B7A0FB;
  --accent-dim:    rgba(167,139,250,0.12);
  --accent-border: rgba(167,139,250,0.24);
  --accent-strong: #8B5CF6;

  --positive:        #4ADE80;
  --positive-dim:    rgba(74,222,128,0.10);
  --positive-border: rgba(74,222,128,0.24);
  --negative:        #F87171;
  --negative-dim:    rgba(248,113,113,0.10);
  --negative-border: rgba(248,113,113,0.24);
  --warning:         #FBBF24;
  --warning-dim:     rgba(251,191,36,0.10);
  --warning-border:  rgba(251,191,36,0.24);

  /* Kategori-ikoner (pastell-tonade bakgrundscirklar + stark ikonfärg) */
  --cat-mat:         rgba(167, 139, 250, 0.15);
  --cat-mat-icon:    #A78BFA;
  --cat-el:          rgba(96, 165, 250, 0.15);
  --cat-el-icon:     #60A5FA;
  --cat-vatten:      rgba(34, 211, 238, 0.15);
  --cat-vatten-icon: #22D3EE;
  --cat-avgift:      rgba(74, 222, 128, 0.15);
  --cat-avgift-icon: #4ADE80;
  --cat-noje:        rgba(244, 114, 182, 0.15);
  --cat-noje-icon:   #F472B6;
  --cat-amortering:  rgba(52, 211, 153, 0.15);
  --cat-amort-icon:  #34D399;
  --cat-ranta:       rgba(251, 146, 60, 0.15);
  --cat-ranta-icon:  #FB923C;
  --cat-privat:      rgba(156, 163, 175, 0.12);
  --cat-privat-icon: #9CA3AF;

  /* Hero glow — radial gradient bakom hem-skärmens topp */
  --hero-glow: radial-gradient(ellipse 90% 100% at 50% 0%,
                rgba(139, 92, 246, 0.35) 0%,
                rgba(91, 63, 169, 0.15) 40%,
                transparent 75%);

  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top:    env(safe-area-inset-top, 0px);
}

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

html, body {
  min-height: 100vh;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: 'Instrument Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.55;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; }

.num, .num-display, .num-value, .num-inline,
.metric-value, .tx-amount, .hero-amount {
  font-variant-numeric: tabular-nums;
}

/* ===== Typografi ===== */
.hero-heading { font-size: 17px; font-weight: 500; letter-spacing: -0.02em; color: var(--text-primary); }
.hero-label   { font-size: 12px; font-weight: 500; color: var(--text-tertiary); letter-spacing: 0.04em; text-transform: uppercase; }
.hero-amount  { font-size: 44px; font-weight: 500; letter-spacing: -0.035em; color: var(--text-primary); line-height: 1.05; }
.hero-meta    { font-size: 13px; color: var(--text-secondary); }

.display    { font-size: 22px; font-weight: 500; letter-spacing: -0.02em; }
.heading    { font-size: 17px; font-weight: 500; letter-spacing: -0.02em; }
.subheading { font-size: 15px; font-weight: 500; letter-spacing: -0.015em; }
.body-sm    { font-size: 13px; font-weight: 400; }
.meta       { font-size: 12px; font-weight: 400; }
.caption    { font-size: 11px; font-weight: 400; letter-spacing: 0.01em; color: var(--text-tertiary); }
.tiny       { font-size: 10px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-tertiary); }

.num-display { font-size: 32px; font-weight: 500; letter-spacing: -0.02em; }
.num-value   { font-size: 22px; font-weight: 500; letter-spacing: -0.02em; }
.num-inline  { font-size: 14px; font-weight: 500; letter-spacing: -0.015em; }

.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary  { color: var(--text-tertiary); }
.text-faint     { color: var(--text-faint); }
.text-positive  { color: var(--positive); }
.text-negative  { color: var(--negative); }
.text-warning   { color: var(--warning); }
.text-accent    { color: var(--accent); }
.text-muted     { color: var(--text-secondary); }

/* ===== Layout ===== */
.main-content {
  max-width: 600px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 14px 120px;
  position: relative;
}

/* hero-glow bakom hem-skärmens topp */
.with-hero-glow::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 420px;
  background: var(--hero-glow);
  pointer-events: none;
  z-index: 0;
}

.with-hero-glow > * { position: relative; z-index: 1; }

/* Page-header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ===== Member row (installningar) ===== */
.member-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 0.5px solid var(--border-subtle);
  flex-wrap: wrap;
}

.member-row:last-child { border-bottom: none; }

.member-info {
  flex: 1;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.member-row input[type="text"] {
  padding: 10px 12px;
  font-size: 13px;
}

/* ===== Install chip (PWA install-prompt) ===== */
.install-chip {
  position: fixed;
  bottom: calc(84px + var(--safe-bottom));
  left: 12px;
  right: 12px;
  max-width: 580px;
  margin: 0 auto;
  background: var(--bg-raised);
  border: 0.5px solid var(--border-default);
  border-radius: 100px;
  padding: 10px 10px 10px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-primary);
  z-index: 200;
  animation: install-chip-up 0.28s ease-out;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.install-chip span { flex: 1; min-width: 0; }

.install-chip button[data-install] {
  background: var(--accent);
  color: var(--bg-base);
  border: none;
  padding: 8px 14px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.install-chip button[data-install]:hover { background: var(--accent-hover); }

.install-chip button[data-dismiss] {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  line-height: 1;
  padding: 6px 10px;
  cursor: pointer;
  min-width: 36px;
}

.install-chip button[data-dismiss]:hover { color: var(--text-primary); }

.install-chip-ios {
  /* iOS-hint har bara en dismiss-knapp, ingen install — strackt ut span */
  padding: 10px 10px 10px 18px;
}

@keyframes install-chip-up {
  from { transform: translateY(calc(100% + 100px)); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

@media (min-width: 1024px) {
  .install-chip {
    left: auto;
    right: 20px;
    bottom: 20px;
    max-width: 380px;
    margin: 0;
  }
}

/* ===== Top-bar (mobile header) ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 16px;
}

.topbar-logo {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, #D946EF 100%);
  display: inline-block;
  flex-shrink: 0;
}

/* Month-picker pill */
.month-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.06);
  border: 0.5px solid var(--border-default);
  border-radius: 100px;
  padding: 6px 6px;
  font-size: 13px;
  color: var(--text-primary);
}

.month-pill a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 100px;
  color: var(--text-secondary);
}

.month-pill a:hover { background: rgba(255,255,255,0.08); color: var(--text-primary); text-decoration: none; }
.month-pill .label { padding: 0 8px; font-weight: 500; }

/* ===== Bottom nav ===== */
.bottom-nav {
  position: fixed;
  bottom: calc(12px + var(--safe-bottom));
  left: 14px;
  right: 14px;
  max-width: 572px;
  margin: 0 auto;
  background: rgba(20, 15, 40, 0.85);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 0.5px solid rgba(255, 255, 255, 0.08);
  border-radius: 100px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  z-index: 100;
}

/* Fallback om backdrop-filter inte stöds */
@supports not (backdrop-filter: blur(20px)) {
  .bottom-nav { background: rgba(20, 15, 40, 0.96); }
}

.nav-pod {
  padding: 10px 6px;
  border-radius: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-tertiary);
  text-decoration: none;
  min-height: 44px;
  transition: color 0.15s, background 0.15s;
}

.nav-pod:hover { text-decoration: none; color: var(--text-primary); }
.nav-pod.active { background: rgba(255,255,255,0.10); color: var(--text-primary); }
.nav-pod span { font-size: 10px; font-weight: 500; }
.nav-pod svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }

/* ===== Panels / cards ===== */
.panel, .card {
  background: rgba(255,255,255,0.04);
  border: 0.5px solid rgba(255,255,255,0.06);
  border-radius: 20px;
  padding: 16px 18px;
  margin-bottom: 14px;
}

.panel-title, .card-title {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 12px;
}

.panel-header-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}

.panel-header-row .panel-title { margin-bottom: 0; }

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

/* Equity-staplar (bolanets formogenhets-sektion) */
.equity-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.equity-bar-track {
  flex: 1;
  height: 12px;
  background: var(--bg-sunken);
  border-radius: 6px;
  overflow: hidden;
}

.equity-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.4s ease;
}

.equity-amort   { background: var(--positive); }
.equity-apprec  { background: var(--accent); }

.equity-bar-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 5.5rem;
  line-height: 1.2;
}

/* ===== Hero ===== */
.hero {
  padding: 20px 4px 24px;
  text-align: left;
}

.hero-label { margin-bottom: 8px; }
.hero-heading { margin-bottom: 4px; }
.hero-amount { margin-bottom: 8px; }
.hero-meta { margin-bottom: 20px; }

.hero-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.hero-amount-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.hero-amount-row .hero-amount { margin-bottom: 0; }

.btn-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  border: 0.5px solid var(--border-default);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}

.btn-copy:hover { background: rgba(255,255,255,0.12); color: var(--text-primary); }

.btn-copy.copied {
  background: var(--positive-dim);
  color: var(--positive);
  border-color: var(--positive-border);
}

/* ===== Metric cards ===== */
.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.metric-card {
  background: rgba(255,255,255,0.04);
  border: 0.5px solid rgba(255,255,255,0.06);
  border-radius: 20px;
  padding: 16px 18px;
}

.metric-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}

.metric-value {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.metric-value.positive { color: var(--positive); }
.metric-value.negative { color: var(--negative); }
.metric-value.accent   { color: var(--accent); }
.metric-value.warning  { color: var(--warning); }

.metric-unit { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }
.metric-sub { font-size: 11px; color: var(--text-secondary); margin-top: 4px; }

/* ===== Banners ===== */
.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  margin-bottom: 14px;
}

.banner-content { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.banner-title   { font-size: 14px; font-weight: 500; color: var(--text-primary); }
.banner-sub     { font-size: 12px; color: var(--text-secondary); }

.banner-accent   { background: var(--accent-dim);   border: 0.5px solid var(--accent-border); }
.banner-warning  { background: var(--warning-dim);  border: 0.5px solid var(--warning-border); border-left-width: 3px; }
.banner-positive { background: var(--positive-dim); border: 0.5px solid var(--positive-border); }
.banner-negative { background: var(--negative-dim); border: 0.5px solid var(--negative-border); }

/* Kompakt review-banner som länk */
.review-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--warning-dim);
  border: 0.5px solid var(--warning-border);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 14px;
  color: var(--text-primary);
  text-decoration: none;
}

.review-banner:hover { text-decoration: none; background: rgba(251,191,36,0.16); }
.review-banner .title { font-size: 14px; font-weight: 500; color: var(--text-primary); }
.review-banner .meta  { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.review-banner .chev  { opacity: 0.7; flex-shrink: 0; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 13px 20px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  border: 0.5px solid var(--border-default);
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
  text-decoration: none !important;
  white-space: nowrap;
  min-height: 44px;
}

.btn:hover { background: rgba(255,255,255,0.10); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--text-primary);
  color: var(--bg-base);
  border-color: transparent;
}
.btn-primary:hover { background: #FFFFFF; color: var(--bg-base); }

.btn-secondary {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.12);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
  min-height: 40px;
  padding: 8px 14px;
}
.btn-ghost:hover { color: var(--text-primary); background: rgba(255,255,255,0.06); }

.btn-danger {
  background: transparent;
  color: var(--negative);
  border-color: var(--negative-border);
}
.btn-danger:hover { background: var(--negative-dim); }

.btn-positive { background: transparent; color: var(--positive); border-color: var(--positive-border); }
.btn-positive:hover { background: var(--positive-dim); }
.btn-negative { background: transparent; color: var(--negative); border-color: var(--negative-border); }
.btn-negative:hover { background: var(--negative-dim); }

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
  min-height: 36px;
}

.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 0.5px solid rgba(255,255,255,0.12);
  color: var(--text-primary);
}

.btn-icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }

/* ===== Inputs ===== */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-sunken);
  border: 0.5px solid var(--border-default);
  border-radius: 14px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder { color: var(--text-faint); }
input[type="file"] { padding: 10px 12px; font-size: 13px; color: var(--text-secondary); }

/* ===== Forms ===== */
.form-card {
  background: rgba(255,255,255,0.04);
  border: 0.5px solid rgba(255,255,255,0.06);
  border-radius: 20px;
  padding: 20px;
  max-width: 560px;
}

.form-section { margin-bottom: 20px; }

.form-section-title {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 0.5px solid var(--border-subtle);
}

.form-group { margin-bottom: 14px; }

.form-group label {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.form-hint { font-size: 11px; color: var(--text-tertiary); margin-bottom: 8px; }

.form-row { display: grid; grid-template-columns: 1fr; gap: 12px; }

/* ===== Chips ===== */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 100px;
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary);
  border: 0.5px solid rgba(255,255,255,0.06);
  white-space: nowrap;
}

.chip::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
  opacity: 0.75;
}

.chip-positive { color: var(--positive); background: var(--positive-dim); border-color: var(--positive-border); }
.chip-accent   { color: var(--accent);   background: var(--accent-dim);   border-color: var(--accent-border); }
.chip-warning  { color: var(--warning);  background: var(--warning-dim);  border-color: var(--warning-border); }
.chip-negative { color: var(--negative); background: var(--negative-dim); border-color: var(--negative-border); }
.chip-faint    { color: var(--text-tertiary); background: transparent; border-color: var(--border-subtle); }

/* Bakåtkompat */
.tx-category {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 100px;
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary);
  border: 0.5px solid rgba(255,255,255,0.06);
  white-space: nowrap;
}

/* ===== Transaktions-rad med ikon-kvadrat ===== */
.tx-list { list-style: none; }

.tx-row, .tx-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 0.5px solid var(--border-subtle);
  min-height: 56px;
}

.tx-row:last-child, .tx-item:last-child { border-bottom: none; }

.tx-icon {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--cat-privat);
  color: var(--cat-privat-icon);
}

.tx-icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }

.tx-icon.cat-mat        { background: var(--cat-mat);        color: var(--cat-mat-icon); }
.tx-icon.cat-el         { background: var(--cat-el);         color: var(--cat-el-icon); }
.tx-icon.cat-vatten     { background: var(--cat-vatten);     color: var(--cat-vatten-icon); }
.tx-icon.cat-avgift     { background: var(--cat-avgift);     color: var(--cat-avgift-icon); }
.tx-icon.cat-noje       { background: var(--cat-noje);       color: var(--cat-noje-icon); }
.tx-icon.cat-amortering { background: var(--cat-amortering); color: var(--cat-amort-icon); }
.tx-icon.cat-ranta      { background: var(--cat-ranta);      color: var(--cat-ranta-icon); }
.tx-icon.cat-privat     { background: var(--cat-privat);     color: var(--cat-privat-icon); }

.tx-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tx-desc {
  font-size: 14px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tx-meta { font-size: 12px; color: var(--text-tertiary); }

/* tx-date & tx-amount behålls för templates som ännu inte migrerats */
.tx-date {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
  min-width: 3.5rem;
  font-variant-numeric: tabular-nums;
}

.tx-amount {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--text-primary);
  text-align: right;
  white-space: nowrap;
  min-width: 5rem;
  font-variant-numeric: tabular-nums;
}

.tx-amount.positive { color: var(--positive); }
.tx-amount.negative { color: var(--negative); }

.review-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 0.5px solid var(--border-subtle);
  flex-wrap: wrap;
}
.review-item:last-child { border-bottom: none; }
.review-actions { display: flex; gap: 6px; margin-left: auto; flex-shrink: 0; }

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

.table th {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  text-align: left;
  padding: 8px 6px;
  border-bottom: 0.5px solid var(--border-default);
}

.table td {
  padding: 12px 6px;
  border-bottom: 0.5px solid var(--border-subtle);
  color: var(--text-primary);
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: rgba(255,255,255,0.02); }
.table td.num, .table th.num {
  text-align: right;
  font-weight: 500;
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums;
}

/* ===== Auth / onboarding ===== */
.auth-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  gap: 8px;
}

.auth-title {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.auth-subtitle { color: var(--text-secondary); margin-bottom: 24px; font-size: 13px; }

.onboarding-container { max-width: 560px; margin: 0 auto; }

/* ===== Split grid / kv-list ===== */
.split-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.split-grid .panel { margin-bottom: 0; }

.kv-list { list-style: none; }

.kv-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.kv-list li.kv-strong { color: var(--text-primary); font-weight: 500; }
.kv-list li.kv-divider { border-bottom: 0.5px solid var(--border-subtle); padding: 0; margin: 4px 0; }

/* Split-bar (onboarding) */
.split-bar-container { margin-bottom: 20px; }
.split-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--bg-raised); margin: 8px 0; }
.split-bar-segment { height: 100%; transition: width 0.3s ease; }
.split-bar-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* ===== Horizontal bar chart ===== */
.hbar-item { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.hbar-label { width: 6rem; font-size: 12px; color: var(--text-secondary); text-align: right; flex-shrink: 0; }
.hbar-track { flex: 1; height: 12px; background: var(--bg-raised); border-radius: 4px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 4px; transition: width 0.4s ease; }
.hbar-value {
  width: 6rem; text-align: right; font-size: 12px; font-weight: 500;
  letter-spacing: -0.015em; color: var(--text-secondary);
  font-variant-numeric: tabular-nums; flex-shrink: 0;
}

/* ===== Category bars (kategorier/privat) ===== */
.cat-bars { list-style: none; }
.cat-bar-item { margin-bottom: 14px; }
.cat-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.cat-bar-label { flex: 1; font-size: 14px; color: var(--text-primary); }
.cat-bar-amount { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.cat-bar-track { height: 6px; background: var(--bg-sunken); border-radius: 3px; overflow: hidden; }
.cat-bar-fill { height: 100%; border-radius: 3px; transition: width 0.3s ease; }
.cat-bar-default { background: var(--text-tertiary); }
.cat-bar-wealth  { background: var(--positive); }
.cat-bar-accent  { background: var(--accent); }

/* Kostnad-vs-wealth bar (bolan) */
.cost-bar {
  display: flex;
  height: 28px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-raised);
  border: 0.5px solid var(--border-subtle);
}
.cost-bar-seg {
  height: 100%; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 500; color: var(--bg-base);
  transition: width 0.3s ease; overflow: hidden; white-space: nowrap;
}
.cost-bar-cost   { background: var(--text-tertiary); color: var(--text-primary); }
.cost-bar-wealth { background: var(--positive); color: var(--bg-base); }

/* Amortering historik */
.amort-bars { display: flex; gap: 10px; align-items: flex-end; height: 160px; padding: 16px 0 0; }
.amort-bar {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 6px; height: 100%; justify-content: flex-end;
}
.amort-bar-value { font-size: 11px; font-weight: 500; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.amort-bar-track {
  width: 100%; flex: 1; background: var(--bg-sunken);
  border-radius: 4px; overflow: hidden; display: flex; align-items: flex-end; min-height: 0;
}
.amort-bar-fill { width: 100%; background: var(--positive); border-radius: 4px; transition: height 0.4s ease; }
.amort-bar-label { font-size: 11px; color: var(--text-tertiary); text-transform: lowercase; }

/* Avi preview */
.avi-preview-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 14px; }
.avi-preview-grid .panel { margin-bottom: 0; }
.avi-image {
  width: 100%; border-radius: 14px;
  border: 0.5px solid var(--border-default);
  background: var(--bg-sunken); display: block;
}

/* Invite link */
.invite-link {
  display: block; font-size: 12px; color: var(--accent); word-break: break-all;
  padding: 12px; background: var(--bg-sunken);
  border: 0.5px solid var(--border-default); border-radius: 14px;
  margin-bottom: 12px; font-variant-numeric: tabular-nums;
}

/* ===== Bottom sheet ===== */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(10, 8, 20, 0.6);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.sheet-backdrop.open { display: flex; }

.sheet {
  background: var(--bg-surface);
  border: 0.5px solid var(--border-default);
  border-radius: 24px 24px 0 0;
  padding: 8px 20px calc(28px + var(--safe-bottom));
  width: 100%;
  max-width: 600px;
  transform: translateY(100%);
  animation: sheet-up 0.22s ease-out forwards;
}

@keyframes sheet-up { to { transform: translateY(0); } }

.sheet-handle {
  width: 32px; height: 4px;
  background: var(--text-faint);
  border-radius: 100px;
  margin: 0 auto 16px;
}

/* ===== Utilities ===== */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.items-baseline { align-items: baseline; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: 8px; }
.gap-md { gap: 12px; }
.gap-lg { gap: 20px; }
.mt-sm { margin-top: 8px; } .mt-md { margin-top: 16px; } .mt-lg { margin-top: 24px; }
.mb-sm { margin-bottom: 8px; } .mb-md { margin-bottom: 16px; } .mb-lg { margin-bottom: 24px; }

.positive { color: var(--positive); }
.negative { color: var(--negative); }
.accent   { color: var(--accent); }
.warning  { color: var(--warning); }

/* ===== Top nav (används bara >=1024px) ===== */
.top-nav {
  display: none;
  max-width: 720px;
  margin: 12px auto 0;
  padding: 8px;
  background: rgba(20, 15, 40, 0.85);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 0.5px solid rgba(255, 255, 255, 0.08);
  border-radius: 100px;
  gap: 4px;
  align-items: center;
  justify-content: space-between;
}

.top-nav-logo {
  font-size: 14px;
  font-weight: 500;
  padding: 0 12px;
  color: var(--text-primary);
}

.top-nav-links { display: flex; gap: 2px; flex: 1; justify-content: center; }

.top-nav-links a {
  padding: 8px 14px;
  border-radius: 100px;
  font-size: 13px;
  color: var(--text-tertiary);
}

.top-nav-links a:hover { color: var(--text-primary); text-decoration: none; background: rgba(255,255,255,0.06); }
.top-nav-links a.active { color: var(--text-primary); background: rgba(255,255,255,0.10); }

.top-nav-user {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 12px 4px 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 100px;
  font-size: 13px; color: var(--text-primary);
}
.top-nav-user .avatar { width: 28px; height: 28px; }

/* ===== Tablet (>=768px) ===== */
@media (min-width: 768px) {
  .main-content { max-width: 680px; padding: 20px 20px 120px; }
  .split-grid { grid-template-columns: 1fr 1fr; gap: 14px; }
  .avi-preview-grid { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr 1fr; }
  .metric-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ===== Desktop (>=1024px) ===== */
@media (min-width: 1024px) {
  .main-content {
    max-width: 1280px;
    padding: 20px 24px 64px;
  }
  .hero-amount { font-size: 32px; }
  .page-title { font-size: 22px; }

  /* Gör bottom-nav till top-nav visuellt */
  .bottom-nav {
    position: sticky;
    top: 12px;
    bottom: auto;
    left: 0;
    right: 0;
    max-width: 720px;
    margin: 0 auto 16px;
  }

  /* Top-nav alternativet visas inte om vi bara återanvänder bottom-nav */
  .top-nav { display: none; }
}
