/* Mobile-Web-Ansicht - selbe Farbpalette wie die Desktop-App (app/gui.py).
   Bewusst hochwertiger gestaltet (Farbverläufe, weiche Schatten, größere
   Radien) - soll sich wie ein "richtiges" Produkt anfühlen, nicht wie ein
   Rohentwurf, ohne dabei von reinem CSS/Systemfonts abzuweichen (keine
   externen Assets - die App bleibt komplett lokal). */
:root {
  --bg: #F5F3EC;
  --bg-alt: #EFEBDF;
  --sidebar-bg: #16231C;
  --sidebar-bg-2: #1D3327;
  --accent: #1F6F4A;
  --accent-light: #E7F0EA;
  --accent-2: #C9A15C;
  --accent-2-light: #F6EEDD;
  --danger: #B14B34;
  --danger-light: #F7E9E5;
  --card-bg: #FFFFFF;
  --card-border: #EAE5D6;
  --text-primary: #1C1C1A;
  --text-muted: #8A8476;
  --chip-bg: #F4F1E6;
  --shadow-sm: 0 1px 2px rgba(28, 28, 26, 0.05), 0 1px 1px rgba(28, 28, 26, 0.04);
  --shadow-md: 0 8px 24px rgba(23, 36, 29, 0.08), 0 2px 6px rgba(23, 36, 29, 0.05);
  --shadow-lg: 0 16px 40px rgba(23, 36, 29, 0.14), 0 4px 10px rgba(23, 36, 29, 0.06);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 9px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

body {
  padding-bottom: calc(78px + env(safe-area-inset-bottom));
  background:
    radial-gradient(1200px 480px at 50% -180px, rgba(31, 111, 74, 0.07), transparent 60%),
    var(--bg);
}

a { color: inherit; text-decoration: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: linear-gradient(155deg, var(--sidebar-bg-2) 0%, var(--sidebar-bg) 70%);
  color: #FFFFFF;
  padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 800; letter-spacing: -0.01em; }
.topbar .sub { font-size: 12px; color: #8FA093; margin-top: 2px; }
.topbar .logout { font-size: 12px; color: #A9B4A9; }

.wrap { padding: 16px 16px 8px; max-width: 640px; margin: 0 auto; }

.hero {
  background: linear-gradient(155deg, var(--sidebar-bg-2) 0%, var(--sidebar-bg) 75%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 18px 18px 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}
.hero::after {
  /* dezenter goldener Glanz oben rechts - rein dekorativ */
  content: "";
  position: absolute;
  top: -60px; right: -40px;
  width: 180px; height: 180px;
  background: radial-gradient(circle, rgba(201, 161, 92, 0.28), transparent 70%);
  pointer-events: none;
}
.hero .stat-label { font-size: 10px; font-weight: 700; letter-spacing: .05em; color: #8FA093; text-transform: uppercase; }
.hero .stat-value { font-size: 20px; font-weight: 800; margin-top: 5px; line-height: 1.25; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.card h2 { font-size: 14.5px; margin: 0 0 8px; font-weight: 800; letter-spacing: -0.005em; }
.card .muted { color: var(--text-muted); font-size: 12.5px; }

.card-feature {
  background:
    linear-gradient(155deg, var(--accent-2-light) 0%, var(--card-bg) 55%);
  border-color: #E9DCBB;
  box-shadow: var(--shadow-md);
}

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.stat-row .box {
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius-md);
  padding: 10px 12px; box-shadow: var(--shadow-sm);
}
.stat-row .box .l { font-size: 9.5px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.stat-row .box .v { font-size: 15.5px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--card-border);
  gap: 10px;
}
.list-row:last-child { border-bottom: none; }
.list-row > div:first-child { flex: 1; min-width: 0; }
.list-row > div:last-child:not(:first-child) { flex-shrink: 0; }
.list-row .name { font-weight: 700; font-size: 14px; }
.list-row .meta { font-size: 12px; color: var(--text-muted); }
.amount-pos { color: var(--accent); font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.amount-neg { color: var(--danger); font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.list-row .name { min-width: 0; overflow-wrap: break-word; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  min-height: 44px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.08s ease, box-shadow 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-accent {
  background: linear-gradient(155deg, #2C8760, var(--accent));
  color: #fff; border-color: var(--accent);
  box-shadow: 0 6px 16px rgba(31, 111, 74, 0.28);
}
.btn-danger-outline { color: var(--danger); border-color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; min-height: 34px; border-radius: 8px; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 5px; color: var(--text-muted); }
.field input, .field select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  background: #fff;
  color: var(--text-primary);
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.form-row { display: flex; gap: 8px; }
.form-row .field { flex: 1; }

.progress-bg { background: var(--chip-bg); border-radius: 8px; height: 12px; overflow: hidden; margin: 8px 0; box-shadow: inset 0 1px 2px rgba(0,0,0,0.05); }
.progress-fill { background: var(--accent); height: 100%; border-radius: 8px; transition: width 0.4s ease; }

.flash {
  background: var(--accent-light);
  color: var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 14px;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.flash.error { background: var(--danger-light); color: var(--danger); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--chip-bg);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  margin: 3px 4px 3px 0;
}

.checkbox-row { display: flex; align-items: center; gap: 10px; }
.checkbox-row input[type="checkbox"] { width: 22px; height: 22px; }

table.plain { width: 100%; border-collapse: collapse; font-size: 13px; }
table.plain th, table.plain td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--card-border); }
table.plain th { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .02em; }

.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(155deg, var(--sidebar-bg-2) 0%, var(--sidebar-bg) 85%);
  display: flex;
  /* Bei vielen Reitern (aktuell 11) passt nicht mehr alles lesbar nebeneinander
     auf ein Handy-Display - lieber horizontal scrollbar als bis zur
     Unleserlichkeit zusammengequetscht. */
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
  box-shadow: 0 -6px 20px rgba(0,0,0,0.2);
}
.bottom-nav::-webkit-scrollbar { display: none; }
.bottom-nav a {
  flex: 0 0 auto;
  min-width: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 9px 6px 8px;
  color: #8FA093;
  font-size: 9.5px;
  font-weight: 700;
  gap: 2px;
  white-space: nowrap;
  position: relative;
}
.bottom-nav a.active { color: #FFFFFF; }
.bottom-nav a.active::before {
  content: "";
  position: absolute;
  top: 2px;
  width: 22px; height: 3px;
  border-radius: 3px;
  background: var(--accent-2);
}
.bottom-nav a .icon { font-size: 18px; line-height: 1; }

.qr-box { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.qr-box img { width: 120px; height: 120px; border-radius: var(--radius-md); border: 1px solid var(--card-border); box-shadow: var(--shadow-sm); }

.login-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 420px at 50% -120px, rgba(31, 111, 74, 0.10), transparent 60%),
    var(--bg);
}
.login-card { max-width: 340px; width: 100%; }
.login-card .brand { text-align: center; margin-bottom: 22px; }
.login-card .brand .icon-circle {
  width: 60px; height: 60px; border-radius: 18px;
  background: linear-gradient(155deg, var(--sidebar-bg-2), var(--sidebar-bg));
  display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; font-size: 28px;
  box-shadow: var(--shadow-lg);
}
.login-card .card { box-shadow: var(--shadow-md); }

.empty-state { color: var(--text-muted); font-size: 13.5px; padding: 10px 0; }

.link-muted { color: var(--text-muted); font-size: 12.5px; text-decoration: underline; }

.month-nav {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-bottom: 14px;
}
.month-nav-btn {
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius-sm);
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; box-shadow: var(--shadow-sm);
}
.month-nav-label { font-size: 14.5px; font-weight: 800; min-width: 130px; text-align: center; }
.month-nav-today {
  color: var(--accent); font-size: 12.5px; font-weight: 700; text-decoration: underline;
  margin-left: 2px;
}
