/* MeisterHub — Neon Dark / Cyberpunk Design System */

:root {
  --bg: #05060a;
  --bg-raised: #0b0e16;
  --glass: rgba(20, 25, 38, 0.55);
  --glass-border: rgba(0, 240, 255, 0.16);
  --cyan: #00f0ff;
  --violet: #b026ff;
  --grad: linear-gradient(135deg, var(--cyan), var(--violet));
  --text: #eaf6ff;
  --text-dim: #8b97ac;
  --text-faint: #57627a;
  --success: #00ffa3;
  --warn: #ffd60a;
  --danger: #ff3b6b;
  --radius: 18px;
  --radius-sm: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
::selection { background: var(--violet); color: #fff; }

/* Ambient background: soft radial glow + faint moving grid */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -2;
  background:
    radial-gradient(60vw 60vw at 15% -10%, rgba(0,240,255,0.10), transparent 60%),
    radial-gradient(70vw 70vw at 110% 30%, rgba(176,38,255,0.10), transparent 60%),
    var(--bg);
}
body::after {
  content: "";
  position: fixed; inset: -50%; z-index: -1;
  background-image:
    linear-gradient(rgba(0,240,255,0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,240,255,0.045) 1px, transparent 1px);
  background-size: 48px 48px;
  animation: grid-drift 40s linear infinite;
  mask-image: radial-gradient(80% 60% at 50% 20%, #000, transparent);
}
@keyframes grid-drift {
  from { transform: translate(0, 0); }
  to { transform: translate(48px, 48px); }
}

/* ---------- Layout shell ---------- */
#app { min-height: 100%; }

.app-shell {
  min-height: 100%;
  padding-top: calc(var(--safe-top) + 56px);
  padding-bottom: calc(var(--safe-bottom) + var(--tabbar-h) + 16px);
}

.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  padding-top: var(--safe-top);
  display: flex; align-items: center; justify-content: space-between;
  height: calc(var(--safe-top) + 56px);
  padding-left: 18px; padding-right: 18px;
  background: rgba(5,6,10,0.72);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.topbar .brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: 0.3px; }
.topbar .brand svg { filter: drop-shadow(0 0 6px rgba(0,240,255,0.7)); }
.topbar .actions { display: flex; gap: 10px; align-items: center; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08);
  color: var(--text-dim); cursor: pointer;
}
.icon-btn:active { transform: scale(0.92); }

main.view { padding: 16px 16px 8px; max-width: 720px; margin: 0 auto; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  padding-bottom: var(--safe-bottom);
  display: flex;
  background: rgba(8,10,18,0.78);
  backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255,255,255,0.07);
}
.tabbar a {
  flex: 1; text-decoration: none; text-align: center;
  padding: 9px 0 8px; color: var(--text-faint);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 10.5px; letter-spacing: 0.2px;
  transition: color 0.15s ease;
}
.tabbar a svg { width: 22px; height: 22px; opacity: 0.75; transition: all 0.2s ease; }
.tabbar a.active { color: var(--cyan); }
.tabbar a.active svg { opacity: 1; filter: drop-shadow(0 0 6px rgba(0,240,255,0.85)); transform: translateY(-2px); }

/* ---------- Glass cards ---------- */
.card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.35);
}
.card-tight { padding: 12px 14px; }
.section-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-dim); margin: 22px 2px 10px;
  display: flex; align-items: center; justify-content: space-between;
}

/* ---------- KPI tiles ---------- */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.kpi-tile {
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: var(--radius);
  padding: 16px; position: relative; overflow: hidden;
}
.kpi-tile::before {
  content: ""; position: absolute; inset: 0; opacity: 0.5;
  background: radial-gradient(120px 60px at 10% 0%, rgba(0,240,255,0.12), transparent 70%);
}
.kpi-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.6px; }
.kpi-value {
  font-size: 26px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.kpi-sub { font-size: 11px; color: var(--text-faint); margin-top: 4px; }
.kpi-wide { grid-column: 1 / -1; }

/* ---------- Buttons ---------- */
.btn {
  border: none; border-radius: var(--radius-sm); padding: 13px 18px;
  font-weight: 600; font-size: 14.5px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  color: #041014;
  background: var(--grad);
  box-shadow: 0 6px 24px rgba(0,240,255,0.22), 0 2px 8px rgba(176,38,255,0.18);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); box-shadow: 0 3px 12px rgba(0,240,255,0.18); }
.btn.block { width: 100%; }
.btn.ghost {
  background: rgba(255,255,255,0.05); color: var(--text);
  border: 1px solid rgba(255,255,255,0.12); box-shadow: none;
}
.btn.danger { background: linear-gradient(135deg, #ff3b6b, #ff7a3b); color: #1a0006; }
.btn.sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

.fab {
  position: fixed; right: 18px; bottom: calc(var(--safe-bottom) + var(--tabbar-h) + 18px);
  width: 56px; height: 56px; border-radius: 50%; z-index: 39;
  display: flex; align-items: center; justify-content: center;
  background: var(--grad); box-shadow: 0 8px 28px rgba(0,240,255,0.35), 0 4px 14px rgba(176,38,255,0.3);
  border: none; color: #041014; cursor: pointer;
}
.fab:active { transform: scale(0.94); }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; letter-spacing: 0.2px; }
input, select, textarea {
  width: 100%; background: rgba(255,255,255,0.04); color: var(--text);
  border: 1px solid rgba(255,255,255,0.1); border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: 15px; outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  -webkit-appearance: none; appearance: none;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus {
  border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(0,240,255,0.15), 0 0 16px rgba(0,240,255,0.15);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.hint { font-size: 11.5px; color: var(--text-faint); margin-top: 5px; }
.error-text { color: var(--danger); font-size: 13px; margin: 6px 0 0; min-height: 1em; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; }
.switch { position: relative; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track {
  position: absolute; inset: 0; background: rgba(255,255,255,0.12); border-radius: 999px; transition: background 0.2s;
}
.switch .thumb {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; transition: transform 0.2s ease;
}
.switch input:checked + .track { background: var(--grad); }
.switch input:checked ~ .thumb { transform: translateX(20px); }

/* ---------- Badges / status ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.3px; white-space: nowrap;
  background: rgba(255,255,255,0.06); color: var(--text-dim); border: 1px solid rgba(255,255,255,0.08);
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.offen { color: #9db4ff; }
.badge.in_arbeit { color: var(--warn); }
.badge.in_arbeit .dot { animation: pulse-dot 1.4s ease-in-out infinite; }
.badge.abgeschlossen { color: #9fe8b0; }
.badge.abgerechnet { color: var(--cyan); }
.badge.bezahlt { color: var(--success); }
.badge.gestellt { color: var(--cyan); }
.badge.storniert { color: var(--danger); }
@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 currentColor; }
  50% { opacity: 0.5; box-shadow: 0 0 0 4px transparent; }
}

/* ---------- Lists ---------- */
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 13px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.06); cursor: pointer;
}
.list-item:last-child { border-bottom: none; }
.list-item:active { background: rgba(255,255,255,0.03); }
.list-item .avatar {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
  background: linear-gradient(135deg, rgba(0,240,255,0.18), rgba(176,38,255,0.18));
  display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--cyan);
}
.list-item .main { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .sub { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.list-item .chev { color: var(--text-faint); flex-shrink: 0; }

.empty-state { text-align: center; padding: 40px 16px; color: var(--text-faint); }
.empty-state svg { opacity: 0.4; margin-bottom: 10px; }

.filter-chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 4px; margin-bottom: 4px; }
.chip {
  flex-shrink: 0; padding: 7px 14px; border-radius: 999px; font-size: 13px; cursor: pointer;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08); color: var(--text-dim);
}
.chip.active { background: var(--grad); color: #041014; font-weight: 600; border-color: transparent; }

/* ---------- Photos ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.photo-grid .photo {
  position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1); background: rgba(255,255,255,0.03);
}
.photo-grid .photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-grid .photo .del {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%;
  background: rgba(5,6,10,0.75); color: var(--danger); border: none; display: flex; align-items: center; justify-content: center;
}
.photo-grid .add {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 1.5px dashed rgba(0,240,255,0.35); border-radius: 12px; aspect-ratio: 1;
  color: var(--cyan); font-size: 11px; cursor: pointer; background: rgba(0,240,255,0.04);
}

/* ---------- Positions table ---------- */
.items-table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.items-table th { font-size: 10.5px; text-transform: uppercase; color: var(--text-faint); text-align: left; padding: 6px 4px; font-weight: 500; }
.items-table td { padding: 8px 4px; border-top: 1px solid rgba(255,255,255,0.06); font-size: 13.5px; }
.items-table td.num, .items-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.totals-box { margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.1); }
.totals-box .row { display: flex; justify-content: space-between; font-size: 13.5px; padding: 3px 0; color: var(--text-dim); }
.totals-box .row.grand { color: var(--text); font-weight: 700; font-size: 16px; margin-top: 4px; }

/* ---------- Charts ---------- */
.chart-wrap { margin-top: 8px; }
.chart-wrap svg .bar { fill: url(#barGrad); }
.chart-wrap svg .line-path { fill: none; stroke: var(--cyan); stroke-width: 2.5; filter: drop-shadow(0 0 6px rgba(0,240,255,0.6)); }
.chart-wrap svg .axis-label { fill: var(--text-faint); font-size: 9px; }

/* ---------- Auth / Setup screen ---------- */
.auth-screen {
  min-height: 100dvh; display: flex; flex-direction: column; justify-content: center;
  padding: 32px 24px calc(32px + var(--safe-bottom)); padding-top: calc(32px + var(--safe-top));
}
.auth-logo { display: flex; flex-direction: column; align-items: center; margin-bottom: 30px; }
.auth-logo .ring {
  width: 84px; height: 84px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  border: 1.5px solid rgba(0,240,255,0.35); position: relative; margin-bottom: 14px;
  animation: logo-pulse 2.6s ease-in-out infinite;
}
.auth-logo .ring::before {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  border: 1px solid rgba(176,38,255,0.25);
}
.auth-logo svg { filter: drop-shadow(0 0 14px rgba(0,240,255,0.75)); }
.auth-logo h1 {
  font-size: 22px; letter-spacing: 1.5px; margin: 0; font-weight: 800;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.auth-logo p { color: var(--text-faint); font-size: 12.5px; margin-top: 4px; letter-spacing: 0.3px; }
@keyframes logo-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0,240,255,0.25); }
  50% { box-shadow: 0 0 0 10px rgba(0,240,255,0); }
}
.auth-card { max-width: 380px; width: 100%; margin: 0 auto; }
.auth-switch { text-align: center; margin-top: 18px; font-size: 13.5px; color: var(--text-dim); }
.auth-switch a { color: var(--cyan); font-weight: 600; text-decoration: none; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(2,3,6,0.7); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; z-index: 60; animation: fade-in 0.15s ease;
}
.modal-backdrop.center { align-items: center; padding: 20px; }
.modal-sheet {
  width: 100%; max-height: 88dvh; overflow-y: auto;
  background: var(--bg-raised); border-radius: 22px 22px 0 0;
  border: 1px solid rgba(255,255,255,0.08); border-bottom: none;
  padding: 18px 18px calc(18px + var(--safe-bottom));
  animation: sheet-up 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.modal-backdrop.center .modal-sheet {
  border-radius: 20px; border-bottom: 1px solid rgba(255,255,255,0.08); max-width: 420px;
  animation: pop-in 0.16s ease;
}
.modal-handle { width: 36px; height: 4px; background: rgba(255,255,255,0.18); border-radius: 4px; margin: 0 auto 14px; }
.modal-title { font-size: 17px; font-weight: 700; margin: 0 0 14px; }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes pop-in { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Toast ---------- */
.toast-root {
  position: fixed; top: calc(var(--safe-top) + 10px); left: 0; right: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.toast {
  background: var(--bg-raised); border: 1px solid var(--glass-border); color: var(--text);
  padding: 11px 18px; border-radius: 999px; font-size: 13.5px; box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  animation: toast-in 0.2s ease;
}
.toast.error { border-color: rgba(255,59,107,0.5); color: #ffb0c3; }
.toast.success { border-color: rgba(0,255,163,0.4); color: #b8ffe3; }
@keyframes toast-in { from { transform: translateY(-12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------- Loading / boot ---------- */
.boot-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 18px; background: var(--bg); z-index: 200;
}
.boot-logo svg { filter: drop-shadow(0 0 16px rgba(0,240,255,0.7)); }
.boot-ring {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2.5px solid rgba(0,240,255,0.18); border-top-color: var(--cyan);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(4,16,20,0.3); border-top-color: #041014; animation: spin 0.7s linear infinite; display: inline-block; }

/* ---------- View transitions ---------- */
.view { animation: view-in 0.22s cubic-bezier(0.2, 0.85, 0.3, 1); }
@keyframes view-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Utility ---------- */
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack-gap { display: flex; flex-direction: column; gap: 12px; }
.text-dim { color: var(--text-dim); }
.text-faint { color: var(--text-faint); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  body::after { animation: none; }
}
