/* SplitPot styles. Mobile-first, single column, light and dark themes.
   Visual language: a clean till-roll ledger. Amounts always in tabular
   monospace, right-aligned, with dotted leaders and dashed separators. */

:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #eef0ec;
  --ink: #1c2430;
  --muted: #5e6873;
  --line: #e1e4de;
  --credit: #0e7a6e;
  --credit-soft: #e2f1ee;
  --debit: #b2402a;
  --debit-soft: #f7e8e3;
  --action: #0e7a6e;
  --action-ink: #ffffff;
  --warn: #8a6d1f;
  --warn-soft: #f5edd6;
  --focus: #2a6db5;
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

[data-theme="dark"] {
  --bg: #0f1417;
  --surface: #171e23;
  --surface-2: #1f2830;
  --ink: #e8edef;
  --muted: #94a1a9;
  --line: #28323a;
  --credit: #43c0aa;
  --credit-soft: #143029;
  --debit: #ef8e6d;
  --debit-soft: #38201a;
  --action: #1e9c8c;
  --action-ink: #07211d;
  --warn: #d9b75a;
  --warn-soft: #33290f;
  --focus: #6aa9e8;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #0f1417;
    --surface: #171e23;
    --surface-2: #1f2830;
    --ink: #e8edef;
    --muted: #94a1a9;
    --line: #28323a;
    --credit: #43c0aa;
    --credit-soft: #143029;
    --debit: #ef8e6d;
    --debit-soft: #38201a;
    --action: #1e9c8c;
    --action-ink: #07211d;
    --warn: #d9b75a;
    --warn-soft: #33290f;
    --focus: #6aa9e8;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
}

#app { max-width: 560px; margin: 0 auto; padding: 0 14px 80px; }

a { color: var(--credit); }

button { font: inherit; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---- top bar ---- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  margin: 0 -14px 16px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar .brand {
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: 1.15rem;
  text-decoration: none;
  color: var(--ink);
}
.topbar .brand span { color: var(--credit); }

.topbar .spacer { flex: 1; }

.iconbtn {
  position: relative;
  background: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  padding: 7px 10px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.iconbtn:hover { background: var(--surface); }

.badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--debit);
  color: #fff;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  min-width: 17px;
  height: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ---- general layout ---- */

h1 { font-size: 1.45rem; letter-spacing: -0.02em; margin: 8px 0 4px; }
h2 { font-size: 1.05rem; margin: 22px 0 10px; }

.sub { color: var(--muted); font-size: 0.9rem; margin: 0 0 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.row { display: flex; align-items: center; gap: 10px; }
.row .grow { flex: 1; min-width: 0; }

.stack > * + * { margin-top: 12px; }

/* ---- forms ---- */

label.field { display: block; }
label.field .lab {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
}

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], select, textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}
input.amount { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
  background: var(--action);
  color: var(--action-ink);
  width: 100%;
}
.btn.secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn.danger { background: var(--debit); color: #fff; }
.btn.small { width: auto; padding: 8px 12px; font-size: 0.86rem; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.seg {
  display: flex;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
}
.seg button {
  flex: 1;
  border: none;
  background: none;
  color: var(--muted);
  border-radius: 8px;
  padding: 9px 4px;
  font-weight: 600;
  font-size: 0.86rem;
  cursor: pointer;
}
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.12); }

/* ---- the ledger language ---- */

.amt {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.amt.pos { color: var(--credit); }
.amt.neg { color: var(--debit); }

.leader {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 9px 0;
}
.leader .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leader .dots {
  flex: 1;
  border-bottom: 2px dotted var(--line);
  transform: translateY(-4px);
  min-width: 16px;
}

.ledger-row { border-bottom: 1px dashed var(--line); }
.ledger-row:last-child { border-bottom: none; }

.netline {
  border-left: 4px solid var(--credit);
  padding: 6px 0 6px 12px;
  margin: 12px 0;
}
.netline.neg { border-left-color: var(--debit); }
.netline .net-lab { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.netline .net-amt { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 1.5rem; font-weight: 600; }

/* ---- pot list ---- */

.potcard {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
.potcard:hover { border-color: var(--muted); }
.potcard .pname { font-weight: 700; font-size: 1.05rem; }
.potcard .pmeta { color: var(--muted); font-size: 0.84rem; margin-top: 2px; }

.pill {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 3px 9px;
  background: var(--surface-2);
  color: var(--muted);
}
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.credit { background: var(--credit-soft); color: var(--credit); }
.pill.debit { background: var(--debit-soft); color: var(--debit); }

/* ---- tabs ---- */

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  margin: 14px 0 16px;
  overflow-x: auto;
}
.tabs button {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-weight: 600;
  padding: 9px 12px;
  cursor: pointer;
  white-space: nowrap;
  font-size: 0.92rem;
}
.tabs button.on { color: var(--ink); border-bottom-color: var(--credit); }

/* ---- expenses ---- */

.exp {
  padding: 12px 0;
  cursor: pointer;
}
.exp .desc { font-weight: 600; }
.exp .meta { color: var(--muted); font-size: 0.82rem; margin-top: 1px; }
.exp .detail {
  margin-top: 10px;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 0.9rem;
}
.exp .detail .leader { padding: 7px 0; }

.split-list { margin-top: 4px; }
.split-list .row { padding: 7px 0; border-bottom: 1px dashed var(--line); }
.split-list .row:last-child { border-bottom: none; }
.split-list input[type="number"], .split-list input[type="text"] { width: 104px; padding: 8px 9px; }
.split-list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.hint { font-size: 0.82rem; color: var(--muted); }
.hint.bad { color: var(--debit); font-weight: 600; }
.hint.good { color: var(--credit); font-weight: 600; }

.banner {
  border: 1px solid var(--line);
  border-left: 4px solid var(--warn);
  background: var(--warn-soft);
  color: var(--ink);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 0.92rem;
}

/* ---- settlements ---- */

.setrow { padding: 12px 0; }
.setrow .meta { color: var(--muted); font-size: 0.82rem; }
.setrow .actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

.status { font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.status.pending { color: var(--warn); }
.status.approved { color: var(--credit); }
.status.rejected { color: var(--debit); }
.status.partial { color: var(--warn); }

/* ---- misc ---- */

.code {
  font-family: var(--mono);
  letter-spacing: 0.22em;
  font-size: 1.25rem;
  font-weight: 600;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px 14px;
  text-align: center;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 30px 10px;
  font-size: 0.94rem;
}

.notif { padding: 12px 0; }
.notif.unseen .body { font-weight: 600; }
.notif .when { color: var(--muted); font-size: 0.8rem; margin-top: 2px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--bg);
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: 88vw;
  z-index: 100;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.authwrap { padding-top: 8vh; }
.authwrap .brand-big {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-align: center;
  margin-bottom: 2px;
}
.authwrap .brand-big span { color: var(--credit); }
.authwrap .tagline { text-align: center; color: var(--muted); margin-bottom: 26px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@media (min-width: 700px) {
  body { font-size: 16.5px; }
  #app { padding-top: 6px; }
}
