/* ============================================================
   Invoicr — app styles
   Bootstrap 5 base + the tracker design language
   ============================================================ */

:root {
  --brand:       #0f7a63;
  --brand-dark:  #0b5c4b;
  --brand-soft:  #e7f4f0;
  --ink:         #101828;
  --muted:       #667085;
  --line:        #e6e8ec;
  --bg:          #f7f8fa;
  --radius:      .8rem;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: .925rem;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4, h5 { letter-spacing: -.015em; font-weight: 700; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.03rem; }

/* ---------- Kicker ---------- */
.kicker {
  display: block;
  text-transform: uppercase;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .09em;
  color: var(--muted);
  margin-bottom: .15rem;
}

/* ---------- Navbar ---------- */
.navbar-app {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: .55rem 0;
}
.navbar-app .navbar-brand {
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.navbar-app .navbar-brand .brand-mark {
  width: 30px; height: 30px;
  border-radius: .55rem;
  background: var(--brand);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .95rem;
}
.navbar-app .nav-link {
  color: var(--muted);
  font-weight: 600;
  font-size: .875rem;
  padding: .4rem .75rem;
  border-radius: .5rem;
}
.navbar-app .nav-link:hover { color: var(--ink); background: #f2f4f7; text-decoration: none; }
.navbar-app .nav-link.active { color: var(--brand); background: var(--brand-soft); }

.app-shell { max-width: 1280px; margin: 0 auto; padding: 1.6rem 1rem 4rem; }

/* ---------- Cards ---------- */
.app-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.app-card > .app-card-head {
  padding: .9rem 1.1rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.app-card > .app-card-head h2,
.app-card > .app-card-head h3 { margin: 0; }
.app-card > .app-card-body { padding: 1.1rem; }
.app-card > .app-card-foot {
  padding: .8rem 1.1rem;
  border-top: 1px solid var(--line);
  background: #fbfcfd;
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ---------- Clickable stat / filter cards ---------- */
.stat-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: .9rem .6rem;
  text-align: center;
  text-decoration: none;
  color: inherit;
  display: block;
  height: 100%;
  transition: box-shadow .15s ease, border-color .15s ease, transform .15s ease;
}
.stat-card:hover {
  box-shadow: 0 6px 14px rgba(16,24,40,.08);
  transform: translateY(-2px);
  color: inherit;
  text-decoration: none;
}
.stat-card.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(15,122,99,.15);
}
.stat-card .stat-card-num {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.1;
}
.stat-card .stat-card-sub {
  font-size: .74rem;
  font-weight: 600;
  color: var(--muted);
}
.stat-card .stat-card-label {
  font-size: .72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-top: .2rem;
}
.sc-draft    { background: #f9fafb; }
.sc-scheduled{ background: #eef4ff; }
.sc-sent     { background: #f0f9ff; }
.sc-overdue  { background: #fef3f2; }
.sc-paid     { background: #ecfdf3; }
.sc-total    { background: var(--brand-soft); }

/* ---------- List rows ---------- */
.list-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .8rem 1.1rem;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
  transition: background .1s ease;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: #fafbfc; color: inherit; text-decoration: none; }
.list-row .lr-main { flex: 1 1 auto; min-width: 0; }
.list-row .lr-title { font-weight: 700; }
.list-row .lr-sub { font-size: .8rem; color: var(--muted); }

/* ---------- Tables ---------- */
.table-app { margin: 0; }
.table-app > thead > tr > th {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  font-weight: 700;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding: .7rem 1.1rem;
  background: #fbfcfd;
  white-space: nowrap;
}
.table-app > tbody > tr > td {
  padding: .75rem 1.1rem;
  border-bottom: 1px solid #f1f3f5;
  vertical-align: middle;
}
.table-app > tbody > tr:last-child > td { border-bottom: none; }
.table-app > tbody > tr.row-link { cursor: pointer; }
.table-app > tbody > tr.row-link:hover { background: #fafbfc; }
.table-app .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Pills ---------- */
.pill {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
}
.st-draft     { background: #f2f4f7; color: #475467; }
.st-scheduled { background: #eef4ff; color: #3538cd; }
.st-sent      { background: #e0f2fe; color: #026aa2; }
.st-partpaid  { background: #fef7c3; color: #854a0e; }
.st-paid      { background: #d1fadf; color: #05603a; }
.st-overdue   { background: #fee4e2; color: #b42318; }
.st-void      { background: #f2f4f7; color: #98a2b3; text-decoration: line-through; }
.st-pending   { background: #f2f4f7; color: #475467; }
.st-failed    { background: #fee4e2; color: #b42318; }
.st-cancelled { background: #f2f4f7; color: #98a2b3; }
.st-skipped   { background: #f2f4f7; color: #98a2b3; }

/* ---------- Buttons ---------- */
.btn { font-weight: 600; font-size: .875rem; border-radius: .55rem; }
.btn-brand {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn-brand:hover, .btn-brand:focus {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  color: #fff;
}
.btn-outline-brand { border-color: var(--brand); color: var(--brand); }
.btn-outline-brand:hover { background: var(--brand); color: #fff; }
.btn-soft { background: #f2f4f7; border-color: transparent; color: #344054; }
.btn-soft:hover { background: #e4e7ec; color: #101828; }

/* ---------- Forms ---------- */
.form-label { font-size: .78rem; font-weight: 700; color: #344054; margin-bottom: .25rem; }
.form-control, .form-select {
  border-color: #d0d5dd;
  border-radius: .55rem;
  font-size: .9rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15,122,99,.12);
}
.form-text { font-size: .76rem; }
.form-section-title {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 800;
  color: var(--muted);
  margin: 1.4rem 0 .6rem;
  padding-bottom: .35rem;
  border-bottom: 1px solid var(--line);
}
.form-section-title:first-child { margin-top: 0; }

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}
.empty i { font-size: 2rem; opacity: .35; display: block; margin-bottom: .5rem; }

/* ---------- Misc ---------- */
.muted { color: var(--muted); }
.mono  { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82rem; }
.small-cap { font-size: .74rem; color: var(--muted); font-weight: 600; }
.divider-y { border-left: 1px solid var(--line); }
.avatar-sq {
  width: 34px; height: 34px; border-radius: .5rem;
  background: var(--brand-soft); color: var(--brand-dark);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .8rem; flex: 0 0 auto;
}

/* Line item editor */
.item-row td { padding: .45rem .4rem; vertical-align: top; }
.item-row .form-control { font-size: .86rem; }
.items-table > thead > tr > th {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 700; padding: .4rem;
  border-bottom: 1px solid var(--line);
}
.drag-handle { cursor: grab; color: #d0d5dd; }

/* Timeline */
.timeline { position: relative; padding-left: 1.25rem; }
.timeline::before {
  content: ''; position: absolute; left: .32rem; top: .35rem; bottom: .35rem;
  width: 2px; background: var(--line);
}
.timeline-item { position: relative; padding: 0 0 .9rem 0; }
.timeline-item::before {
  content: ''; position: absolute; left: -1.02rem; top: .35rem;
  width: .55rem; height: .55rem; border-radius: 50%;
  background: #fff; border: 2px solid var(--brand);
}
.timeline-item .ti-time { font-size: .72rem; color: var(--muted); }

/* Schedule rule strip */
.rule-strip {
  display: flex; align-items: center; gap: .7rem;
  padding: .7rem .9rem; border: 1px solid var(--line);
  border-radius: .6rem; background: #fff; margin-bottom: .5rem;
}
.rule-when {
  flex: 0 0 auto; min-width: 118px; font-weight: 800; font-size: .8rem;
  color: var(--brand-dark); background: var(--brand-soft);
  padding: .25rem .55rem; border-radius: .4rem; text-align: center;
}
.rule-when.before { color: #3538cd; background: #eef4ff; }
.rule-when.on     { color: #854a0e; background: #fef7c3; }
.rule-when.after  { color: #b42318; background: #fee4e2; }

/* Merge tag chips */
.tag-chip {
  display: inline-block; font-family: ui-monospace, monospace; font-size: .72rem;
  background: #f2f4f7; border: 1px solid var(--line); border-radius: .35rem;
  padding: .08rem .35rem; margin: 0 .2rem .3rem 0; cursor: pointer; color: #344054;
}
.tag-chip:hover { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); }

/* Public invoice page */
.public-wrap { max-width: 880px; margin: 0 auto; padding: 2rem 1rem 4rem; }
.inv-paper {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 2.2rem;
  box-shadow: 0 1px 3px rgba(16,24,40,.06);
}
.inv-logo { max-height: 72px; max-width: 260px; }
.inv-total-row td { border-top: 2px solid var(--ink) !important; font-weight: 800; }

@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .inv-paper { border: none; box-shadow: none; padding: 0; }
}

@media (max-width: 576px) {
  .app-shell { padding: 1rem .75rem 3rem; }
  .stat-card { padding: .7rem .35rem; }
  .stat-card .stat-card-num { font-size: 1.1rem; }
  .table-app > thead > tr > th,
  .table-app > tbody > tr > td { padding: .6rem .7rem; }
}
