/* Filamentlager – mobil först, fungerar på dator, platta och telefon */
:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #667085;
  --line: #e1e5ea;
  --accent: #0f766e;
  --accent-text: #ffffff;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --danger: #b42318;
  --ok-bg: #dcfce7;
  --err-bg: #fee4e2;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141a;
    --card: #182029;
    --text: #e6eaef;
    --muted: #98a2b3;
    --line: #2a3441;
    --accent: #2dd4bf;
    --accent-text: #062a26;
    --warn: #fbbf24;
    --warn-bg: #3a2c0b;
    --danger: #f97066;
    --ok-bg: #12351f;
    --err-bg: #3b1513;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: .2rem 0; }
.muted { color: var(--muted); font-size: .9rem; }
.center { text-align: center; }
.inline { display: inline; }

/* --- Toppmeny ------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem;
  padding: .6rem 1rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--text); text-decoration: none; }
.logo {
  width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle, var(--card) 0 25%, var(--accent) 26% 100%);
}
.nav { display: flex; gap: .25rem; overflow-x: auto; margin-left: auto; scrollbar-width: none; }
.nav a, .linkbtn {
  padding: .45rem .7rem; border-radius: 8px; white-space: nowrap;
  color: var(--text); text-decoration: none; font: inherit; font-size: .95rem;
  background: none; border: 0; cursor: pointer;
}
.nav a.on { background: var(--accent); color: var(--accent-text); }
.nav a:hover:not(.on), .linkbtn:hover { background: var(--line); }
.pill { display: inline-block; min-width: 1.4em; padding: 0 .35em; border-radius: 99px; background: var(--warn); color: #fff; font-size: .75rem; text-align: center; }
@media (max-width: 640px) {
  .nav { width: 100%; margin: 0; }
}

/* --- Layout -------------------------------------------------------- */
.wrap { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.auth { max-width: 420px; margin: 2rem auto; }

/* --- Startsida ----------------------------------------------------- */
.hero { text-align: center; padding: 3rem 1rem 2rem; }
.hero h1 { font-size: 2rem; margin-top: 1rem; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 32rem; margin: 0 auto 1.5rem; }
.center-row { justify-content: center; }
.swatch.big { width: 88px; height: 88px; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .75rem; }
.features .card { margin: 0; }
.empty-state { text-align: center; padding: 2rem 1rem; }
.title-row { display: flex; align-items: center; gap: .75rem; margin-bottom: .75rem; }
.title-row.spread { justify-content: space-between; }
.title-row h1, .title-row h2 { margin: 0; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; }

/* --- Statistik ----------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin-bottom: 1rem; }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat {
  display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .8rem 1rem; color: var(--muted); text-decoration: none; font-size: .9rem;
}
.stat .num { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.stat.warn { background: var(--warn-bg); border-color: var(--warn); }
.stat.warn .num { color: var(--warn); }

/* --- Filter -------------------------------------------------------- */
.chips { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .5rem; margin-bottom: .5rem; }
.chip {
  padding: .35rem .75rem; border-radius: 99px; white-space: nowrap;
  border: 1px solid var(--line); background: var(--card); color: var(--text); text-decoration: none; font-size: .9rem;
}
.chip span { color: var(--muted); margin-left: .2rem; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip.on span { color: inherit; opacity: .8; }
/* --- Typ- och färgfilter ------------------------------------------- */
.small { font-size: .85rem; }
.facets { display: grid; gap: 1rem; }
@media (min-width: 900px) { .facets { grid-template-columns: 1fr 1fr; } .facets > p { grid-column: 1 / -1; margin: 0; } }
.facet-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; margin-bottom: .5rem; }
.facet-head h2 { margin: 0; font-size: 1rem; }
.wrap-chips { flex-wrap: wrap; overflow: visible; padding: 0; margin: 0; }
.chip { display: inline-flex; align-items: center; gap: .35rem; min-height: 36px; }
.chip:hover { border-color: var(--accent); }
.color-chip { padding-left: .35rem; }
.dot { --c: #999; display: inline-block; width: 18px; height: 18px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0,0,0,.25), 0 0 0 1px rgba(255,255,255,.15); }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.filters input[type=search] { flex: 1 1 220px; }

/* --- Filamentkort -------------------------------------------------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: .75rem; }
.spool {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "sw info qty" "act act act";
  gap: .5rem .75rem; align-items: start; margin: 0;
}
.spool .swatch { grid-area: sw; }
.spool .info { grid-area: info; min-width: 0; }
.spool .qty { grid-area: qty; }
.spool .actions { grid-area: act; display: flex; gap: 1rem; border-top: 1px solid var(--line); padding-top: .5rem; font-size: .9rem; }
.spool.low { border-color: var(--warn); }
.spool.out { opacity: .7; }

.swatch {
  --c: #999;
  display: inline-block; flex: none;
  width: 44px; height: 44px; border-radius: 50%;
  background: radial-gradient(circle, var(--card) 0 22%, var(--c) 23% 100%);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.25);
}
.swatch.sm { width: 28px; height: 28px; }

.qty { display: flex; align-items: center; gap: .35rem; }
.qty form { margin: 0; }
.count { min-width: 2ch; text-align: center; font-size: 1.3rem; font-weight: 700; }
.round {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
  font-size: 1.2rem; cursor: pointer;
}
.round:hover:not(:disabled) { border-color: var(--accent); }
.round:disabled { opacity: .35; cursor: default; }

.badge { display: inline-block; margin-top: .25rem; padding: .1rem .5rem; border-radius: 99px; font-size: .75rem; background: var(--line); color: var(--muted); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }

/* --- Listor -------------------------------------------------------- */
.list { list-style: none; margin: 0 0 1rem; padding: 0; }
.list li { display: flex; align-items: center; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.list li:last-child { border-bottom: 0; }
.list li.group { font-weight: 600; font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding-top: 1rem; }
.list form { margin: 0; }
.grow { flex: 1 1 180px; min-width: 0; display: flex; flex-direction: column; }
.buy { display: flex; gap: .35rem; align-items: center; }
.buy input { width: 6.5rem; }

.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; margin-bottom: 1rem; }
.color-item { display: flex; align-items: center; gap: .5rem; }
.color-item form { margin-left: auto; }

details summary { cursor: pointer; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details[open] summary { margin-bottom: 1rem; }

/* --- Formulär ------------------------------------------------------ */
.stack { display: flex; flex-direction: column; gap: .8rem; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: .8rem; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } .form-grid .full { grid-column: 1 / -1; } }
label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; font-weight: 600; }
label small { font-weight: 400; }
label.check { flex-direction: row; align-items: center; font-weight: 400; }
.pair { display: flex; gap: .5rem; }
input, select, textarea {
  width: 100%; font: inherit; font-weight: 400;
  padding: .6rem .7rem; min-height: 44px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text);
}
input[type=checkbox] { width: auto; min-height: 0; }
input[type=color] { padding: .2rem; height: 44px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: .55rem 1rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: none; }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.small { min-height: 36px; padding: .35rem .7rem; font-size: .9rem; }
.danger-zone { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }

.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; background: var(--ok-bg); }
.flash.err { background: var(--err-bg); color: var(--danger); }

/* --- Tabeller ------------------------------------------------------ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .5rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
