:root {
  color-scheme: dark;
  --font-sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #050508;
  --bg-soft: #08080d;
  --surface: #0d0d14;
  --surface-raised: #12121c;
  --surface-hover: #171724;
  --surface-active: #1d1d2c;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f7f7fb;
  --text-soft: #c3c3ce;
  --muted: #888895;
  --faint: #656571;
  --blue: #0080ff;
  --blue-bright: #3b9dff;
  --violet: #8000ff;
  --violet-bright: #9d3dff;
  --accent: linear-gradient(135deg, #0080ff 0%, #8000ff 100%);
  --accent-soft: linear-gradient(135deg, rgba(0, 128, 255, 0.18), rgba(128, 0, 255, 0.16));
  --success: #37d39a;
  --warning: #ffbb52;
  --danger: #ff5f72;
  --info: #69b7ff;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 16px 40px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 28px 80px rgba(0, 0, 0, 0.42);
  --sidebar-width: 252px;
  --topbar-height: 72px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
  font-family: var(--font-sans);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 78% -8%, rgba(128, 0, 255, 0.09), transparent 30rem),
    radial-gradient(circle at 22% 0%, rgba(0, 128, 255, 0.07), transparent 25rem),
    var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
input[type="checkbox"],
input[type="radio"] {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

a {
  color: var(--blue-bright);
  text-decoration: none;
}

a:hover {
  color: #76baff;
}

img,
svg {
  display: block;
  max-width: 100%;
}

hr {
  height: 1px;
  margin: 20px 0;
  border: 0;
  background: var(--line);
}

::selection {
  background: rgba(0, 128, 255, 0.36);
  color: #fff;
}

::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.17);
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.27);
  background-clip: padding-box;
}

:focus-visible {
  outline: 3px solid rgba(0, 128, 255, 0.52);
  outline-offset: 2px;
}

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

.hidden,
[hidden] {
  display: none !important;
}

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

.sidebar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  grid-column: 1;
  grid-row: 1 / -1;
  flex-direction: column;
  width: var(--sidebar-width);
  height: 100vh;
  height: 100svh;
  padding: 22px 16px 18px;
  border-right: 1px solid var(--line);
  background: rgba(7, 7, 12, 0.92);
  box-shadow: 10px 0 34px rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(22px);
}

.brand {
  display: flex;
  align-items: center;
  min-height: 42px;
  gap: 12px;
  padding: 4px 10px 20px;
  color: #fff;
}

.brand img {
  width: auto;
  max-width: 132px;
  height: 30px;
  object-fit: contain;
  object-position: left center;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  background: var(--accent);
  box-shadow: 0 8px 24px rgba(91, 45, 255, 0.28);
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.05em;
}

.brand-copy {
  min-width: 0;
}

.brand-name {
  display: block;
  color: #fff;
  font-size: 16px;
  font-weight: 720;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.brand-subtitle {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
}

.nav-label {
  margin: 12px 10px 8px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 760;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.nav-button {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 620;
  line-height: 1.2;
  text-align: left;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease, transform 150ms ease;
}

.nav-button::before {
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: -4px;
  width: 2px;
  border-radius: 99px;
  background: var(--accent);
  content: "";
  opacity: 0;
  transform: scaleY(0.4);
  transition: opacity 150ms ease, transform 150ms ease;
}

.nav-button:hover {
  border-color: rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.045);
  color: #fff;
}

.nav-button.active,
.nav-button[aria-current="page"] {
  border-color: rgba(97, 103, 255, 0.2);
  background: var(--accent-soft);
  color: #fff;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.035);
}

.nav-button.active::before,
.nav-button[aria-current="page"]::before {
  opacity: 1;
  transform: scaleY(1);
}

.nav-icon {
  display: grid;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  place-items: center;
  color: currentColor;
  opacity: 0.82;
}

.nav-button.active .nav-icon,
.nav-button[aria-current="page"] .nav-icon {
  opacity: 1;
}

.sidebar-footer {
  padding-top: 16px;
  margin-top: auto;
  border-top: 1px solid var(--line);
}

.sidebar-note {
  padding: 10px 12px 0;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.55;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  min-height: var(--topbar-height);
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 clamp(20px, 3vw, 42px);
  border-bottom: 1px solid var(--line);
  background: rgba(5, 5, 8, 0.78);
  backdrop-filter: blur(22px);
}

.topbar-title {
  min-width: 0;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 620;
  letter-spacing: 0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-title strong {
  color: #fff;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.content {
  grid-column: 2;
  grid-row: 2;
  width: 100%;
  min-width: 0;
  max-width: 1660px;
  padding: clamp(24px, 3.5vw, 48px);
  margin: 0 auto;
}

.view-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.view-header h1,
.view-header h2 {
  margin: 0;
  color: #fff;
  font-size: clamp(27px, 3vw, 38px);
  font-weight: 720;
  letter-spacing: -0.045em;
  line-height: 1.08;
}

.view-header h2 {
  font-size: clamp(23px, 2.2vw, 30px);
}

.view-header p {
  max-width: 660px;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.view-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  position: relative;
  min-width: 0;
  padding: 19px 20px 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(18, 18, 28, 0.94), rgba(11, 11, 18, 0.96));
  box-shadow: var(--shadow-sm);
}

.stat-card::after {
  position: absolute;
  top: -46px;
  right: -38px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 128, 255, 0.14), transparent 68%);
  content: "";
  pointer-events: none;
}

.stat-card:nth-child(even)::after {
  background: radial-gradient(circle, rgba(128, 0, 255, 0.14), transparent 68%);
}

.stat-label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 720;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.stat-value {
  display: block;
  color: #fff;
  font-size: clamp(23px, 2.4vw, 31px);
  font-variant-numeric: tabular-nums;
  font-weight: 720;
  letter-spacing: -0.04em;
  line-height: 1.08;
}

.stat-detail {
  display: block;
  margin-top: 9px;
  color: var(--faint);
  font-size: 12px;
  line-height: 1.4;
}

.stat-detail.positive {
  color: var(--success);
}

.stat-detail.warning {
  color: var(--warning);
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(13, 13, 20, 0.93);
  box-shadow: var(--shadow-sm);
}

.panel + .panel {
  margin-top: 18px;
}

.panel-header {
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2,
.panel-header h3 {
  margin: 0;
  color: #fff;
  font-size: 16px;
  font-weight: 690;
  letter-spacing: -0.02em;
}

.panel-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.panel-body {
  padding: 22px;
}

.panel-body.flush {
  padding: 0;
}

.panel-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.014);
}

.toolbar {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
}

.toolbar-group {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
}

.toolbar .field {
  min-width: 150px;
  margin: 0;
}

.toolbar .search-field {
  min-width: min(310px, 100%);
}

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

.data-table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
  color: var(--text-soft);
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  background: rgba(255, 255, 255, 0.018);
  color: var(--faint);
  font-size: 10px;
  font-weight: 760;
  letter-spacing: 0.11em;
  line-height: 1.3;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table tbody tr {
  transition: background 140ms ease;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.025);
}

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

.data-table .cell-title {
  display: block;
  color: #fff;
  font-weight: 640;
  line-height: 1.35;
}

.data-table .cell-subtitle {
  display: block;
  margin-top: 3px;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.35;
}

.data-table .numeric,
.data-table .amount {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.data-table .amount {
  color: #fff;
  font-weight: 650;
}

.data-table .actions {
  width: 1%;
  text-align: right;
  white-space: nowrap;
}

.status-badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-soft);
  font-size: 10px;
  font-weight: 760;
  letter-spacing: 0.055em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-badge::before {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.04);
  content: "";
}

.status-badge.draft,
.status-badge[data-status="draft"] {
  border-color: rgba(164, 164, 179, 0.2);
  background: rgba(164, 164, 179, 0.08);
  color: #b9b9c6;
}

.status-badge.finalised,
.status-badge.finalized,
.status-badge[data-status="finalised"],
.status-badge[data-status="finalized"] {
  border-color: rgba(105, 183, 255, 0.22);
  background: rgba(0, 128, 255, 0.1);
  color: #72bbff;
}

.status-badge.submitted,
.status-badge.sent,
.status-badge[data-status="submitted"],
.status-badge[data-status="sent"] {
  border-color: rgba(176, 105, 255, 0.23);
  background: rgba(128, 0, 255, 0.11);
  color: #b779ff;
}

.status-badge.paid,
.status-badge.success,
.status-badge[data-status="paid"] {
  border-color: rgba(55, 211, 154, 0.22);
  background: rgba(55, 211, 154, 0.09);
  color: #55dda9;
}

.status-badge.overdue,
.status-badge.warning,
.status-badge[data-status="overdue"] {
  border-color: rgba(255, 187, 82, 0.23);
  background: rgba(255, 187, 82, 0.09);
  color: #ffc66c;
}

.status-badge.void,
.status-badge.cancelled,
.status-badge.danger,
.status-badge[data-status="void"] {
  border-color: rgba(255, 95, 114, 0.23);
  background: rgba(255, 95, 114, 0.09);
  color: #ff7c8c;
}

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: #fff;
  font-size: 13px;
  font-weight: 670;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, box-shadow 140ms ease, color 140ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:active:not(:disabled) {
  transform: translateY(0);
}

.button.primary {
  border-color: rgba(98, 87, 255, 0.64);
  background: var(--accent);
  box-shadow: 0 8px 24px rgba(60, 70, 255, 0.2), inset 0 1px rgba(255, 255, 255, 0.19);
  color: #fff;
}

.button.primary:hover:not(:disabled) {
  box-shadow: 0 11px 30px rgba(60, 70, 255, 0.3), inset 0 1px rgba(255, 255, 255, 0.24);
}

.button.secondary {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.035);
  color: var(--text);
}

.button.secondary:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.23);
  background: rgba(255, 255, 255, 0.1);
}

.button.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-soft);
}

.button.ghost:hover:not(:disabled) {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.button.danger {
  border-color: rgba(255, 95, 114, 0.22);
  background: rgba(255, 95, 114, 0.09);
  color: #ff8391;
}

.button.danger:hover:not(:disabled) {
  border-color: rgba(255, 95, 114, 0.36);
  background: rgba(255, 95, 114, 0.14);
}

.button.small {
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 11px;
}

.button.large {
  min-height: 46px;
  padding: 11px 18px;
  border-radius: 11px;
  font-size: 14px;
}

.button.icon-only {
  width: 40px;
  padding: 0;
}

.button.small.icon-only {
  width: 32px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

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

.form-grid .full-width,
.field.full-width {
  grid-column: 1 / -1;
}

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 7px;
}

.field label,
.field-label {
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 710;
  letter-spacing: 0.025em;
  line-height: 1.35;
}

.field label .required,
.field-label .required {
  color: #ff8593;
}

.field input,
.field select,
.field textarea,
input.input,
select.input,
textarea.input {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  outline: none;
  background: #0a0a11;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.24);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.field textarea,
textarea.input {
  min-height: 96px;
  resize: vertical;
}

.field input:hover:not(:disabled),
.field select:hover:not(:disabled),
.field textarea:hover:not(:disabled),
input.input:hover:not(:disabled),
select.input:hover:not(:disabled),
textarea.input:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.23);
  background: #0c0c14;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
input.input:focus,
select.input:focus,
textarea.input:focus {
  border-color: rgba(0, 128, 255, 0.76);
  background: #0d0d16;
  box-shadow: 0 0 0 3px rgba(0, 128, 255, 0.13), inset 0 1px 2px rgba(0, 0, 0, 0.22);
}

.field input::placeholder,
.field textarea::placeholder,
input.input::placeholder,
textarea.input::placeholder {
  color: #5f5f6c;
}

.field input[type="date"],
.field input[type="datetime-local"],
.field input[type="month"] {
  color-scheme: dark;
}

.field-help {
  color: var(--faint);
  font-size: 11px;
  line-height: 1.45;
}

.field-error {
  color: #ff8492;
  font-size: 11px;
  line-height: 1.45;
}

.field.has-error input,
.field.has-error select,
.field.has-error textarea,
.field input[aria-invalid="true"],
.field select[aria-invalid="true"],
.field textarea[aria-invalid="true"] {
  border-color: rgba(255, 95, 114, 0.62);
  box-shadow: 0 0 0 3px rgba(255, 95, 114, 0.1);
}

.input-group {
  display: flex;
  min-width: 0;
}

.input-group > * {
  border-radius: 0 !important;
}

.input-group > :first-child {
  border-top-left-radius: 9px !important;
  border-bottom-left-radius: 9px !important;
}

.input-group > :last-child {
  border-top-right-radius: 9px !important;
  border-bottom-right-radius: 9px !important;
}

.input-prefix,
.input-suffix {
  display: flex;
  min-height: 42px;
  align-items: center;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
  font-size: 12px;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.5;
}

.checkbox-row input[type="checkbox"],
.checkbox-row input[type="radio"] {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  margin: 1px 0 0;
  accent-color: var(--blue);
}

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

.form-section-heading {
  margin-bottom: 16px;
}

.form-section-heading h3 {
  margin: 0;
  color: #fff;
  font-size: 14px;
  font-weight: 680;
}

.form-section-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(420px, 0.82fr) minmax(620px, 1.18fr);
  align-items: start;
  gap: 20px;
}

.editor-pane {
  min-width: 0;
}

.editor-pane .panel {
  overflow: hidden;
}

.preview-pane {
  position: sticky;
  top: calc(var(--topbar-height) + 20px);
  min-width: 0;
  max-height: calc(100vh - var(--topbar-height) - 40px);
  max-height: calc(100svh - var(--topbar-height) - 40px);
  padding: 24px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.018) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.018) 75%),
    linear-gradient(45deg, rgba(255, 255, 255, 0.018) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.018) 75%),
    #09090f;
  background-position: 0 0, 12px 12px;
  background-size: 24px 24px;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.025);
}

.preview-toolbar {
  position: sticky;
  top: -24px;
  z-index: 3;
  display: flex;
  min-width: max-content;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 2px 14px;
  margin: -12px 0 14px;
  background: linear-gradient(#09090f 78%, transparent);
}

.preview-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

#invoice-preview {
  width: max-content;
  min-width: 100%;
  margin: 0 auto;
}

.invoice-paper {
  position: relative;
  display: flex;
  width: 210mm;
  min-height: 297mm;
  flex-direction: column;
  padding: 17mm 17mm 14mm;
  margin: 0 auto;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.48), 0 0 0 1px rgba(255, 255, 255, 0.08);
  color: #181921;
  font-family: var(--font-sans);
  font-size: 10pt;
  line-height: 1.45;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.invoice-paper::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3.2mm;
  background: linear-gradient(90deg, #0080ff 0%, #395eff 48%, #8000ff 100%);
  content: "";
}

.invoice-paper a {
  color: #056dcf;
}

.invoice-paper address {
  margin: 0;
  color: #575d6b;
  font-style: normal;
  line-height: 1.58;
}

.invoice-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18mm;
  padding-top: 2mm;
  padding-bottom: 12mm;
  border-bottom: 0.35mm solid #e7e9ef;
}

.invoice-brand {
  min-width: 0;
  max-width: 95mm;
}

.invoice-brand img {
  width: auto;
  max-width: 42mm;
  max-height: 12mm;
  object-fit: contain;
  object-position: left center;
}

.invoice-brand-name {
  margin: 0;
  color: #0f1016;
  font-size: 18pt;
  font-weight: 760;
  letter-spacing: -0.05em;
  line-height: 1;
}

.invoice-brand-tagline {
  margin: 3mm 0 0;
  color: #707585;
  font-size: 8.5pt;
  font-weight: 540;
}

.invoice-title-block {
  min-width: 48mm;
  text-align: right;
}

.invoice-title-block h1,
.invoice-title-block .invoice-title {
  margin: 0;
  color: #11131a;
  font-size: 29pt;
  font-weight: 760;
  letter-spacing: -0.055em;
  line-height: 0.95;
}

.invoice-number {
  display: block;
  margin-top: 3.5mm;
  color: #5b6170;
  font-size: 10pt;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.invoice-status {
  display: inline-block;
  padding: 1.5mm 3mm;
  margin-top: 3.5mm;
  border: 0.25mm solid #dbe9f8;
  border-radius: 99px;
  background: #f3f8fe;
  color: #086ec8;
  font-size: 7pt;
  font-weight: 760;
  letter-spacing: 0.09em;
  line-height: 1;
  text-transform: uppercase;
}

.invoice-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8mm;
  padding: 7mm 0;
  border-bottom: 0.35mm solid #eceef3;
}

.invoice-meta-item {
  min-width: 0;
}

.invoice-label,
.party-label,
.payment-label {
  display: block;
  margin-bottom: 1.8mm;
  color: #8a8f9d;
  font-size: 7pt;
  font-weight: 760;
  letter-spacing: 0.105em;
  line-height: 1.2;
  text-transform: uppercase;
}

.invoice-meta-value {
  display: block;
  color: #20232c;
  font-size: 9.5pt;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.party-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13mm;
  padding: 9mm 0 10mm;
}

.party-block {
  min-width: 0;
}

.party-name {
  margin: 0 0 1.7mm;
  color: #161821;
  font-size: 11pt;
  font-weight: 720;
  letter-spacing: -0.018em;
  line-height: 1.25;
}

.party-detail {
  margin: 0;
  color: #5f6472;
  font-size: 8.5pt;
  line-height: 1.58;
  overflow-wrap: anywhere;
}

.service-table {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  color: #242731;
  font-size: 9pt;
}

.service-table thead th {
  padding: 3.3mm 3mm;
  border: 0;
  border-bottom: 0.35mm solid #dfe2e9;
  background: #f5f6f8;
  color: #6e7380;
  font-size: 7pt;
  font-weight: 760;
  letter-spacing: 0.085em;
  line-height: 1.25;
  text-align: left;
  text-transform: uppercase;
}

.service-table thead th:first-child {
  border-radius: 2.2mm 0 0 2.2mm;
}

.service-table thead th:last-child {
  border-radius: 0 2.2mm 2.2mm 0;
}

.service-table th.numeric,
.service-table td.numeric,
.service-table th.amount,
.service-table td.amount {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.service-table tbody td {
  padding: 4.5mm 3mm;
  border-bottom: 0.25mm solid #eceef2;
  vertical-align: top;
}

.service-table tbody tr:last-child td {
  border-bottom-color: #dfe2e9;
}

.service-description {
  color: #1c1f28;
  font-size: 9.3pt;
  font-weight: 650;
  line-height: 1.4;
}

.service-note {
  display: block;
  margin-top: 1.2mm;
  color: #747987;
  font-size: 8pt;
  font-weight: 450;
  line-height: 1.5;
}

.invoice-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 70mm;
  gap: 12mm;
  align-items: start;
  padding: 7mm 0 9mm;
}

.invoice-notes {
  color: #666b78;
  font-size: 8pt;
  line-height: 1.58;
}

.invoice-notes p {
  margin: 0;
}

.invoice-notes p + p {
  margin-top: 2mm;
}

.totals-panel {
  width: 100%;
  margin-left: auto;
}

.total-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8mm;
  padding: 2mm 0;
  color: #646977;
  font-size: 8.5pt;
}

.total-row span:last-child {
  color: #252831;
  font-variant-numeric: tabular-nums;
  font-weight: 630;
  text-align: right;
  white-space: nowrap;
}

.total-row.grand-total {
  padding: 4mm 0 2mm;
  margin-top: 2mm;
  border-top: 0.5mm solid #171921;
  color: #171921;
  font-size: 10pt;
  font-weight: 720;
}

.total-row.grand-total span:last-child {
  color: #11131a;
  font-size: 16pt;
  font-weight: 760;
  letter-spacing: -0.035em;
}

.payment-panel {
  display: grid;
  grid-template-columns: 38mm repeat(3, minmax(0, 1fr));
  gap: 6mm;
  padding: 6mm;
  margin-top: auto;
  border: 0.3mm solid #e1e6ef;
  border-radius: 3mm;
  background: linear-gradient(110deg, #f5f9fe, #f8f6ff);
}

.payment-heading {
  color: #161923;
  font-size: 9pt;
  font-weight: 720;
  line-height: 1.35;
}

.payment-heading small {
  display: block;
  margin-top: 1.5mm;
  color: #777d8b;
  font-size: 7pt;
  font-weight: 470;
  line-height: 1.4;
}

.payment-item {
  min-width: 0;
}

.payment-value {
  display: block;
  color: #262a34;
  font-size: 8pt;
  font-variant-numeric: tabular-nums;
  font-weight: 620;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.invoice-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12mm;
  padding-top: 7mm;
  color: #8b909c;
  font-size: 7pt;
  line-height: 1.5;
}

.invoice-footer strong {
  color: #525764;
  font-weight: 680;
}

.invoice-footer-right {
  flex: 0 0 auto;
  text-align: right;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  padding: 22px;
  overflow-y: auto;
  place-items: center;
  background: rgba(2, 2, 5, 0.78);
  backdrop-filter: blur(8px);
}

.modal[hidden] {
  display: none;
}

.modal-dialog {
  width: min(620px, 100%);
  max-height: calc(100svh - 44px);
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: #0e0e16;
  box-shadow: var(--shadow-lg);
  animation: modal-in 160ms ease-out;
}

.modal-dialog.wide {
  width: min(860px, 100%);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2,
.modal-header h3 {
  margin: 0;
  color: #fff;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.modal-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.modal-body {
  padding: 22px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.015);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.toast-container {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 140;
  display: flex;
  width: min(390px, calc(100vw - 44px));
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  position: relative;
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 13px 14px 13px 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(18, 18, 28, 0.97);
  box-shadow: var(--shadow-md);
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.45;
  pointer-events: auto;
  animation: toast-in 200ms ease-out;
}

.toast::before {
  align-self: stretch;
  border-radius: 0 99px 99px 0;
  background: var(--blue);
  content: "";
}

.toast.success::before {
  background: var(--success);
}

.toast.warning::before {
  background: var(--warning);
}

.toast.error::before,
.toast.danger::before {
  background: var(--danger);
}

.toast strong {
  display: block;
  margin-bottom: 2px;
  color: #fff;
  font-size: 12px;
}

.toast-close {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}

.toast-close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.empty-state {
  display: flex;
  min-height: 300px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 48px 24px;
  text-align: center;
}

.empty-state-icon {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  margin-bottom: 16px;
  border: 1px solid rgba(85, 102, 255, 0.24);
  border-radius: 15px;
  background: var(--accent-soft);
  color: #82baff;
  font-size: 20px;
}

.empty-state h2,
.empty-state h3 {
  margin: 0;
  color: #fff;
  font-size: 18px;
  font-weight: 690;
  letter-spacing: -0.025em;
}

.empty-state p {
  max-width: 430px;
  margin: 8px 0 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.inline-alert {
  padding: 13px 14px;
  border: 1px solid rgba(105, 183, 255, 0.2);
  border-radius: 10px;
  background: rgba(0, 128, 255, 0.075);
  color: #b7d9f9;
  font-size: 12px;
  line-height: 1.55;
}

.inline-alert.warning {
  border-color: rgba(255, 187, 82, 0.22);
  background: rgba(255, 187, 82, 0.075);
  color: #f0c67f;
}

.inline-alert.danger,
.inline-alert.error {
  border-color: rgba(255, 95, 114, 0.22);
  background: rgba(255, 95, 114, 0.075);
  color: #ffabb5;
}

.line-items-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.line-item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 44px;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.018);
}

.line-item-row .field {
  margin: 0;
}

.section-heading {
  margin: 0 0 14px;
  color: #fff;
  font-size: 15px;
  font-weight: 680;
  letter-spacing: -0.018em;
}

.muted {
  color: var(--muted) !important;
}

.text-danger {
  color: var(--danger) !important;
}

.text-success {
  color: var(--success) !important;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

.eyebrow {
  display: block;
  margin: 0 0 7px;
  color: #7baeff;
  font-size: 10px;
  font-weight: 760;
  letter-spacing: 0.13em;
  line-height: 1.3;
  text-transform: uppercase;
}

.view-header.compact {
  align-items: center;
}

.view-header.compact h1 {
  font-size: clamp(25px, 2.5vw, 34px);
}

.header-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
}

.back-link {
  padding: 0;
  margin: 0 0 9px;
  border: 0;
  background: transparent;
  color: #7eb9f4;
  font-size: 12px;
  font-weight: 650;
}

.back-link:hover {
  color: #acd5ff;
}

.stat-card > span:first-child {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 720;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.stat-card > strong {
  display: block;
  overflow: hidden;
  color: #fff;
  font-size: clamp(23px, 2.4vw, 31px);
  font-variant-numeric: tabular-nums;
  font-weight: 720;
  letter-spacing: -0.04em;
  line-height: 1.15;
  text-overflow: ellipsis;
}

.stat-card > small {
  display: block;
  margin-top: 9px;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.4;
}

.search-field {
  display: block;
  width: min(340px, 100%);
}

.search-field input,
.toolbar > label select {
  width: 100%;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  outline: none;
  background: #0a0a11;
  color: var(--text);
  font-size: 12px;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.search-field input {
  min-width: min(340px, calc(100vw - 64px));
}

.search-field input:focus,
.toolbar > label select:focus {
  border-color: rgba(0, 128, 255, 0.76);
  background: #0d0d16;
  box-shadow: 0 0 0 3px rgba(0, 128, 255, 0.13);
}

.table-link {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 13px;
  font-weight: 670;
  line-height: 1.35;
  text-align: left;
}

.table-link:hover {
  color: #82c2ff;
}

.data-table td > small,
.data-table td > strong + small,
.data-table .table-link + small {
  display: block;
  margin-top: 3px;
  color: var(--faint);
  font-size: 10px;
  line-height: 1.35;
}

.data-table td > strong {
  display: block;
  color: #fff;
  font-weight: 650;
}

.actions-cell {
  text-align: right !important;
  white-space: nowrap;
}

.icon-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-soft);
  font-size: 16px;
  line-height: 1;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease, transform 140ms ease;
}

.icon-button:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.075);
  color: #fff;
  transform: translateY(-1px);
}

.danger-text {
  color: #ff8492 !important;
}

.status-badge.status-draft {
  border-color: rgba(164, 164, 179, 0.2);
  background: rgba(164, 164, 179, 0.08);
  color: #b9b9c6;
}

.status-badge.status-finalised,
.status-badge.status-finalized {
  border-color: rgba(105, 183, 255, 0.22);
  background: rgba(0, 128, 255, 0.1);
  color: #72bbff;
}

.status-badge.status-submitted {
  border-color: rgba(176, 105, 255, 0.23);
  background: rgba(128, 0, 255, 0.11);
  color: #b779ff;
}

.status-badge.status-paid {
  border-color: rgba(55, 211, 154, 0.22);
  background: rgba(55, 211, 154, 0.09);
  color: #55dda9;
}

.status-badge.status-overdue {
  border-color: rgba(255, 187, 82, 0.23);
  background: rgba(255, 187, 82, 0.09);
  color: #ffc66c;
}

.status-badge.status-void {
  border-color: rgba(255, 95, 114, 0.23);
  background: rgba(255, 95, 114, 0.09);
  color: #ff7c8c;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  align-items: start;
  gap: 18px;
}

.settings-grid .panel + .panel {
  margin-top: 0;
}

.panel > form,
.editor-pane > form {
  padding: 22px;
}

.panel form fieldset,
.editor-pane fieldset {
  min-width: 0;
  padding: 0;
  margin: 0;
  border: 0;
}

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

.form-grid .span-2,
.span-2 {
  grid-column: span 2;
}

.field > span:first-child {
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 710;
  letter-spacing: 0.025em;
  line-height: 1.35;
}

.field > small {
  color: var(--faint);
  font-size: 10px;
  line-height: 1.45;
}

.form-actions,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  padding-top: 18px;
  margin-top: 20px;
  border-top: 1px solid var(--line);
}

.inline-control {
  display: flex;
  min-width: 0;
  align-items: stretch;
  gap: 8px;
}

.inline-control select,
.inline-control input {
  min-width: 0;
  flex: 1 1 auto;
}

.form-section {
  padding: 0;
}

.form-section + .form-section {
  padding-top: 24px;
  margin-top: 24px;
}

.form-section-title {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  margin-bottom: 18px;
}

.form-section-title > span {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid rgba(77, 105, 255, 0.22);
  border-radius: 9px;
  background: var(--accent-soft);
  color: #8abfff;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  font-weight: 760;
  letter-spacing: 0.06em;
}

.form-section-title h2 {
  margin: 0;
  color: #fff;
  font-size: 14px;
  font-weight: 690;
  letter-spacing: -0.015em;
}

.form-section-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.editor-status-row {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.015);
  color: var(--faint);
  font-size: 10px;
}

.invoice-item-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(180px, 1.25fr) minmax(150px, 1fr) 112px 36px;
  gap: 9px;
  align-items: end;
  padding: 12px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.018);
}

.invoice-item-row .remove-item {
  margin-bottom: 4px;
}

.bank-card-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.bank-card {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.bank-card:last-child {
  border-bottom: 0;
}

.bank-card > div:first-child {
  min-width: 0;
}

.bank-card > div:last-child {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 5px;
}

.bank-card strong {
  display: block;
  margin-top: 9px;
  color: #fff;
  font-size: 13px;
  font-weight: 660;
}

.bank-card p {
  margin: 4px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
}

.currency-pill {
  display: inline-flex;
  padding: 4px 7px;
  border: 1px solid rgba(105, 183, 255, 0.18);
  border-radius: 6px;
  background: rgba(0, 128, 255, 0.075);
  color: #7dbdff;
  font-size: 9px;
  font-weight: 760;
  letter-spacing: 0.075em;
}

.invoice-history {
  padding: 22px 20px;
  border-top: 1px solid var(--line);
}

.invoice-history-header h2 {
  margin: 0;
  font-size: 14px;
  letter-spacing: -0.015em;
}

.invoice-history-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.invoice-history ol {
  display: grid;
  gap: 0;
  padding: 0;
  margin: 17px 0 0;
  list-style: none;
}

.invoice-history li {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: start;
  padding: 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.055);
}

.invoice-history li:first-child {
  border-top: 0;
}

.history-dot {
  width: 7px;
  height: 7px;
  margin-top: 4px;
  border: 2px solid rgba(0, 128, 255, 0.3);
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 128, 255, 0.08);
}

.invoice-history strong {
  display: block;
  color: var(--text);
  font-size: 11px;
  font-weight: 660;
}

.invoice-history li p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.invoice-history time {
  color: var(--faint);
  font-size: 9px;
  white-space: nowrap;
}

.empty-state.compact {
  min-height: 150px;
  padding: 26px 20px;
}

.loading-state {
  display: flex;
  min-height: 320px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.loading-state p {
  margin: 0;
}

.loading-state__mark,
.spinner {
  width: 28px;
  height: 28px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--blue-bright);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.noscript-message {
  position: fixed;
  inset: auto 20px 20px;
  z-index: 300;
  padding: 14px 16px;
  border: 1px solid rgba(255, 187, 82, 0.24);
  border-radius: 10px;
  background: #17130c;
  color: #f3ca83;
  font-size: 12px;
  text-align: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  padding: 22px;
  overflow-y: auto;
  place-items: center;
  background: rgba(2, 2, 5, 0.78);
  backdrop-filter: blur(8px);
}

.modal-backdrop > .modal {
  position: relative;
  inset: auto;
  z-index: auto;
  display: block;
  width: min(680px, 100%);
  max-height: calc(100svh - 44px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: #0e0e16;
  box-shadow: var(--shadow-lg);
  animation: modal-in 160ms ease-out;
}

.modal-backdrop > .modal > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 19px 21px;
  border-bottom: 1px solid var(--line);
}

.modal-backdrop > .modal > header h2 {
  margin: 0;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.modal-form {
  padding: 21px;
}

.toast.toast-success::before {
  background: var(--success);
}

.toast.toast-error::before,
.toast.toast-danger::before {
  background: var(--danger);
}

.toast.toast-warning::before {
  background: var(--warning);
}

.toast-region .toast {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast-region .toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* The generated invoice snapshot uses direct semantic descendants. */
.invoice-accent {
  display: none;
}

.invoice-brand-lockup {
  display: flex;
  align-items: center;
  gap: 3mm;
}

.invoice-brand-lockup img {
  width: 10mm;
  height: 10mm;
  object-fit: contain;
}

.invoice-brand-lockup span {
  color: #10121a;
  font-size: 18pt;
  font-weight: 760;
  letter-spacing: -0.05em;
  line-height: 1;
}

.invoice-brand > p {
  margin: 3mm 0 0;
  color: #707585;
  font-size: 8.5pt;
  line-height: 1.45;
}

.invoice-title-block .invoice-kicker {
  display: block;
  margin-bottom: 1.6mm;
  color: #858a97;
  font-size: 7pt;
  font-weight: 760;
  letter-spacing: 0.13em;
  line-height: 1.2;
  text-transform: uppercase;
}

.invoice-title-block > strong {
  display: block;
  color: #11131a;
  font-size: 21pt;
  font-variant-numeric: tabular-nums;
  font-weight: 760;
  letter-spacing: -0.04em;
  line-height: 1;
}

.invoice-status-draft {
  border-color: #e3e5ea;
  background: #f4f5f7;
  color: #6f7480;
}

.invoice-status-finalised,
.invoice-status-finalized {
  border-color: #dbe9f8;
  background: #f3f8fe;
  color: #086ec8;
}

.invoice-status-submitted {
  border-color: #e9dff8;
  background: #faf6ff;
  color: #7731bb;
}

.invoice-status-paid {
  border-color: #d6eee5;
  background: #f2faf7;
  color: #157550;
}

.invoice-status-void {
  border-color: #f1dce0;
  background: #fff6f7;
  color: #a33c4b;
}

.invoice-meta-grid > div {
  min-width: 0;
}

.invoice-meta-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.invoice-meta-grid > div > span,
.invoice-reference-row > div > span {
  display: block;
  margin-bottom: 1.8mm;
  color: #8a8f9d;
  font-size: 7pt;
  font-weight: 760;
  letter-spacing: 0.105em;
  line-height: 1.2;
  text-transform: uppercase;
}

.invoice-meta-grid > div > strong,
.invoice-reference-row > div > strong {
  display: block;
  color: #20232c;
  font-size: 9pt;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.party-grid > div {
  min-width: 0;
}

.party-grid > div > strong {
  display: block;
  margin-bottom: 1.8mm;
  color: #161821;
  font-size: 10.5pt;
  font-weight: 720;
  letter-spacing: -0.018em;
  line-height: 1.3;
}

.party-grid > div > p {
  margin: 0 0 1.6mm;
  color: #5f6472;
  font-size: 8.2pt;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.invoice-reference-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9mm;
  padding: 4.2mm 5mm;
  margin-bottom: 6mm;
  border: 0.25mm solid #e6e9ef;
  border-radius: 2.4mm;
  background: #fafbfc;
}

.service-table tbody td:first-child strong {
  display: block;
  color: #1c1f28;
  font-size: 9.3pt;
  font-weight: 650;
  line-height: 1.4;
}

.service-table tbody td:first-child span {
  display: block;
  margin-top: 1.2mm;
  color: #747987;
  font-size: 8pt;
  line-height: 1.5;
}

.service-table thead th:last-child,
.service-table tbody td:last-child {
  width: 42mm;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.invoice-notes .invoice-label:not(:first-child) {
  margin-top: 4mm;
}

.invoice-notes p {
  white-space: pre-line;
}

.totals-panel > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8mm;
  padding: 2mm 0;
  color: #646977;
  font-size: 8.5pt;
}

.totals-panel > div > strong {
  color: #252831;
  font-variant-numeric: tabular-nums;
  font-weight: 630;
  text-align: right;
  white-space: nowrap;
}

.totals-panel > .total-due {
  padding: 4mm 0 2mm;
  margin-top: 2mm;
  border-top: 0.5mm solid #171921;
  color: #171921;
  font-size: 10pt;
  font-weight: 720;
}

.totals-panel > .total-due > strong {
  color: #11131a;
  font-size: 16pt;
  font-weight: 760;
  letter-spacing: -0.035em;
}

.totals-panel > small {
  display: block;
  margin-top: 1mm;
  color: #999da8;
  font-size: 6.8pt;
  line-height: 1.4;
  text-align: right;
}

.payment-panel > div:first-child {
  min-width: 0;
}

.payment-panel > div:first-child > strong {
  display: block;
  color: #161923;
  font-size: 8.5pt;
  font-weight: 700;
  line-height: 1.4;
}

.payment-panel > dl {
  display: grid;
  grid-column: 2 / -1;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5mm;
  padding: 0;
  margin: 0;
}

.payment-panel > dl > div {
  min-width: 0;
}

.payment-panel dt {
  margin: 0 0 1.5mm;
  color: #8a8f9d;
  font-size: 6.5pt;
  font-weight: 760;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
}

.payment-panel dd {
  margin: 0;
  color: #262a34;
  font-size: 7.5pt;
  font-variant-numeric: tabular-nums;
  font-weight: 620;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.invoice-footer > span:last-child {
  flex: 0 0 auto;
  color: #525764;
  font-weight: 680;
  text-align: right;
}

/* Shell aliases used by the semantic application markup. */
.workspace {
  display: grid;
  grid-column: 2;
  grid-row: 1 / -1;
  grid-template-rows: var(--topbar-height) minmax(calc(100svh - var(--topbar-height)), auto);
  min-width: 0;
}

.brand__mark {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 8px 24px rgba(49, 65, 255, 0.16);
}

.brand__mark img,
.brand .brand__mark img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.brand__copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  line-height: 1.15;
}

.brand__copy strong {
  color: #fff;
  font-size: 15px;
  font-weight: 740;
  letter-spacing: -0.025em;
}

.brand__copy span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 620;
  letter-spacing: 0.075em;
  text-transform: uppercase;
}

.workspace > .topbar {
  grid-column: 1;
  grid-row: 1;
}

.workspace > .content,
.workspace > #app-content,
#app-content {
  grid-column: 1;
  grid-row: 2;
  width: 100%;
  min-width: 0;
  max-width: 1660px;
  padding: clamp(24px, 3.5vw, 48px);
  margin: 0 auto;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.sidebar__label {
  margin: 12px 10px 8px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 760;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.nav-link {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 620;
  line-height: 1.2;
  text-align: left;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease, transform 150ms ease;
}

.nav-link::before {
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: -4px;
  width: 2px;
  border-radius: 99px;
  background: var(--accent);
  content: "";
  opacity: 0;
  transform: scaleY(0.4);
  transition: opacity 150ms ease, transform 150ms ease;
}

.nav-link:hover {
  border-color: rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.045);
  color: #fff;
}

.nav-link.active,
.nav-link.is-active,
.nav-link[aria-current="page"] {
  border-color: rgba(97, 103, 255, 0.2);
  background: var(--accent-soft);
  color: #fff;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.035);
}

.nav-link.active::before,
.nav-link.is-active::before,
.nav-link[aria-current="page"]::before {
  opacity: 1;
  transform: scaleY(1);
}

.nav-link__icon {
  display: grid;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  place-items: center;
  color: currentColor;
  opacity: 0.82;
}

.sidebar__footer {
  display: flex;
  padding-top: 16px;
  margin-top: auto;
  align-items: flex-start;
  gap: 10px;
  border-top: 1px solid var(--line);
}

.privacy-indicator {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(55, 211, 154, 0.08);
}

.sidebar__footer > span:last-child {
  min-width: 0;
}

.sidebar__footer strong,
.sidebar__footer small {
  display: block;
}

.sidebar__footer strong {
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 650;
}

.sidebar__footer small {
  margin-top: 3px;
  color: var(--faint);
  font-size: 9px;
  line-height: 1.4;
}

.topbar__context {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.topbar__context p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.topbar__context .eyebrow {
  margin: 0 0 3px;
  color: #709fd4;
  font-size: 8px;
  letter-spacing: 0.12em;
}

.topbar__context #page-title {
  margin: 0;
  overflow: hidden;
  color: #fff;
  font-size: 15px;
  font-weight: 690;
  letter-spacing: -0.015em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar__actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 9px;
}

.local-status {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border: 1px solid rgba(55, 211, 154, 0.16);
  border-radius: 999px;
  background: rgba(55, 211, 154, 0.055);
  color: #75d8b4;
  font-size: 10px;
  font-weight: 690;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.local-status::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(55, 211, 154, 0.1);
  content: "";
}

.local-status__dot {
  display: none;
}

.local-status.has-unsaved {
  border-color: rgba(255, 187, 82, 0.2);
  background: rgba(255, 187, 82, 0.065);
  color: #efc473;
}

.local-status.has-unsaved::before {
  background: var(--warning);
  box-shadow: 0 0 0 3px rgba(255, 187, 82, 0.1);
}

.void-print-note {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  padding: 7px 10px;
  border: 1px solid rgba(255, 95, 114, 0.18);
  border-radius: 8px;
  background: rgba(255, 95, 114, 0.055);
  color: #ff9aa6;
  font-size: 10px;
  font-weight: 680;
}

.button--primary {
  border-color: rgba(98, 87, 255, 0.64);
  background: var(--accent);
  box-shadow: 0 8px 24px rgba(60, 70, 255, 0.2), inset 0 1px rgba(255, 255, 255, 0.19);
  color: #fff;
}

.button--primary:hover:not(:disabled) {
  box-shadow: 0 11px 30px rgba(60, 70, 255, 0.3), inset 0 1px rgba(255, 255, 255, 0.24);
}

.button--secondary {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
}

.button--ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-soft);
}

.button--danger {
  border-color: rgba(255, 95, 114, 0.22);
  background: rgba(255, 95, 114, 0.09);
  color: #ff8391;
}

.sidebar-toggle {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.045);
  color: #fff;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 50%;
  z-index: 300;
  padding: 10px 14px;
  border-radius: 9px;
  background: #fff;
  color: #08080d;
  font-size: 12px;
  font-weight: 700;
  transform: translate(-50%, -150%);
  transition: transform 150ms ease;
}

.skip-link:focus {
  color: #08080d;
  transform: translate(-50%, 0);
}

.toast-region {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 140;
  display: flex;
  width: min(390px, calc(100vw - 44px));
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

@media (max-width: 1380px) {
  .editor-layout {
    grid-template-columns: minmax(380px, 0.75fr) minmax(580px, 1.25fr);
  }

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

@media (max-width: 1120px) {
  .editor-layout {
    grid-template-columns: 1fr;
  }

  .preview-pane {
    position: relative;
    top: auto;
    max-height: none;
  }

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

@media (max-width: 860px) {
  :root {
    --topbar-height: 62px;
  }

  .app-shell {
    display: block;
    min-height: 100svh;
  }

  .workspace {
    display: block;
    min-height: 0;
  }

  .sidebar {
    position: relative;
    z-index: 35;
    width: 100%;
    height: auto;
    min-height: 0;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.16);
  }

  .brand {
    min-height: 40px;
    padding: 0 4px 10px;
  }

  .brand img {
    max-width: 116px;
    height: 27px;
  }

  .brand-subtitle,
  .nav-label,
  .sidebar-footer {
    display: none;
  }

  .nav-list {
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 1px;
    scrollbar-width: none;
  }

  .sidebar__nav {
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 1px;
    scrollbar-width: none;
  }

  .sidebar__nav::-webkit-scrollbar {
    display: none;
  }

  .nav-link {
    width: auto;
    min-height: 38px;
    flex: 0 0 auto;
    padding: 8px 12px;
    white-space: nowrap;
  }

  .nav-link::before {
    top: auto;
    right: 12px;
    bottom: -1px;
    left: 12px;
    width: auto;
    height: 2px;
    transform: scaleX(0.4);
  }

  .nav-link.active::before,
  .nav-link[aria-current="page"]::before {
    transform: scaleX(1);
  }

  .nav-list::-webkit-scrollbar {
    display: none;
  }

  .nav-list li {
    flex: 0 0 auto;
  }

  .nav-button {
    width: auto;
    min-height: 38px;
    padding: 8px 12px;
    white-space: nowrap;
  }

  .nav-button::before {
    top: auto;
    right: 12px;
    bottom: -1px;
    left: 12px;
    width: auto;
    height: 2px;
    transform: scaleX(0.4);
  }

  .nav-button.active::before,
  .nav-button[aria-current="page"]::before {
    transform: scaleX(1);
  }

  .topbar {
    position: sticky;
    min-height: var(--topbar-height);
    padding: 0 18px;
  }

  .content {
    padding: 26px 18px 40px;
  }

  .workspace > .content,
  .workspace > #app-content,
  #app-content {
    padding: 26px 18px 40px;
  }

  .view-header {
    align-items: flex-start;
    flex-direction: column;
    margin-bottom: 22px;
  }

  .view-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .editor-layout {
    display: block;
  }

  .preview-pane {
    margin-top: 18px;
  }
}

@media (max-width: 640px) {
  .topbar-title {
    display: none;
  }

  .topbar {
    justify-content: flex-end;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .stat-grid,
  .form-grid,
  .form-grid.three-columns {
    grid-template-columns: 1fr;
  }

  .form-grid .full-width,
  .field.full-width {
    grid-column: auto;
  }

  .stat-card {
    padding: 17px 18px;
  }

  .panel {
    border-radius: 14px;
  }

  .panel-header,
  .panel-footer,
  .modal-header,
  .modal-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-body,
  .modal-body {
    padding: 18px;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-group,
  .toolbar .field,
  .toolbar .search-field {
    width: 100%;
  }

  .toolbar-group .button {
    flex: 1 1 auto;
  }

  .preview-pane {
    padding: 16px;
    margin-right: -18px;
    margin-left: -18px;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .preview-toolbar {
    top: -16px;
    padding-top: 13px;
  }

  .line-item-row {
    grid-template-columns: 1fr 92px 40px;
  }

  .modal {
    align-items: end;
    padding: 12px;
  }

  .modal-dialog,
  .modal-dialog.wide {
    width: 100%;
    max-height: calc(100svh - 24px);
  }

  .toast-container {
    right: 12px;
    bottom: 12px;
    width: calc(100vw - 24px);
  }

  .toast-region {
    right: 12px;
    bottom: 12px;
    width: calc(100vw - 24px);
  }
}

@media (max-width: 430px) {
  .content {
    padding-right: 14px;
    padding-left: 14px;
  }

  .view-actions .button {
    flex: 1 1 auto;
  }

  .line-item-row {
    grid-template-columns: 1fr 40px;
  }

  .line-item-row .field:nth-child(2) {
    grid-column: 1;
  }

  .line-item-row .button {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: stretch;
    height: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Compact off-canvas navigation for phones and tablets. */
@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 80;
    width: min(300px, 86vw);
    height: 100svh;
    padding: 20px 16px 18px;
    overflow-y: auto;
    border-right: 1px solid var(--line-strong);
    border-bottom: 0;
    background: rgba(7, 7, 12, 0.985);
    box-shadow: 28px 0 70px rgba(0, 0, 0, 0.45);
    transform: translateX(-105%);
    transition: transform 190ms ease-out;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar .brand {
    padding: 2px 8px 21px;
  }

  .sidebar__label {
    display: block;
  }

  .sidebar__nav {
    flex-direction: column;
    gap: 5px;
    overflow: visible;
  }

  .nav-link {
    width: 100%;
    min-height: 44px;
    flex: none;
    padding: 10px 12px;
    white-space: normal;
  }

  .nav-link::before {
    top: 10px;
    right: auto;
    bottom: 10px;
    left: -4px;
    width: 2px;
    height: auto;
    transform: scaleY(0.4);
  }

  .nav-link.active::before,
  .nav-link.is-active::before,
  .nav-link[aria-current="page"]::before {
    transform: scaleY(1);
  }

  .sidebar__footer {
    display: flex;
  }

  .sidebar-toggle {
    display: inline-flex;
  }

  .workspace,
  .topbar,
  .content,
  #app-content {
    width: 100%;
  }

  .topbar {
    justify-content: space-between;
  }

  .topbar__actions {
    width: auto;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .invoice-item-row {
    grid-template-columns: minmax(0, 1fr) 110px 36px;
  }

  .invoice-item-row .item-description,
  .invoice-item-row .item-detail {
    grid-column: 1;
  }

  .invoice-item-row .item-amount {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .invoice-item-row .remove-item {
    grid-column: 3;
    grid-row: 1 / span 2;
    align-self: stretch;
    height: auto;
    margin: 0;
  }
}

@media (max-width: 640px) {
  .view-header.compact,
  .editor-header {
    align-items: stretch;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .header-actions .button {
    flex: 1 1 auto;
  }

  .form-grid.two-column {
    grid-template-columns: 1fr;
  }

  .form-grid .span-2,
  .span-2 {
    grid-column: auto;
  }

  .bank-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .bank-card > div:last-child {
    width: 100%;
    justify-content: flex-end;
  }

  .invoice-item-row {
    grid-template-columns: minmax(0, 1fr) 38px;
  }

  .invoice-item-row .item-description,
  .invoice-item-row .item-detail,
  .invoice-item-row .item-amount {
    grid-column: 1;
    grid-row: auto;
  }

  .invoice-item-row .remove-item {
    grid-column: 2;
    grid-row: 1 / span 3;
  }

  .local-status {
    display: none;
  }

  .topbar__context #page-title {
    max-width: 34vw;
  }
}

/* ---------------------------------------------------------------------------
   Shared access: sign-in gate, viewer chip, actors and the activity log
   --------------------------------------------------------------------------- */

[hidden] {
  display: none !important;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  padding: 24px;
  overflow: auto;
  place-items: center;
  background:
    radial-gradient(circle at 78% -8%, rgba(128, 0, 255, 0.12), transparent 30rem),
    radial-gradient(circle at 22% 0%, rgba(0, 128, 255, 0.09), transparent 25rem),
    var(--bg);
}

.auth-gate__panel {
  width: min(100%, 460px);
  padding: 28px 26px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.auth-gate__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.auth-gate__brand img {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
}

.auth-gate__brand > span {
  display: grid;
  line-height: 1.15;
}

.auth-gate__brand strong {
  color: #fff;
  font-size: 15px;
  letter-spacing: -0.02em;
}

.auth-gate__brand span span {
  color: var(--muted);
  font-size: 11px;
}

.auth-gate__title {
  margin: 0;
  color: #fff;
  font-size: 20px;
  font-weight: 690;
  letter-spacing: -0.02em;
}

.auth-gate__copy {
  margin: 8px 0 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.auth-gate__clerk {
  display: grid;
  justify-items: center;
}

.auth-gate__clerk:empty {
  display: none;
}

.auth-gate__status {
  min-height: 1.3em;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.auth-gate__status.is-error {
  color: #ff9aa6;
}

.auth-gate__actions {
  margin-top: 14px;
}

.viewer-menu {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.viewer-chip {
  display: inline-flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.15;
}

.viewer-chip__name {
  max-width: 190px;
  overflow: hidden;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-chip__role {
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.viewer-chip__role.is-admin {
  color: #75d8b4;
}

.user-button {
  display: grid;
  min-width: 32px;
  min-height: 32px;
  place-items: center;
}

.user-button:empty {
  display: none;
}

.panel-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.muted-note {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.history-actor {
  display: block;
  margin-top: 2px;
  color: var(--faint);
  font-size: 10px;
}

.audit-panel {
  margin-top: 18px;
}

.audit-list {
  display: grid;
  padding: 0;
  margin: 0;
  list-style: none;
}

.audit-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.055);
}

.audit-entry:first-child {
  border-top: 0;
}

.audit-entry strong {
  display: block;
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.audit-entry small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.audit-entry time {
  color: var(--faint);
  font-size: 10px;
  white-space: nowrap;
}

.audit-entry.is-denied strong {
  color: #ffb08a;
}

.audit-more {
  margin-top: 12px;
}

@media (max-width: 760px) {
  .viewer-chip {
    display: none;
  }
}

.field > small.is-error {
  color: #ff9aa6;
}

/* Revising an issued invoice */
.revision-banner {
  display: grid;
  gap: 14px;
  padding: 16px;
  margin-bottom: 26px;
  border: 1px solid rgba(255, 187, 82, 0.22);
  border-radius: var(--radius);
  background: rgba(255, 187, 82, 0.055);
}

.revision-banner__copy strong {
  display: block;
  color: #efc473;
  font-size: 12px;
  font-weight: 690;
}

.revision-banner__copy p {
  margin: 5px 0 0;
  color: var(--text-soft);
  font-size: 11px;
  line-height: 1.55;
}

/* Bank statements */
.stat-grid.coverage-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.coverage-card > strong {
  font-size: 17px;
  letter-spacing: -0.02em;
  white-space: normal;
}

.coverage-card__actions {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.field input[type="file"] {
  padding: 8px;
  cursor: pointer;
}

.field input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 6px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface-raised);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.toolbar.statement-toolbar {
  flex: 0 0 auto;
  padding: 0;
}
