:root {
  --bg: #0d0d0f;
  --card: #17181c;
  --card2: #1f2026;
  --border: #2a2b33;
  --text: #f2f2f4;
  --muted: #9a9ba6;
  --orange: #0070e8;
  --orange-dark: #0058c0;
  --green: #34c26b;
  --red: #e5484d;
  --amber: #f5a623;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  overscroll-behavior-y: none;
}
#app { display: flex; flex-direction: column; min-height: 100dvh; }

#topbar {
  position: sticky; top: 0; z-index: 20;
  background: #0b2a5b;
  padding: calc(var(--safe-top) + 10px) 16px 10px;
  display: flex; align-items: center; justify-content: center;
  border-bottom: 2px solid var(--orange);
}
#logo { height: 46px; max-width: 72vw; object-fit: contain; }
#logo.plate { background: #fff; padding: 5px 12px; border-radius: 10px; }
.sitecard { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: var(--card); border: 1px solid var(--border); border-left: 4px solid var(--orange); border-radius: 14px; padding: 14px 16px; margin: 4px 0 16px; }
.sitecard .lbl { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.sitecard a:not(.btn) { font-weight: 700; color: var(--text); word-break: break-all; }
.sitecard .sitebtns { display: flex; gap: 8px; }
.sitecard .btn { padding: 9px 16px; font-size: 14px; text-decoration: none; width: auto; display: inline-block; margin: 0; }

#view { flex: 1; padding: 16px 16px calc(90px + var(--safe-bottom)); max-width: 640px; width: 100%; margin: 0 auto; }

#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex;
  background: #0b2a5b;
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}
#tabbar button {
  flex: 1; background: none; border: none; color: var(--muted);
  font-size: 11px; font-weight: 600; padding: 10px 0 8px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  cursor: pointer;
}
#tabbar button .ico { font-size: 22px; line-height: 1; }
#tabbar button.active { color: var(--orange); }

h1 { font-size: 24px; margin: 4px 0 16px; }
h2 { font-size: 17px; margin: 20px 0 10px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px; margin-bottom: 12px;
}
.card.tap { cursor: pointer; }
.card.tap:active { background: var(--card2); }

.statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px; }
.stat .val { font-size: 24px; font-weight: 700; margin-top: 2px; }
.stat .lbl { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat.alert { border-color: var(--red); }
.stat.alert .val { color: var(--red); }
.stat.ok .val { color: var(--green); }
.stat.orange .val { color: var(--orange); }

.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.row .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.amount { font-weight: 700; font-size: 17px; white-space: nowrap; }

.pill {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 10px;
  border-radius: 999px; text-transform: uppercase; letter-spacing: .03em;
}
.pill.draft { background: #33343d; color: #cfd0d8; }
.pill.sent { background: #1e3a5f; color: #7fb8f0; }
.pill.accepted { background: #14371f; color: var(--green); }
.pill.declined { background: #3d1d1e; color: #f08a8d; }
.pill.unpaid { background: #3f2c12; color: var(--amber); }
.pill.part-paid { background: #1e3a5f; color: #7fb8f0; }
.pill.paid { background: #14371f; color: var(--green); }
.pill.overdue { background: #3d1d1e; color: #f08a8d; }

button.btn, a.btn {
  display: block; width: 100%;
  background: var(--orange); color: #fff;
  border: none; border-radius: 14px;
  font-size: 17px; font-weight: 700;
  padding: 16px; margin: 10px 0;
  cursor: pointer;
}
button.btn:active { background: var(--orange-dark); }
button.btn.secondary, a.btn.secondary { background: var(--card2); color: var(--text); border: 1px solid var(--border); }
button.btn.danger { background: none; color: var(--red); border: 1px solid var(--red); }
button.btn.green { background: var(--green); }
button.btn:disabled { opacity: .5; }
.btnrow { display: flex; gap: 10px; }
.btnrow button.btn { flex: 1; }

label.field { display: block; margin-bottom: 14px; }
label.field span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
input, textarea, select {
  width: 100%; background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  font-size: 16px; padding: 14px;
  font-family: inherit;
  -webkit-appearance: none; appearance: none;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--orange); }
textarea { min-height: 80px; resize: vertical; }

.item-row {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px; margin-bottom: 10px; position: relative;
}
.item-row textarea { min-height: 54px; margin-bottom: 8px; background: var(--card2); }
.item-row .nums { display: flex; gap: 8px; }
.item-row .nums input { background: var(--card2); }
.item-row .del {
  position: absolute; top: 6px; right: 6px;
  background: none; border: none; color: var(--red); font-size: 20px; padding: 6px 10px; cursor: pointer;
}

.totalbar {
  display: flex; justify-content: space-between;
  font-size: 18px; font-weight: 700;
  padding: 14px 4px;
}

.empty { text-align: center; color: var(--muted); padding: 40px 20px; }

.backlink { color: var(--orange); font-weight: 600; text-decoration: none; display: inline-block; margin-bottom: 12px; font-size: 15px; cursor: pointer; }

/* login */
#login { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 70dvh; gap: 20px; }
#login img { width: 240px; }
#pin { text-align: center; font-size: 28px; letter-spacing: 12px; max-width: 240px; }
.err { color: var(--red); font-weight: 600; }

.seg { display: flex; background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-bottom: 14px; }
.seg button { flex: 1; background: none; border: none; color: var(--muted); font-size: 14px; font-weight: 700; padding: 12px 0; cursor: pointer; }
.seg button.on { background: var(--orange); color: #fff; }

.toast {
  position: fixed; left: 50%; bottom: calc(100px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--green); color: #0a0a0a;
  font-weight: 700; padding: 12px 22px; border-radius: 999px;
  z-index: 50; box-shadow: 0 4px 20px rgba(0,0,0,.5);
}
.toast.bad { background: var(--red); color: #fff; }

/* --- Pocket Paperwork additions --- */
#topbar { gap: 10px; }
#brandname { font-weight: 800; font-size: 18px; letter-spacing: .01em; color: #fff; }
#logo[hidden] { display: none; }
#login .loginmark { width: 96px; height: 96px; display: block; margin: 0 auto 10px; border-radius: 22px; }
#login .wordmark { font-weight: 800; font-size: 26px; color: #fff; text-align: center; }
#login .wordmark .pp-blue { color: var(--orange); }
#login .wordmark small { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 4px; }
#login input { max-width: 280px; text-align: center; font-size: 20px; }
#login #pin { letter-spacing: 12px; font-size: 28px; }
.hint { font-size: 13px; color: var(--muted); margin-top: -8px; margin-bottom: 12px; }
.swatch { display: inline-block; width: 22px; height: 22px; border-radius: 6px; vertical-align: middle; margin-right: 8px; border: 1px solid var(--border); }
input[type=color] { padding: 4px; height: 52px; }
.logo-preview { max-height: 60px; max-width: 220px; background: #fff; border-radius: 8px; padding: 6px; display: block; margin-bottom: 10px; }
a.btn { display: block; text-align: center; text-decoration: none; background: var(--orange); color: #fff; border-radius: 14px; font-size: 17px; font-weight: 700; padding: 16px; margin: 10px 0; }
a.btn.secondary { background: var(--card2); color: var(--text); border: 1px solid var(--border); }
a.btn.whatsapp { background: #25d366; color: #0a0a0a; border: none; border-radius: 14px; font-size: 17px; font-weight: 700; padding: 16px; margin: 10px 0; }
.banner { background: #3f2c12; color: var(--amber); border: 1px solid #6b4a17; border-radius: 12px; padding: 12px 14px; font-weight: 600; margin-bottom: 12px; font-size: 14px; }

/* expenses */
.receipt-img { display: block; width: 100%; max-height: 360px; object-fit: contain; background: #fff; border-radius: 12px; border: 1px solid var(--border); margin-bottom: 8px; }
.seg.monthnav button { font-size: 15px; }
.seg.monthnav button:disabled { opacity: .35; }
#tabbar button { font-size: 10.5px; }
details.exportbox { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 12px 16px; margin: 12px 0; }
details.exportbox summary { cursor: pointer; font-weight: 700; color: var(--text); list-style: none; }
details.exportbox summary::before { content: '\2913  '; color: var(--orange); }
details.exportbox .seg { margin-bottom: 10px; }
details.exportbox .seg button { font-size: 12px; padding: 10px 0; }
details.exportbox a.btn { margin: 6px 0; }
