:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --text: #17212b;
  --muted: #677482;
  --line: #dde3e8;
  --primary: #176b5b;
  --primary-dark: #0e5447;
  --danger: #b42318;
  --shadow: 0 14px 40px rgba(23, 33, 43, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(23, 107, 91, 0.08), transparent 30rem),
    var(--bg);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 2rem;
  padding: 2.2rem clamp(1rem, 4vw, 4rem) 1.6rem;
  color: #fff;
  background: linear-gradient(135deg, #122b27, #176b5b);
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: .5rem; font-size: clamp(2rem, 4vw, 3.4rem); letter-spacing: -.04em; }
h2 { margin-bottom: .35rem; }
.subtitle { margin-bottom: 0; color: rgba(255,255,255,.76); max-width: 48rem; }
.eyebrow { margin-bottom: .4rem; text-transform: uppercase; letter-spacing: .12em; font-size: .74rem; font-weight: 800; opacity: .75; }

.page-shell { width: min(1440px, calc(100% - 2rem)); margin: 1.5rem auto 3rem; }

.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1rem; }
.stat-card { padding: 1.15rem 1.25rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.stat-card span { display: block; margin-bottom: .35rem; color: var(--muted); font-size: .9rem; }
.stat-card strong { font-size: 1.9rem; }

.toolbar { display: grid; grid-template-columns: minmax(260px, 2fr) repeat(3, minmax(150px, 1fr)); gap: .8rem; margin: 1rem 0; }
.search-field { display: block; }

input, select, textarea {
  width: 100%;
  border: 1px solid #cfd7de;
  border-radius: 12px;
  padding: .78rem .9rem;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(23,107,91,.13); }
textarea { resize: vertical; }

.content-card { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1.25rem 1.35rem; border-bottom: 1px solid var(--line); }
.section-heading p { margin-bottom: 0; color: var(--muted); }
.data-actions { display: flex; gap: .6rem; }

.primary-btn, .secondary-btn, .danger-btn, .icon-btn {
  border: 0;
  border-radius: 12px;
  font-weight: 750;
}
.primary-btn { padding: .78rem 1.05rem; color: #fff; background: var(--primary); }
.primary-btn:hover { background: var(--primary-dark); }
.secondary-btn { padding: .72rem .95rem; color: var(--text); border: 1px solid var(--line); background: #fff; }
.secondary-btn:hover { background: var(--surface-soft); }
.danger-btn { padding: .72rem .95rem; color: #fff; background: var(--danger); }
.icon-btn { width: 2.4rem; height: 2.4rem; font-size: 1.6rem; color: var(--muted); background: transparent; }
.icon-btn:hover { background: var(--surface-soft); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 1rem 1.15rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; background: var(--surface-soft); }
tbody tr:hover { background: #fbfcfc; }
.item-name { font-weight: 780; }
.item-meta { margin-top: .2rem; color: var(--muted); font-size: .83rem; }
.badge { display: inline-flex; padding: .35rem .58rem; border-radius: 999px; font-size: .82rem; background: #edf5f3; color: #145c4f; }
.actions { display: flex; gap: .4rem; justify-content: flex-end; }
.table-btn { border: 1px solid var(--line); border-radius: 9px; padding: .42rem .62rem; background: #fff; }
.table-btn:hover { background: var(--surface-soft); }
.table-btn-danger { color: var(--danger); border-color: rgba(180,35,24,.35); }
.table-btn-danger:hover { color: #fff; background: var(--danger); border-color: var(--danger); }
.actions-column { text-align: right; }

.empty-state { padding: 4rem 1.2rem; text-align: center; }
.empty-state p { color: var(--muted); }
.empty-icon { font-size: 3rem; margin-bottom: .8rem; }

::backdrop { background: rgba(10, 20, 24, .6); backdrop-filter: blur(3px); }
dialog { width: min(780px, calc(100% - 1.5rem)); max-height: 92vh; overflow: auto; border: 0; border-radius: 20px; padding: 0; box-shadow: 0 25px 90px rgba(0,0,0,.3); }
dialog form, .detail-dialog { background: #fff; }
.dialog-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: 1.35rem 1.5rem; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin-bottom: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; padding: 1.4rem 1.5rem; }
.form-grid label span { display: block; margin-bottom: .4rem; font-size: .88rem; font-weight: 750; }
.full-width { grid-column: 1 / -1; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .7rem; padding: 1.1rem 1.5rem; border-top: 1px solid var(--line); }

.detail-content { padding: 1.4rem 1.5rem; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.detail-box { padding: .9rem 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.detail-box span { display: block; margin-bottom: .25rem; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.detail-box strong { white-space: pre-wrap; }
.detail-box.full { grid-column: 1 / -1; }

.toast { position: fixed; right: 1rem; bottom: 1rem; transform: translateY(120px); opacity: 0; padding: .85rem 1rem; color: #fff; border-radius: 12px; background: #17212b; box-shadow: var(--shadow); transition: .25s; z-index: 10; }
.toast.show { transform: translateY(0); opacity: 1; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 950px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
}

@media (max-width: 680px) {
  .topbar { align-items: stretch; flex-direction: column; }
  .topbar .primary-btn { width: 100%; }
  .page-shell { width: min(100% - 1rem, 1440px); }
  .stats { grid-template-columns: 1fr 1fr; }
  .toolbar { grid-template-columns: 1fr; }
  .search-field { grid-column: auto; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .data-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .form-grid, .detail-grid { grid-template-columns: 1fr; }
  .full-width, .detail-box.full { grid-column: auto; }
  th:nth-child(4), td:nth-child(4), th:nth-child(5), td:nth-child(5), th:nth-child(6), td:nth-child(6) { display: none; }
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: radial-gradient(circle at top, rgba(67, 97, 238, .18), transparent 42%), var(--background);
}
.login-screen[hidden], #appContent[hidden] { display: none !important; }
.login-card {
  width: min(430px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 2rem;
  box-shadow: var(--shadow);
}
.login-card label { display: grid; gap: .5rem; margin: 1.4rem 0 1rem; }
.login-card input { width: 100%; }
.login-card .primary-btn { width: 100%; justify-content: center; }
.login-error { min-height: 1.4em; color: #b42318; margin: .8rem 0 0; }
.header-actions { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; justify-content: flex-end; }
.storage-status { font-size: .85rem; color: var(--muted); padding: .45rem .75rem; border: 1px solid var(--border); border-radius: 999px; background: var(--card); }
@media (max-width: 700px) { .header-actions { justify-content: flex-start; } .storage-status { width: 100%; text-align: center; } }

/* Zusätzliche Eingabe für neue Kategorien und Lagerorte */
.new-option-input:not([hidden]) { margin-top: 8px; }


/* Ausleihverwaltung V1.5 */
.loan-section { margin-top: 1.5rem; }
.tab-buttons { display:flex; gap:.55rem; }
.active-tab { border-color: var(--primary) !important; color: var(--primary) !important; background: rgba(23,107,91,.08) !important; }
.loan-list { display:grid; gap:.8rem; }
.loan-card { display:flex; justify-content:space-between; align-items:center; gap:1rem; padding:1rem 1.1rem; border:1px solid var(--line); border-radius:14px; background:var(--surface-soft); }
.loan-card p { margin:.35rem 0 0; color:var(--muted); }
.loan-card small { display:block; margin-top:.45rem; white-space:pre-wrap; }
.loan-card.archived { opacity:.86; }
.loan-empty { padding:2rem; text-align:center; color:var(--muted); border:1px dashed var(--line); border-radius:14px; }
.loan-status { color:#9a6700; font-weight:700; }
.compact { padding:.55rem .75rem; }
@media (max-width:700px){ .loan-card{align-items:stretch;flex-direction:column}.loan-card button{width:100%}.tab-buttons{width:100%}.tab-buttons button{flex:1} }


/* Artikelfotos V1.6 */
.field-label { display:block; margin-bottom:.4rem; font-size:.88rem; font-weight:750; }
.photo-dropzone { min-height:190px; border:2px dashed var(--line); border-radius:14px; background:var(--surface-soft); display:grid; place-items:center; padding:1rem; cursor:pointer; transition:.2s; }
.photo-dropzone:hover, .photo-dropzone.dragover { border-color:var(--primary); background:rgba(23,107,91,.07); }
.photo-empty { text-align:center; color:var(--muted); display:grid; gap:.45rem; }
.photo-empty strong { color:var(--text); }
.photo-preview-wrap { width:100%; text-align:center; }
.photo-preview-wrap img { display:block; max-width:100%; max-height:360px; object-fit:contain; margin:0 auto .8rem; border-radius:12px; box-shadow:0 5px 18px rgba(0,0,0,.12); }
.detail-photo { margin-bottom:1.2rem; text-align:center; }
.detail-photo img { max-width:100%; max-height:430px; object-fit:contain; border-radius:14px; box-shadow:var(--shadow); }

.exit-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
