/* App shell: nav rail / bottom bar, module header, boot + login screens. */

.app {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
}
.app.is-ready { display: block; }

/* ── Navigation ──────────────────────────────────────────────────────────
   One <nav>, two layouts, zero duplicate DOM. Bottom bar on phones because
   the highest-frequency action is logging a spend, and that belongs at thumb
   height. Left rail on desktop because each module already wants its own
   horizontal toolbar and top tabs would stack two bars. */
.nav {
  position: fixed;
  z-index: 40;
  background: var(--surface);
  display: flex;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  background: none;
  border: 0;
  color: var(--ink-3);
  text-decoration: none;
  transition: color 120ms var(--ease);
}
.nav-item .nav-icon { display: block; width: 22px; height: 22px; }
.nav-item.is-active { color: var(--accent); }
.nav-item:hover { color: var(--ink); }
.nav-item.is-active:hover { color: var(--accent); }

.nav-label { font-size: var(--t-micro); font-weight: 500; }

/* phone: bottom bar */
@media (max-width: 899px) {
  .nav {
    left: 0; right: 0; bottom: 0;
    height: calc(var(--bar-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    border-top: 1px solid var(--rule);
    justify-content: space-around;
    align-items: stretch;
  }
  .nav-item {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: var(--s-1) 0;
  }
  /* There is no rail footer on a phone, so secondary items flow into the bar
     rather than disappearing — display:none here left admin unreachable on
     mobile entirely. `contents` keeps them as direct flex children. */
  .nav-rail-foot { display: contents; }
  .app-main { padding-bottom: calc(var(--bar-h) + var(--safe-bottom) + var(--s-5)); }
}

/* desktop: left rail */
@media (min-width: 900px) {
  .nav {
    top: 0; bottom: 0; left: 0;
    width: var(--rail-w);
    padding: var(--s-5) 0 var(--s-4);
    padding-left: var(--safe-left);
    border-right: 1px solid var(--rule);
    flex-direction: column;
    align-items: stretch;
    gap: var(--s-1);
  }
  .nav-item {
    flex-direction: column;
    gap: 4px;
    padding: var(--s-3) var(--s-1);
  }
  /* Admin is not a peer tab — it sits in the rail footer so the three money
     modules stay the primary axis. */
  .nav-rail-foot { margin-top: auto; display: flex; flex-direction: column; }
  .app-main { margin-left: var(--rail-w); }
}

/* ── Module header ───────────────────────────────────────────────────────
   One large amount, one short label, one rule whose width encodes progress.
   Same position in every module; only the meaning changes. This is the one
   place boldness is spent. */
.app-main {
  padding: var(--s-5) var(--s-4) 0;
  padding-left: max(var(--s-4), var(--safe-left));
  padding-right: max(var(--s-4), var(--safe-right));
  max-width: 1100px;
}
@media (min-width: 900px) {
  .app-main { padding: var(--s-6) var(--s-6) var(--s-6); }
}

.headline { margin-bottom: var(--s-5); }

.headline-module {
  font-size: var(--t-label);
  font-weight: 500;
  color: var(--ink-3);
  margin-bottom: var(--s-2);
}

.hero-amount {
  font-size: var(--t-hero);
  font-weight: 600;
  font-stretch: 115%;          /* the gesture: wider, not just bigger */
  font-variation-settings: "wdth" 115;
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--ink);
}

.headline-label {
  margin-top: var(--s-2);
  font-size: var(--t-small);
  color: var(--ink-2);
}

/* Not decoration: the width is the progress. */
.headline-meter {
  margin-top: var(--s-3);
  height: 2px;
  width: 160px;
  max-width: 100%;
  background: var(--rule);
  border-radius: 2px;
  overflow: hidden;
}
.headline-meter > i {
  display: block;
  height: 100%;
  width: var(--pct, 0%);
  background: var(--accent);
  transition: width 320ms var(--ease);
}

.module-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-bottom: var(--s-5);
}

/* ── Module mount ────────────────────────────────────────────────────────
   The only orchestrated motion: the content crossfades, the nav and header
   never move. */
#module-root { animation: module-in 140ms var(--ease); }
@keyframes module-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ── Boot and login ──────────────────────────────────────────────────────── */
.boot, .login {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--canvas);
  padding: var(--s-5);
  z-index: 100;
}

.spinner {
  width: 26px; height: 26px;
  border: 2px solid var(--rule);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.login-card { width: 100%; max-width: 360px; text-align: left; }

.login-mark {
  font-size: var(--t-h1);
  font-weight: 600;
  font-variation-settings: "wdth" 115;
  letter-spacing: -0.02em;
  margin-bottom: var(--s-2);
}
.login-blurb { color: var(--ink-2); font-size: var(--t-small); margin-bottom: var(--s-5); }

.login-error {
  background: var(--out-dim);
  color: var(--out);
  border-radius: var(--r-1);
  padding: var(--s-3);
  font-size: var(--t-small);
  margin-bottom: var(--s-4);
}

/* ── No access ───────────────────────────────────────────────────────────── */
.no-access {
  max-width: 420px;
  margin: var(--s-7) auto;
  text-align: left;
}

/* ── Read-only degradation ───────────────────────────────────────────────
   Modules mark their create/edit/delete affordances [data-write] and never
   branch on permissions themselves. This is cosmetic only — the server is
   authoritative. */
[data-access="read"] [data-write] { display: none !important; }
