/* ============================================================
   ATM10 Dashboard – Design-System v2
   ============================================================ */
:root {
  --bg: #0f1115;
  --bg-soft: #161a21;
  --surface: #1c212b;
  --surface-2: #232936;
  --border: #2e3644;
  --text: #e6e9ef;
  --text-dim: #8b93a3;
  --accent: #4ade80;
  --accent-soft: rgba(74, 222, 128, 0.12);
  --accent-strong: #22c55e;
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --info: #60a5fa;
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar-w: 230px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

h1, h2, h3 { margin: 0; font-weight: 650; }
.hidden { display: none !important; }
.text-dim { color: var(--text-dim); }
.small { font-size: 0.8rem; }

/* ---------- Lucide-Icons ---------- */
svg.lucide {
  width: 1.1em;
  height: 1.1em;
  vertical-align: -0.18em;
  stroke-width: 2;
  flex-shrink: 0;
}
h2 svg.lucide, h3 svg.lucide { color: var(--accent); vertical-align: -0.14em; }
button svg.lucide { pointer-events: none; }
.badge svg.lucide { width: 0.95em; height: 0.95em; }

/* ---------- Formulare ---------- */
input, select, textarea, button {
  font: inherit;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.8rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder { color: var(--text-dim); }

button { cursor: pointer; user-select: none; }
.btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #06220f;
  font-weight: 650;
}
.btn:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-icon { padding: 0.35rem 0.55rem; line-height: 1; }

.field-row { display: flex; gap: 0.5rem; }
.field-row > input[type="text"], .field-row > input[type="password"] { flex: 1; min-width: 0; }
.field-row.wrap { flex-wrap: wrap; }
.field-row.wrap > input[type="text"], .field-row.wrap > input[type="password"] { min-width: 150px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
  white-space: nowrap;
}
.badge.green { background: var(--accent-soft); color: var(--accent); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.yellow { background: var(--warn-soft); color: var(--warn); }

/* ============================================================
   Login
   ============================================================ */
.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background:
    radial-gradient(60vw 60vw at 15% 10%, rgba(74, 222, 128, 0.07), transparent 60%),
    radial-gradient(50vw 50vw at 90% 90%, rgba(96, 165, 250, 0.06), transparent 60%),
    var(--bg);
}
.login-card {
  width: min(92vw, 380px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.2rem 2rem;
}
.login-card .logo {
  text-align: center;
  margin-bottom: 0.4rem;
  color: var(--accent);
}
.login-card .logo svg.lucide { width: 44px; height: 44px; }
.login-card h1 { text-align: center; font-size: 1.25rem; margin-bottom: 0.25rem; }
.login-card .sub { text-align: center; color: var(--text-dim); font-size: 0.85rem; margin: 0 0 1.6rem; }
.login-card label { display: block; font-size: 0.8rem; color: var(--text-dim); margin: 0.9rem 0 0.3rem; }
.login-card input { width: 100%; }
.login-card .btn { width: 100%; margin-top: 1.4rem; padding: 0.65rem; }
.login-error {
  margin: 1rem 0 0;
  padding: 0.55rem 0.8rem;
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  text-align: center;
}

/* ============================================================
   App-Layout: Sidebar + Panels
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  padding: 1rem 0.75rem;
  gap: 0.25rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.6rem 1.1rem;
}
.brand .logo { color: var(--accent); display: flex; }
.brand .logo svg.lucide { width: 26px; height: 26px; }
.brand .name { font-weight: 700; font-size: 1rem; line-height: 1.2; }
.brand .name span { display: block; font-size: 0.7rem; font-weight: 500; color: var(--text-dim); }

.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  color: var(--text-dim);
  font-weight: 550;
  text-decoration: none;
}
.nav-btn:hover { background: var(--surface); color: var(--text); }
.nav-btn.active { background: var(--accent-soft); color: var(--accent); }
.nav-btn svg.ico, .nav-btn svg.lucide { width: 18px; height: 18px; }
.nav-btn .count {
  margin-left: auto;
  font-size: 0.7rem;
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  min-width: 1.3em;
  text-align: center;
  padding: 0.1em 0.35em;
}

.sidebar .spacer { flex: 1; }

.user-box {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.5rem;
  border-top: 1px solid var(--border);
}
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #06220f;
  display: grid;
  place-items: center;
  font-weight: 800;
  flex-shrink: 0;
}
.user-box .who { min-width: 0; flex: 1; }
.user-box .who .n { font-weight: 650; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; }
.user-box .who .s { font-size: 0.7rem; display: flex; align-items: center; gap: 0.3rem; color: var(--text-dim); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); display: inline-block; }
.dot.on { background: var(--accent); }

/* ---------- Hauptbereich ---------- */
.main { overflow: hidden; display: flex; flex-direction: column; }

.panel {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  padding: 1.4rem 1.6rem;
  gap: 1rem;
}
.panel.active { display: flex; }

.panel-head { display: flex; align-items: baseline; gap: 0.8rem; flex-wrap: wrap; }
.panel-head h2 { font-size: 1.3rem; }
.panel-head .sub { color: var(--text-dim); font-size: 0.85rem; }
.panel-head .right { margin-left: auto; display: flex; gap: 0.5rem; align-items: center; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
}

/* ============================================================
   Chat
   ============================================================ */
.chat-scroll {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.25rem 0.25rem 0.75rem;
}
.msg { display: flex; flex-direction: column; max-width: min(72%, 560px); }
.msg.own { align-self: flex-end; align-items: flex-end; }
.msg .meta { font-size: 0.7rem; color: var(--text-dim); margin: 0 0.4rem 0.2rem; }
.msg .meta b { color: var(--accent); font-weight: 650; }
.msg .bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-top-left-radius: 4px;
  padding: 0.55rem 0.85rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.msg.own .bubble {
  background: var(--accent-soft);
  border-color: transparent;
  border-radius: var(--radius);
  border-top-right-radius: 4px;
}
.msg .bubble img {
  display: block;
  max-width: 300px;
  max-height: 220px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.chat-empty { margin: auto; text-align: center; color: var(--text-dim); }
.chat-empty .big, .drop-overlay .big { display: flex; justify-content: center; margin-bottom: 0.6rem; }
.chat-empty .big svg.lucide, .drop-overlay .big svg.lucide { width: 44px; height: 44px; }

.chat-compose { display: flex; gap: 0.5rem; }
.chat-compose input { flex: 1; padding: 0.7rem 1rem; border-radius: 999px; }
.chat-compose .btn { border-radius: 999px; padding: 0.7rem 1.3rem; }

/* Drop-Overlay (ganzer Bildschirm) */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(15, 17, 21, 0.85);
  backdrop-filter: blur(3px);
}
.drop-overlay .inner {
  border: 3px dashed var(--accent);
  border-radius: var(--radius);
  padding: 3rem 4rem;
  text-align: center;
  color: var(--accent);
  font-size: 1.2rem;
  font-weight: 650;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 110;
  background: rgba(0, 0, 0, 0.85);
  display: grid;
  place-items: center;
  cursor: zoom-out;
}
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: var(--radius-sm); }

/* ============================================================
   Listen (To-Dos, Bestellungen, Benutzer)
   ============================================================ */
.item-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.item-list li {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.9rem;
  margin-bottom: 0.5rem;
}
.item-list li .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.item-list li.done .grow { text-decoration: line-through; color: var(--text-dim); }
.item-list .sub { display: block; font-size: 0.72rem; color: var(--text-dim); margin-top: 0.1rem; }

.check {
  appearance: none;
  width: 21px;
  height: 21px;
  border: 2px solid var(--border);
  border-radius: 6px;
  background: var(--bg-soft);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin: 0;
  padding: 0;
}
.check:checked { background: var(--accent); border-color: var(--accent); }
.check:checked::after { content: "✓"; color: #06220f; font-size: 0.85rem; font-weight: 900; }

.seg { display: inline-flex; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.seg button {
  border: none;
  background: transparent;
  color: var(--text-dim);
  border-radius: 999px;
  padding: 0.3rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 600;
}
.seg button.active { background: var(--accent); color: #06220f; }

.empty-note { color: var(--text-dim); text-align: center; padding: 2rem 0; }

/* ============================================================
   Tabellen (Farm, Statistiken)
   ============================================================ */
.table-wrap { overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: left;
  padding: 0.6rem 1rem;
}
tbody td { padding: 0.6rem 1rem; border-top: 1px solid var(--border); background: var(--surface); }
tbody tr:hover td { background: var(--surface-2); }
td.num { font-variant-numeric: tabular-nums; font-weight: 650; }

/* ============================================================
   Modal
   ============================================================ */
.modal-back {
  position: fixed;
  inset: 0;
  z-index: 130;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem;
  width: min(92vw, 380px);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.modal h3 { font-size: 1rem; }

/* ============================================================
   Item-Rechner
   ============================================================ */
.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1rem;
  overflow-y: auto;
  align-items: start;
  padding-bottom: 1rem;
}
.calc-grid .card h3 { font-size: 1rem; margin-bottom: 0.9rem; }
.calc-h {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 1.1rem 0 0.5rem;
}
.calc-h svg.lucide { color: var(--accent); }
.ing-row { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
.ing-row .ing-item { flex: 1; min-width: 0; }
.plan-list {
  margin: 0;
  padding-left: 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.plan-list li::marker { color: var(--accent); font-weight: 700; }
.plan-list .sub { display: block; font-size: 0.75rem; color: var(--text-dim); margin-top: 0.1rem; }

/* ============================================================
   Toasts
   ============================================================ */
.toasts {
  position: fixed;
  bottom: 1.2rem;
  right: 1.2rem;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 0.7rem 1.1rem;
  font-size: 0.88rem;
  animation: toast-in 0.25s ease;
}
.toast.error { border-left-color: var(--danger); }
@keyframes toast-in {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* ============================================================
   Admin-Grid
   ============================================================ */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1rem;
  overflow-y: auto;
  padding-bottom: 1rem;
}
.admin-grid .card h3 { font-size: 1rem; margin-bottom: 0.9rem; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.stat {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
}
.stat .v { font-size: 1.35rem; font-weight: 750; color: var(--accent); }
.stat .l { font-size: 0.72rem; color: var(--text-dim); margin-top: 0.15rem; }

.key-row { display: flex; gap: 0.5rem; }
.key-row input { flex: 1; font-family: ui-monospace, monospace; font-size: 0.8rem; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .sidebar {
    order: 2;
    flex-direction: row;
    align-items: center;
    border-right: none;
    border-top: 1px solid var(--border);
    padding: 0.4rem 0.5rem;
    overflow-x: auto;
  }
  .brand, .user-box .who, .sidebar .spacer { display: none; }
  .user-box { border: none; padding: 0.2rem; }
  .nav-btn { flex-direction: column; gap: 0.15rem; font-size: 0.65rem; padding: 0.45rem 0.6rem; }
  .nav-btn svg.ico, .nav-btn svg.lucide { width: 20px; height: 20px; }
  .nav-btn .count { position: absolute; transform: translate(14px, -6px); }
  .panel { padding: 1rem; }
  .msg { max-width: 88%; }
}

/* iOS-Web-App (Home-Bildschirm): Notch & Home-Indicator freihalten */
@media (display-mode: standalone) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}

/* ---------- To-Do-Details (GitHub-artig) ---------- */
.todo-title { cursor: pointer; }
.todo-title:hover { color: var(--accent); }
.todo-item .badge { flex-shrink: 0; }

.todo-modal {
  width: min(640px, 94vw);
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.todo-modal-head { display: flex; justify-content: space-between; align-items: center; }
.todo-modal textarea { resize: vertical; min-height: 90px; font-family: inherit; }
.todo-done-label { display: inline-flex; align-items: center; gap: 0.45rem; color: var(--text-dim); cursor: pointer; }
.todo-comments-head {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.9rem; margin: 0.3rem 0 0;
  border-top: 1px solid var(--border); padding-top: 0.8rem;
}
.todo-comments-head svg.lucide { width: 16px; height: 16px; }

.comment-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; max-height: 260px; overflow-y: auto; }
.comment {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 0.7rem;
}
.comment-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.2rem; }
.comment-user { font-weight: 600; font-size: 0.8rem; color: var(--accent); }
.comment-time { font-size: 0.72rem; color: var(--text-dim); flex: 1; }
.comment-del svg.lucide { width: 14px; height: 14px; }
.comment-text { font-size: 0.86rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-empty { color: var(--text-dim); font-size: 0.85rem; padding: 0.3rem 0; }
