/* ═══════════════════════════════════════════════════════════
   knitty — varm ull-palett på leafys designbas
   rost · senap · himmel · plysch
   ═══════════════════════════════════════════════════════════ */

:root {
  --cream:      #FAF7F0;
  --cream-deep: #F1EBDF;
  --ink:        #3B342B;
  --ink-soft:   #7C7466;
  --ink-faint:  #ABA392;

  --rust:       #C0764F;   /* rost — primär, färdiga */
  --rust-deep:  #A2603C;
  --rust-soft:  #ECD5C5;
  --rust-tint:  #F8EBE1;

  --butter:     #D9B95C;   /* senap — stickade */
  --butter-deep:#B39A3E;
  --butter-tint:#F7F0D9;

  --sky:        #8FB4C6;   /* himmel — tovade */
  --sky-deep:   #6E93A8;
  --sky-tint:   #E7F0F4;

  --plum:       #A98BB3;   /* extra diagramfärg */
  --plum-tint:  #F0E8F2;

  --card:       #FFFFFF;
  --line:       #E8E0CF;
  --danger:     #C47A70;

  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 12px;

  --shadow-soft: 0 1px 2px rgba(59,52,43,.04), 0 8px 24px rgba(59,52,43,.06);
  --shadow-lift: 0 2px 4px rgba(59,52,43,.05), 0 14px 34px rgba(59,52,43,.10);

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Karla", -apple-system, sans-serif;

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

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { scrollbar-gutter: stable; height: 100%; }

body {
  min-height: 100%;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

/* subtle atmosphere: two soft wool washes */
body::before {
  content: "";
  position: fixed; inset: 0;
  background:
    radial-gradient(60% 40% at 85% -5%, var(--rust-tint) 0%, transparent 70%),
    radial-gradient(70% 45% at 5% 100%, var(--butter-tint) 0%, transparent 65%);
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 20px) 20px calc(var(--safe-bottom) + 108px);
}

.hidden { display: none !important; }
.sheet.hidden, .sheet-backdrop.hidden { display: block !important; }

/* ── type ─────────────────────────────────────────────────── */
h1, h2, h3 { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.01em; }
h2 { font-size: 28px; }
.eyebrow {
  font-size: 12px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--rust-deep);
  margin-bottom: 2px;
}

/* ── auth ─────────────────────────────────────────────────── */
.auth-card {
  margin-top: 8vh;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 36px 26px 30px;
  text-align: center;
}
.brand { display: flex; align-items: center; justify-content: center; gap: 12px; }
.brand-mark { width: 44px; height: 44px; color: var(--rust); }
.brand h1 { font-size: 40px; font-weight: 600; }
.tagline { color: var(--ink-soft); margin: 14px 0 28px; font-size: 15px; }

#auth-form { text-align: left; }
.field { display: block; margin-bottom: 16px; }
.field > span {
  display: block; font-size: 12px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-soft); margin-bottom: 7px;
}
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field input[type="date"],
.field textarea,
.field select {
  width: 100%;
  font: inherit;
  padding: 13px 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--cream);
  color: var(--ink);
  outline: none;
  transition: border-color .15s, background .15s;
  -webkit-appearance: none;
  appearance: none;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--rust); background: #fff; }
.field input::placeholder { color: var(--ink-faint); }
.field-opt { font-style: normal; font-weight: 500; color: var(--ink-faint); font-size: 12px; text-transform: none; letter-spacing: 0; }

.form-error { color: var(--danger); font-size: 13.5px; min-height: 18px; margin: -6px 0 8px; }

/* ── buttons ──────────────────────────────────────────────── */
.btn {
  font: inherit; font-weight: 700;
  border: none; border-radius: 999px;
  padding: 14px 22px; cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .15s;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  width: 100%;
  background: var(--rust); color: #fff;
  box-shadow: 0 6px 16px rgba(192,118,79,.35);
}
.btn-primary:disabled { opacity: .6; }
.btn-ghost { background: var(--cream-deep); color: var(--ink-soft); }

.icon-btn {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  background: var(--card); border: 1.5px solid var(--line);
  border-radius: 50%; cursor: pointer; color: var(--ink);
  box-shadow: var(--shadow-soft);
  transition: transform .12s;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 20px; height: 20px; }

/* ── topbar ───────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 22px;
}
.topbar-actions { display: flex; gap: 10px; }

/* ── cards ────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 20px 20px 18px;
}
.card + .card { margin-top: 12px; }
.card-title {
  font-size: 12px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-faint);
  margin-bottom: 14px;
}

/* ── hero (totalmätare) ───────────────────────────────────── */
.hero-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lift);
  padding: 24px 22px 20px;
  margin-bottom: 12px;
}
.hero-top { display: flex; align-items: baseline; gap: 8px; }
.hero-num {
  font-family: var(--font-display);
  font-size: 64px; font-weight: 600; line-height: 1;
  color: var(--rust-deep);
}
.hero-of { color: var(--ink-soft); font-size: 15px; font-weight: 600; }

.meter {
  height: 14px; border-radius: 999px;
  background: var(--cream-deep);
  overflow: hidden; margin: 16px 0 14px;
}
.meter-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--butter), var(--rust));
  transition: width .5s ease;
}

.hero-facts { display: flex; gap: 8px; }
.fact {
  flex: 1; text-align: center;
  background: var(--cream);
  border-radius: var(--radius-sm);
  padding: 10px 6px 8px;
}
.fact strong { display: block; font-size: 17px; line-height: 1.2; }
.fact small { color: var(--ink-faint); font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }

.hero-verdict {
  margin-top: 14px; font-size: 14px; line-height: 1.45;
  color: var(--ink-soft);
  padding: 10px 14px; border-radius: var(--radius-sm);
}
.hero-verdict.ok   { background: var(--butter-tint); color: #6B5A22; }
.hero-verdict.warn { background: var(--sky-tint);   color: var(--sky-deep); }
.hero-verdict.bad  { background: var(--rust-tint);  color: var(--rust-deep); }
.hero-verdict.done { background: var(--butter-tint); color: #6B5A22; }

/* ── funnel (pipelinen) ───────────────────────────────────── */
.funnel-row { display: flex; align-items: center; gap: 14px; }
.funnel-row + .funnel-row { margin-top: 14px; }
.funnel-icon {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
}
.funnel-icon svg { width: 24px; height: 24px; }
.funnel-num {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 600; line-height: 1;
}
.funnel-icon.st-knitted  { background: var(--butter-tint); color: var(--butter-deep); }
.funnel-icon.st-felted   { background: var(--sky-tint);    color: var(--sky-deep); }
.funnel-icon.st-finished { background: var(--rust-tint);   color: var(--rust-deep); }

.funnel-body { flex: 1; min-width: 0; }
.funnel-label { display: flex; justify-content: space-between; align-items: baseline; }
.funnel-label strong { font-size: 14.5px; }
.funnel-label small { color: var(--ink-faint); font-size: 12px; font-weight: 600; }
.funnel-bar {
  height: 10px; border-radius: 999px;
  background: var(--cream-deep); margin-top: 6px; overflow: hidden;
}
.funnel-bar-fill { height: 100%; border-radius: 999px; transition: width .5s ease; }
.funnel-row.st-knitted  .funnel-bar-fill { background: var(--butter); }
.funnel-row.st-felted   .funnel-bar-fill { background: var(--sky); }
.funnel-row.st-finished .funnel-bar-fill { background: var(--rust); }

/* ── feed ─────────────────────────────────────────────────── */
.feed-row {
  display: flex; align-items: center; gap: 12px;
  font-size: 14px;
}
.feed-row + .feed-row { margin-top: 10px; }
.feed-what { flex: 1; min-width: 0; }
.feed-what small { color: var(--ink-faint); font-size: 12.5px; }
.feed-when { color: var(--ink-faint); font-size: 12.5px; flex: none; }

/* ── person-sektioner ─────────────────────────────────────── */
.section-title {
  font-size: 12px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-faint);
  margin: 26px 0 10px;
}

.person-card { padding: 18px 18px 16px; }
.person-card + .person-card { margin-top: 10px; }
.person-card.me { border: 1.5px solid var(--rust-soft); }

.person-head { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--c, var(--rust));
  color: #fff;
  font-weight: 700; font-size: 18px;
}
.person-meta { flex: 1; min-width: 0; }
.person-meta strong { display: block; font-size: 16px; line-height: 1.25; }
.person-sub { color: var(--ink-faint); font-size: 12.5px; display: block; margin-top: 1px; }
.you-badge {
  flex: none;
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--rust-deep); background: var(--rust-tint);
  padding: 3px 10px; border-radius: 999px;
}

.person-meter {
  height: 7px; border-radius: 999px;
  background: var(--cream-deep); overflow: hidden;
  margin: 12px 0 4px;
}
.person-meter .meter-fill { background: var(--c, var(--rust)); height: 100%; }
.person-meter-note { color: var(--ink-faint); font-size: 11.5px; }

.person-actions { display: flex; gap: 8px; margin-top: 14px; }

.count-btn {
  font: inherit; font-weight: 700;
  border: none; border-radius: 999px;
  padding: 12px 18px; cursor: pointer;
  transition: transform .12s, background .15s, opacity .15s;
}
.count-btn:active { transform: scale(.94); }
.count-btn.plus {
  flex: 1;
  background: var(--rust); color: #fff;
  box-shadow: 0 5px 14px rgba(192,118,79,.3);
  white-space: nowrap;
}
.count-btn.plus.st-knitted  { background: var(--butter-deep); box-shadow: 0 5px 14px rgba(179,154,62,.3); }
.count-btn.plus.st-felted   { background: var(--sky-deep);    box-shadow: 0 5px 14px rgba(110,147,168,.3); }
.count-btn.plus.st-finished { background: var(--rust);        box-shadow: 0 5px 14px rgba(192,118,79,.3); }
.count-btn.minus {
  width: 46px; flex: none; padding: 12px 0;
  background: var(--cream-deep); color: var(--ink-soft);
  font-size: 19px; line-height: 1;
}
.count-btn.minus:disabled { opacity: .35; }
.count-btn.small { padding: 9px 14px; font-size: 13.5px; }
.count-btn.minus.small { width: 40px; padding: 9px 0; font-size: 17px; }

.stage-rows { margin-top: 12px; border-top: 1.5px dashed var(--line); padding-top: 12px; }
.stage-row { display: flex; align-items: center; gap: 10px; }
.stage-row + .stage-row { margin-top: 10px; }
.stage-label {
  flex: 1; font-size: 13.5px; font-weight: 600; color: var(--ink-soft);
}
.stage-label strong { color: var(--ink); font-size: 15px; margin-left: 6px; }

/* ── statistiksidan ───────────────────────────────────────── */
.chart-wrap { margin: 4px 0 2px; }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.stat-note { color: var(--ink-soft); font-size: 13px; margin-top: 10px; line-height: 1.45; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

.hbar-row { display: flex; align-items: center; gap: 10px; }
.hbar-row + .hbar-row { margin-top: 10px; }
.hbar-label { width: 64px; flex: none; font-size: 13.5px; font-weight: 700; }
.hbar-track { flex: 1; height: 12px; border-radius: 999px; background: var(--cream-deep); overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 999px; background: var(--c, var(--rust)); transition: width .5s ease; }
.hbar-val { width: 52px; flex: none; text-align: right; font-size: 12.5px; font-weight: 700; color: var(--ink-soft); }

.trend-pill {
  display: inline-block;
  font-size: 12px; font-weight: 700;
  padding: 3px 10px; border-radius: 999px;
}
.trend-pill.up   { background: var(--butter-tint); color: #6B5A22; }
.trend-pill.down { background: var(--rust-tint);  color: var(--rust-deep); }
.trend-pill.flat { background: var(--cream-deep); color: var(--ink-soft); }

.kv-list { display: flex; flex-direction: column; gap: 0; }
.kv-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 10px 0;
  border-bottom: 1.5px solid var(--cream-deep);
}
.kv-row:last-child { border-bottom: none; }
.kv-key { font-size: 14px; color: var(--ink-soft); }
.kv-val { font-size: 14.5px; font-weight: 700; text-align: right; }
.kv-val small { display: block; font-weight: 500; color: var(--ink-faint); font-size: 11.5px; }

/* ── stepper (antal i sheet) ──────────────────────────────── */
.stepper { display: flex; align-items: center; gap: 12px; }
.stepper button {
  width: 46px; height: 46px; flex: none;
  border: 1.5px solid var(--line); border-radius: 50%;
  background: var(--card); color: var(--ink);
  font: inherit; font-size: 20px; font-weight: 700;
  cursor: pointer; transition: transform .12s, border-color .15s;
}
.stepper button:active { transform: scale(.9); border-color: var(--rust); }
.stepper strong { flex: 1; text-align: center; font-size: 26px; font-family: var(--font-display); }

/* ── chip-knapp (⋯ etc) ───────────────────────────────────── */
.chip-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  background: var(--cream-deep); color: var(--ink-soft);
  border: none; border-radius: 999px;
  padding: 9px 13px; font: inherit; font-size: 13px; font-weight: 700;
  cursor: pointer; transition: transform .12s;
}
.chip-btn:active { transform: scale(.95); }
.chip-btn.wide { width: 46px; padding: 9px 0; font-size: 16px; }

/* ── sheets ───────────────────────────────────────────────── */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(59,52,43,.35);
  opacity: 1; transition: opacity .2s;
}
.sheet-backdrop.hidden { opacity: 0; pointer-events: none; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61;
  max-width: 480px; margin: 0 auto;
  background: var(--card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 22px 22px calc(var(--safe-bottom) + 22px);
  box-shadow: var(--shadow-lift);
  transform: translateY(0); transition: transform .25s ease;
}
.sheet.hidden { transform: translateY(105%); }
.sheet h3 { font-size: 22px; margin-bottom: 18px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 20px; }
.sheet-actions .btn { flex: 1; }

/* ── tabbar ───────────────────────────────────────────────── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; justify-content: center; gap: 4px;
  padding: 8px 12px calc(var(--safe-bottom) + 8px);
  background: rgba(250,247,240,.92);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1.5px solid var(--line);
}
.tab {
  flex: 1; max-width: 130px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font: inherit; font-size: 11px; font-weight: 700;
  color: var(--ink-faint);
  background: none; border: none;
  padding: 7px 4px; border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color .15s, background .15s;
}
.tab svg { width: 23px; height: 23px; }
.tab.active { color: var(--rust-deep); background: var(--rust-tint); }

/* ── toast ────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 88px);
  transform: translateX(-50%);
  z-index: 70;
  display: flex; align-items: center; gap: 14px;
  background: var(--ink); color: #FAF7F0;
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-lift);
  max-width: min(92vw, 420px);
  animation: toast-in .25s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }
.toast-action {
  background: none; border: none;
  font: inherit; font-weight: 700;
  color: var(--butter);
  cursor: pointer; flex: none;
}

/* ── switch (påminnelser) ────────────────────────────────── */
.switch {
  position: relative; width: 52px; height: 30px; flex: none;
  border: none; border-radius: 999px;
  background: var(--cream-deep);
  cursor: pointer; padding: 0;
  transition: background .18s;
}
.switch-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(59,52,43,.25);
  transition: transform .18s;
}
.switch.on { background: var(--rust); }
.switch.on .switch-thumb { transform: translateX(22px); }
.notify-hint {
  margin-top: 10px; font-size: 13px; line-height: 1.45;
  color: var(--ink-soft);
}

/* ── pop-menu (⋯) ─────────────────────────────────────────── */
.pop-menu {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 76px);
  transform: translateX(-50%);
  z-index: 55;
  background: var(--card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lift);
  padding: 6px;
  min-width: 200px;
  animation: toast-in .18s ease;
}
.pop-menu button {
  display: block; width: 100%;
  font: inherit; font-size: 14.5px; font-weight: 600;
  color: var(--ink);
  background: none; border: none;
  padding: 12px 16px; border-radius: var(--radius-sm);
  cursor: pointer; text-align: left;
}
.pop-menu button:active { background: var(--cream); }

/* ── empty / misc ─────────────────────────────────────────── */
.empty { text-align: center; padding: 60px 20px; color: var(--ink-soft); }
.empty-spark { width: 46px; height: 46px; margin: 0 auto 14px; color: var(--rust); }
.empty-spark svg { width: 100%; height: 100%; }

.settings-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 0;
  border-bottom: 1.5px solid var(--cream-deep);
  font-weight: 600;
}
.settings-row:last-child { border-bottom: none; }
.settings-row small { display: block; font-weight: 500; color: var(--ink-faint); font-size: 12.5px; }

.logout-btn {
  width: 100%; margin-top: 12px;
  font: inherit; font-weight: 700;
  background: none; border: none;
  color: var(--danger);
  padding: 14px; border-radius: 999px;
  cursor: pointer;
}
.logout-btn:active { background: var(--rust-tint); }

.offline-pill {
  margin: 22px auto 0; width: fit-content;
  font-size: 12.5px; font-weight: 700;
  color: var(--ink-soft);
  background: var(--butter-tint);
  border: 1.5px dashed var(--butter);
  padding: 8px 16px; border-radius: 999px;
}
