/*
 * InvoiceBound Web.
 *
 * The same palette as the marketing site, because a customer who signs in
 * should not feel handed to a different company. Light by default with dark
 * support, and no framework: the whole app is three files, and the CSS is the
 * part most likely to still be readable in a year.
 */

:root {
  --primary: #635bff;
  --primary-deep: #4f46e5;
  --primary-soft: #ebeaff;
  --on-primary: #ffffff;
  --base: #f6f9fc;
  --surface: #ffffff;
  --fill: #eff3f9;
  --text-primary: #1a1f36;
  --text-secondary: #5a6485;
  --text-tertiary: #8a93ad;
  --separator: #e4e9f2;
  --ok-ink: #12805c;
  --ok-fill: #d9f0e7;
  --warn-ink: #8a5a00;
  --warn-fill: #fdf0d5;
  --bad-ink: #b3261e;
  --bad-fill: #fbe3e1;
  --neutral-ink: #5a6485;
  --neutral-fill: #eff3f9;

  --radius-card: 20px;
  --radius-control: 12px;
  --shadow-low: 0 4px 12px rgba(26, 31, 54, 0.06);
  --shadow-card: 0 8px 20px rgba(26, 31, 54, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --base: #0b0d10;
    --surface: #151a21;
    --fill: #191f27;
    --primary: #7a73ff;
    --primary-soft: #20203c;
    --text-primary: #e9eef5;
    --text-secondary: #9aa6ba;
    --text-tertiary: #6f7c92;
    --separator: #242c38;
    --ok-ink: #4bc08c;
    --ok-fill: #0f2c22;
    --warn-ink: #e3b341;
    --warn-fill: #2e2410;
    --bad-ink: #f28b82;
    --bad-fill: #341b1a;
    --neutral-ink: #9aa6ba;
    --neutral-fill: #1c232c;
    --shadow-low: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-card: 0 8px 20px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--base);
  color: var(--text-primary);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.6rem; letter-spacing: -.02em; margin: 0 0 .2rem; }
h2 { font-size: 1.05rem; margin: 0 0 .8rem; }

/* ── Sign-in gate ────────────────────────────────────────────────────────── */

#gate {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: var(--base); padding: 1.5rem; z-index: 50;
}
#gate .box {
  width: min(400px, 100%); background: var(--surface);
  border: 1px solid var(--separator); border-radius: var(--radius-card);
  box-shadow: var(--shadow-card); padding: 2rem; text-align: center;
}
.mark {
  width: 46px; height: 46px; border-radius: 14px; margin: 0 auto 1rem;
  background: var(--primary); color: var(--on-primary);
  display: grid; place-items: center; font-weight: 800; letter-spacing: -.04em;
}

/* Apple's mark is black-on-white in light, white-on-black in dark. */
.apple-button {
  width: 100%; border: 0; border-radius: var(--radius-control);
  background: #000; color: #fff; font-size: .95rem; font-weight: 600;
  padding: .85rem 1rem; cursor: pointer; min-height: 46px;
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
}
@media (prefers-color-scheme: dark) {
  .apple-button { background: #fff; color: #000; }
}
.apple-button:hover { opacity: .9; }

/* Google's own guidance: white surface, its four-colour mark, a real border.
   In dark mode the surface stays light, which is what their brand rules ask
   for and what makes the mark legible. */
.google-button {
  width: 100%; border: 1px solid #dadce0; border-radius: var(--radius-control);
  background: #fff; color: #3c4043; font-size: .95rem; font-weight: 600;
  padding: .85rem 1rem; cursor: pointer; min-height: 46px;
  display: inline-flex; align-items: center; justify-content: center; gap: .6rem;
}
.google-button:hover { background: #f7f8f8; }

/* ── Shell ───────────────────────────────────────────────────────────────── */

#shell { display: none; min-height: 100vh; grid-template-columns: 232px 1fr; }
#shell.ready { display: grid; }

aside {
  border-right: 1px solid var(--separator); background: var(--surface);
  padding: 1.2rem .9rem; display: flex; flex-direction: column; gap: 1.2rem;
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; letter-spacing: -.02em; }
.brand .mark { width: 30px; height: 30px; border-radius: 9px; margin: 0; font-size: .78rem; }

nav { display: flex; flex-direction: column; gap: .15rem; }
nav button {
  text-align: left; border: 0; background: transparent; color: var(--text-secondary);
  font: inherit; font-weight: 500; padding: .6rem .7rem; border-radius: 10px;
  cursor: pointer; min-height: 40px;
}
nav button:hover { background: var(--fill); color: var(--text-primary); }
nav button[aria-current="true"] { background: var(--primary-soft); color: var(--primary-deep); font-weight: 600; }
@media (prefers-color-scheme: dark) {
  nav button[aria-current="true"] { color: var(--text-primary); }
}

aside .foot { margin-top: auto; }

main { padding: 1.8rem 2rem 3rem; max-width: 1100px; }

@media (max-width: 760px) {
  #shell.ready { grid-template-columns: 1fr; }
  aside { border-right: 0; border-bottom: 1px solid var(--separator); }
  nav { flex-direction: row; flex-wrap: wrap; }
  main { padding: 1.2rem 1rem 3rem; }
}

/* ── Pieces ──────────────────────────────────────────────────────────────── */

.head { margin-bottom: 1.3rem; }
.sub { color: var(--text-tertiary); font-size: .88rem; }

.card {
  background: var(--surface); border: 1px solid var(--separator);
  border-radius: var(--radius-card); box-shadow: var(--shadow-low); padding: 1.1rem;
}

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .9rem; margin-bottom: 1.3rem; }
.stat .label { font-size: .74rem; font-weight: 700; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .06em; }
.stat .value { font-size: 1.85rem; font-weight: 700; letter-spacing: -.03em; margin-top: .25rem; }
.stat .hint { font-size: .82rem; color: var(--text-tertiary); }

button.primary {
  border: 0; border-radius: var(--radius-control); background: var(--primary);
  color: var(--on-primary); font: inherit; font-weight: 600;
  padding: .7rem 1.1rem; cursor: pointer; min-height: 44px;
}
button.primary:hover { background: var(--primary-deep); }
button.sm {
  border: 1px solid var(--separator); border-radius: 9px; background: var(--surface);
  color: var(--text-secondary); font: inherit; font-size: .85rem;
  padding: .4rem .7rem; cursor: pointer; min-height: 34px;
}
button.sm:hover { background: var(--fill); color: var(--text-primary); }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
thead th {
  text-align: left; font-size: .74rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-tertiary);
  padding: .7rem 1rem; border-bottom: 1px solid var(--separator); white-space: nowrap;
}
td { padding: .8rem 1rem; border-bottom: 1px solid var(--separator); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--fill); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; color: var(--text-secondary); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.pill {
  display: inline-block; padding: .18rem .55rem; border-radius: 999px;
  font-size: .74rem; font-weight: 700; letter-spacing: .01em;
}
.pill.ok { background: var(--ok-fill); color: var(--ok-ink); }
.pill.warn { background: var(--warn-fill); color: var(--warn-ink); }
.pill.bad { background: var(--bad-fill); color: var(--bad-ink); }
.pill.neutral { background: var(--neutral-fill); color: var(--neutral-ink); }

.toolbar { display: flex; gap: .6rem; align-items: center; margin-bottom: .9rem; flex-wrap: wrap; }
.spacer { flex: 1; }
input, select {
  font: inherit; padding: .55rem .7rem; border-radius: 10px;
  border: 1px solid var(--separator); background: var(--surface); color: var(--text-primary);
  min-height: 42px;
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

.empty { text-align: center; padding: 3rem 1rem; color: var(--text-tertiary); }
.empty .glyph {
  width: 54px; height: 54px; border-radius: 16px; margin: 0 auto .9rem;
  background: var(--fill); display: grid; place-items: center; font-size: 1.4rem;
}
.empty strong { display: block; color: var(--text-primary); font-size: 1rem; margin-bottom: .3rem; }

.loading { color: var(--text-tertiary); padding: 2.5rem; text-align: center; }
.error {
  background: var(--bad-fill); color: var(--bad-ink); padding: .8rem 1rem;
  border-radius: var(--radius-control); font-size: .88rem;
}

.kv { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1.4rem; font-size: .9rem; }
.kv dt { color: var(--text-tertiary); }
.kv dd { margin: 0; }

/* The locked-feature panel. Deliberately shows the shape of what is behind it
   rather than an opaque wall — a gate you cannot see past is easy to ignore. */
.locked {
  position: relative; border: 1px dashed var(--separator);
  border-radius: var(--radius-card); padding: 1.6rem; text-align: center;
  background: var(--fill);
}
.locked .badge {
  display: inline-block; background: var(--primary-soft); color: var(--primary-deep);
  font-size: .74rem; font-weight: 700; padding: .2rem .6rem; border-radius: 999px;
  margin-bottom: .6rem; text-transform: uppercase; letter-spacing: .06em;
}
@media (prefers-color-scheme: dark) { .locked .badge { color: var(--text-primary); } }
