/* Expense Manager v1.0.0 — mobile first.
   Palette lives in this :root block only. */
:root {
  --primary: #D90429;
  --primary-dark: #A8031F;
  --accent: #5C677D;
  --bg: #F2F4F7;
  --surface: #FFFFFF;
  --text: #000000;
  --muted: #5C677D;
  --border: #D5DAE3;
  --success: #000000;
  --danger: #D90429;

  --success-bg: #EEF1F5;
  --danger-bg: #FDE8EC;
  --danger-ink: #A8031F;
  --owing: #D90429;
  --on-primary: #FFFFFF;
  --input: #FFFFFF;
  --placeholder: #5C677D;
  --focus: rgba(217, 4, 41, 0.35);
  --radius: 16px;
  --tap: 48px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 8px 24px rgba(0, 0, 0, .06);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body { min-height: 100dvh; display: flex; flex-direction: column; font-size: 17px; line-height: 1.45; }
a { color: var(--accent); }
main { width: min(100%, 42rem); margin: 0 auto; padding: 1rem 1.1rem 2.5rem; flex: 1; }
h1 { font-size: 1.55rem; margin: .2rem 0 .8rem; letter-spacing: -.02em; }
h2 { font-size: 1.05rem; margin: 1.4rem 0 .6rem; }
p { margin: .4rem 0 .8rem; }
.tagline, .lead, .hint, .muted, .crumb, footer p { color: var(--muted); }
.hint { font-size: .95rem; }
.crumb { margin: 0 0 .8rem; }
.crumb a { text-decoration: none; font-weight: 600; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: .7rem 1.1rem; padding-top: max(.7rem, env(safe-area-inset-top));
  background: var(--primary); color: var(--on-primary);
}
.top .brand {
  color: var(--on-primary); text-decoration: none; font-weight: 700; font-size: 1.05rem;
  display: inline-flex; align-items: center; gap: .5rem;
}
.top .brand img { width: 28px; height: 28px; display: block; flex: none; }
.auth-logo { display: block; width: 72px; height: 72px; margin: 0 auto .9rem; }
.top .link-btn { color: var(--on-primary); }

.auth-card { background: var(--surface); border-radius: 20px; padding: 1.4rem 1.2rem 1.6rem; box-shadow: var(--shadow); margin-top: 1.2rem; }
.auth-card h1 { margin-bottom: .2rem; text-align: center; }
.auth-card .tagline { text-align: center; margin-bottom: 1.2rem; }
.switch { text-align: center; margin-top: 1.1rem; }

label { display: block; font-weight: 650; margin: .85rem 0 .35rem; }
input[type="text"], input[type="password"], input[type="date"], select {
  width: 100%; height: var(--tap); border: 1.5px solid var(--border); border-radius: 12px;
  padding: 0 .9rem; font: inherit; background: var(--input); color: inherit;
}
input::placeholder { color: var(--placeholder); opacity: 1; }
input:focus, select:focus { outline: 3px solid var(--focus); border-color: var(--accent); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%; background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; }

.btn {
  display: block; width: 100%; min-height: var(--tap); border: 0; border-radius: 12px;
  font: inherit; font-weight: 700; text-align: center; text-decoration: none;
  cursor: pointer; padding: .8rem 1rem; margin-top: .9rem;
  -webkit-tap-highlight-color: transparent;
}
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.row-actions { margin: 1rem 0; }
.row-actions.two { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.row-actions.two .btn { margin-top: 0; }

.totals { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; margin: 0 0 1rem; }
.total { background: var(--surface); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); }
.total span { display: block; color: var(--muted); font-size: .85rem; }
.total strong { font-size: 1.2rem; }
.total.pos strong { color: var(--text); }
.total.neg strong { color: var(--owing); }

.stack { display: flex; flex-direction: column; gap: .7rem; }
.card {
  background: var(--surface); border-radius: var(--radius); padding: .95rem 1rem;
  box-shadow: var(--shadow); text-decoration: none; color: inherit; display: block;
}
a.card:hover { outline: 2px solid var(--focus); }
.group-card strong { display: block; font-size: 1.05rem; }
.group-card span { display: block; margin-top: .2rem; }
.pos { color: var(--text); font-weight: 700; }
.neg { color: var(--owing); font-weight: 700; }
.zero { color: var(--muted); }

.tabs {
  display: flex; gap: .2rem; overflow-x: auto; margin: 0 0 1rem; padding: .2rem 0;
  -webkit-overflow-scrolling: touch;
}
.tabs a {
  flex: 1 1 0; text-align: center; text-decoration: none; color: var(--muted);
  font-weight: 650; padding: .7rem .25rem; border-bottom: 3px solid transparent; min-width: 0;
  font-size: .95rem; white-space: nowrap;
}
.tabs a[aria-current="page"] { color: var(--primary); border-bottom-color: var(--primary); }

.flash { border-radius: 12px; padding: .8rem 1rem; margin: 0 0 1rem; font-weight: 600; }
.flash.ok { background: var(--success-bg); color: var(--success); }
.flash.err { background: var(--danger-bg); color: var(--danger-ink); }

.share-list { display: flex; flex-direction: column; gap: .55rem; margin: .6rem 0 1rem; }
.share-row {
  display: flex; align-items: center; gap: .6rem; margin: 0; font-weight: 500;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 12px; padding: .45rem .6rem;
  min-height: var(--tap);
}
.share-row input[type="checkbox"] { width: 1.35rem; height: 1.35rem; accent-color: var(--accent); flex: none; }
.share-row .who { flex: 1; }
.inr-wrap { display: flex; align-items: center; gap: .25rem; color: var(--muted); font-weight: 650; }
.inr-wrap input { width: 6.4rem; height: 2.4rem; text-align: right; padding: 0 .5rem; }
.share-sum { font-weight: 650; min-height: 1.4em; }
.share-sum.bad { color: var(--danger); }
.share-sum.good { color: var(--success); }

.exp-top { display: flex; justify-content: space-between; gap: .8rem; align-items: baseline; }
.amt { font-weight: 700; white-space: nowrap; }
.shares { font-size: .92rem; color: var(--muted); }
.item-actions { display: flex; gap: 1rem; margin-top: .5rem; }
.link-btn {
  background: none; border: 0; color: var(--accent); font: inherit; font-weight: 650;
  cursor: pointer; padding: .4rem 0; min-height: 44px;
}
.item-actions .link-btn { color: var(--danger); }
form.inline { display: inline; margin: 0; }
.deleted { opacity: .55; }
.deleted strong { text-decoration: line-through; }

.people, .balances { list-style: none; padding: 0; margin: 0 0 1rem; }
.people li, .balances li {
  background: var(--surface); border-radius: 12px; padding: .85rem 1rem; margin-bottom: .5rem;
  box-shadow: var(--shadow);
}
.balances li { display: flex; justify-content: space-between; gap: .8rem; align-items: baseline; }
.you { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.suggest { display: flex; justify-content: space-between; align-items: center; gap: .8rem; }
.empty { background: var(--surface); border-radius: var(--radius); padding: 1.1rem; color: var(--muted); }
.more { margin-top: 1rem; }

footer {
  text-align: center;
  flex-shrink: 0;
  padding: 1rem 1.1rem 1.4rem;
  padding-bottom: max(1.4rem, env(safe-area-inset-bottom));
  font-size: .78rem;
  line-height: 1.4;
}
footer p { margin: 0; }
footer .powered { margin-top: .2rem; }
footer .powered a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

@media (min-width: 720px) {
  main { padding-top: 1.6rem; }
  .auth-card { padding: 2rem; }
}
