/* =========================
   THEME TOKENS
========================= */
:root{
  --radius: 14px;
  --radius2: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono","Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";

  /* LIGHT default */
  --bg: #f6f8fc;
  --text: rgba(12, 18, 33, 0.92);
  --muted: rgba(12, 18, 33, 0.60);

  --surface: rgba(255,255,255,0.92);
  --surface2: rgba(255,255,255,0.78);
  --line: rgba(12, 18, 33, 0.12);

  /* Accent (NO PINK) */
  --accent: #1e6fff;   /* blue */
  --accent2: #14b8a6;  /* teal */

  /* Status */
  --good: #16a34a;
  --warn: #f59e0b;
  --bad:  #dc2626;     /* Dåligt skick */

  --danger: #64748b;

  --shadow: 0 10px 30px rgba(0,0,0,0.15);
  --ring: color-mix(in srgb, var(--accent) 22%, transparent);
  --focus: color-mix(in srgb, var(--accent) 55%, transparent);

  color-scheme: light;
}

html[data-theme="dark"]{
  --bg: #0b1020;
  --text: rgba(255,255,255,0.92);
  --muted: rgba(255,255,255,0.65);

  --surface: rgba(255,255,255,0.06);
  --surface2: rgba(255,255,255,0.09);
  --line: rgba(255,255,255,0.12);

  --accent: #63b3ff;
  --accent2: #2dd4bf;

  --good: #2ee59d;
  --warn: #ffcf5a;
  --bad:  #ff6b6b;     /* Dåligt skick */

  --danger: #94a3b8;

  --shadow: 0 10px 30px rgba(0,0,0,0.35);
  --ring: color-mix(in srgb, var(--accent) 18%, transparent);
  --focus: color-mix(in srgb, var(--accent) 60%, transparent);

  color-scheme: dark;
}

.w-80{ width:80px; }
.w-110{ width:110px; }
.w-120{ width:120px; }
.w-160{ width:160px; }


/* =========================
   BASE
========================= */
*{ box-sizing:border-box; }

body{
  margin:0;
  font-family: var(--sans);
  color: var(--text);
  padding: 24px;

  /* Nice but neutral (no pink) */
  background:
    radial-gradient(1200px 700px at 10% 0%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 60%),
    radial-gradient(900px 500px at 90% 10%, color-mix(in srgb, var(--accent2) 10%, transparent), transparent 55%),
    radial-gradient(900px 700px at 50% 100%, color-mix(in srgb, var(--good) 7%, transparent), transparent 55%),
    var(--bg);
}

.app{ max-width:1280px; margin:0 auto; }

.panel{
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow:hidden;
}

/* Sticky controls */
.sticky{
  position: sticky;
  top: 14px;
  z-index: 50;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* =========================
   TOP BAR
========================= */
.topbar{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap:wrap;
}

.brand{ display:flex; flex-direction:column; gap:6px; }
.brand h1{
  margin:0;
  font-size: 22px;
  letter-spacing: 0.3px;
  display:flex;
  align-items:center;
  gap:10px;
}
.badge{
  font-family: var(--mono);
  font-size: 12px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface2) 65%, transparent);
}
.subtitle{ margin:0; color: var(--muted); font-size: 13px; }

.save-indicator{
  display:flex;
  align-items:center;
  gap:8px;
  color: var(--muted);
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface2) 60%, transparent);
  box-shadow: var(--shadow);
  user-select:none;
  white-space:nowrap;
}
.dot{
  width:10px; height:10px; border-radius:50%;
  background: var(--good);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--good) 18%, transparent);
}
.dot.saving{
  background: var(--warn);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--warn) 18%, transparent);
}

/* =========================
   TABS + TOOLBAR
========================= */
.tabs{
  display:flex;
  gap:8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface2) 55%, transparent);
  flex-wrap:wrap;
}

.tab{
  border:1px solid var(--line);
  background: color-mix(in srgb, var(--surface2) 35%, transparent);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 999px;
  cursor:pointer;
  font-weight: 700;
  font-size: 13px;
  transition: transform .08s ease, background .2s ease, border-color .2s ease;
  display:flex;
  align-items:center;
  gap:8px;
  user-select:none;
}
.tab:hover{ transform: translateY(-1px); border-color: color-mix(in srgb, var(--text) 18%, transparent); }

.tab.active{
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--accent) 20%, transparent),
    color-mix(in srgb, var(--accent2) 18%, transparent)
  );
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}

.tab .count{
  font-family: var(--mono);
  font-size: 12px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface2) 60%, transparent);
  color: var(--muted);
}

.toolbar{
  display:flex;
  gap: 12px;
  padding: 12px;
  align-items:flex-start;
  flex-wrap:wrap;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface2) 45%, transparent);
}

.search{
  flex: 1 1 320px;
  min-width: 260px;
  display:flex;
  flex-direction:column;
  gap:10px;
}

.search input{
  width:100%;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface2) 70%, transparent);
  color: var(--text);
  outline:none;
}
.search input::placeholder{ color: color-mix(in srgb, var(--muted) 85%, transparent); }

/* filters */
.filters{ display:flex; gap:8px; flex-wrap:wrap; }
.pill{
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface2) 40%, transparent);
  cursor:pointer;
  font-weight: 800;
  font-size: 12px;
  color: var(--text);
  user-select:none;
  transition: background .2s ease, border-color .2s ease;
}
.pill:hover{ border-color: color-mix(in srgb, var(--text) 18%, transparent); }
.pill.active{
  background: color-mix(in srgb, var(--accent2) 18%, transparent);
  border-color: color-mix(in srgb, var(--accent2) 55%, transparent);
}

/* kpis */
.chips{ display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
.chip{
  border:1px solid var(--line);
  background: color-mix(in srgb, var(--surface2) 45%, transparent);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 12px;
  color: var(--text);
  display:flex;
  gap:8px;
  align-items:center;
  white-space:nowrap;
}
.chip b{ font-family: var(--mono); font-weight: 900; }
.kpi-dot{ width:8px; height:8px; border-radius:50%; display:inline-block; }
.kpi-owned{ background: var(--good); }
.kpi-missing{ background: color-mix(in srgb, var(--muted) 55%, transparent); }
.kpi-dupes{ background: var(--warn); }
.kpi-bad{ background: var(--bad); }

/* actions */
.actions{
  display:flex;
  gap:10px;
  flex: 0 1 auto;
  flex-wrap:wrap;
  align-items:center;
  justify-content:flex-end;
}

.btn{
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface2) 40%, transparent);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor:pointer;
  font-weight: 900;
  font-size: 13px;
  user-select:none;
  transition: transform .08s ease, border-color .2s ease, background .2s ease;
  display:flex;
  align-items:center;
  gap:8px;
  white-space:nowrap;
}
.btn:hover{ transform: translateY(-1px); border-color: color-mix(in srgb, var(--text) 18%, transparent); }

.btn.primary{
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}
.btn.danger{
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  border-color: color-mix(in srgb, var(--danger) 55%, transparent);
}
.btn.muted{
  background: color-mix(in srgb, var(--surface2) 28%, transparent);
  color: var(--muted);
}
#btnTheme{ box-shadow: var(--shadow); }

/* Focus ring */
.search input:focus,
input.cell:focus,
select.cell:focus{
  border-color: var(--focus);
  box-shadow: 0 0 0 4px var(--ring);
}

/* =========================
   TABLE
========================= */
.table-wrap{ overflow:auto; }

table{
  width:100%;
  border-collapse: collapse;
  min-width: 980px;
}

thead th{
  text-align:left;
  font-size: 12px;
  letter-spacing: .3px;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--muted) 95%, transparent);
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface2) 60%, transparent);
  position: sticky;
  top: 0;
  z-index: 10;
}

tbody td{
  padding: 10px 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 75%, transparent);
  vertical-align: middle;
}

tbody tr{ background: color-mix(in srgb, var(--surface2) 20%, transparent); }
tbody tr.owned{ background: color-mix(in srgb, var(--good) 6%, transparent); }
tbody tr:hover{ background: color-mix(in srgb, var(--surface2) 36%, transparent); }

/* Inputs in table */
input.cell, select.cell{
  width: 100%;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface2) 65%, transparent);
  color: var(--text);
  outline:none;
  font-size: 13px;
}

.id-cell{ width: 72px; font-family: var(--mono); text-align:center; }
.id-cell input{ text-align:center; }

.img-cell{ width: 150px; }
.img-wrap{ display:flex; gap:8px; align-items:center; }

.thumb{
  width: 56px; height: 42px;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface2) 60%, transparent);
  cursor: zoom-in;
  transition: transform .15s ease;
}
.thumb:hover{ transform: scale(1.7); z-index: 5; position: relative; }

.ph{
  width: 56px; height: 42px;
  border-radius: 10px;
  border: 1px dashed color-mix(in srgb, var(--muted) 45%, transparent);
  display:flex; align-items:center; justify-content:center;
  color: var(--muted);
  font-size: 11px;
  font-family: var(--mono);
  background: color-mix(in srgb, var(--surface2) 40%, transparent);
  user-select:none;
}

.center{ text-align:center; }
.check{ transform: scale(1.3); cursor:pointer; accent-color: var(--good); }
.small{ width: 92px; }
.cond{ min-width: 150px; }

.row-actions{ display:flex; justify-content:flex-end; }
.mini{ padding: 8px 10px; font-size: 12px; border-radius: 10px; }

/* =========================
   FOOTER + MODAL
========================= */
.footer{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap: 12px;
  padding: 14px 12px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface2) 50%, transparent);
  flex-wrap:wrap;
}
.hint{
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.modal{
  position:fixed; inset:0;
  background: rgba(0,0,0,0.82);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index: 9999;
  cursor: zoom-out;
  padding: 24px;
}
.modal img{
  max-width: 92vw;
  max-height: 92vh;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.06);
  box-shadow: var(--shadow);
}

/* =========================
   RESPONSIVE
========================= */
@media (max-width: 820px){
  body{ padding: 14px; }
  .save-indicator{ display:none; }
  .sticky{ top: 8px; }
}

/* =========================
   FALLBACK (no color-mix support)
========================= */
@supports not (color: color-mix(in srgb, white, black)) {
  body{ background: var(--bg); }

  .tab.active{ background: rgba(20,184,166,0.16); border-color: rgba(30,111,255,0.55); }
  .pill.active{ background: rgba(20,184,166,0.16); border-color: rgba(20,184,166,0.55); }

  .btn.primary{ background: rgba(30,111,255,0.14); border-color: rgba(30,111,255,0.55); }
  .btn.danger{ background: rgba(220,38,38,0.14); border-color: rgba(220,38,38,0.55); }

  .search input, input.cell, select.cell{ background: rgba(255,255,255,0.75); }
  html[data-theme="dark"] .search input,
  html[data-theme="dark"] input.cell,
  html[data-theme="dark"] select.cell{ background: rgba(0,0,0,0.25); }
}

/* Advanced (details/summary) */
.advanced{ position: relative; }
.advanced > summary{ list-style:none; }
.advanced > summary::-webkit-details-marker{ display:none; }

.advanced[open] > summary{
  border-color: color-mix(in srgb, var(--accent2) 55%, transparent);
  background: color-mix(in srgb, var(--accent2) 12%, transparent);
}

.advanced-panel{
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface2) 55%, transparent);
  min-width: 320px;
}

.advanced-row{
  display:flex;
  gap: 12px;
  align-items:center;
  justify-content:space-between;
  padding: 10px 0;
}
.advanced-row + .advanced-row{ border-top: 1px solid var(--line); }

.advanced-text{ max-width: 520px; }
.advanced-title{ font-weight: 900; font-size: 13px; color: var(--text); }
.advanced-sub{ font-size: 12px; color: var(--muted); margin-top: 3px; }

.dupe-chips{
  display:flex;
  gap:6px;
  flex-wrap:nowrap;         
  overflow-x:auto;          
  margin-top: 0;            
  justify-content:flex-end; 
  padding-bottom: 2px;      
}

.dupe-chip{ flex: 0 0 auto; } /* chips krymper inte */


.dupe-chip{
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface2) 55%, transparent);
  color: var(--text);
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 12px;
  cursor:pointer;
}

.dupe-row{
  display:flex;
  align-items:center;
  gap:10px;
}

.dupe-row .cell.small{
  width: 60px;   /* lite tightare */
  flex: 0 0 auto;
}

.dupe-row .dupe-chips{
  flex: 0 0 auto;
}

/* Skick-cellen ska bete sig som dupe-row (tight) */
.cond-row{
  display:flex;
  align-items:center;
  justify-content:flex-end;
}

/* Samma "tight" känsla som dupe, fast för select */
.cond-row select.cell.cond{
  width: 78px;
  line-height: 1.1;
  min-width: 78px;
  flex: 0 0 auto;
  padding: 8px 8px;
  font-size: 12px;
}


.advanced > summary::after{
  content:"▾";
  margin-left: 8px;
  opacity: .7;
}
.advanced[open] > summary::after{
  content:"▴";
}

.dupe-chip[data-v="1"]{ border-color: color-mix(in srgb, var(--good) 55%, transparent); }
.dupe-chip[data-v="2"]{ border-color: color-mix(in srgb, var(--warn) 55%, transparent); }
.dupe-chip[data-v="3"]{ border-color: color-mix(in srgb, var(--bad) 55%, transparent); }


.login-card{
  max-width: 360px;
  width: 100%;
}

.login-pad{
  padding: 16px;
}

.login-pad input + input{
  margin-top: 8px;
}

.hidden{ display:none !important; }

.login-modal{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 24px;
}

.login-box{
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 360px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-box input{
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface2) 70%, transparent);
  color: var(--text);
}

.login-actions{
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 6px;
}

