@font-face { font-family: Inter; font-weight: 400; font-display: swap; src: url(fonts/inter-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: Inter; font-weight: 500; font-display: swap; src: url(fonts/inter-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: Inter; font-weight: 600; font-display: swap; src: url(fonts/inter-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Space Grotesk'; font-weight: 500; font-display: swap; src: url(fonts/space-grotesk-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Space Grotesk'; font-weight: 600; font-display: swap; src: url(fonts/space-grotesk-latin-600-normal.woff2) format('woff2'); }

:root {
  --bg: #0F1117; --surface: #171A22; --surface2: #1F2330; --line: #2A2F3D; --line2: #3A4050;
  --text: #ECEEF3; --soft: #C9CED8; --muted: #9AA1B2; --accent: #8EA2FF; --on-accent: #0F1117;
  --danger: #FF8A8A; --ok: #5FD08A;
  --icon: 76px; --radius: 22px; --cols: 6;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { font: 14px/1.5 Inter, 'Segoe UI', system-ui, sans-serif; -webkit-font-smoothing: antialiased; user-select: none; overflow: hidden; }
#root { height: 100%; overflow-y: auto; transition: background-color .25s; background: var(--bg); }
input, textarea, select, button { font: inherit; color: inherit; }
input, textarea { user-select: text; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
svg { width: 20px; height: 20px; flex: none; }
.search svg { width: 18px; height: 18px; }
.version { position: fixed; left: 16px; bottom: 12px; z-index: 5; font-size: 11px; color: var(--muted); opacity: .7; pointer-events: none; letter-spacing: .2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.page { min-height: 100%; padding: 40px 48px 36px; display: flex; flex-direction: column; gap: 36px; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 20px; }
.head.center { align-items: center; }
.titlewrap { display: flex; align-items: center; gap: 16px; }
.date { font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.title { font-family: 'Space Grotesk', Inter, sans-serif; font-size: 34px; font-weight: 600; letter-spacing: -.5px; line-height: 1.15; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.soft { color: var(--soft); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }

.search { display: flex; align-items: center; gap: 10px; width: 280px; max-width: 100%; height: 44px; padding: 0 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; color: var(--muted); }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--text); }
.search input::placeholder { color: var(--muted); }
.pill { height: 44px; padding: 0 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--soft); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.dot.off { background: var(--danger); }
.badge { height: 28px; padding: 0 12px; border-radius: 14px; background: #232A4A; color: #AEBBFF; font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; }
.back { width: 44px; height: 44px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); color: var(--soft); display: flex; align-items: center; justify-content: center; padding: 0; }
.back:hover { border-color: var(--line2); }

/* Ikoner */
.t-blue { --tbg: #232A4A; --tfg: #AEBBFF; }
.t-green { --tbg: #1C3530; --tfg: #7FD8B6; }
.t-orange { --tbg: #3A2A22; --tfg: #F2B38A; }
.t-purple { --tbg: #30243D; --tfg: #D1A6F0; }
.t-gray { --tbg: #232733; --tfg: #C9CED8; }
.grid { width: 100%; max-width: 980px; margin: 0 auto; display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 36px 16px; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 6px 0; background: none; border: 0; color: var(--soft); font-size: 13px; border-radius: 16px; min-width: 0; }
.tile .label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ic { position: relative; flex: none; width: var(--icon); height: var(--icon); border-radius: var(--radius); background: var(--tbg); color: var(--tfg); border: 1px solid #FFFFFF12; display: flex; align-items: center; justify-content: center; transition: transform .15s ease, border-color .15s; }
.ic svg { width: 42%; height: 42%; }
.ic img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.tile:hover .ic { transform: translateY(-2px); border-color: #FFFFFF26; }
.tile:active .ic { transform: scale(.96); }
.ic.dashed { background: none; border: 1.5px dashed var(--line2); color: var(--muted); }
.count { position: absolute; top: -6px; right: -6px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center; border: 2px solid var(--bg); }
.ring { position: absolute; inset: auto 8px 8px 8px; height: 5px; border-radius: 3px; background: #00000066; overflow: hidden; }
.ring > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.dots { display: flex; justify-content: center; gap: 8px; }
.dots span, .dots button { width: 6px; height: 6px; border-radius: 3px; background: var(--line2); border: 0; padding: 0; }
.dots .on { width: 22px; background: var(--text); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* Kort och knappar */
.card { background: var(--surface); border-radius: 24px; padding: 20px; }
.btn { height: 42px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface2); color: var(--text); font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; }
.btn:hover { border-color: var(--line2); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { background: none; color: var(--danger); }
.btn.ghost { background: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn svg { width: 18px; height: 18px; }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }

/* Formulär */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea { height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); padding: 0 12px; outline: none; }
.field textarea { height: auto; padding: 10px 12px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.radio { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text); }
.radio input { accent-color: var(--accent); width: 16px; height: 16px; }
.pick { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 12px 14px; border: 1.5px dashed var(--line2); border-radius: 14px; background: none; color: var(--muted); text-align: left; width: 100%; }
.pick:hover { border-color: var(--accent); }
.pick b { color: var(--text); font-weight: 500; word-break: break-all; }
.error { color: var(--danger); font-size: 13px; min-height: 0; }

/* Bibliotek */
.groups { width: 100%; max-width: 1040px; margin: 0 auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 24px; }
.group { background: var(--surface); border-radius: 28px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.group .mini { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; justify-items: center; --icon: 64px; }
.group.open .mini { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.group .tile { font-size: 12px; }
.more { --tbg: var(--surface2); --tfg: var(--soft); font-size: 15px; font-weight: 600; }
.ghead { display: flex; align-items: baseline; justify-content: space-between; padding: 0 4px; }
.ghead h2 { font-size: 15px; font-weight: 600; }

/* Butik */
.split { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.split > .main { flex: 999 1 540px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.split > .side { flex: 1 1 360px; max-width: 440px; min-width: 0; }
.section-title { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: .3px; }
.appcard { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; --icon: 68px; }
.appcard .info { flex: 1 1 240px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.appcard h3 { font-size: 17px; font-weight: 600; }
.appcard .actions { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; min-width: 140px; }
.appcard .actions .bar { width: 140px; }

/* Anpassa */
.opt { display: flex; flex-direction: column; gap: 10px; }
.opt h2 { font-size: 13px; font-weight: 600; color: var(--muted); }
.swatches { display: flex; gap: 12px; flex-wrap: wrap; }
.swatch { width: 44px; height: 44px; border-radius: 50%; border: 3px solid transparent; padding: 0; }
.swatch.on { border-color: var(--text); }
.bgs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.bgopt { display: flex; flex-direction: column; align-items: center; gap: 6px; background: none; border: 0; color: var(--soft); font-size: 12px; padding: 0; }
.bgopt span { width: 100%; height: 52px; border-radius: 12px; border: 2px solid var(--line); }
.bgopt.on span { border-color: var(--accent); }
.seg { display: flex; gap: 4px; padding: 4px; background: var(--surface); border-radius: 14px; }
.seg button { flex: 1; height: 40px; border-radius: 10px; border: 0; background: none; color: var(--muted); font-weight: 500; }
.seg button.on { background: var(--line); color: var(--text); }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 0 16px; background: var(--surface); border-radius: 14px; }
.toggle input { width: 20px; height: 20px; accent-color: var(--accent); }
.preview { border-radius: 24px; border: 1px solid var(--line); padding: 32px; min-height: 440px; display: flex; flex-direction: column; gap: 28px; background: var(--bg); }
.preview .grid { gap: 24px 8px; }
.preview .title { font-size: 24px; }

/* Listor */
.list { display: flex; flex-direction: column; }
.list .item { display: flex; align-items: center; gap: 14px; padding: 12px 6px; border-bottom: 1px solid var(--line); min-height: 60px; --icon: 40px; --radius: 12px; }
.list .item:last-child { border-bottom: 0; }
.list .item .ic svg { width: 50%; height: 50%; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--text); text-align: left; font-weight: 500; }
.linkbtn:hover { color: var(--accent); }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--muted); }
.crumbs button { background: none; border: 0; padding: 2px 4px; color: var(--soft); border-radius: 6px; }
.crumbs button:hover { color: var(--accent); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat { background: var(--surface); border-radius: 20px; padding: 18px 20px; }
.stat b { display: block; font-family: 'Space Grotesk', Inter, sans-serif; font-size: 26px; font-weight: 600; margin-top: 4px; }
.narrow { width: 100%; max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }

/* Inloggning */
.login { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 40px; }
.login .card { width: 380px; max-width: 100%; padding: 32px; display: flex; flex-direction: column; gap: 22px; }
.logo { width: 56px; height: 56px; border-radius: 18px; background: #232A4A; color: #AEBBFF; display: flex; align-items: center; justify-content: center; }
.logo svg { width: 30px; height: 30px; }

/* Meny och notiser */
.menu { position: fixed; z-index: 20; min-width: 200px; background: var(--surface2); border: 1px solid var(--line); border-radius: 14px; padding: 6px; display: flex; flex-direction: column; box-shadow: 0 12px 32px #00000066; }
.menu button { text-align: left; background: none; border: 0; border-radius: 9px; padding: 9px 12px; color: var(--text); }
.menu button:hover { background: var(--line); }
.menu button.danger { color: var(--danger); }
#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; z-index: 30; pointer-events: none; }
.toast { background: var(--surface2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; font-size: 13px; box-shadow: 0 8px 24px #00000055; animation: fade .2s ease-out; max-width: 520px; }
.toast.err { border-color: #6B3030; color: #FFC7C7; }
.banner { background: #3A2A22; color: #F2B38A; border-radius: 14px; padding: 12px 16px; font-size: 13px; }

@media (max-width: 900px) {
  .page { padding: 28px 22px; }
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

a.btn { text-decoration: none; }
@media (max-width: 600px) {
  .page { padding: 22px 16px 28px; gap: 24px; }
  .title { font-size: 26px; }
  .head .row { width: 100%; }
  .search { width: 100%; }
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px 6px; }
  .grid .ic { width: min(var(--icon), 62px); height: min(var(--icon), 62px); }
  .tile { font-size: 12px; }
  .groups { grid-template-columns: 1fr; }
  .appcard .actions { width: 100%; align-items: stretch; }
  .appcard .actions .bar { width: 100%; }
  .split > .side { max-width: none; }
  .two { grid-template-columns: 1fr; }
  .bgs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .login { padding: 16px; }
  .login .card { padding: 24px; }
}

.search { position: relative; cursor: text; }
.search:focus-within { border-color: var(--accent); }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.grid > .nohits, .groups > .nohits { grid-column: 1 / -1; }
@media (max-width: 600px) {
  /* 16 px hindrar mobilen från att zooma in när man trycker i ett fält */
  input, select, textarea { font-size: 16px; }
}
