:root {
  --bg: oklch(92.8% 0.028 260);
  --chrome: oklch(97.4% 0.01 260);
  --surface: oklch(99.4% 0.003 260);
  --surface-muted: oklch(96.1% 0.009 260);
  --surface-tint: oklch(94.8% 0.03 130);
  --border: oklch(91.2% 0.012 260);
  --border-strong: oklch(83.5% 0.018 260);
  --text: oklch(18% 0.02 255);
  --muted: oklch(58% 0.025 255);
  --lime: oklch(88% 0.21 126);
  --lime-dark: oklch(80% 0.19 126);
  --teal: oklch(48% 0.102 172);
  --teal-dark: oklch(39% 0.09 172);
  --blue: oklch(53% 0.18 260);
  --amber: oklch(56% 0.13 68);
  --red: oklch(48% 0.17 29);
  --green: oklch(48% 0.13 148);
  --focus-ring: oklch(88% 0.21 126 / 0.34);
  --shadow: 0 24px 70px oklch(40% 0.04 260 / 0.14);
  --shadow-soft: 0 12px 28px oklch(40% 0.04 260 / 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 86% 8%, oklch(98% 0.01 260 / 0.72), transparent 18%),
    linear-gradient(180deg, oklch(94.8% 0.026 260), var(--bg));
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body.has-modal {
  overflow: hidden;
}

body.public-invoice-page {
  background: oklch(92.8% 0.028 260);
}

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

button {
  border: 0;
}

.app-shell {
  min-height: 100vh;
  padding: 30px;
}

.public-invoice-shell {
  min-height: 100vh;
  padding: 28px;
  display: grid;
  gap: 22px;
  align-content: start;
}

.public-invoice-status {
  width: min(100%, 210mm);
  margin: 0 auto;
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: oklch(99% 0.003 260);
  box-shadow: var(--shadow-soft);
}

.public-invoice-status h1 {
  margin: 0;
  font-size: 1.45rem;
}

.public-status-grid {
  display: grid;
  grid-template-columns: repeat(4, max-content);
  gap: 14px;
}

.public-status-grid div {
  min-width: 92px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.public-status-grid span,
.pin-card label {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.public-status-grid strong {
  display: block;
  margin-top: 2px;
  font-size: 0.9rem;
}

.public-invoice-gate {
  min-height: 100vh;
  padding: 28px;
  display: grid;
  place-items: center;
}

.pin-card {
  width: min(100%, 420px);
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.pin-card__mark {
  width: 52px;
  height: auto;
  display: block;
  margin-bottom: 22px;
}

.pin-card h1 {
  margin: 0;
  font-size: 1.8rem;
}

.pin-card p {
  margin: 8px 0 22px;
  color: var(--muted);
}

.pin-card form {
  display: grid;
  gap: 12px;
}

.pin-input {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-align: center;
}

.app-frame {
  min-height: calc(100vh - 60px);
  max-width: 1560px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid oklch(99% 0.003 260 / 0.92);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.sidebar {
  min-width: 0;
  position: sticky;
  top: 0;
  min-height: calc(100vh - 60px);
  height: 100%;
  background: var(--chrome);
  color: var(--text);
  border-right: 1px solid var(--border);
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.sidebar__top {
  display: grid;
  gap: 18px;
}

.brand h1 {
  margin: 0;
  font-size: 1.18rem;
  line-height: 1.15;
  font-weight: 850;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand__mark {
  width: 32px;
  height: 32px;
  display: block;
}

.sidebar__action {
  width: 100%;
}

.side-nav {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.side-nav__item {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 8px;
  color: oklch(55% 0.025 255);
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.side-nav__item span,
.side-nav__item small {
  display: block;
}

.side-nav__item span {
  font-weight: 760;
}

.side-nav__item:hover {
  background: oklch(99% 0.003 260);
  color: var(--text);
}

.side-nav__item[aria-selected="true"] {
  background: var(--lime);
  color: var(--text);
  box-shadow: 0 10px 22px oklch(74% 0.18 126 / 0.22);
}

.sidebar__metrics {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.metric {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 12px;
  background: oklch(99% 0.003 260);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 1rem;
}

.app-content {
  min-width: 0;
}

.page-header {
  min-height: 116px;
  padding: 34px 40px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 0;
  background: var(--surface);
}

.page-header h2 {
  margin: 3px 0 0;
  font-size: 1.76rem;
  line-height: 1.1;
  font-weight: 850;
}

.page-header p {
  max-width: 62ch;
  margin: 8px 0 0;
  color: var(--muted);
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.page-header__actions {
  margin-left: auto;
}

.page-header__summary {
  min-width: min(360px, 100%);
  display: grid;
  grid-template-columns: 1.1fr 0.72fr 0.72fr;
  gap: 10px;
}

.page-header__summary div {
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
  box-shadow: none;
}

.page-header__summary span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.page-header__summary strong {
  display: block;
  margin-top: 6px;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.main {
  width: min(1240px, calc(100% - 80px));
  margin: 0 auto;
  padding: 18px 0 48px;
}

.flash {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}

.flash--error {
  border-color: oklch(86.5% 0.073 28);
  color: var(--red);
  background: oklch(97.2% 0.014 28);
}

.flash--success {
  border-color: oklch(86.5% 0.08 148);
  color: var(--green);
  background: oklch(97% 0.018 148);
}

.workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
}

.panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: none;
}

.panel__header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
}

.panel__header h2,
.panel__header h3 {
  margin: 0;
  font-size: 1rem;
}

.panel-meta {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.panel__body {
  padding: 20px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 180px auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.toolbar--single {
  grid-template-columns: 1fr;
  margin-bottom: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label,
.group-label {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 760;
}

.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;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  background: var(--surface-muted);
  transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

.textarea {
  min-height: 88px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: 3px solid var(--focus-ring);
  border-color: var(--lime-dark);
  background: var(--surface);
}

.button {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--text);
  cursor: pointer;
  font-weight: 780;
  white-space: nowrap;
  transition: background-color 180ms ease, box-shadow 180ms ease, color 180ms ease, transform 180ms ease;
}

.button:hover {
  background: oklch(92% 0.012 260);
}

.button:focus-visible,
.side-nav__item:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.button:active {
  transform: translateY(1px);
}

.button--primary {
  background: var(--lime);
  color: var(--text);
  box-shadow: 0 12px 22px oklch(74% 0.18 126 / 0.22);
}

.button--primary:hover {
  background: var(--lime-dark);
}

.button--danger {
  background: oklch(94.5% 0.036 28);
  color: var(--red);
}

.button--danger:hover {
  background: oklch(91.5% 0.052 28);
}

.button--secondary {
  background: var(--surface-muted);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}

.button--secondary:hover {
  background: var(--surface);
  border-color: var(--border-strong);
}

.button--small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.86rem;
}

.button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.icon {
  width: 18px;
  height: 18px;
  display: block;
}

.icon-button {
  width: 40px;
  min-width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--text);
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.icon-button:hover {
  border-color: var(--border-strong);
  background: var(--surface);
}

.icon-button:active {
  transform: translateY(1px);
}

.icon-button:focus-visible,
.sort-button:focus-visible,
.link-button:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.icon-button--danger {
  color: var(--red);
  background: oklch(96.2% 0.018 28);
}

.icon-button--compact {
  width: 40px;
  min-width: 40px;
  height: 40px;
  border-radius: 10px;
}

.sort-button {
  width: 100%;
  min-height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: 850;
  text-align: left;
  text-transform: inherit;
}

.sort-button--right {
  justify-content: flex-end;
}

.sort-button .icon {
  width: 14px;
  height: 14px;
  color: var(--muted);
}

.sort-button.is-active {
  color: var(--text);
}

.link-button {
  min-height: 32px;
  padding: 0;
  color: var(--teal-dark);
  background: transparent;
  cursor: pointer;
  font-weight: 800;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 0;
  border-radius: var(--radius);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

.data-table th,
.data-table td {
  padding: 16px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

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

.data-table th {
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  background: transparent;
}

.data-table tbody tr:hover {
  background: var(--surface-tint);
}

.data-table tbody tr[data-action] {
  cursor: pointer;
}

.data-table tbody tr[data-action]:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: -3px;
}

.recurring-table {
  min-width: 980px;
}

.data-table td:last-child {
  text-align: right;
}

.amount {
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

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

.empty-state {
  padding: 42px 18px;
  text-align: center;
  color: var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: capitalize;
}

.status--draft {
  background: oklch(91.8% 0.006 245);
  color: oklch(36% 0.03 245);
}

.status--sent {
  background: oklch(92.5% 0.035 260);
  color: oklch(43% 0.16 260);
}

.status--paid {
  background: oklch(92.8% 0.045 148);
  color: oklch(38% 0.11 148);
}

.status--quote {
  background: oklch(94% 0.028 78);
  color: oklch(42% 0.09 78);
}

.status--active {
  background: oklch(92.8% 0.045 148);
  color: oklch(38% 0.11 148);
}

.status--paused {
  background: oklch(91.8% 0.006 245);
  color: oklch(36% 0.03 245);
}

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

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

.form-grid .field--code {
  max-width: 148px;
}

.form-grid--client {
  grid-template-columns: 132px minmax(0, 1fr) minmax(0, 1fr);
}

.invoice-form-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
}

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

.form-section,
.invoice-summary-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 20px;
}

.form-section__header {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.form-section__header h3,
.invoice-summary-card h3 {
  margin: 0;
  color: var(--text);
  font-size: 1.05rem;
  line-height: 1.25;
}

.form-section__header--compact {
  min-height: 0;
  margin: 4px 0 10px;
  padding-bottom: 10px;
}

.client-projects {
  display: grid;
  gap: 8px;
}

.client-project-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 8px;
  align-items: end;
}

.invoice-summary-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
}

.summary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin-bottom: 14px;
  color: var(--text);
  font-weight: 780;
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--lime-dark);
}

.recurring-fields {
  transition: opacity 180ms ease;
}

.recurring-fields[aria-disabled="true"] {
  opacity: 0.58;
}

.variable-palette {
  display: grid;
  gap: 12px;
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.variable-palette strong,
.variable-palette span {
  display: block;
}

.variable-palette span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.variable-palette__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.variable-chip {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 800;
}

.variable-chip:hover {
  border-color: var(--border-strong);
  background: var(--surface-tint);
}

.line-items {
  display: grid;
  gap: 8px;
}

.line-items__header {
  display: grid;
  grid-template-columns: minmax(104px, 0.66fr) minmax(190px, 1.12fr) minmax(150px, 0.95fr) minmax(170px, 1.18fr) 58px 84px 96px 76px;
  gap: 8px;
  padding: 0 8px 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.line-item {
  display: grid;
  grid-template-columns: minmax(104px, 0.66fr) minmax(190px, 1.12fr) minmax(150px, 0.95fr) minmax(170px, 1.18fr) 58px 84px 96px 76px;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.line-item .field {
  gap: 0;
}

.line-item .input,
.line-item .select {
  min-height: 40px;
  padding: 8px 10px;
  background: var(--surface-muted);
}

.service-combobox {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 6px;
  align-items: center;
}

.service-combobox .input {
  min-width: 0;
}

.line-item__project,
.line-item__service {
  min-width: 0;
}

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

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

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

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

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

.line-item__remove {
  justify-self: stretch;
  width: 100%;
}

.line-total {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--surface);
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.totals {
  margin-top: 0;
  margin-left: auto;
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 14px 26px;
  justify-content: flex-end;
}

.totals div {
  display: grid;
  gap: 3px;
  min-width: 120px;
  text-align: right;
}

.totals .grand-total {
  min-width: 152px;
  padding-top: 0;
  padding-left: 24px;
  border-top: 0;
  border-left: 2px solid var(--text);
  font-size: 1.24rem;
  font-weight: 800;
}

.invoice-view {
  background: var(--surface);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: oklch(15% 0.025 255 / 0.54);
  backdrop-filter: blur(10px);
}

.invoice-modal {
  width: min(1120px, 100%);
  max-height: min(92dvh, 960px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 28px 90px oklch(10% 0.025 255 / 0.38);
}

.invoice-modal--editor {
  width: min(1280px, 100%);
}

.invoice-modal--editor .panel__header {
  border-radius: 8px 8px 0 0;
}

.invoice-modal--editor .panel__body {
  overflow: auto;
}

.form-modal {
  width: min(860px, 100%);
  max-height: min(92dvh, 900px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 28px 90px oklch(10% 0.025 255 / 0.38);
}

.form-modal--narrow {
  width: min(560px, 100%);
}

.form-modal .panel__body {
  overflow: auto;
}

.invoice-modal__header {
  min-width: 0;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.invoice-modal__header h2 {
  margin: 2px 0 0;
  font-size: 1.16rem;
}

.invoice-modal__body {
  min-width: 0;
  overflow: auto;
  padding: 24px;
  background: oklch(94% 0.024 260);
}

.invoice-print {
  width: min(100%, 210mm);
  height: 297mm;
  margin: 0 auto;
  padding: 18mm 14mm 12mm;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 8mm;
  background: oklch(93% 0.026 260);
  border: 1px solid var(--border);
  color: oklch(14% 0.01 260);
  box-shadow: 0 18px 46px oklch(23% 0.032 245 / 0.1);
}

.invoice-sheet {
  position: relative;
  min-height: 0;
  padding: 30mm 14mm 18mm;
  display: flex;
  flex-direction: column;
  background: oklch(99.5% 0.002 260);
}

.invoice-sheet-mark {
  position: absolute;
  top: -15mm;
  left: 50%;
  width: 30mm;
  height: auto;
  transform: translateX(-50%);
  display: block;
}

.invoice-sheet__header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(68mm, auto);
  gap: 18mm;
  align-items: start;
}

.invoice-business-address,
.invoice-client-block address {
  margin: 0;
  color: oklch(16% 0.01 260);
  font-size: 9pt;
  font-style: normal;
  line-height: 1.48;
}

.invoice-business-address strong,
.invoice-client-block strong {
  display: block;
  margin-bottom: 1mm;
  font-size: 9.5pt;
  font-weight: 850;
}

.invoice-title-block {
  text-align: right;
}

.invoice-title-block h3 {
  margin: 0;
  font-size: 22pt;
  font-weight: 900;
  line-height: 1.05;
  text-transform: uppercase;
}

.invoice-title-block h3 span {
  margin-left: 4mm;
}

.invoice-title-block time {
  display: block;
  margin-top: 8mm;
  font-size: 11pt;
}

.invoice-client-block {
  margin-top: 24mm;
}

.invoice-table-block {
  margin-top: 24mm;
}

.invoice-pdf-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.invoice-pdf-table th {
  padding: 0 1mm 3mm;
  border-bottom: 1px solid oklch(14% 0.01 260);
  color: oklch(14% 0.01 260);
  font-size: 7.8pt;
  font-weight: 850;
  text-align: left;
}

.invoice-pdf-table td {
  height: 8.5mm;
  padding: 1mm 1mm;
  border-bottom: 1px solid oklch(14% 0.01 260);
  border-left: 1px solid oklch(82% 0.005 260);
  font-size: 8.3pt;
  line-height: 1.25;
  vertical-align: middle;
}

.invoice-pdf-table th:first-child,
.invoice-pdf-table td:first-child {
  border-left: 0;
  width: 13%;
}

.invoice-pdf-table th:nth-child(2),
.invoice-pdf-table td:nth-child(2) {
  width: 42%;
}

.invoice-pdf-table th:nth-child(3),
.invoice-pdf-table td:nth-child(3) {
  width: 34%;
}

.invoice-pdf-table th:last-child,
.invoice-pdf-table td:last-child {
  border-left: 1px solid oklch(82% 0.005 260);
  width: 11%;
  text-align: right;
}

.invoice-pdf-table .invoice-empty-row td {
  color: transparent;
}

.invoice-pdf-total-row td {
  height: 10mm;
  border-top: 1.5px solid oklch(14% 0.01 260);
  border-bottom: 1.5px solid oklch(14% 0.01 260);
  border-left: 0;
  font-weight: 900;
}

.invoice-pdf-total-row td:first-child {
  text-transform: uppercase;
}

.invoice-access-band {
  min-height: 24mm;
  margin: auto -14mm -18mm;
  padding: 3.5mm 42mm;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24mm minmax(0, 1fr);
  gap: 7mm;
  align-items: center;
  background: oklch(88% 0.028 260);
}

.invoice-access-band__link {
  justify-self: end;
  max-width: 100%;
  font-size: 12pt;
  font-weight: 400;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  text-align: right;
}

.invoice-access-band__link a {
  color: inherit;
  text-decoration: none;
}

.invoice-access-band__link strong {
  font-weight: 900;
}

.invoice-access-band__qr {
  width: 24mm;
  height: 24mm;
  display: grid;
  place-items: center;
  border: 1px solid oklch(14% 0.01 260);
  border-radius: 4mm;
  background: white;
  overflow: hidden;
}

.invoice-access-band__qr img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.qr-placeholder {
  padding: 2mm;
  color: oklch(45% 0.02 260);
  font-size: 6.5pt;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.invoice-access-band__pin {
  display: flex;
  gap: 3.1mm;
  align-items: center;
  font-size: 12pt;
  letter-spacing: 0;
}

.invoice-access-band__pin strong {
  font-weight: 900;
}

.invoice-access-band__pin .pin-digit {
  display: inline-block;
  font-weight: 400;
}

.lock-icon {
  width: 4.2mm;
  height: 4.2mm;
  object-fit: contain;
}

.invoice-page-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48mm;
  gap: 10mm;
  align-items: end;
}

.payment-details {
  display: flex;
  flex-wrap: wrap;
  column-gap: 4mm;
  row-gap: 3mm;
  align-items: baseline;
  color: oklch(14% 0.01 260);
  font-size: 7.5pt;
  line-height: 1.4;
}

.payment-details strong {
  flex-basis: 100%;
  font-weight: 900;
}

.payment-details span {
  white-space: nowrap;
}

.payment-detail b {
  font-weight: 900;
}

.payment-separator {
  color: oklch(56% 0.02 260);
  margin-left: -1.5mm;
  margin-right: -1.5mm;
}

.invoice-wordmark {
  width: 48mm;
  max-width: 100%;
  height: auto;
  justify-self: end;
  display: block;
}

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

.settings-backup {
  grid-column: 1 / -1;
}

.settings-template {
  grid-column: 1 / -1;
}

.pdf-template-panel {
  display: grid;
  gap: 16px;
}

.pdf-template-panel p {
  margin: 0;
}

.pdf-template-panel p + p {
  margin-top: -10px;
}

.pdf-template-editor {
  display: grid;
  gap: 10px;
}

.template-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
  overflow: hidden;
}

.template-section summary {
  min-height: 58px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  list-style: none;
}

.template-section summary::-webkit-details-marker {
  display: none;
}

.template-section summary span {
  display: grid;
  gap: 3px;
}

.template-section summary small {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.template-section .icon {
  color: var(--muted);
  transition: transform 180ms ease;
}

.template-section[open] .icon {
  transform: rotate(180deg);
}

.template-field-grid {
  padding: 0 14px 14px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.template-field label {
  font-size: 0.76rem;
}

.template-field .input[type="color"] {
  min-height: 42px;
  padding: 5px;
}

.pdf-template-actions {
  padding-top: 2px;
}

.backup-panel {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.backup-panel p {
  margin: 0;
}

.backup-panel p + p {
  margin-top: 4px;
}

.clients-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
}

.client-detail-layout {
  display: grid;
  gap: 18px;
}

.client-detail-hero .panel__header {
  align-items: flex-start;
}

.client-detail-hero h2 {
  margin-top: 4px;
  font-size: 1.45rem;
}

.client-detail-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.82fr) minmax(0, 1.18fr);
  gap: 18px;
}

.client-contact-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.client-contact-card strong,
.client-contact-card p {
  margin: 6px 0 0;
}

.client-dashboard {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.client-dashboard div {
  min-height: 94px;
  padding: 14px;
  display: grid;
  align-content: space-between;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.client-dashboard span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.client-dashboard strong {
  font-size: 1.18rem;
  font-variant-numeric: tabular-nums;
}

.services-layout {
  display: block;
}

.workspace > *,
.settings-layout > *,
.clients-layout > *,
.services-layout > * {
  min-width: 0;
}

.services-panel .panel__body {
  display: grid;
  gap: 14px;
}

.service-toolbar {
  grid-template-columns: minmax(260px, 520px);
  margin-bottom: 0;
}

.service-editor {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: stretch;
}

.service-editor strong,
.service-editor span {
  display: block;
}

.service-editor strong {
  line-height: 1.25;
}

.service-editor span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.86rem;
}

.service-editor__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
}

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

.service-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
}

.service-table th {
  padding: 12px 14px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-align: left;
  text-transform: uppercase;
}

.service-table th:nth-child(2),
.service-table td:nth-child(2) {
  width: 160px;
  text-align: right;
}

.service-table th:nth-child(3),
.service-table td:nth-child(3) {
  width: 150px;
  text-align: right;
}

.service-table td {
  padding: 16px 14px;
  border-bottom: 1px solid var(--border);
  background: transparent;
  vertical-align: middle;
}

.service-table td:first-child {
  border-left: 0;
  border-radius: 0;
}

.service-table td:last-child {
  border-right: 0;
  border-radius: 0;
}

.service-table tbody tr:hover td {
  background: var(--surface-tint);
  box-shadow: none;
}

.service-table td strong,
.service-table td span {
  display: block;
}

.service-table td strong {
  line-height: 1.25;
}

.service-table td span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.84rem;
}

.service-table__actions {
  justify-content: flex-end;
}

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

  .service-editor__actions {
    justify-content: flex-start;
  }

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

  .service-table thead {
    display: none;
  }

  .service-table tbody,
  .service-table tr,
  .service-table td {
    display: block;
  }

  .service-table tr {
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: oklch(98.4% 0.005 240);
  }

  .service-table td {
    width: 100% !important;
    padding: 12px 14px;
    border: 0;
    background: transparent;
    text-align: left !important;
  }

  .service-table td:first-child,
  .service-table td:last-child {
    border: 0;
    border-radius: 0;
  }

  .service-table td:nth-child(2)::before,
  .service-table td:nth-child(3)::before {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 850;
    text-transform: uppercase;
  }

  .service-table td:nth-child(2)::before {
    content: "Default price";
  }

  .service-table td:nth-child(3)::before {
    content: "Manage";
  }

  .service-table__actions {
    justify-content: flex-start;
  }
}

@media (max-width: 920px) {
  .app-shell {
    padding: 0;
  }

  .app-frame {
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .app-frame {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    min-height: 0;
    height: auto;
    padding: 16px;
    max-width: 100vw;
    overflow: hidden;
    border-right: 0;
    border-bottom: 1px solid oklch(47% 0.104 181 / 0.36);
  }

  .sidebar__top {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .sidebar__action {
    width: auto;
  }

  .side-nav {
    display: flex;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
  }

  .side-nav__item {
    flex: 0 0 132px;
  }

  .sidebar__metrics {
    display: none;
  }

  .page-header {
    align-items: stretch;
    flex-direction: column;
    padding: 22px 20px;
  }

  .page-header__actions {
    margin-left: 0;
  }

  .page-header__summary {
    min-width: 0;
  }

  .header-metrics,
  .workspace,
  .settings-layout,
  .clients-layout,
  .client-detail-grid,
  .services-layout {
    grid-template-columns: 1fr;
  }

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

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

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

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

  .invoice-form-layout {
    grid-template-columns: 1fr;
  }

  .invoice-summary-card {
    position: static;
  }

  .invoice-sheet__header,
  .invoice-page-footer {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .invoice-title-block {
    text-align: left;
  }

  .invoice-wordmark {
    justify-self: start;
  }
}

@media (max-width: 760px) {
  .template-field-grid {
    grid-template-columns: 1fr;
  }

  .line-items__header {
    display: none;
  }

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

  .line-item__project,
  .line-item__service,
  .line-item__description,
  .line-item__details,
  .line-item__remove {
    grid-column: 1 / -1;
  }

  .line-item__quantity,
  .line-item__price,
  .line-item__total {
    grid-column: span 1;
  }

  .client-project-row {
    grid-template-columns: 1fr;
  }

  .invoice-modal {
    max-height: 96dvh;
  }

  .invoice-modal__header {
    align-items: flex-start;
    flex-direction: column;
  }

  .invoice-modal__header .button-row {
    width: 100%;
  }

  .invoice-modal__header .button {
    flex: 1 1 128px;
  }

  .invoice-modal__body {
    padding: 14px;
  }

  .invoice-summary-card {
    grid-template-columns: 1fr;
  }

  .form-grid--client,
  .client-dashboard {
    grid-template-columns: 1fr;
  }

  .form-grid .field--code {
    max-width: none;
  }

  .totals {
    justify-content: stretch;
  }

  .totals div {
    min-width: 0;
    text-align: left;
  }

  .totals .grand-total {
    padding-top: 12px;
    padding-left: 0;
    border-top: 2px solid var(--text);
    border-left: 0;
  }

  .summary-actions {
    justify-content: stretch;
  }

  .summary-actions .button {
    flex: 1 1 180px;
  }
}

@media (max-width: 620px) {
  .main {
    width: min(100% - 20px, 1180px);
  }

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

  .sidebar__action {
    width: 100%;
  }

  .page-header__summary {
    grid-template-columns: 1fr;
  }

  .header-metrics,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .invoice-print {
    padding: 22px;
    height: auto;
    min-height: 0;
    gap: 28px;
  }

  .invoice-sheet {
    min-height: 760px;
    padding: 58px 22px 26px;
  }

  .payment-details {
    flex-direction: column;
    align-items: flex-start;
  }

  .payment-separator {
    display: none;
  }

  .invoice-sheet-mark {
    top: -30px;
    width: 62px;
  }

  .invoice-pdf-table {
    min-width: 540px;
  }

  .invoice-table-block {
    overflow-x: auto;
  }
}

@page {
  size: A4;
  margin: 0;
}

@media print {
  html,
  body {
    width: 210mm;
    min-height: 297mm;
    background: oklch(93% 0.026 260);
    color: oklch(14% 0.01 260);
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .app-header,
  .sidebar,
  .page-header,
  .nav-band,
  .flash,
  .workspace-list,
  .panel__header,
  .panel__header .button-row,
  .invoice-actions,
  .no-print {
    display: none !important;
  }

  body.has-modal .app-frame {
    display: none !important;
  }

  .main,
  .app-shell,
  .app-frame,
  .app-content,
  .workspace,
  .panel,
  .invoice-view {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .panel__body,
  .invoice-print {
    padding: 0;
  }

  .modal-backdrop {
    position: static;
    display: block;
    padding: 0;
    background: transparent;
    backdrop-filter: none;
  }

  .invoice-modal {
    display: block;
    width: 210mm;
    max-height: none;
    margin: 0;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .invoice-modal__header {
    display: none !important;
  }

  .invoice-modal__body {
    overflow: visible;
    padding: 0;
    background: transparent;
  }

  .invoice-print {
    width: 210mm;
    height: 297mm;
    min-height: 297mm;
    margin: 0;
    padding: 18mm 14mm 12mm;
    border: 0;
    box-shadow: none;
    font-size: 11pt;
    background: oklch(93% 0.026 260);
  }

  .invoice-sheet {
    min-height: 0;
  }

  .invoice-table-block {
    overflow: visible;
  }

  a {
    color: inherit;
    text-decoration: none;
  }
}
