/* Bornemann Buchhaltung – mobile PWA. Vanilla CSS, mobil-first, Safe-Area-tauglich. */
:root {
  --gelb: #f5c518;
  --gelb-dark: #d9aa00;
  --ink: #1b1b1d;
  --ink-2: #4a4a4f;
  --ink-3: #8a8a90;
  --bg: #f4f5f7;
  --card: #ffffff;
  --line: #e6e7ea;
  --danger: #c8372d;
  --ok: #2e7d4f;
  --warn: #b6792a;
  --info: #2a6db6;
  --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; }
.neg { color: var(--danger); } .pos { color: var(--ok); } .warn { color: var(--warn); }
.muted { color: var(--ink-3); }
.muted-line { color: var(--ink-3); font-size: .8rem; margin: 2px 4px 12px; }

/* --------------------------- 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: .76rem; line-height: 1.4; }

/* --------------------------- 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); }

/* --------------------------- 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) + 24px); min-height: calc(100vh - var(--bar-h)); }

/* --------------------------- BOTTOM NAV --------------------------- */
.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(4, 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: .66rem; font-weight: 600; }
.nav-item.active { color: var(--gelb); }
.nav-item svg { opacity: .9; }

/* --------------------------- FILTER / SEGMENTS --------------------------- */
.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 {
  flex: 0 0 auto; background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 16px; font-size: .85rem; font-weight: 600; color: var(--ink-2); box-shadow: var(--shadow);
}
.chip.active { background: var(--gelb); border-color: var(--gelb); color: #1b1b1d; }
.segmented { display: flex; background: var(--line); border-radius: 12px; padding: 3px; margin-bottom: 14px; }
.seg { flex: 1; padding: 9px 8px; border-radius: 9px; font-size: .88rem; font-weight: 600; color: var(--ink-2); }
.seg.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

/* --------------------------- LIST CARDS --------------------------- */
.lcard { display: flex; gap: 12px; align-items: center; background: var(--card);
  border-radius: var(--radius); padding: 12px 13px; margin-bottom: 10px; box-shadow: var(--shadow); }
.lcard[data-id]:active { background: #fafafa; }
.lmain { flex: 1; min-width: 0; }
.ltop { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.lname { font-weight: 700; font-size: .98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lamount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lamount.neg { color: var(--danger); } .lamount.pos { color: var(--ok); }
.lzweck { color: var(--ink-2); font-size: .82rem; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lsub { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 5px; color: var(--ink-3); font-size: .78rem; }

.status { font-size: .68rem; font-weight: 700; border-radius: 6px; padding: 2px 7px; white-space: nowrap; }
.st-ok { background: #e3f3ea; color: var(--ok); }
.st-open { background: #e7eefb; color: var(--info); }
.st-info { background: #e7eefb; color: var(--info); }
.st-warn { background: #fff3da; color: var(--warn); }
.st-danger { background: #fbe4e1; color: var(--danger); }
.st-muted { background: #ececef; color: var(--ink-3); }
.chip-tag { background: #f1eede; color: #6c5a18; border-radius: 6px; padding: 1px 7px; font-size: .72rem; font-weight: 600; }

.empty { text-align: center; color: var(--ink-3); padding: 60px 20px; }
.empty svg { opacity: .4; margin-bottom: 12px; }
.skeleton { height: 74px; 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: 6px; }
.kpi { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.kpi .lbl { color: var(--ink-3); font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
.kpi .val { font-size: 1.35rem; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .val.neg { color: var(--danger); } .kpi .val.pos { color: var(--ok); } .kpi .val.warn { color: var(--warn); }
.kpi-sub { color: var(--ink-3); font-size: .74rem; margin-top: 3px; }
.section-title { font-size: .82rem; font-weight: 700; color: var(--ink-3); text-transform: uppercase; margin: 20px 4px 8px; letter-spacing:.03em; }
.card-list { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.card-list .row { display: flex; justify-content: space-between; gap: 10px; padding: 12px 14px;
  border-bottom: 1px solid var(--line); font-size: .92rem; }
.card-list .row:last-child { border-bottom: none; }
.card-list .row .liq { display: flex; gap: 10px; font-variant-numeric: tabular-nums; }

/* --------------------------- SHEET / KV --------------------------- */
.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: 92vh; 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; }
.kv { margin: 0; }
.kv > div { display: flex; justify-content: space-between; gap: 14px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.kv > div:last-child { border-bottom: none; }
.kv dt { color: var(--ink-3); font-size: .85rem; margin: 0; }
.kv dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* --------------------------- TOAST + MENU --------------------------- */
.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); } }
.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); } }
.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; }

/* --------------------------- DARK --------------------------- */
@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 { background:#1e1e21; } .chip-tag{ background:#3a3424; color:#e8d48a; }
  .icon-btn{ background:#2a2a2e; } .segmented{ background:#2a2a2e; } .lcard[data-id]:active{background:#26262a;}
  .st-ok{background:#1f3a2b;} .st-open,.st-info{background:#1e2c44;} .st-warn{background:#3a3119;} .st-danger{background:#3a2320;} .st-muted{background:#2a2a2e;}
}
