:root {
  color: #17221d;
  background: #f4f3ed;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
  font-synthesis: none;
  --forest: #173f35;
  --deep: #0f2d26;
  --mint: #9ae6c8;
  --lime: #c4f36b;
  --cream: #f4f3ed;
  --paper: #fbfaf6;
  --ink: #17221d;
  --muted: #69746f;
  --line: #dce0d8;
  --danger: #9d3e31;
  --warn: #9a5d19;
  --shadow: 0 16px 50px rgba(26, 49, 40, 0.08);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid #65c9a5;
  outline-offset: 2px;
}
a {
  color: inherit;
  text-decoration: none;
}
.boot {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  color: var(--muted);
}
.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--lime);
  color: var(--deep);
  font-weight: 900;
}
.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(340px, 1.05fr) minmax(420px, 0.95fr);
}
.auth-story {
  padding: clamp(38px, 7vw, 96px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: radial-gradient(circle at 80% 15%, #2a5a4c, var(--deep) 55%, #071a15);
  color: white;
}
.wordmark {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
}
.wordmark small {
  display: block;
  margin-top: 2px;
  color: #8aa69b;
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.auth-copy {
  max-width: 650px;
}
.eyebrow {
  color: var(--mint);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}
.auth-copy h1 {
  max-width: 680px;
  margin: 18px 0;
  font-size: clamp(42px, 6vw, 78px);
  line-height: 0.98;
  letter-spacing: -0.055em;
}
.auth-copy p {
  max-width: 600px;
  color: #c7d9d2;
  line-height: 1.75;
}
.auth-foot {
  color: #819b91;
  font-size: 11px;
}
.auth-panel {
  padding: clamp(30px, 7vw, 90px);
  display: grid;
  place-content: center;
  background: var(--paper);
}
.auth-card {
  width: min(440px, 100%);
}
.auth-card h2 {
  margin: 8px 0 10px;
  font-size: 32px;
  letter-spacing: -0.035em;
}
.auth-card > p {
  margin: 0 0 28px;
  color: var(--muted);
  line-height: 1.55;
}
.form {
  display: grid;
  gap: 17px;
}
label {
  display: grid;
  gap: 7px;
  color: #44514b;
  font-size: 12px;
  font-weight: 750;
}
input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border: 1px solid #cbd2cc;
  border-radius: 9px;
  background: white;
  color: var(--ink);
}
textarea {
  min-height: 88px;
  resize: vertical;
}
input:focus,
select:focus,
textarea:focus {
  border-color: #4caa88;
  box-shadow: 0 0 0 4px rgba(76, 170, 136, 0.1);
  outline: 0;
}
.button {
  min-height: 44px;
  padding: 10px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--forest);
  color: white;
  font-weight: 800;
  cursor: pointer;
}
.button:hover {
  background: var(--deep);
}
.button:disabled {
  opacity: 0.55;
  cursor: wait;
}
.button.secondary {
  border: 1px solid #bdc8c0;
  background: transparent;
  color: var(--forest);
}
.button.secondary:hover {
  background: #edf2ee;
}
.button.ghost {
  background: transparent;
  color: var(--forest);
}
.button.danger {
  background: #f9e8e5;
  color: var(--danger);
}
.button.small {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 11px;
}
.form-message,
.notice {
  padding: 12px 14px;
  border-radius: 8px;
  background: #fce8e4;
  color: #8e3528;
  font-size: 12px;
  line-height: 1.5;
}
.form-message {
  margin-bottom: 18px;
}
.form-message.success {
  background: #e4f5ec;
  color: #256347;
}
.auth-links {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  font-weight: 750;
}
.auth-links a {
  color: var(--forest);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.field-help {
  margin-top: -10px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}
.notice.success {
  background: #e4f5ec;
  color: #256347;
}
.profile-notice {
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff0dc;
  color: var(--warn);
}
.profile-notice span {
  flex: 1;
}
.security-note {
  margin-top: 20px;
  color: #87918c;
  font-size: 11px;
}
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  background: var(--deep);
  color: #d5e1dc;
}
.sidebar .wordmark {
  padding: 0 10px 22px;
}
.sidebar-nav {
  display: grid;
  gap: 4px;
}
.nav-label {
  margin: 16px 10px 8px;
  color: #719188;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}
.nav-item {
  min-height: 43px;
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  color: #c8d7d1;
  font-size: 12px;
  font-weight: 650;
}
.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.09);
  color: white;
}
.nav-glyph {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 7px;
  color: #a6c0b6;
  font-size: 9px;
  font-weight: 900;
}
.sidebar-foot {
  margin-top: auto;
  padding: 16px 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: #829d93;
  font-size: 10px;
}
.live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border-radius: 50%;
  background: #65d49f;
  box-shadow: 0 0 0 4px rgba(101, 212, 159, 0.1);
}
.workspace {
  min-width: 0;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 70px;
  padding: 12px 28px;
  display: flex;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 250, 246, 0.94);
  backdrop-filter: blur(12px);
}
.menu-button {
  display: none;
}
.global-search {
  position: relative;
  flex: 1;
  max-width: 560px;
}
.global-search input {
  min-height: 40px;
  padding-left: 36px;
  background: #f0f1eb;
  border-color: transparent;
}
.global-search::before {
  content: '⌕';
  position: absolute;
  left: 13px;
  top: 9px;
  color: #819089;
}
.user-context {
  margin-left: auto;
  text-align: right;
}
.user-context span {
  display: block;
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.user-context strong {
  font-size: 12px;
}
.page {
  padding: clamp(24px, 4vw, 52px);
}
.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}
.page-head h1 {
  margin: 5px 0 0;
  font-size: clamp(31px, 4vw, 50px);
  letter-spacing: -0.05em;
}
.page-head p {
  max-width: 650px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}
.kicker {
  color: #38836c;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}
.metric {
  min-height: 128px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.metric span {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.metric strong {
  display: block;
  margin-top: 14px;
  font-size: 30px;
  letter-spacing: -0.04em;
}
.metric small {
  color: #8b9590;
}
.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.6fr);
  gap: 18px;
}
.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head {
  min-height: 62px;
  padding: 15px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 {
  margin: 0;
  font-size: 17px;
}
.panel-body {
  padding: 20px;
}
.section-gap {
  margin-top: 18px;
}
.muted {
  color: var(--muted);
  line-height: 1.6;
}
.filter-bar {
  padding: 14px 18px;
  display: flex;
  align-items: end;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  background: #f7f7f2;
}
.filter-bar label {
  min-width: min(320px, 100%);
}
.filter-bar input,
.filter-bar select {
  min-height: 40px;
}
.report-filter {
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.report-filter label {
  min-width: 180px;
}
.summary-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.summary-chip {
  padding: 9px 11px;
  border-radius: 8px;
  background: #e5f5ec;
  color: #2a6d50;
  font-size: 11px;
}
.summary-chip strong {
  font-size: 15px;
}
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  padding: 13px 18px;
  border-bottom: 1px solid #e9ebe7;
  text-align: left;
  font-size: 11px;
  white-space: nowrap;
}
th {
  color: #8a948f;
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
td.primary-cell {
  font-weight: 750;
  color: #21362e;
}
.row-actions {
  display: flex;
  gap: 5px;
}
.status {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e5f5ec;
  color: #2a6d50;
  font-size: 8px;
  font-weight: 850;
  text-transform: uppercase;
}
.status.Draft {
  background: #edf0ed;
  color: #69746f;
}
.status.Declined,
.status.Cancelled {
  background: #f9e8e5;
  color: var(--danger);
}
.status.Sent,
.status.Awaiting-Payment {
  background: #fff0dc;
  color: var(--warn);
}
.status.Part-paid {
  background: #e9ecff;
  color: #454d9a;
}
.status.Overdue {
  background: #f9e8e5;
  color: var(--danger);
}
.empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--muted);
}
.empty strong {
  display: block;
  margin-bottom: 5px;
  color: var(--ink);
}
.stack {
  display: grid;
  gap: 13px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
}
.form-grid .wide {
  grid-column: 1 / -1;
}
.line-items {
  display: grid;
  gap: 8px;
}
.line-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 85px 110px 70px 34px;
  gap: 8px;
  align-items: end;
}
.line-row label {
  font-size: 9px;
}
.line-row input,
.line-row select {
  min-height: 40px;
}
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  justify-items: end;
  background: rgba(7, 18, 15, 0.48);
}
.drawer {
  width: min(620px, 100%);
  height: 100%;
  padding: 26px;
  overflow-y: auto;
  background: var(--paper);
  box-shadow: -20px 0 70px rgba(0, 0, 0, 0.16);
}
.drawer-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.drawer-head h2 {
  margin: 4px 0 0;
  font-size: 26px;
}
.drawer-actions {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.detail-grid > div {
  min-height: 76px;
  padding: 13px;
  display: grid;
  align-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
}
.detail-grid > div.wide {
  grid-column: 1 / -1;
}
.detail-grid span {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.detail-grid strong {
  overflow-wrap: anywhere;
  font-size: 12px;
}
.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  cursor: pointer;
}
.search-results {
  position: absolute;
  z-index: 40;
  top: 46px;
  left: 0;
  right: 0;
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  box-shadow: var(--shadow);
}
.search-result {
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid #eef0eb;
  font-size: 11px;
}
.search-result small {
  color: var(--muted);
}
.timeline-list {
  display: grid;
  gap: 1px;
  background: var(--line);
}
.timeline-event {
  padding: 14px 18px;
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 16px;
  background: var(--paper);
}
.timeline-event time {
  color: var(--muted);
  font-size: 10px;
}
.timeline-event strong {
  font-size: 12px;
}
.timeline-event pre {
  margin: 5px 0 0;
  color: var(--muted);
  font:
    10px/1.45 ui-monospace,
    monospace;
  white-space: pre-wrap;
}
.timeline-event p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}
.activity-list {
  display: grid;
}
.activity-event {
  padding: 18px 20px;
  display: grid;
  grid-template-columns: 165px minmax(0, 1fr);
  gap: 18px;
  border-bottom: 1px solid var(--line);
}
.activity-event time {
  color: var(--muted);
  font-size: 10px;
}
.activity-event h3 {
  margin: 4px 0 5px;
  font-size: 15px;
}
.activity-event p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}
.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 120;
  max-width: 390px;
  padding: 13px 16px;
  border-radius: 9px;
  background: var(--deep);
  color: white;
  box-shadow: 0 14px 45px rgba(0, 0, 0, 0.2);
  font-size: 12px;
}
.toast.error {
  background: #7f3026;
}
.mobile-overlay {
  display: none;
}
@media (max-width: 1050px) {
  .metric-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 780px) {
  .auth-page {
    grid-template-columns: 1fr;
  }
  .auth-story {
    min-height: 300px;
    padding: 34px 26px;
  }
  .auth-copy h1 {
    font-size: 44px;
  }
  .auth-foot {
    display: none;
  }
  .auth-panel {
    padding: 42px 24px;
  }
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    z-index: 70;
    left: 0;
    transform: translateX(-105%);
    width: 245px;
    transition: transform 0.2s ease;
  }
  .app-shell.menu-open .sidebar {
    transform: translateX(0);
  }
  .mobile-overlay {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(0, 0, 0, 0.35);
  }
  .app-shell.menu-open .mobile-overlay {
    display: block;
  }
  .menu-button {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
  }
  .topbar {
    padding: 10px 16px;
  }
  .user-context {
    display: none;
  }
  .page {
    padding: 26px 16px 50px;
  }
  .page-head {
    align-items: start;
    flex-direction: column;
  }
  .profile-notice,
  .filter-bar {
    align-items: stretch;
    flex-direction: column;
  }
  .filter-bar label,
  .report-filter label {
    min-width: 0;
  }
  .metric-grid {
    grid-template-columns: 1fr 1fr;
  }
  .metric {
    min-height: 112px;
    padding: 16px;
  }
  .metric strong {
    font-size: 24px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .detail-grid {
    grid-template-columns: 1fr;
  }
  .detail-grid > div.wide {
    grid-column: auto;
  }
  .activity-event {
    grid-template-columns: 1fr;
    gap: 7px;
  }
  .line-row {
    grid-template-columns: 1fr 72px 92px 60px 34px;
  }
}
@media (max-width: 520px) {
  .metric-grid {
    grid-template-columns: 1fr;
  }
  .line-row {
    grid-template-columns: 1fr 1fr;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 9px;
  }
  .line-row label:first-child {
    grid-column: 1 / -1;
  }
  .line-row .remove-line {
    align-self: end;
  }
  .drawer {
    padding: 20px 16px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
