/* Bornemann Belege – mobile PWA. Vanilla CSS, mobil-first, Safe-Area-tauglich. */
:root {
  --gelb: #f5c518;            /* Bornemann-Gelb-Akzent */
  --gelb-dark: #d9aa00;
  --ink: #1b1b1d;
  --ink-2: #4a4a4f;
  --ink-3: #8a8a90;
  --bg: #f4f5f7;
  --card: #ffffff;
  --line: #e6e7ea;
  --danger: #c8372d;
  --ok: #2e7d4f;
  --warn: #b6792a;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 6px 18px rgba(0,0,0,.06);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  --nav-h: 62px;
  --bar-h: 54px;
  font-size: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  background: var(--bg); color: var(--ink);
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 1rem; }
a { color: var(--gelb-dark); }

/* --------------------------- LOGIN --------------------------- */
.login {
  position: fixed; inset: 0; display: grid; place-items: center;
  padding: calc(24px + var(--safe-top)) 22px calc(24px + var(--safe-bot));
  background: radial-gradient(120% 80% at 50% 0%, #2a2a2e 0%, #161618 70%);
  color: #fff; z-index: 50;
}
.login-card { width: 100%; max-width: 360px; text-align: center; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 8px; }
.brand-logo {
  width: 76px; height: 76px; border-radius: 20px; background: var(--gelb); color: #1b1b1d;
  font-weight: 800; font-size: 40px; display: grid; place-items: center;
  box-shadow: 0 8px 28px rgba(245,197,24,.35);
}
.brand h1 { font-size: 28px; line-height: 1.05; margin: 0; font-weight: 700; }
.brand h1 span { color: var(--gelb); }
.login-sub { color: #b8b8be; margin: 14px 0 26px; }
.login-status { min-height: 22px; margin-top: 16px; color: var(--gelb); font-size: .92rem; }
.login-foot { margin-top: 30px; color: #6a6a70; font-size: .8rem; }

/* --------------------------- BUTTONS --------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 50px; padding: 0 20px; border-radius: 13px; font-size: 1rem; font-weight: 600;
  transition: transform .06s ease, background .15s ease; user-select: none;
}
.btn:active { transform: scale(.98); }
.btn-block { width: 100%; }
.btn-primary { background: var(--gelb); color: #1b1b1d; }
.btn-primary:active { background: var(--gelb-dark); }
.btn-ghost { background: rgba(255,255,255,.08); color: #fff; }
.btn-soft { background: #efeff1; color: var(--ink); }
.btn-danger { background: #fbe9e7; color: var(--danger); }
.btn-row { display: flex; gap: 10px; }

/* --------------------------- APP SHELL --------------------------- */
.app { min-height: 100%; }
.appbar {
  position: sticky; top: 0; z-index: 20;
  height: calc(var(--bar-h) + var(--safe-top)); padding-top: var(--safe-top);
  display: flex; align-items: center; justify-content: space-between;
  padding-left: 18px; padding-right: 14px;
  background: #1b1b1d; color: #fff;
}
.appbar h2 { font-size: 1.18rem; margin: 0; font-weight: 700; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--gelb); color: #1b1b1d;
  font-weight: 700; font-size: .9rem; display: grid; place-items: center;
}
.view {
  padding: 14px 14px calc(var(--nav-h) + var(--safe-bot) + 84px);
  min-height: calc(100vh - var(--bar-h));
}

/* --------------------------- BOTTOM NAV + FAB --------------------------- */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  height: calc(var(--nav-h) + var(--safe-bot)); padding-bottom: var(--safe-bot);
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: #1b1b1d; border-top: 1px solid #2c2c30;
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: #9a9aa0; font-size: .68rem; font-weight: 600;
}
.nav-item.active { color: var(--gelb); }
.nav-item svg { opacity: .9; }
.fab {
  position: fixed; right: 18px; z-index: 26;
  bottom: calc(var(--nav-h) + var(--safe-bot) + 16px);
  width: 58px; height: 58px; border-radius: 18px; background: var(--gelb); color: #1b1b1d;
  display: grid; place-items: center; box-shadow: 0 8px 22px rgba(245,197,24,.45);
}
.fab:active { transform: scale(.95); }

/* --------------------------- BELEGE LIST --------------------------- */
.filterbar {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 12px; margin: -2px -2px 4px;
  scrollbar-width: none;
}
.filterbar::-webkit-scrollbar { display: none; }
.chip-select {
  flex: 0 0 auto; background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 12px; font-size: .85rem; font-weight: 600; color: var(--ink-2); box-shadow: var(--shadow);
}
.chip-select.active { border-color: var(--gelb); color: var(--ink); }

.pull-hint { text-align: center; color: var(--ink-3); font-size: .8rem; padding: 4px 0 10px; }

.beleg-card {
  display: flex; gap: 12px; align-items: center; background: var(--card);
  border-radius: var(--radius); padding: 10px; margin-bottom: 10px; box-shadow: var(--shadow);
}
.beleg-card:active { background: #fafafa; }
.thumb {
  width: 58px; height: 58px; border-radius: 12px; flex: 0 0 auto; object-fit: cover;
  background: #ececef center/24px no-repeat; display: grid; place-items: center; color: var(--ink-3);
  font-size: .7rem; font-weight: 700; overflow: hidden;
}
.beleg-main { flex: 1; min-width: 0; }
.beleg-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.beleg-lief { font-weight: 700; font-size: .98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.beleg-betrag { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.beleg-betrag.neg { color: var(--danger); }
.beleg-betrag.pos { color: var(--ok); }
.beleg-sub { display: flex; gap: 8px; align-items: center; margin-top: 4px; color: var(--ink-3); font-size: .8rem; }
.kat-chip { background: #f1eede; color: #6c5a18; border-radius: 6px; padding: 1px 7px; font-size: .72rem; font-weight: 600; }
.badge { font-size: .68rem; font-weight: 700; border-radius: 6px; padding: 1px 6px; }
.badge.proc { background: #fff3da; color: var(--warn); }
.badge.miss { background: #fbe4e1; color: var(--danger); }
.badge.ok { background: #e3f3ea; color: var(--ok); }

.empty { text-align: center; color: var(--ink-3); padding: 60px 20px; }
.empty svg { opacity: .4; margin-bottom: 12px; }
.skeleton { height: 78px; border-radius: var(--radius); margin-bottom: 10px;
  background: linear-gradient(90deg,#eee 25%,#f6f6f6 37%,#eee 63%); background-size: 400% 100%;
  animation: sk 1.3s ease infinite; }
@keyframes sk { 0%{background-position:100% 0} 100%{background-position:-100% 0} }

/* --------------------------- DASHBOARD --------------------------- */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.kpi {
  background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
}
.kpi.wide { grid-column: 1 / -1; }
.kpi .lbl { color: var(--ink-3); font-size: .76rem; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
.kpi .val { font-size: 1.5rem; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .val.neg { color: var(--danger); } .kpi .val.pos { color: var(--ok); }
.section-title { font-size: .82rem; font-weight: 700; color: var(--ink-3); text-transform: uppercase; margin: 18px 4px 8px; letter-spacing:.03em; }
.kat-row { display: flex; justify-content: space-between; padding: 11px 14px; background: var(--card);
  border-bottom: 1px solid var(--line); font-size: .92rem; }
.kat-row:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.kat-row:last-child { border-radius: 0 0 var(--radius) var(--radius); border-bottom: none; }

/* --------------------------- SHEET / MODAL --------------------------- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  background: var(--bg); border-radius: 20px 20px 0 0; max-height: 94vh; overflow-y: auto;
  padding: 0 0 calc(20px + var(--safe-bot)); box-shadow: 0 -8px 30px rgba(0,0,0,.25);
  animation: rise .24s cubic-bezier(.2,.8,.2,1);
}
@keyframes rise { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: #cfcfd4; margin: 9px auto 4px; }
.sheet-head { position: sticky; top: 0; background: var(--bg); display: flex; align-items: center;
  justify-content: space-between; padding: 6px 16px 10px; z-index: 2; }
.sheet-head h3 { margin: 0; font-size: 1.05rem; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-2); background: #ececef; }
.sheet-body { padding: 4px 16px; }

.preview {
  width: 100%; max-height: 46vh; object-fit: contain; border-radius: 14px; background: #111;
  display: block; margin-bottom: 14px;
}
.preview-pdf { width: 100%; height: 46vh; border: none; border-radius: 14px; background:#fff; margin-bottom:14px; }

.field { margin-bottom: 13px; }
.field label { display: block; font-size: .78rem; font-weight: 600; color: var(--ink-3); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 11px;
  padding: 12px 13px; color: var(--ink); -webkit-appearance: none; appearance: none;
}
.field textarea { min-height: 64px; resize: vertical; }
.field.two { display: flex; gap: 10px; }
.field.two > div { flex: 1; }
.field select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238a8a90' d='M1 1l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 34px; }

/* --------------------------- UPLOAD --------------------------- */
.up-actions { display: grid; gap: 12px; margin-bottom: 8px; }
.up-action {
  display: flex; align-items: center; gap: 14px; background: var(--card); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); text-align: left;
}
.up-action:active { background: #fafafa; }
.up-icon { width: 46px; height: 46px; border-radius: 12px; background: var(--gelb); color:#1b1b1d; display:grid; place-items:center; flex:0 0 auto; }
.up-action .t { font-weight: 700; } .up-action .s { color: var(--ink-3); font-size: .82rem; }

.queue { margin-top: 18px; }
.qitem { display:flex; align-items:center; gap:12px; background:var(--card); border-radius:14px; padding:10px; margin-bottom:10px; box-shadow:var(--shadow); }
.qitem img { width:46px; height:46px; border-radius:10px; object-fit:cover; flex:0 0 auto; }
.qitem .qmain { flex:1; min-width:0; }
.qitem .qname { font-size:.85rem; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.qitem .qstat { font-size:.78rem; margin-top:3px; }
.qstat.run { color: var(--warn); } .qstat.done { color: var(--ok); } .qstat.err { color: var(--danger); }
.spin { width:16px; height:16px; border:2px solid #ddd; border-top-color: var(--gelb-dark); border-radius:50%; display:inline-block; animation: rot .7s linear infinite; vertical-align:-3px; margin-right:5px; }
@keyframes rot { to { transform: rotate(360deg); } }

/* --------------------------- TOAST --------------------------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-bot) + 20px); transform: translateX(-50%);
  background: #1b1b1d; color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 60;
  font-size: .9rem; max-width: 88%; box-shadow: 0 8px 24px rgba(0,0,0,.3); animation: fade .2s ease;
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }
@keyframes fade { from { opacity: 0; transform: translate(-50%, 8px); } }

.menu-list { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.menu-list button { display:flex; width:100%; align-items:center; gap:12px; padding:15px 16px; border-bottom:1px solid var(--line); text-align:left; font-size:.95rem; }
.menu-list button:last-child { border-bottom:none; }
.menu-list .danger { color: var(--danger); }
.user-meta { padding: 4px 4px 16px; }
.user-meta .nm { font-weight: 700; font-size: 1.1rem; }
.user-meta .un { color: var(--ink-3); font-size: .85rem; }

@media (prefers-color-scheme: dark) {
  :root { --bg:#121214; --card:#1e1e21; --line:#2c2c30; --ink:#f2f2f4; --ink-2:#c7c7cc; --ink-3:#85858c; --shadow: 0 1px 2px rgba(0,0,0,.4); }
  .chip-select { background:#1e1e21; } .kat-chip{ background:#3a3424; color:#e8d48a; }
  .icon-btn{ background:#2a2a2e; } .btn-soft{ background:#2a2a2e; color:var(--ink);} .up-action:active,.beleg-card:active{background:#26262a;}
  .field select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2385858c' d='M1 1l5 5 5-5'/%3E%3C/svg%3E"); }
}
