@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap');

:root {
  --bg-top: #eef4fb;
  --bg-mid: #f7f9fc;
  --bg-bottom: #e3edf8;
  --glass-bg: rgba(255, 255, 255, 0.78);
  --glass-strong: rgba(255, 255, 255, 0.92);
  --glass-border: rgba(255, 255, 255, 0.95);
  --card-stroke: rgba(15, 23, 42, 0.08);
  --text-main: #0f172a;
  --text-muted: #64748b;
  --accent: #0284c7;
  --accent-deep: #1d4ed8;
  --success: #15803d;
  --success-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --danger: #be123c;
  --danger-bg: #ffe4e6;
  --radius-lg: 22px;
  --radius-md: 15px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  background-color: var(--bg-top);
  min-height: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-main);
  background: var(--bg-top);
  padding-bottom: calc(105px + env(safe-area-inset-bottom));
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background: linear-gradient(155deg, var(--bg-top) 0%, var(--bg-mid) 50%, var(--bg-bottom) 100%);
  pointer-events: none;
}

.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(85px);
  z-index: -1;
  pointer-events: none;
}

.bg-glow-1 {
  width: 300px;
  height: 300px;
  background: rgba(14, 165, 233, 0.14);
  top: 40px;
  right: -80px;
}

.bg-glow-2 {
  width: 320px;
  height: 320px;
  background: rgba(99, 102, 241, 0.1);
  bottom: 70px;
  left: -90px;
}

.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.06), inset 0 0 0 1px var(--card-stroke);
}

/* Header */
.app-header {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 18px 14px;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
}

.org-pill {
  display: inline-block;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}

.app-header h1 {
  margin: 0;
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.year-badge {
  background: rgba(2, 132, 199, 0.12);
  color: var(--accent);
  border: 1px solid rgba(2, 132, 199, 0.25);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
}

/* Main */
.app-content {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

/* KPI-kort */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

@media (min-width: 600px) {
  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.kpi-card {
  border-radius: var(--radius-lg);
  padding: 15px 16px;
}

.kpi-clickable {
  cursor: pointer;
  transition: transform 0.15s ease;
}

.kpi-clickable:active {
  transform: scale(0.97);
}

.kpi-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 1.65rem;
  font-weight: 800;
  margin: 4px 0;
  letter-spacing: -0.02em;
}

.kpi-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.text-success {
  color: var(--success);
}

.text-warn {
  color: var(--warn);
}

.progress-bar {
  height: 6px;
  background: rgba(15, 23, 42, 0.08);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #16a34a, #22c55e);
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* Sektionsrubriker & knappar */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 6px 2px 10px;
}

.section-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.text-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 4px 6px;
}

/* Sök & filter */
.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 15px;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}

.search-box svg {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-box input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 0.96rem;
  outline: none;
}

.filter-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
}

.chip {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--card-stroke);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Kortlistor */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.member-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.member-card:active {
  transform: scale(0.985);
  background: var(--glass-strong);
}

.card-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e0f2fe, #dbeafe);
  color: var(--accent-deep);
  border: 1px solid rgba(2, 132, 199, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.92rem;
  flex-shrink: 0;
}

.card-info {
  min-width: 0;
}

.card-name {
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.role-tag {
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(2, 132, 199, 0.1);
  color: var(--accent);
  padding: 2px 7px;
  border-radius: 6px;
}

.card-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.badge {
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge.paid {
  background: var(--success-bg);
  color: var(--success);
}

.badge.unpaid {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge.inactive {
  background: rgba(100, 116, 139, 0.14);
  color: var(--text-muted);
}

.quick-pay-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

/* Paneler & formulär */
.panel {
  border-radius: var(--radius-lg);
  padding: 18px;
}

.panel-title {
  font-size: 1.02rem;
  font-weight: 800;
  margin-bottom: 14px;
}

.form-group {
  margin-bottom: 12px;
  flex: 1;
}

.form-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.hint {
  font-weight: 500;
  font-size: 0.72rem;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-main);
  font-size: 0.94rem;
  font-family: inherit;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.14);
}

.recipient-summary {
  background: rgba(2, 132, 199, 0.08);
  border: 1px solid rgba(2, 132, 199, 0.2);
  color: var(--accent-deep);
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.preview-box {
  background: #f8fafc;
  border: 1px dashed rgba(15, 23, 42, 0.2);
  border-radius: 12px;
  padding: 11px 13px;
  font-size: 0.82rem;
  color: #334155;
  white-space: pre-wrap;
  margin-bottom: 14px;
}

/* Medlemsnivåer i Admin */
.tiers-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.tier-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--card-stroke);
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 0.9rem;
}

.inline-add-form {
  display: flex;
  gap: 8px;
}

.export-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

/* Knappar */
.btn {
  padding: 11px 15px;
  border-radius: 13px;
  border: none;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff;
}

.btn-secondary {
  background: rgba(15, 23, 42, 0.07);
  color: var(--text-main);
}

.btn-success {
  background: #16a34a;
  color: #fff;
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.full-width {
  width: 100%;
}

/* Bottenmeny */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  margin: 0 auto;
  bottom: calc(14px + env(safe-area-inset-bottom));
  width: calc(100% - 28px);
  max-width: 540px;
  height: 66px;
  border-radius: 34px;
  display: grid;
  grid-template-columns: 1fr 1fr 70px 1fr 1fr;
  align-items: center;
  padding: 0 8px;
  z-index: 50;
  background: rgba(255, 255, 255, 0.86);
}

.nav-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  padding: 6px 0;
}

.nav-btn svg {
  width: 21px;
  height: 21px;
}

.nav-btn.active {
  color: var(--accent);
}

.nav-add-btn {
  width: 58px;
  height: 58px;
  margin: -24px auto 0;
  border-radius: 50%;
  border: 2px solid #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(2, 132, 199, 0.35);
}

.nav-add-btn svg {
  width: 26px;
  height: 26px;
}

/* Modaler */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.38);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  padding: 12px;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-sheet {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 28px;
  padding: 12px 20px calc(22px + env(safe-area-inset-bottom));
  background: var(--glass-strong);
}

@media (min-width: 640px) {
  .modal-backdrop {
    align-items: center;
  }
}

.modal-handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: rgba(15, 23, 42, 0.18);
  margin: 0 auto 12px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.3rem;
}

.member-no-tag {
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--accent);
}

.icon-close {
  background: rgba(15, 23, 42, 0.08);
  border: none;
  color: var(--text-main);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.25rem;
  cursor: pointer;
}

.detail-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.detail-row {
  background: rgba(15, 23, 42, 0.035);
  border: 1px solid var(--card-stroke);
  padding: 10px 13px;
  border-radius: 13px;
}

.detail-label {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-muted);
}

.detail-value {
  font-size: 0.92rem;
  margin-top: 2px;
}

.detail-value a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.payment-box {
  background: rgba(2, 132, 199, 0.06);
  border: 1px solid rgba(2, 132, 199, 0.18);
  border-radius: 15px;
  padding: 12px;
  margin-bottom: 14px;
}

.payment-box-title {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--accent-deep);
  margin-bottom: 8px;
}

.inline-payment-form {
  display: flex;
  gap: 8px;
}

.payment-history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 11px;
  border-radius: 10px;
  background: rgba(22, 163, 74, 0.08);
  font-size: 0.84rem;
  margin-bottom: 6px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.modal-actions .btn {
  flex: 1;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 28px 16px;
  font-size: 0.92rem;
}

.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.25);
  z-index: 200;
}

.toast.hidden {
  display: none;
}

/* CSV-import i Admin */
.panel-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.panel-desc {
  margin: 0 0 14px;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.file-drop-label {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1.5px dashed rgba(2, 132, 199, 0.4);
  background: rgba(2, 132, 199, 0.05);
  color: var(--accent-deep);
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s ease;
}

.file-drop-label:hover {
  background: rgba(2, 132, 199, 0.1);
}

.file-drop-label input[type="file"] {
  display: none;
}

.csv-preview-area {
  margin-top: 14px;
}

.csv-table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--card-stroke);
  background: rgba(255, 255, 255, 0.88);
}

.csv-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  text-align: left;
}

.csv-preview-table th,
.csv-preview-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--card-stroke);
  white-space: nowrap;
}

.csv-preview-table th {
  background: rgba(15, 23, 42, 0.04);
  font-weight: 800;
  color: var(--text-muted);
}

.hidden {
  display: none !important;
}

/* AI-skrivhjälp i Utskick */
.ai-assist-box {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.07), rgba(99, 102, 241, 0.08));
  border: 1px solid rgba(2, 132, 199, 0.22);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 14px;
}

.ai-assist-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--accent-deep);
  margin-bottom: 10px;
}

.ai-badge {
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.85);
  color: var(--accent);
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(2, 132, 199, 0.2);
}

.btn-ai {
  background: linear-gradient(135deg, #0284c7, #4f46e5);
  color: #fff;
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.22);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.btn-ai:disabled {
  opacity: 0.65;
  cursor: wait;
}

.dev-ai-box {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--card-stroke);
}

/* Inloggning, Onboarding & Abonnemang */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  border-radius: 28px;
  padding: 24px 22px;
  background: var(--glass-strong);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.auth-logo {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff;
  font-weight: 900;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 18px rgba(2, 132, 199, 0.28);
}

.auth-title {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.auth-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: rgba(15, 23, 42, 0.06);
  padding: 4px;
  border-radius: 14px;
  margin-bottom: 16px;
}

.auth-tab {
  border: none;
  background: transparent;
  padding: 9px 10px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--text-muted);
  cursor: pointer;
}

.auth-tab.active {
  background: #fff;
  color: var(--text-main);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.auth-error {
  color: var(--danger);
  background: var(--danger-bg);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  margin: 0 0 12px;
}

.demo-login-hint {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--card-stroke);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.trial-offer-box {
  background: rgba(2, 132, 199, 0.08);
  border: 1px solid rgba(2, 132, 199, 0.22);
  color: var(--accent-deep);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.8rem;
  line-height: 1.4;
  margin-bottom: 12px;
}

.trial-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 11px 15px;
  border-radius: 16px;
  margin-bottom: 14px;
  font-size: 0.82rem;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(224, 242, 254, 0.85));
}

input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-main);
  font-size: 0.94rem;
  font-family: inherit;
  outline: none;
}

input[type="password"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.14);
}