/* ======================================================================
   Cyborg — Claude-inspired design, kühles Neutral mit Indigo-Akzent
   ====================================================================== */

:root {
  --bg:          #F4F4F5;
  --surface:    #FFFFFF;
  --surface-2: #FAFAFA;
  --text:      #18181B;
  --text-2:    #52525B;
  --text-3:    #A1A1AA;
  --border:    #E4E4E7;
  --border-2:  #D4D4D8;

  --accent:       #4338CA;
  --accent-hover: #3730A3;
  --accent-soft:  #EEF2FF;
  --accent-text:  #3730A3;

  --verborgt-bg:  #FEF3C7;
  --verborgt-fg:  #92400E;
  --geborgt-bg:   #DBEAFE;
  --geborgt-fg:   #1E40AF;
  --erledigt-bg:  #F4F4F5;
  --erledigt-fg:  #71717A;
  --overdue-bg:   #FEE2E2;
  --overdue-fg:   #991B1B;
  --success-bg:   #DCFCE7;
  --success-fg:   #166534;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 2px rgba(24,24,27,0.04);
  --shadow-md: 0 2px 8px rgba(24,24,27,0.06);

  --font-sans: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  --safe-top:    env(safe-area-inset-top, 0);
  --safe-bottom: env(safe-area-inset-bottom, 0);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:       #09090B;
    --surface: #18181B;
    --surface-2:#1F1F23;
    --text:    #FAFAFA;
    --text-2:  #A1A1AA;
    --text-3:  #71717A;
    --border:  #27272A;
    --border-2:#3F3F46;
    --accent:       #818CF8;
    --accent-hover: #A5B4FC;
    --accent-soft:  #1E1B4B;
    --accent-text:  #C7D2FE;
    --verborgt-bg:  #422006;
    --verborgt-fg:  #FBBF24;
    --geborgt-bg:   #172554;
    --geborgt-fg:   #93C5FD;
    --erledigt-bg:  #27272A;
    --erledigt-fg:  #A1A1AA;
    --overdue-bg:   #450A0A;
    --overdue-fg:   #FCA5A5;
    --success-bg:   #052E16;
    --success-fg:   #86EFAC;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* =============== Login =============== */
.login {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-md);
}
.login-logo { display: flex; justify-content: center; margin-bottom: 16px; }
.login-card h1 { font-size: 22px; font-weight: 600; text-align: center; margin-bottom: 4px; }
.login-card .muted { text-align: center; color: var(--text-2); margin-bottom: 24px; font-size: 14px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); }
.err { color: var(--overdue-fg); font-size: 13px; min-height: 18px; }

/* =============== Inputs =============== */
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { min-height: 80px; resize: vertical; font-family: inherit; }

/* =============== Buttons =============== */
button { cursor: pointer; border: none; background: transparent; }
.btn-primary {
  background: var(--accent); color: white;
  padding: 11px 18px; border-radius: var(--radius-md);
  font-weight: 500; font-size: 15px;
  transition: background .15s, transform .1s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 16px; border-radius: var(--radius-md);
  font-weight: 500; transition: background .15s, border-color .15s;
}
.btn-secondary:hover { background: var(--surface-2); border-color: var(--border-2); }

.btn-danger {
  background: var(--overdue-bg); color: var(--overdue-fg);
  padding: 10px 16px; border-radius: var(--radius-md);
  font-weight: 500;
}

.icon-btn {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md);
  color: var(--text-2);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* =============== Shell / Layout =============== */
.shell {
  display: flex; flex-direction: column;
  min-height: 100vh; min-height: 100dvh;
}
.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: calc(var(--safe-top) + 10px) 12px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar-title { flex: 1; font-size: 17px; font-weight: 600; text-align: center; }

main#view {
  flex: 1;
  padding: 16px;
  padding-bottom: calc(80px + var(--safe-bottom));
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + var(--safe-bottom));
  z-index: 10;
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px;
  color: var(--text-3);
  font-size: 11px; font-weight: 500;
  transition: color .15s;
  border-radius: var(--radius-md);
}
.bottom-nav a.active, .bottom-nav a:hover { color: var(--accent); }
.bottom-nav a.fab {
  background: var(--accent); color: white;
  width: 52px; height: 52px;
  border-radius: 50%;
  align-self: center;
  justify-self: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
}
.bottom-nav a.fab span { display: none; }
.bottom-nav a.fab:hover { background: var(--accent-hover); color: white; }

/* =============== Cards & common =============== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  transition: border-color .15s, box-shadow .15s;
}
.card + .card { margin-top: 10px; }
.card:hover { border-color: var(--border-2); box-shadow: var(--shadow-sm); }

.section-title {
  font-size: 13px; font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase; letter-spacing: 0.05em;
  margin: 20px 0 10px;
}
.section-title:first-child { margin-top: 0; }

.muted { color: var(--text-2); }
.muted-small { color: var(--text-3); font-size: 12px; }

/* =============== Dashboard =============== */
.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
@media (min-width: 520px) { .stats { grid-template-columns: repeat(4, 1fr); } }

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.stat-label { font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.stat-value { font-size: 24px; font-weight: 600; }
.stat.verborgt .stat-value { color: var(--verborgt-fg); }
.stat.geborgt .stat-value  { color: var(--geborgt-fg); }
.stat.overdue .stat-value  { color: var(--overdue-fg); }

/* =============== Badges =============== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-verborgt { background: var(--verborgt-bg); color: var(--verborgt-fg); }
.badge-geborgt  { background: var(--geborgt-bg);  color: var(--geborgt-fg); }
.badge-erledigt { background: var(--erledigt-bg); color: var(--erledigt-fg); }
.badge-overdue  { background: var(--overdue-bg);  color: var(--overdue-fg); }
.badge-success  { background: var(--success-bg);  color: var(--success-fg); }

/* =============== Filter chips =============== */
.filter-bar {
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 14px;
}
.search {
  position: relative;
}
.search input {
  padding-left: 38px;
}
.search svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); pointer-events: none;
}
.chips {
  display: flex; gap: 6px; overflow-x: auto;
  padding: 2px 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
  cursor: pointer;
  transition: all .15s;
}
.chip:hover { border-color: var(--border-2); }
.chip.active {
  background: var(--accent); color: white; border-color: var(--accent);
}

/* =============== Item list =============== */
.item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  display: flex; gap: 12px;
  align-items: stretch;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.item + .item { margin-top: 8px; }
.item:hover { border-color: var(--border-2); box-shadow: var(--shadow-sm); }

.item-thumb {
  width: 56px; height: 56px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  flex-shrink: 0;
  background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
  border: 1px solid var(--border);
}
.item-thumb svg { width: 22px; height: 22px; }
.item-body { flex: 1; display: flex; flex-direction: column; justify-content: space-between; min-width: 0; }
.item-title { font-weight: 600; font-size: 15px; margin-bottom: 2px; word-break: break-word; }
.item-sub { font-size: 12px; color: var(--text-2); }
.item-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; }

/* =============== Quantity stepper =============== */
.qty {
  display: inline-flex; align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.qty button {
  width: 32px; height: 32px;
  font-size: 16px; font-weight: 500;
  color: var(--text-2);
  transition: background .15s;
}
.qty button:hover { background: var(--border); color: var(--text); }
.qty button:disabled { opacity: 0.4; cursor: not-allowed; }
.qty span {
  min-width: 28px; text-align: center;
  font-weight: 600; font-size: 14px;
}

/* =============== Detail view =============== */
.detail {
  display: flex; flex-direction: column; gap: 14px;
}
.detail-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.detail-photos {
  display: flex; gap: 2px; overflow-x: auto;
  aspect-ratio: 16/9;
  background: var(--surface-2);
}
.detail-photos img {
  width: 100%; height: 100%; object-fit: cover;
  flex-shrink: 0; scroll-snap-align: start;
}
.detail-photos { scroll-snap-type: x mandatory; }
.detail-photos-empty {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 16/9;
  background: var(--surface-2);
  color: var(--text-3);
}
.detail-head { padding: 16px; }
.detail-head h2 { font-size: 20px; font-weight: 600; margin-bottom: 6px; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--text-2); font-size: 13px; }

.kv {
  display: grid; grid-template-columns: 120px 1fr; gap: 10px 14px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  font-size: 14px;
}
.kv dt { color: var(--text-2); }
.kv dd { color: var(--text); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions > * { flex: 1; min-width: 140px; }

/* =============== Form =============== */
.form {
  display: flex; flex-direction: column; gap: 14px;
}
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); font-weight: 500; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-row label { margin: 0; }

.radio-group {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
}
.radio-group label {
  position: relative;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: center;
  font-weight: 500;
  color: var(--text);
  transition: all .15s;
}
.radio-group input { position: absolute; opacity: 0; pointer-events: none; }
.radio-group input:checked + span {
  color: var(--accent-text);
}
.radio-group label:has(input:checked) {
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* =============== Photo uploader =============== */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
}
.photo-item {
  aspect-ratio: 1; position: relative;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  overflow: hidden;
  border: 1px solid var(--border);
}
.photo-item img { width: 100%; height: 100%; object-fit: cover; }
.photo-item button {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px;
  background: rgba(0,0,0,0.6);
  color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.photo-add {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px dashed var(--border-2);
  border-radius: var(--radius-md);
  color: var(--text-2);
  cursor: pointer;
  background: var(--surface);
  font-size: 12px;
  flex-direction: column; gap: 4px;
  transition: border-color .15s, color .15s;
}
.photo-add:hover { border-color: var(--accent); color: var(--accent); }
.photo-add input { display: none; }

/* =============== Toast =============== */
.toast {
  position: fixed;
  bottom: calc(84px + var(--safe-bottom));
  left: 50%; transform: translateX(-50%) translateY(8px);
  background: var(--text); color: var(--surface);
  padding: 10px 16px; border-radius: var(--radius-md);
  font-size: 13px; font-weight: 500;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 100;
  max-width: 90%;
  box-shadow: var(--shadow-md);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* =============== Empty state =============== */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-2);
}
.empty svg { width: 48px; height: 48px; color: var(--text-3); margin-bottom: 12px; }
.empty h3 { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 4px; }

/* =============== QR scanner =============== */
.scanner {
  position: relative;
  width: 100%; aspect-ratio: 1;
  max-width: 360px;
  margin: 20px auto;
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner-frame {
  position: absolute; inset: 15%;
  border: 2px solid var(--accent);
  border-radius: var(--radius-md);
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.4);
}

/* =============== QR code print =============== */
.qr-print {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 20px;
  background: white;
  border-radius: var(--radius-lg);
}
.qr-print canvas, .qr-print img { width: 180px; height: 180px; }

/* =============== Skeleton =============== */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--border) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-md);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* =============== Utilities =============== */
.row { display: flex; align-items: center; gap: 8px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.gap-4 { gap: 4px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }

/* =============== User-Picker (Login) =============== */
.user-picker { display: flex; flex-direction: column; gap: 6px; }
.user-btn {
  width: 100%;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  color: var(--text);
}
.user-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 600; font-size: 13px;
  flex-shrink: 0;
}

/* =============== Toasts (Container-Variante) =============== */
#toast-container {
  position: fixed;
  bottom: calc(84px + var(--safe-bottom));
  left: 0; right: 0;
  display: flex; flex-direction: column; gap: 6px;
  align-items: center;
  pointer-events: none;
  z-index: 100;
  padding: 0 20px;
}
#toast-container .toast {
  position: static; left: auto; transform: translateY(8px);
  opacity: 0; pointer-events: auto;
  max-width: 100%;
}
#toast-container .toast.show { transform: translateY(0); opacity: 1; }
.toast-error { background: var(--overdue-fg) !important; color: white !important; }
.toast-success { background: var(--success-fg) !important; color: white !important; }

/* Print */
@media print {
  .topbar, .bottom-nav, .toast, #toast-container { display: none !important; }
  main#view { padding: 0; }
  body { background: white; }
}
