:root {
  --ink: #16241f;
  --paper: #f7f6f1;
  --card: #ffffff;
  --line: #e2e0d6;
  --accent: #0f6b4f;
  --accent-dark: #0a4f3a;
  --warn: #b4531a;
  --bs-body-font-family: 'Figtree', system-ui, sans-serif;
  --bs-body-color: var(--ink);
  --bs-body-bg: var(--paper);
  --bs-link-color: var(--accent);
  --bs-link-hover-color: var(--accent-dark);
}
body { background: var(--paper); }
.app-nav { background: var(--card); border-bottom: 1px solid var(--line); }
.navbar-brand { font-weight: 700; color: var(--accent) !important; letter-spacing: -.02em; }
.nav-link.active { font-weight: 600; color: var(--accent) !important; }
.btn-primary { --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent);
  --bs-btn-hover-bg: var(--accent-dark); --bs-btn-hover-border-color: var(--accent-dark);
  --bs-btn-active-bg: var(--accent-dark); --bs-btn-active-border-color: var(--accent-dark); }
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 .2rem rgba(15,107,79,.18); }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.invoice-scroll { max-width: 820px; margin: 0 auto; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.invoice-scroll .paper { width: 100%; max-width: 820px; min-width: 0; margin: 0; padding: 40px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.invoice-scroll .inv { min-width: 620px; }

.auth-wrap { max-width: 420px; margin: 4vh auto 0; }
.auth-brand { font-size: 1.6rem; font-weight: 700; color: var(--accent); letter-spacing: -.02em; }
.type-choice input { position: absolute; opacity: 0; }
.type-choice label { display: block; height: 100%; padding: .75rem 1rem; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; background: var(--card); }
.type-choice label small { display: block; color: #6b7a74; }
.type-choice input:checked + label { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.type-choice input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }

.stat { padding: 1rem 1.25rem; }
.stat .label { color: #5d6c66; font-size: .875rem; }
.stat .value { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }
.stat.overdue .value { color: var(--warn); }
.badge-status { font-weight: 600; padding: .35em .65em; border-radius: 999px; font-size: .75rem; }
.st-draft { background: #ebeae3; color: #4a544f; }
.st-sent { background: #dbeaf5; color: #1d4e75; }
.st-paid { background: #d8efe4; color: #0a4f3a; }
.st-overdue { background: #f7e1d3; color: #8a3d10; }
.st-select { border-radius: 999px; font-weight: 600; font-size: .8rem; }

/* Luxe template card in the profile picker */
.type-choice label.tpl-luxe { background: #121212; color: #e7dcc3; border-color: #b8975a; font-family: Georgia, serif; letter-spacing: .5px; }
.type-choice label.tpl-luxe small { color: #b8975a; }
.type-choice input:checked + label.tpl-luxe { box-shadow: 0 0 0 2px #b8975a; }


/* Luxe template card — responsive at phone, tablet and desktop widths */
.type-choice label.tpl-luxe {
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: normal;
}

.type-choice label.tpl-luxe small {
  line-height: 1.35;
  overflow-wrap: anywhere;
}

@media (max-width: 767.98px) {
  .type-choice label.tpl-luxe {
    padding: .7rem .75rem;
    letter-spacing: .25px;
  }

  .type-choice label.tpl-luxe small {
    margin-top: .2rem;
  }
}

/* Root cause of the cramped/overflowing Luxe card: with 4 templates, "col-6" forces
   two cards per row even on narrow phones (~150px of usable width each). Stack every
   type-choice grid (template picker, freelancer/business picker) to one per row below
   480px instead, so no card — especially Luxe's longer label/description — has to be
   squeezed and shrunk to fit. */
@media (max-width: 480px) {
  .type-choice.row > [class*="col-"] {
    flex: 0 0 100%;
    max-width: 100%;
  }

  .type-choice label.tpl-luxe {
    padding: .75rem .9rem;
    font-size: .95rem;
    letter-spacing: .15px;
  }

  .type-choice label.tpl-luxe small {
    font-size: .8rem;
    line-height: 1.35;
  }
}

/* Responsive layout fixes */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

img,
svg,
video,
canvas {
  max-width: 100%;
  height: auto;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.panel {
  min-width: 0;
  overflow-wrap: anywhere;
}

.form-control,
.form-select,
.btn {
  max-width: 100%;
}

@media (max-width: 767.98px) {
  main.container {
    padding-left: 12px;
    padding-right: 12px;
  }

  .navbar .container {
    padding-left: 12px;
    padding-right: 12px;
    flex-wrap: wrap;
  }

  .navbar-brand {
    max-width: calc(100% - 130px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .navbar-user-name { display: inline-block; max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }

  .navbar .navbar-collapse {
    order: 3;
    flex: 0 0 100%;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .navbar .navbar-nav {
    flex-direction: row;
    flex-wrap: nowrap;
    width: max-content;
  }

  .navbar .navbar-nav .nav-link { white-space: nowrap; }
  .navbar-account-actions { order: 2; }

  .invoice-scroll .paper { width: 820px; max-width: none; padding: 24px; }

  .auth-wrap {
    width: 100%;
    max-width: 420px;
    margin-top: 2rem;
  }

  .panel.p-4 {
    padding: 1rem !important;
  }

  .stat {
    padding: .85rem .9rem;
  }

  .stat .value {
    font-size: 1.35rem;
    overflow-wrap: anywhere;
  }

  .display-6 {
    font-size: 2rem;
  }

  .d-flex.justify-content-between.align-items-center {
    flex-wrap: wrap;
    gap: .75rem;
  }

  .btn {
    white-space: normal;
  }

  .type-choice label {
    padding: .7rem .75rem;
  }

  /* Keep wide invoice/item tables usable on narrow screens without
     forcing the entire page wider than the viewport. */
  #itemsTable {
    min-width: 620px;
  }
}

@media (max-width: 575.98px) {
  main.container {
    padding-left: 10px;
    padding-right: 10px;
  }

  .navbar .container {
    padding-left: 10px;
    padding-right: 10px;
  }

  .auth-wrap {
    margin-top: 1rem;
  }

  .panel.p-4 {
    padding: .85rem !important;
  }

  .h3 {
    font-size: 1.35rem;
  }

  .h4 {
    font-size: 1.2rem;
  }

  .h5 {
    font-size: 1.05rem;
  }

  .stat .label {
    font-size: .78rem;
  }

  .stat .value {
    font-size: 1.15rem;
  }

  .type-choice {
    --bs-gutter-x: .5rem;
  }

  .type-choice label {
    padding: .65rem .6rem;
    font-size: .9rem;
  }

  .type-choice label small {
    font-size: .75rem;
  }

  .form-control,
  .form-select {
    font-size: 16px;
  }

  .alert {
    overflow-wrap: anywhere;
  }
}
