:root {
  --bg-dark: #0a0f1c;
  --bg-mid: #141e33;
  --bg-light: #203152;
  --glass-bg: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.16);
  --glass-highlight: rgba(255, 255, 255, 0.14);
  --text-main: #f5f7fb;
  --text-muted: rgba(235, 240, 255, 0.65);
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --alert-today: #f43f5e;
  --alert-soon: #f59e0b;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-main);
  background: linear-gradient(160deg, var(--bg-dark) 0%, var(--bg-mid) 52%, var(--bg-light) 100%);
  background-attachment: fixed;
  padding-bottom: calc(105px + env(safe-area-inset-bottom));
  overflow-x: hidden;
}

button { font-family: inherit; }

/* Diskreta ljuspunkter bakom glaset */
.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  z-index: -1;
  pointer-events: none;
}
.bg-glow-1 {
  width: 280px;
  height: 280px;
  background: rgba(56, 189, 248, 0.18);
  top: -60px;
  right: -60px;
}
.bg-glow-2 {
  width: 300px;
  height: 300px;
  background: rgba(139, 92, 246, 0.16);
  bottom: 80px;
  left: -90px;
}

/* Frostat glas */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.28);
}

/* Header */
.app-header {
  max-width: 600px;
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) 20px 14px;
}
.app-header h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.subtitle {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Innehåll */
.app-content {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 16px;
}
.view {
  display: none;
}
.view.active {
  display: block;
}

/* Sökfält */
.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 14px;
}
.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: 1rem;
  outline: none;
}
.search-box input::placeholder {
  color: var(--text-muted);
}

/* Kortlista */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.person-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}
.person-card:active {
  transform: scale(0.98);
  background: var(--glass-highlight);
}
.card-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.35), rgba(99, 102, 241, 0.35));
  border: 1px solid rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}
.card-info {
  min-width: 0;
}
.card-name {
  font-weight: 600;
  font-size: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Badge för nedräkning */
.badge {
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.badge.today {
  background: rgba(244, 63, 94, 0.25);
  border-color: rgba(244, 63, 94, 0.6);
  color: #fda4af;
}
.badge.soon {
  background: rgba(245, 158, 11, 0.22);
  border-color: rgba(245, 158, 11, 0.55);
  color: #fcd34d;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
}

/* Bottenmeny */
.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom));
  width: calc(100% - 28px);
  max-width: 520px;
  height: 66px;
  border-radius: 34px;
  display: grid;
  grid-template-columns: 1fr 1fr 72px 1fr 1fr;
  align-items: center;
  padding: 0 8px;
  z-index: 50;
}
.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;
  cursor: pointer;
  padding: 6px 0;
  transition: color 0.2s;
}
.nav-btn svg {
  width: 22px;
  height: 22px;
}
.nav-btn.active {
  color: var(--accent);
}

/* Stort + i mitten */
.nav-add-btn {
  width: 60px;
  height: 60px;
  margin: 0 auto;
  margin-top: -26px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: linear-gradient(135deg, var(--accent), #2563eb);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(14, 165, 233, 0.45);
  transition: transform 0.15s ease;
}
.nav-add-btn svg {
  width: 28px;
  height: 28px;
}
.nav-add-btn:active {
  transform: scale(0.92);
}

/* Modaler (iOS-sheet) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 16, 0.65);
  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: 540px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 28px;
  padding: 12px 20px calc(22px + env(safe-area-inset-bottom));
  background: rgba(20, 30, 52, 0.88);
  animation: slideUp 0.22s ease-out;
}
@media (min-width: 640px) {
  .modal-backdrop {
    align-items: center;
  }
}
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.28);
  margin: 0 auto 12px;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-header h2 {
  margin: 0;
  font-size: 1.3rem;
}
.icon-close {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text-main);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

/* Formulär */
.form-group {
  margin-bottom: 12px;
  flex: 1;
}
.form-row {
  display: flex;
  gap: 10px;
}
label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 5px;
}
input[type="text"],
input[type="date"],
input[type="tel"],
textarea {
  width: 100%;
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-main);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
}
input:focus, textarea:focus {
  border-color: var(--accent);
}
input[type="date"] {
  color-scheme: dark;
}

/* Knappar */
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.btn {
  flex: 1;
  padding: 12px 16px;
  border-radius: 14px;
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #2563eb);
  color: #fff;
}
.btn-secondary {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-main);
}
.btn-danger {
  background: rgba(244, 63, 94, 0.22);
  color: #fda4af;
  border: 1px solid rgba(244, 63, 94, 0.45);
}
.full-width {
  width: 100%;
  margin-top: 10px;
}

/* Detaljvy */
.detail-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.detail-row, .info-box {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 12px 14px;
  border-radius: 14px;
}
.detail-label {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-bottom: 3px;
}
.detail-value a {
  color: var(--accent);
  text-decoration: none;
}

/* Utskrift (dold på skärm, ren svartvit lista på papper/PDF) */
.print-only {
  display: none;
}
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
    padding: 0 !important;
  }
  .bg-glow, .app-header, .bottom-nav, .modal-backdrop, .view {
    display: none !important;
  }
  .print-only {
    display: block !important;
  }
  .print-only h1 {
    font-size: 18pt;
    margin-bottom: 12px;
  }
  .print-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10pt;
  }
  .print-table th, .print-table td {
    border-bottom: 1px solid #ccc;
    padding: 8px 6px;
    text-align: left;
  }
}

/* Uppdatera header så länken hamnar snyggt till höger */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.header-link {
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: var(--accent);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 8px 13px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  margin-top: 4px;
  transition: background 0.15s ease, transform 0.15s ease;
}
.header-link:active {
  transform: scale(0.95);
  background: rgba(56, 189, 248, 0.25);
}

/* Dropdown (select) i samma glasstil som input */
select {
  width: 100%;
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: rgba(20, 30, 52, 0.95);
  color: var(--text-main);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
}
select:focus {
  border-color: var(--accent);
}

.label-hint {
  font-size: 0.72rem;
  opacity: 0.75;
}

.hidden {
  display: none !important;
}