*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --c-primary:       #1B8B5C;
  --c-primary-dark:  #146B47;
  --c-primary-light: #E8F5EE;
  --c-accent:        #FF6B35;
  --c-bg:            #F4F8F6;
  --c-surface:       #FFFFFF;
  --c-text:          #111827;
  --c-text-2:        #6B7280;
  --c-border:        #D1D5DB;
  --c-danger:        #EF4444;
  --c-danger-light:  #FEE2E2;
  --radius:          12px;
  --radius-sm:       8px;
  --shadow:          0 1px 3px rgba(0,0,0,.1);
  --shadow-md:       0 4px 12px rgba(0,0,0,.1);
  --nav-h:           64px;
  --header-h:        56px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --c-bg:       #0F1C17;
    --c-surface:  #1A2E24;
    --c-text:     #F0F4F2;
    --c-text-2:   #9CA3AF;
    --c-border:   #2D4A3A;
    --c-primary-light: #1A3828;
  }
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-text);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 600px;
  margin: 0 auto;
  overflow: hidden;
}

/* ── Header ─────────────────────────────── */
#app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 12px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  position: relative;
  z-index: 10;
  flex-shrink: 0;
}

#app-title {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
  pointer-events: none;
}

.header-btn {
  background: none;
  border: none;
  color: var(--c-primary);
  font-size: 1rem;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  touch-action: manipulation;
}
.header-btn:active { opacity: .6; }
.header-btn[hidden] { display: none; }
.header-btn--icon { padding: 8px; display: flex; align-items: center; justify-content: center; }
.header-btn--icon svg { width: 20px; height: 20px; }
#btn-back { padding: 4px 6px; }
#btn-back svg { width: 28px; height: 28px; }

.header-left {
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-right {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
}

.btn-admin {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.75;
  touch-action: manipulation;
  transition: opacity .15s;
}
.btn-admin:active { opacity: .5; }
.btn-admin[hidden] { display: none; }

.btn-auth {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--c-text-2);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0;
  flex-shrink: 0;
  touch-action: manipulation;
  transition: opacity .15s;
}
.btn-auth:active { opacity: .7; }
.btn-auth[hidden] { display: none; }
.btn-auth.auth-avatar--signed-in { background: transparent; }

.auth-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}
.header-btn.danger { color: var(--c-danger); }

/* ── Main content ───────────────────────── */
#app-main {
  flex: 1;
  overflow: hidden;
  position: relative;
  min-height: 0;
}

.view {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: none;
  padding-bottom: 16px;
}
.view.active { display: block; }

/* ── Bottom nav ─────────────────────────── */
#app-nav {
  display: flex;
  height: var(--nav-h);
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  flex-shrink: 0;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--c-text-2);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
  transition: color .15s;
}
.nav-btn.active { color: var(--c-primary); }
.nav-btn:active { opacity: .6; }
.nav-icon { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; }
.nav-icon svg { width: 24px; height: 24px; display: block; }

/* ── Shared primitives ──────────────────── */
.card {
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
  transition: opacity .15s;
}
.btn:active { opacity: .7; }
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-ghost   { background: transparent; color: var(--c-primary); }
.btn-danger  { background: var(--c-danger-light); color: var(--c-danger); }
.btn-icon    { padding: 8px; border-radius: 50%; background: none; border: none; cursor: pointer; font-size: 1.2rem; color: var(--c-text-2); touch-action: manipulation; }
.btn-icon:active { opacity: .6; }

.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + 20px);
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--c-primary);
  color: #fff;
  border: none;
  box-shadow: 0 4px 16px rgba(27, 139, 92, .45);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  z-index: 5;
  transition: transform .15s, box-shadow .15s, opacity .2s;
}
.fab:active {
  transform: scale(.92);
  box-shadow: 0 2px 8px rgba(27, 139, 92, .35);
}
.fab[hidden] { display: none; }
.fab svg { width: 28px; height: 28px; display: block; }
.fab.fab--open { transform: rotate(45deg) scale(1.05); }

/* FAB speed-dial menu */
#fab-menu-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  z-index: 10;
  display: flex; align-items: flex-end; justify-content: center;
  animation: sht-fade .15s;
}
#fab-menu {
  background: var(--c-surface); border-radius: 20px 20px 0 0;
  width: 100%; max-width: 600px;
  padding: 10px 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
  animation: sht-up .2s ease;
}
.fab-menu-handle {
  width: 40px; height: 4px; background: var(--c-border); border-radius: 2px;
  margin: 0 auto 14px;
}
.fab-menu-section {
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--c-text-2); margin-bottom: 10px;
}
.fab-menu-btn {
  width: 100%; padding: 14px 12px; background: var(--c-bg);
  border: none; border-radius: var(--radius-sm);
  display: flex; align-items: center; gap: 14px;
  cursor: pointer; touch-action: manipulation; margin-bottom: 8px;
  text-align: left; font-family: var(--font);
}
.fab-menu-btn:active { background: var(--c-primary-light); }
.fab-menu-icon {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  background: var(--c-primary-light); color: var(--c-primary);
  display: flex; align-items: center; justify-content: center;
}
.fab-menu-icon svg { width: 22px; height: 22px; }
.fab-menu-label { font-weight: 600; font-size: 1.0rem; color: var(--c-text); display: block; }
.fab-menu-sub   { font-size: 0.8rem; color: var(--c-text-2); display: block; margin-top: 2px; }

input, select, textarea {
  font-family: var(--font);
  font-size: 1rem;
  color: var(--c-text);
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  outline: none;
  width: 100%;
  transition: border-color .15s;
}
input:focus, select:focus { border-color: var(--c-primary); }

.section-title {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-text-2);
  padding: 16px 16px 6px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 64px 32px;
  color: var(--c-text-2);
  text-align: center;
}
.empty-state .emoji { font-size: 3rem; }
.empty-state p { font-size: 0.95rem; }

.search-bar {
  padding: 12px 16px 8px;
}

/* ── Install banner ─────────────────────── */
.install-banner {
  position: fixed;
  bottom: calc(var(--nav-h) + 12px);
  left: 12px; right: 12px;
  max-width: 576px;
  margin: 0 auto;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  z-index: 50;
  animation: slide-up .25s ease;
}
.install-banner[hidden] { display: none; }
@keyframes slide-up {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.install-banner-body { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.install-banner-icon { font-size: 1.6rem; flex-shrink: 0; }
.install-banner-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.install-banner-text strong { font-size: 0.9rem; }
.install-banner-text span { font-size: 0.78rem; color: var(--c-text-2); }
.install-banner-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.install-btn {
  background: var(--c-primary); color: #fff; border: none;
  border-radius: var(--radius-sm); padding: 7px 14px;
  font-size: 0.85rem; font-weight: 500; cursor: pointer;
  touch-action: manipulation;
}
.install-btn:active { opacity: .7; }
.install-dismiss {
  background: none; border: none; color: var(--c-text-2);
  font-size: 1rem; cursor: pointer; padding: 6px;
  border-radius: 50%; touch-action: manipulation;
}
.install-dismiss:active { color: var(--c-text); }

/* ── Auth screen ────────────────────────── */
#auth-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--c-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
}

.auth-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.auth-logo { font-size: 4rem; line-height: 1; margin-bottom: 4px; }

.auth-app-name {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--c-primary);
}

.auth-tagline {
  font-size: 0.95rem;
  color: var(--c-text-2);
  margin-top: -4px;
}

.auth-google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 13px 20px;
  margin-top: 12px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  color: var(--c-text);
  cursor: pointer;
  box-shadow: var(--shadow);
  touch-action: manipulation;
  transition: opacity .15s;
}
.auth-google-btn:active { opacity: .7; }
.auth-google-btn:disabled { opacity: .5; cursor: default; }

.auth-local-btn {
  background: none;
  border: none;
  color: var(--c-primary);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  touch-action: manipulation;
}
.auth-local-btn:active { opacity: .6; }

.auth-local-note {
  font-size: 0.78rem;
  color: var(--c-text-2);
  line-height: 1.5;
  max-width: 280px;
}

.auth-later-note {
  font-size: 0.78rem;
  color: var(--c-text-2);
  line-height: 1.5;
  max-width: 280px;
  font-style: italic;
}

.auth-consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 20px;
  padding: 12px 14px;
  background: var(--c-bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--c-border);
  max-width: 300px;
  text-align: left;
}

.auth-consent-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--c-text-2);
}

.auth-consent p {
  font-size: 0.75rem;
  color: var(--c-text-2);
  line-height: 1.5;
  margin: 0;
}

.auth-privacy-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--c-primary);
  font-size: inherit;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
  touch-action: manipulation;
}

/* ── Uppdaterings-overlay ────────────────── */
#update-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, .45);
  opacity: 1;
  transition: opacity .6s ease;
}
#update-overlay.uo-hide { opacity: 0; }
.uo-box {
  background: var(--c-surface);
  color: var(--c-text);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 20px 22px;
  max-width: 280px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.uo-spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid var(--c-primary-light);
  border-top-color: var(--c-primary);
  animation: uo-spin .8s linear infinite;
}
.uo-title { font-size: 1rem; font-weight: 600; }
.uo-text { font-size: 0.85rem; color: var(--c-text-2); line-height: 1.45; }
@keyframes uo-spin { to { transform: rotate(360deg); } }

