/* Bookkeeping — mobile-first stylesheet. One file, no build step. */
:root {
  --brand: #1a73e8;
  --brand-dark: #1558b0;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e2e6ee;
  --green: #0f7b3d;
  --red: #c0392b;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
}
#app { max-width: 960px; margin: 0 auto; padding: 0 12px 48px; }
.loading { text-align: center; color: var(--muted); margin-top: 40px; }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 4px; flex-wrap: wrap;
}
.topbar h1 { font-size: 1.15rem; margin: 0; flex: 1; min-width: 120px; }
.topbar .brand { color: var(--brand); font-weight: 700; }
.linklike {
  background: none; border: none; color: var(--brand); cursor: pointer;
  font-size: 0.95rem; padding: 6px 4px; text-decoration: none;
}
.linklike:hover { text-decoration: underline; }

/* Tabs */
.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 4px 2px 10px; }
.tabs a {
  padding: 8px 14px; border-radius: 999px; text-decoration: none;
  color: var(--text); background: var(--card); border: 1px solid var(--border);
  white-space: nowrap; font-size: 0.95rem;
}
.tabs a.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin: 10px 0;
}
.card h2, .card h3 { margin: 0 0 10px; font-size: 1.05rem; }

/* Summary tiles */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 10px 0; }
.tile {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; text-align: center;
}
.tile .label { font-size: 0.8rem; color: var(--muted); }
.tile .value { font-size: 1.25rem; font-weight: 700; margin-top: 4px; }
.tile.income .value { color: var(--green); }
.tile.expense .value { color: var(--red); }

/* Tables */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f0f5ff; }
.pos { color: var(--green); } .neg { color: var(--red); }

/* Forms */
label { display: block; font-size: 0.85rem; color: var(--muted); margin: 8px 0 4px; }
input[type=text], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%; padding: 10px; font-size: 1rem;
  border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text);
}
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }
button, .btn {
  display: inline-block; padding: 10px 18px; font-size: 1rem; border-radius: 8px;
  border: 1px solid var(--brand); background: var(--brand); color: #fff; cursor: pointer;
  text-decoration: none; text-align: center;
}
button:hover, .btn:hover { background: var(--brand-dark); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.secondary, .btn.secondary { background: #fff; color: var(--brand); }
button.danger, .btn.danger { background: #fff; color: var(--red); border-color: var(--red); }
button.danger:hover { background: var(--red); color: #fff; }
button.small { padding: 6px 10px; font-size: 0.85rem; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* Entry lines editor */
.linelist { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.linerow {
  display: grid; grid-template-columns: 1fr 110px 110px 34px; gap: 6px; align-items: end;
}
.linerow input { min-width: 0; }
.totals { display: flex; justify-content: flex-end; gap: 18px; margin-top: 8px; font-weight: 600; }
.totals .ok { color: var(--green); } .totals .bad { color: var(--red); }

/* Journal entries */
.entry { border: 1px solid var(--border); border-radius: var(--radius); background: #fff; margin: 10px 0; }
.entry-head { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.entry-head .date { font-weight: 700; }
.entry-head .memo { flex: 1; min-width: 140px; }
.entry-head .ref { color: var(--muted); font-size: 0.85rem; }
.entry table { margin: 0; }
.entry-actions { padding: 8px 12px; display: flex; gap: 8px; justify-content: flex-end; }

/* Filters */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.filters > div { flex: 1 1 140px; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.presets button { padding: 6px 12px; font-size: 0.85rem; }
.presets button.on { background: var(--brand-dark); }

/* Auth */
.authwrap { max-width: 420px; margin: 60px auto 0; }
.error {
  background: #fdecea; color: var(--red); border: 1px solid #f5c6cb;
  border-radius: 8px; padding: 10px; margin: 10px 0;
}
.success {
  background: #e6f4ea; color: var(--green); border: 1px solid #a3d9b1;
  border-radius: 8px; padding: 10px; margin: 10px 0;
}
.muted { color: var(--muted); font-size: 0.9rem; }
.badge {
  display: inline-block; font-size: 0.75rem; padding: 2px 8px; border-radius: 999px;
  background: #e8f0fe; color: var(--brand); font-weight: 600;
}
.badge.gray { background: #eef0f4; color: var(--muted); }
.badge.red { background: #fdecea; color: var(--red); }
.dangerzone { border: 1px solid #f5c6cb; }
.dangerzone h3 { color: var(--red); }

@media (max-width: 560px) {
  .tiles { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
  .tile .value { font-size: 1.05rem; }
  .linerow { grid-template-columns: 1fr 96px 96px 32px; }
}
