:root {
  --brand: #3b4fa0;
  --brand-dark: #2c3d80;
  --accent: #f2542d;
  --bg: #f2f3f7;
  --card: #ffffff;
  --text: #1c1f2a;
  --muted: #6b7080;
  --line: #e3e5ec;
  --ok: #1e9e5a;
  --warn: #c98a04;
  --bad: #d23b3b;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 16px;
}
#app { max-width: 560px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
#topbar {
  position: sticky; top: 0; z-index: 10; background: var(--card);
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  padding-top: calc(10px + env(safe-area-inset-top));
}
#toplogo { height: 30px; }
#toptitle { font-weight: 700; color: var(--brand); font-size: 18px; }
#view { flex: 1; padding: 14px 14px 90px; }
#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  max-width: 560px; margin: 0 auto; background: var(--card);
  display: flex; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabbar a {
  flex: 1; text-align: center; padding: 8px 0 6px; text-decoration: none;
  color: var(--muted); font-size: 11px; display: flex; flex-direction: column; gap: 2px;
}
#tabbar a .ti { font-size: 20px; line-height: 1; }
#tabbar a.active { color: var(--brand); font-weight: 600; }

h2 { font-size: 20px; margin: 4px 0 12px; }
h3 { font-size: 16px; margin: 18px 0 8px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; margin-bottom: 12px;
}
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.kpi .v { font-size: 20px; font-weight: 700; color: var(--brand); }
.kpi .l { font-size: 12px; color: var(--muted); margin-top: 2px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 13px; }
.pill { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; }
.pill.paid { background: #e3f5ea; color: var(--ok); }
.pill.sent { background: #e8ecf9; color: var(--brand); }
.pill.draft { background: #f4f4f4; color: var(--muted); }
.pill.due { background: #fdf1e3; color: var(--warn); }
.pill.over { background: #fbe4e4; color: var(--bad); }
.pill.flag { background: #fbe4e4; color: var(--bad); }

.btn {
  display: inline-block; border: none; border-radius: 12px; padding: 12px 16px;
  font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none; text-align: center;
  background: var(--brand); color: #fff;
}
.btn:active { opacity: 0.85; }
.btn.secondary { background: #eceef5; color: var(--brand-dark); }
.btn.ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); }
.btn.danger { background: #fbe4e4; color: var(--bad); }
.btn.block { display: block; width: 100%; }
.btnrow { display: flex; gap: 10px; margin-top: 10px; }
.btnrow .btn { flex: 1; }

label.f { display: block; margin-bottom: 10px; }
label.f span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px;
  font-size: 16px; font-family: inherit; background: #fff; color: var(--text);
}
textarea { resize: vertical; }
.list { display: flex; flex-direction: column; gap: 10px; }
.listitem {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; text-decoration: none; color: inherit; display: block;
}
.listitem .t { font-weight: 600; }
table.rep { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
table.rep th, table.rep td { border: 1px solid var(--line); padding: 7px 8px; text-align: right; }
table.rep th:first-child, table.rep td:first-child { text-align: left; }
table.rep th { background: #eceef5; color: var(--brand-dark); }
table.rep tr.tot td { font-weight: 700; background: #f7f8fb; }
.repwrap { overflow-x: auto; border-radius: 12px; }
.fab {
  position: fixed; right: 18px; bottom: 84px; z-index: 9;
  width: 56px; height: 56px; border-radius: 50%; background: var(--brand); color: #fff;
  font-size: 28px; border: none; box-shadow: 0 4px 14px rgba(44,61,128,.35); cursor: pointer;
}
.notice { background: #fff8ec; border: 1px solid #f0d9a8; color: #7a5b12; border-radius: 12px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.menu a { display: flex; justify-content: space-between; align-items: center; padding: 14px 4px; text-decoration: none; color: inherit; border-bottom: 1px solid var(--line); font-weight: 600; }
.menu a:last-child { border-bottom: none; }
.chk { display: flex; gap: 8px; align-items: center; }
.chk input { width: auto; }
#toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 90px; z-index: 50;
  background: #222; color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px;
  display: none;
}
