@font-face {
  font-family: "Outfit";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/Outfit-Regular.ttf") format("truetype");
}

@font-face {
  font-family: "Outfit";
  font-style: normal;
  font-weight: 600 900;
  font-display: swap;
  src: url("/assets/fonts/Outfit-SemiBold.ttf") format("truetype");
}

:root {
  color-scheme: light;
  --ink: #111318;
  --muted: #6f747c;
  --line: #dedfdc;
  --surface: #ffffff;
  --soft: #f5f5f2;
  --success: #18724a;
  --success-bg: #edf8f1;
  --danger: #a52b2b;
  --danger-bg: #fff2f0;
  --sidebar-width: 220px;
  font-family: "Outfit", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--surface);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  align-self: start;
  height: 100vh;
  padding: 34px 24px 24px;
  border-right: 1px solid var(--line);
  background: #fafaf8;
}

.brand {
  display: block;
  margin-bottom: 54px;
  font-size: 1.05rem;
  font-weight: 750;
  text-decoration: none;
}

.sidebar nav {
  display: grid;
  gap: 7px;
}

.sidebar nav a {
  display: block;
  padding: 10px 12px;
  border-radius: 5px;
  color: #3e4248;
  font-size: 0.94rem;
  font-weight: 650;
  text-decoration: none;
}

.sidebar nav a:hover,
.sidebar nav a[aria-current="page"] {
  background: #ebece8;
  color: var(--ink);
}

.sign-out {
  margin-top: auto;
}

.sign-out button {
  width: 100%;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.sign-out span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.75rem;
}

.content {
  width: min(1320px, 100%);
  padding: 48px clamp(28px, 4vw, 64px) 80px;
}

.page-header {
  display: flex;
  min-height: 54px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 30px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.7rem, 2.4vw, 2.25rem);
  line-height: 1.15;
}

h2 {
  margin-bottom: 16px;
  font-size: 1rem;
}

.page-actions,
.action-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 9px 15px;
  border: 1px solid #cfd1ce;
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  border-color: #9da19c;
}

.button-primary {
  border-color: var(--ink);
  background: var(--ink);
  color: white;
}

.button-primary:hover {
  border-color: #34373d;
  background: #34373d;
}

.button-quiet {
  border-color: transparent;
  background: transparent;
}

.button-danger {
  border-color: #ebc8c5;
  color: var(--danger);
}

.page-section,
.form-section {
  margin: 0 0 30px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.page-section:first-of-type,
.document-form > .form-section:first-of-type,
.customer-form > .form-section:first-of-type,
.settings-form > .form-section:first-of-type {
  padding-top: 0;
  border-top: 0;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

.section-heading h2 {
  margin: 0;
}

.section-heading > span,
.field-note {
  color: var(--muted);
  font-size: 0.84rem;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.91rem;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: lowercase;
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #fafaf8;
}

.row-link {
  display: block;
  margin: -14px -16px;
  padding: 14px 16px;
  font-weight: 720;
  text-decoration: none;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86rem;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border: 1px solid #d8d9d6;
  border-radius: 999px;
  color: #555a62;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-paid,
.status-issued {
  border-color: #c7e5d2;
  background: var(--success-bg);
  color: var(--success);
}

.status-overdue {
  border-color: #ebc8c5;
  background: var(--danger-bg);
  color: var(--danger);
}

.alert {
  margin: 0 0 26px;
  padding: 12px 14px;
  border: 1px solid;
  border-radius: 5px;
}

.alert-success {
  border-color: #c7e5d2;
  background: var(--success-bg);
  color: var(--success);
}

.alert-error,
.form-error {
  border-color: #ebc8c5;
  background: var(--danger-bg);
  color: var(--danger);
}

.form-grid {
  display: grid;
  gap: 18px;
}

.form-grid-two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid-four {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.field,
.field-wide {
  display: grid;
  align-content: start;
  gap: 7px;
  min-width: 0;
  font-size: 0.86rem;
  font-weight: 700;
}

.field-wide {
  grid-column: 1 / -1;
}

.field input,
.field select,
.field textarea,
.line-table input,
.line-table select,
.line-table textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #cfd1ce;
  border-radius: 4px;
  outline: 0;
  background: var(--surface);
  color: var(--ink);
  font-weight: 500;
}

.field textarea,
.line-table textarea {
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.line-table input:focus,
.line-table select:focus,
.line-table textarea:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px rgba(17, 19, 24, 0.08);
}

.field input:disabled,
.field select:disabled {
  background: #efefec;
  color: var(--muted);
}

.field-pair {
  display: grid;
  grid-template-columns: minmax(90px, 0.42fr) minmax(120px, 1fr);
  gap: 12px;
}

.check-field {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  align-self: end;
  font-size: 0.9rem;
  font-weight: 700;
}

.check-field input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin: 0;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.form-actions-spread {
  justify-content: space-between;
}

.line-heading {
  align-items: center;
}

.line-table-wrap {
  overflow: visible;
}

.line-table {
  table-layout: fixed;
}

.line-table th:nth-child(1) { width: 35%; }
.line-table th:nth-child(2) { width: 10%; }
.line-table th:nth-child(3) { width: 10%; }
.line-table th:nth-child(4) { width: 16%; }
.line-table th:nth-child(5) { width: 16%; }
.line-table th:nth-child(6) { width: 116px; }

.line-table td {
  padding: 9px;
  vertical-align: top;
}

.line-table textarea {
  min-height: 42px;
}

.line-actions {
  display: flex;
  gap: 4px;
}

.icon-button {
  width: 30px;
  height: 36px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #555a62;
  font-size: 1rem;
  cursor: pointer;
}

.icon-button:hover {
  background: #ebece8;
}

.icon-danger:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.context-line {
  margin: -16px 0 28px;
  color: var(--muted);
}

.document-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 22px;
  padding: 22px 0 28px;
  border-top: 1px solid var(--line);
}

.document-summary > div {
  display: grid;
  align-content: start;
  gap: 5px;
}

.meta-label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
}

.totals {
  display: grid;
  gap: 9px;
  width: min(360px, 100%);
  margin: 24px 0 0 auto;
}

.totals > div {
  display: flex;
  justify-content: space-between;
  gap: 24px;
}

.total-final {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--ink);
  font-size: 1.05rem;
}

.action-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.action-band h2,
.action-band p {
  margin-bottom: 0;
}

.action-band p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.84rem;
}

.action-band form,
.payments-section form {
  margin: 0;
}

.inline-form {
  display: grid;
  grid-template-columns: 150px 180px minmax(180px, 1fr) auto;
  align-items: end;
  gap: 12px;
  margin-top: 20px !important;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--danger);
  text-decoration: underline;
  cursor: pointer;
}

.pre-wrap {
  max-width: 72ch;
  white-space: pre-wrap;
}

.empty-state {
  padding: 42px 0;
  color: var(--muted);
}

.error-state {
  display: grid;
  min-height: 60vh;
  place-content: center;
  text-align: center;
}

.error-state strong {
  font-size: 5rem;
  line-height: 1;
}

.error-state p {
  margin: 18px 0;
}

.login-page {
  min-height: 100vh;
  background: #000000;
  color: #ffffff;
}

.login-main {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-form {
  display: grid;
  width: min(340px, 100%);
  gap: 12px;
}

.login-form input {
  width: 100%;
  height: 48px;
  padding: 0 2px;
  border: 0;
  border-bottom: 1px solid #4d4d4d;
  border-radius: 0;
  outline: 0;
  background: transparent;
  color: white;
}

.login-form input::placeholder {
  color: #8a8a8a;
  opacity: 1;
}

.login-form input:focus {
  border-color: white;
}

.login-submit {
  height: 46px;
  margin-top: 12px;
  border: 1px solid white;
  border-radius: 0;
  background: white;
  color: black;
  font-weight: 750;
  cursor: pointer;
}

.form-error {
  margin: 0 0 8px;
  padding: 10px 12px;
  border-radius: 0;
  font-size: 0.88rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 980px) {
  .form-grid-four,
  .document-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .line-table-wrap {
    overflow-x: auto;
  }

  .line-table {
    min-width: 890px;
  }

  .inline-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  html,
  body {
    overflow-x: hidden;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    display: grid;
    grid-template-columns: 1fr auto;
    height: auto;
    padding: 18px 18px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    margin: 0;
  }

  .sidebar nav {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, 1fr);
    margin-top: 14px;
  }

  .sidebar nav a {
    text-align: center;
  }

  .sign-out {
    margin: 0;
  }

  .sign-out button {
    padding: 0;
    text-align: right;
  }

  .sign-out span {
    display: none;
  }

  .content {
    padding: 30px 18px 60px;
  }

  .form-grid-two,
  .form-grid-three,
  .form-grid-four,
  .document-summary,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .line-table-wrap {
    overflow: visible;
    border: 0;
  }

  .line-table,
  .line-table tbody,
  .line-table tr,
  .line-table td {
    display: block;
    width: 100%;
  }

  .line-table {
    min-width: 0;
  }

  .line-table thead {
    display: none;
  }

  .line-table tr {
    margin-bottom: 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
  }

  .line-table td {
    padding: 6px 0;
    border: 0;
  }

  .line-table td::before {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    content: attr(data-label);
    font-size: 0.72rem;
    font-weight: 700;
  }

  .line-table .line-actions {
    display: flex;
    justify-content: flex-end;
  }

  .line-table .line-actions::before {
    display: none;
  }

  .page-header,
  .action-band,
  .form-actions-spread {
    align-items: stretch;
    flex-direction: column;
  }

  .page-actions .button,
  .action-band .button,
  .form-actions .button {
    width: 100%;
  }

  .action-group {
    display: grid;
    width: 100%;
  }

  th,
  td {
    padding: 12px;
  }

  .row-link {
    margin: -12px;
    padding: 12px;
  }
}

@media print {
  .sidebar,
  .page-actions,
  .action-band,
  .payments-section,
  .form-actions {
    display: none !important;
  }

  .app-shell {
    display: block;
  }

  .content {
    width: 100%;
    padding: 0;
  }
}
