/* ItemStore – Design
   Farben ausschließlich über Tokens; Farbschemata über html[data-theme]. */

:root, [data-theme="hell"] {
  --bg: #eef2f6;
  --panel: #ffffff;
  --panel-2: #f5f7fa;
  --glass: rgba(255, 255, 255, .74);
  --line: #d8dfe8;
  --text: #14283c;
  --muted: #5d6d7f;
  --accent: #0f8b8d;
  --accent-ink: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --brand: #14283c;
  --warn: #e0a82e;
  --danger: #c0392b;
  --shadow: 0 10px 30px rgba(20, 40, 60, .10), 0 1px 2px rgba(20, 40, 60, .08);
  --overlay: rgba(14, 26, 40, .45);
  --bg-op: .9;
  --bg-filter: none;
  --radius: 14px;
  --font: "Aptos", "Aptos Display", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: "Aptos Mono", "Cascadia Mono", "Cascadia Code", Consolas, "SF Mono", monospace;
  color-scheme: light;
}
[data-theme="wald"]  { --bg: #edf3ee; --accent: #2f7d4f; --line: #d3e0d6; --text: #17301f; --brand: #17301f; --muted: #57705e; }
[data-theme="sand"]  { --bg: #f5f0e8; --accent: #a8561a; --line: #e4dccd; --text: #2e2418; --brand: #2e2418; --muted: #7a6b58; --panel-2: #faf7f2; }
[data-theme="kontrast"] { --bg: #ffffff; --glass: #ffffff; --line: #1a1a1a; --text: #000000; --muted: #333333; --accent: #0047b3; --brand: #000000; --bg-op: .35; }
[data-theme="nacht"], [data-theme="graphit"] {
  --bg: #0d1724; --panel: #142233; --panel-2: #192a3e; --glass: rgba(20, 34, 51, .78);
  --line: #27394f; --text: #e6edf5; --muted: #8fa2b6; --accent: #2bb5b3; --accent-ink: #06222a;
  --brand: #e6edf5; --shadow: 0 10px 30px rgba(0, 0, 0, .35); --overlay: rgba(0, 0, 0, .6);
  --bg-op: .5; --bg-filter: invert(1) hue-rotate(180deg); color-scheme: dark;
}
[data-theme="graphit"] { --bg: #1b1e23; --panel: #23272e; --panel-2: #2a2f37; --glass: rgba(35, 39, 46, .8); --line: #363c46; --accent: #e0a82e; --accent-ink: #1b1e23; --bg-op: .35; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.5 var(--font); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; letter-spacing: .005em;
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: url("bg.svg") center / cover no-repeat;
  opacity: var(--bg-op); filter: var(--bg-filter);
}
a { color: var(--accent); }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
[data-lucide], svg.lucide { width: 18px; height: 18px; stroke-width: 1.8; flex: none; }
.glass { background: var(--glass); backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2); border: 1px solid var(--line); box-shadow: var(--shadow); }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 252px 1fr; gap: 18px; min-height: 100vh; padding: 18px; }
.side { border-radius: var(--radius); padding: 18px 12px; display: flex; flex-direction: column; gap: 14px; position: sticky; top: 18px; height: calc(100vh - 36px); }
.brand { display: block; padding: 4px 10px 10px; }
.brand img { width: 170px; height: auto; display: block; }
[data-theme="nacht"] .brand img, [data-theme="graphit"] .brand img,
[data-theme="nacht"] .auth-logo, [data-theme="graphit"] .auth-logo { filter: brightness(0) invert(.92); }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--text); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--accent-soft); }
.nav a.on { background: var(--accent); color: var(--accent-ink); }
.nav a .pos { margin-left: auto; font: 11px var(--mono); opacity: .55; }
.nav .sep { height: 1px; background: var(--line); margin: 8px 6px; }
.nav .label { font: 600 11px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 6px 12px 2px; }
.nav .spacer { flex: 1; min-height: 8px; }
.side-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); padding: 12px 6px 0; }
.who { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; overflow: hidden; }
.who span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.view { min-width: 0; display: flex; flex-direction: column; gap: 18px; }

/* ---------- Bausteine ---------- */
.card { border-radius: var(--radius); padding: 20px 22px; }
.head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.head h1 { margin: 0; font-size: 24px; font-weight: 650; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; }
.head h1 [data-lucide], .head h1 svg { width: 24px; height: 24px; color: var(--accent); }
.head .grow { flex: 1; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.kicker { font: 600 11px var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; font: 500 14px var(--font); color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.sm { padding: 5px 8px; font-size: 13px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: transparent; border: 1px solid transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--accent-soft); color: var(--text); }
.icon-btn.star.on { color: var(--warn); }
.icon-btn.star.on svg { fill: currentColor; }

input, select, textarea { font: 14px var(--font); color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; width: 100%; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .nav a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
textarea { min-height: 96px; resize: vertical; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
input[type="color"] { padding: 2px; height: 36px; width: 52px; }
.form { display: grid; gap: 12px; }
.form label, .form .lbl { display: grid; gap: 5px; font-size: 13px; font-weight: 500; color: var(--muted); }
.form label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.form .row, .row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 .full { grid-column: 1 / -1; }
.req::after { content: " *"; color: var(--danger); }

.search { position: relative; flex: 1; min-width: 200px; max-width: 420px; }
.search input { padding-left: 36px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-size: 13px; cursor: pointer; color: var(--text); }
.chip.on { border-color: var(--accent); background: var(--accent-soft); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--muted)); flex: none; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 9px; border-radius: 999px; background: color-mix(in srgb, var(--c, var(--muted)) 16%, transparent); color: color-mix(in srgb, var(--c, var(--muted)) 65%, var(--text)); white-space: nowrap; }

/* ---------- Tabellen / Listen ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font: 600 11px var(--mono); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--panel-2); white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: var(--accent-soft); }
td.t { font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty svg { width: 34px; height: 34px; opacity: .5; display: block; margin: 0 auto 8px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.tile { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); text-decoration: none; color: var(--text); position: relative; }
.tile:hover { border-color: var(--accent); }
.tile .ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.tile .n { font: 600 26px var(--mono); line-height: 1.1; }
.tile .l { color: var(--muted); font-size: 13px; }

.list { display: flex; flex-direction: column; }
.list .li { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--text); }
.list .li:last-child { border-bottom: 0; }
.list .li:hover { background: var(--accent-soft); }
.list .li .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.typerow { display: grid; grid-template-columns: 40px 1fr auto auto auto; gap: 12px; align-items: center; padding: 10px 6px; border-bottom: 1px solid var(--line); }
.typerow:last-child { border-bottom: 0; }
.typerow .ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.typerow select { width: auto; padding: 5px 8px; }
.typerow .tname { font-weight: 600; }
.typerow .tname small { display: block; font-weight: 400; color: var(--muted); font-family: var(--mono); font-size: 12px; }

.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.theme { border: 2px solid var(--line); border-radius: 12px; padding: 10px; cursor: pointer; background: var(--panel); text-align: left; color: var(--text); font: 500 14px var(--font); }
.theme.on { border-color: var(--accent); }
.theme .sw { display: flex; height: 34px; border-radius: 8px; overflow: hidden; margin-bottom: 8px; border: 1px solid var(--line); }
.theme .sw span { flex: 1; }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 18px; align-items: start; }
.catrow { display: grid; grid-template-columns: 44px 1fr auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.catrow:last-child { border-bottom: 0; }

.file-box { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px dashed var(--line); border-radius: 9px; background: var(--panel-2); color: var(--text); font-size: 14px; }
.file-box a { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Modal / Toast ---------- */
.modal-back { position: fixed; inset: 0; background: var(--overlay); display: grid; place-items: center; padding: 18px; z-index: 50; animation: fade .15s; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 36px); overflow: auto; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); }
.modal.wide { width: min(820px, 100%); }
.modal header { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.modal header h3 { margin: 0; font-size: 17px; flex: 1; }
.modal .body { padding: 18px 20px; }
.modal footer { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--panel); }
.modal footer .left { margin-right: auto; }
@keyframes fade { from { opacity: 0; } }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--brand); color: var(--bg); padding: 10px 18px; border-radius: 10px; box-shadow: var(--shadow); z-index: 60; font-size: 14px; }
.toast.err { background: var(--danger); color: #fff; }
.alert { background: color-mix(in srgb, var(--danger) 12%, var(--panel)); color: color-mix(in srgb, var(--danger) 75%, var(--text)); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); padding: 9px 12px; border-radius: 9px; font-size: 14px; }
.hint { background: var(--accent-soft); border-radius: 9px; padding: 10px 12px; font-size: 14px; }

/* ---------- Login ---------- */
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 18px; }
.auth-card { width: min(400px, 100%); border-radius: 18px; padding: 32px 30px 22px; display: grid; gap: 14px; }
.auth-card h1 { margin: 0; font-size: 20px; }
.auth-logo { width: 220px; height: auto; margin: 0 auto 4px; display: block; }
.auth-card .muted { text-align: center; margin: 0; }
.auth-card .foot { text-align: center; color: var(--muted); font-size: 11px; margin: 4px 0 0; }
.log { background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 12px; font: 12px/1.5 var(--mono); white-space: pre-wrap; max-height: 360px; overflow: auto; }

/* ---------- Mobil ---------- */
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; padding: 10px; gap: 10px; }
  .side { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; align-items: center; padding: 8px 10px; gap: 6px; }
  .brand { padding: 0; }
  .brand img { width: 34px; height: 34px; object-fit: cover; object-position: left; }
  .nav { flex-direction: row; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
  .nav a { padding: 7px 10px; white-space: nowrap; }
  .nav a .pos, .nav .label, .nav .spacer { display: none; }
  .nav .sep { width: 1px; height: 22px; margin: 0 4px; }
  .side-foot { border: 0; padding: 0; }
  .who span { display: none; }
  .grid2 { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .typerow { grid-template-columns: 36px 1fr auto auto; }
  .typerow .cnt { display: none; }
}
