:root {
  color-scheme: light;
  --bg: #fbfbf5;
  --surface: #ffffff;
  --surface-strong: #d4f9e0;
  --surface-muted: #fbfbf5;
  --ink: #000000;
  --muted: #71717a;
  --muted-strong: #52525b;
  --shade-30: #d4d4d8;
  --line: #e4e4e7;
  --line-strong: #d4d4d8;
  --brand: #000000;
  --brand-strong: #3f3f46;
  --accent: #c1fbd4;
  --accent-soft: #d4f9e0;
  --danger: #8f1d38;
  --success-bg: #d4f9e0;
  --warning-bg: #fff4d1;
  --danger-bg: #ffe1ea;
  --shadow: 0 8px 8px rgba(0, 0, 0, 0.08), 0 4px 4px rgba(0, 0, 0, 0.08), 0 2px 2px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.08);
  --shadow-subtle: 0 1px 2px rgba(0, 0, 0, 0.05);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(193, 251, 212, 0.38), transparent 260px),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-feature-settings: "ss03";
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.app-shell {
  width: min(100%, 960px);
  margin: 0 auto;
  padding: 18px;
}

.unlock-view {
  display: grid;
  align-content: center;
  width: 100%;
  min-height: 100svh;
  gap: 24px;
  min-width: 0;
}

.brand-lockup {
  display: grid;
  justify-items: center;
  gap: 14px;
  text-align: center;
}

.brand-mark {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  overflow: hidden;
  color: #fff;
  background: var(--ink);
  border: 1px solid #000;
  border-radius: 14px;
  box-shadow: var(--shadow-subtle);
  font-size: 15px;
  font-weight: 850;
  line-height: 1;
}

.brand-mark::after {
  position: absolute;
  right: -8px;
  bottom: -8px;
  width: 24px;
  height: 24px;
  background: var(--accent);
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 999px;
  content: "";
}

.brand-mark-large {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  font-size: 21px;
}

.brand-mark-large::after {
  right: -10px;
  bottom: -10px;
  width: 34px;
  height: 34px;
}

.brand-lockup h1,
.app-header h1,
.section-heading h2 {
  margin: 0;
  line-height: 1.05;
}

.brand-lockup h1 {
  font-size: clamp(40px, 8vw, 62px);
  font-weight: 430;
  letter-spacing: 0.4px;
}

.auth-panel,
.panel,
fieldset,
.generated-summary,
.company-row,
.invoice-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-subtle);
}

.auth-panel {
  display: grid;
  width: 100%;
  min-width: 0;
  gap: 16px;
  padding: 22px;
}

.password-fallback {
  display: grid;
  gap: 12px;
  padding-top: 2px;
}

.password-fallback summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
}

.password-fallback[open] {
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.legal-links {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.legal-links a {
  color: inherit;
  text-decoration: none;
}

.legal-links a:hover,
.legal-links a:focus-visible {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.app-footer {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 8px 0 2px;
}

.app-version {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.main-view {
  display: grid;
  gap: 18px;
  padding-bottom: 28px;
}

.section-heading,
.action-row,
.invoice-row,
.company-row,
.invoice-document-header,
.invoice-total-block div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 4px 0 0;
}

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

.signed-in-email {
  max-width: min(34vw, 260px);
  overflow: hidden;
  color: var(--muted-strong);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 650;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legal-body {
  display: block;
}

.legal-document {
  width: min(100%, 860px);
  margin: 0 auto;
  padding: 20px 18px 56px;
}

.legal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 36px;
}

.legal-home-link {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
  text-decoration: none;
}

.legal-hero {
  display: grid;
  gap: 14px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-subtle);
}

.legal-hero h1 {
  margin: 0;
  font-size: clamp(42px, 8vw, 74px);
  font-weight: 430;
  line-height: 0.98;
}

.legal-hero p,
.legal-content p {
  margin: 0;
  color: var(--muted-strong);
  line-height: 1.65;
}

.legal-updated {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  text-transform: uppercase;
}

.legal-note {
  padding: 12px 14px;
  color: var(--ink) !important;
  background: var(--warning-bg);
  border: 1px solid #ead387;
  border-radius: 14px;
  font-size: 14px;
}

.legal-content {
  display: grid;
  gap: 12px;
  margin-top: 24px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-subtle);
}

.legal-content h2 {
  margin: 22px 0 0;
  font-size: 18px;
  line-height: 1.25;
}

.legal-content h2:first-child {
  margin-top: 0;
}

.legal-content a {
  color: var(--ink);
  font-weight: 750;
  text-underline-offset: 4px;
}

.section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.section-subtitle {
  max-width: 640px;
  margin: 4px 0 0;
  color: var(--muted-strong);
  font-size: 14px;
  line-height: 1.45;
}

.business-setup-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.business-setup-panel h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.business-setup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.muted-copy {
  margin: 6px 0 0;
  color: var(--muted-strong);
  font-size: 14px;
  line-height: 1.45;
}

.help-guide-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 14px;
}

.help-card,
.help-examples {
  padding: 16px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.help-card-featured {
  background: var(--accent-soft);
}

.help-card h3,
.help-examples h3 {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 650;
}

.help-card p,
.help-definition-list,
.help-steps {
  margin: 0;
}

.help-steps {
  display: grid;
  gap: 8px;
  padding-left: 20px;
  color: var(--muted-strong);
  font-size: 14px;
  line-height: 1.45;
}

.help-definition-list {
  display: grid;
  gap: 12px;
}

.help-definition-list div {
  display: grid;
  gap: 3px;
}

.help-definition-list dt {
  color: var(--ink);
  font-size: 14px;
  font-weight: 750;
}

.help-definition-list dd {
  margin: 0;
  color: var(--muted-strong);
  font-size: 14px;
  line-height: 1.45;
}

.help-note {
  margin-top: 12px !important;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.help-examples {
  display: grid;
  gap: 14px;
  margin-top: 14px;
  background: var(--surface);
}

.help-example-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.help-example-button {
  display: grid;
  min-height: 96px;
  align-content: start;
  gap: 6px;
  padding: 14px;
  color: var(--ink);
  text-align: left;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-subtle);
}

.help-example-button:hover {
  background: var(--accent-soft);
  border-color: var(--line-strong);
}

.help-example-button strong {
  font-size: 14px;
  line-height: 1.2;
}

.help-example-button span {
  color: var(--muted-strong);
  font-size: 12px;
  line-height: 1.35;
}

.change-summary-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  margin: 0;
  overflow: auto;
  padding: 0;
  list-style: none;
}

.change-summary-list li {
  display: grid;
  grid-template-columns: minmax(96px, 0.8fr) minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted-strong);
  font-size: 13px;
  line-height: 1.35;
}

.change-summary-list strong {
  color: var(--ink);
  font-weight: 650;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.change-summary-list .change-summary-empty {
  grid-template-columns: 1fr;
}

.app-brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.app-header h1 {
  overflow: hidden;
  font-size: 25px;
  font-weight: 650;
  letter-spacing: 0.2px;
  margin: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 999px;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-subtle);
}

.tab-button,
.segment-button,
.primary-button,
.secondary-button,
.google-signin-button,
.icon-button,
.danger-button,
.danger-link-button,
.text-button {
  min-height: 44px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 650;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

a.primary-button,
a.secondary-button,
a.google-signin-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.tab-button,
.segment-button {
  color: var(--muted);
  background: transparent;
}

.tab-button.is-active,
.segment-button.is-active,
.icon-button.is-active {
  color: var(--ink);
  background: var(--accent-soft);
}

.primary-button {
  color: #fff;
  background: var(--brand);
  border: 1px solid var(--brand);
  padding: 0 20px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.14);
}

.primary-button:active,
.tab-button.is-active:active,
.segment-button.is-active:active,
.icon-button.is-active:active {
  background: var(--brand-strong);
}

.secondary-button,
.icon-button {
  color: var(--brand-strong);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 0 18px;
}

.secondary-button:hover,
.icon-button:hover {
  border-color: var(--line-strong);
  background: var(--accent-soft);
}

.google-signin-button {
  gap: 12px;
  min-height: 48px;
  color: #1f1f1f;
  background: #fff;
  border: 1px solid #dadce0;
  padding: 0 18px;
  box-shadow: var(--shadow-subtle);
  font-weight: 650;
}

.google-signin-button:hover {
  background: #f8fafd;
  border-color: #c9d2e3;
}

.google-mark {
  width: 20px;
  height: 20px;
  display: block;
  flex: 0 0 auto;
  background: #fff;
  object-fit: contain;
}

.back-button {
  color: var(--ink);
  background: var(--accent-soft);
}

.language-toggle-button {
  min-width: 76px;
}

.danger-button {
  color: #fff;
  background: var(--danger);
  border: 1px solid var(--danger);
  padding: 0 18px;
}

.compact-button {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.danger-link-button {
  min-height: 28px;
  color: var(--danger);
  background: transparent;
  padding: 0 2px;
  font-size: 12px;
  font-weight: 850;
}

.text-button {
  justify-self: start;
  min-height: 36px;
  color: var(--danger);
  background: transparent;
  padding: 0;
}

.panel {
  padding: 18px;
  box-shadow: var(--shadow);
}

.section-heading {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.section-heading h2 {
  font-size: 28px;
  font-weight: 500;
  letter-spacing: 0.42px;
}

.stacked-form,
fieldset,
.mode-fields,
.custom-items,
.reference-list {
  display: grid;
  gap: 12px;
}

fieldset {
  margin: 0 0 14px;
  padding: 16px;
  background: var(--surface-muted);
  box-shadow: none;
}

legend {
  padding: 0 6px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
}

label,
.search-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.inline-help-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.label-title-help {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.label-with-info {
  display: inline-flex;
  position: relative;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.field-info {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.field-info summary {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: var(--ink);
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: help;
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
  list-style: none;
}

.field-info summary::-webkit-details-marker {
  display: none;
}

.field-info summary:focus-visible {
  outline: 3px solid rgba(193, 251, 212, 0.8);
  outline-offset: 2px;
}

.field-info-text {
  display: none;
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  left: 0;
  width: min(280px, calc(100vw - 32px));
  padding: 10px 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.45;
}

.field-info[open] .field-info-text,
.field-info:hover .field-info-text,
.field-info:focus-within .field-info-text {
  display: block;
}

.inline-help {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  padding: 10px 12px;
  font-size: 16px;
}

.money-input {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  overflow: hidden;
}

.money-input > span {
  display: grid;
  place-items: center;
  align-self: stretch;
  min-width: 40px;
  color: var(--ink);
  background: var(--accent-soft);
  border-right: 1px solid var(--line);
  font-weight: 850;
}

.money-input input {
  min-height: 44px;
  border: 0;
  border-radius: 0;
}

.money-input:focus-within {
  outline: 3px solid rgba(193, 251, 212, 0.8);
  border-color: var(--brand);
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(193, 251, 212, 0.8);
  border-color: var(--brand);
}

input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
}

.checkbox-field {
  grid-template-columns: auto 1fr;
  align-items: center;
  width: fit-content;
}

.checkbox-field input {
  width: 18px;
  min-height: 18px;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.inline-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.custom-item {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.advanced-section,
.reference-item {
  display: grid;
  gap: 10px;
}

.field-row-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.field-row-heading > span,
.field-group-label {
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

.generated-summary {
  display: grid;
  gap: 10px;
  margin: 4px 0 14px;
  padding: 14px;
  background: var(--accent-soft);
}

.generated-summary div {
  display: grid;
  gap: 4px;
}

.generated-summary span,
.invoice-muted,
.invoice-row span,
.company-row span,
.invoice-row small,
.company-row small {
  color: var(--muted);
}

.generated-summary strong {
  overflow-wrap: anywhere;
}

.invoice-advisory {
  margin: 2px 0 0;
  color: var(--muted-strong);
  font-size: 0.9rem;
  line-height: 1.4;
}

.action-row {
  align-items: stretch;
  flex-wrap: wrap;
}

.action-row > button {
  flex: 1;
  min-width: 116px;
}

.compact-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.compact-actions > button {
  flex: 0 1 auto;
}

.security-settings {
  display: grid;
  gap: 10px;
}

.confirm-save-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--accent-soft);
}

.confirm-save-panel[hidden] {
  display: none;
}

.unsaved-changes-panel {
  position: sticky;
  top: 8px;
  z-index: 8;
  margin: 12px 0;
}

.settings-row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.settings-row h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.settings-row .secondary-button {
  flex: 0 0 auto;
}

.invoice-list,
.company-list,
.admin-user-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.admin-user-row {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-subtle);
}

.admin-create-user-form {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(120px, 0.5fr) minmax(120px, 0.5fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.admin-search-field,
.member-email-user-search-field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.member-email-user-search-field {
  margin-bottom: 0;
}

.admin-stats-panel,
.admin-member-email-panel,
.admin-tenant-view-panel {
  display: grid;
  gap: 12px;
  margin: 12px 0;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-subtle);
}

.admin-stats-summary,
.admin-tenant-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.admin-stat-card {
  display: grid;
  gap: 4px;
  padding: 12px;
  background: var(--canvas-cream);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.admin-stat-card span,
.admin-stat-card small,
.admin-stat-chip-row span,
.admin-top-user-list small,
.admin-readonly-list dt,
.admin-readonly-table span,
.admin-readonly-table small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.admin-stat-card strong {
  font-size: 20px;
}

.admin-stats-detail,
.admin-tenant-view-content,
.admin-tenant-section {
  display: grid;
  gap: 10px;
}

.admin-stats-detail {
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
}

.admin-stats-detail h4,
.admin-tenant-section h4 {
  margin: 0;
  font-size: 14px;
}

.admin-stat-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-stat-chip-row span {
  padding: 6px 8px;
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.admin-top-user-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.admin-top-user-list li,
.admin-readonly-table article {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  background: var(--canvas-cream);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.admin-readonly-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.admin-readonly-list div {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  background: var(--canvas-cream);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.admin-readonly-list dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.admin-readonly-table {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
}

.admin-readonly-row-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.compact-heading {
  margin-bottom: 0;
}

.compact-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.admin-member-email-form,
.member-email-user-list {
  display: grid;
  gap: 10px;
}

.member-email-user-list {
  max-height: 260px;
  overflow: auto;
  padding: 10px;
  background: var(--canvas-cream);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.member-email-selection-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.member-email-selection-summary strong {
  color: var(--ink);
}

.member-email-user-option {
  width: 100%;
}

.member-email-user-option span {
  display: grid;
  gap: 2px;
}

.member-email-user-option small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.member-email-preview {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
  padding: 12px;
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 13px;
}

.member-email-preview p,
.member-email-preview ul {
  margin: 0;
}

.member-email-preview ul {
  padding-left: 18px;
}

.member-email-runs {
  display: grid;
  gap: 8px;
}

.member-email-run {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  background: var(--canvas-cream);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 13px;
}

.member-email-run > div {
  display: grid;
  gap: 3px;
}

.member-email-run span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.member-email-run summary {
  cursor: pointer;
  font-weight: 750;
}

.member-email-run ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.admin-user-summary,
.admin-user-meta {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 10px;
}

.admin-user-summary div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.admin-user-summary span,
.admin-user-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.admin-user-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.admin-checkbox {
  align-self: end;
}

.invoice-row,
.company-row {
  align-items: flex-start;
  padding: 16px;
  border-color: var(--line);
  box-shadow: var(--shadow-subtle);
}

.invoice-row:hover,
.company-row:hover,
.admin-user-row:hover {
  border-color: var(--line-strong);
}

.invoice-row > div:first-child,
.company-row > div:first-child {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.invoice-row-title {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.invoice-row-title strong {
  min-width: 0;
  font-size: 16px;
  font-weight: 650;
}

.invoice-row-title .status-pill {
  justify-self: end;
}

.invoice-row strong,
.company-row strong,
.invoice-row span,
.invoice-row small {
  min-width: 0;
  overflow-wrap: anywhere;
}

.invoice-row-actions {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.invoice-row-meta,
.invoice-row-buttons {
  display: flex;
  align-items: center;
  gap: 6px 8px;
}

.invoice-row-buttons {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.invoice-row-buttons .danger-link-button {
  flex: 0 0 auto;
}

.delete-confirm-panel {
  display: grid;
  gap: 8px;
  justify-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--danger);
  font-size: 13px;
  font-weight: 800;
}

.delete-confirm-panel > div {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--surface-strong);
  padding: 0 9px;
  font-size: 12px;
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
}

.status-pill.is-active {
  color: var(--ink);
  background: var(--success-bg);
  border-color: rgba(0, 0, 0, 0.12);
}

.status-pill.is-restricted {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: rgba(143, 29, 56, 0.16);
}

.status-pill.is-paid {
  color: var(--ink);
  background: var(--success-bg);
  border-color: rgba(0, 0, 0, 0.12);
}

.status-pill.is-unpaid {
  color: var(--ink);
  background: var(--warning-bg);
  border-color: rgba(0, 0, 0, 0.12);
}

.status-pill.is-overdue {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: rgba(143, 29, 56, 0.16);
}

.status-pill.is-draft {
  color: var(--ink);
  background: var(--shade-30, #d4d4d8);
  border-color: rgba(0, 0, 0, 0.12);
}

.follow-up-panel {
  display: grid;
  gap: 12px;
  margin: 12px 0;
  padding: 14px;
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.follow-up-panel > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.follow-up-panel span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.empty-state,
.form-error,
.helper-note,
.field-help,
.form-message {
  margin: 0;
  color: var(--muted);
}

.field-help {
  font-size: 13px;
  font-weight: 650;
}

.mode-summary {
  margin: 0;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 650;
}

.form-error {
  color: var(--danger);
  font-weight: 800;
}

.form-message {
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
}

.form-message.is-error {
  color: var(--danger);
}

.is-created-invoice-view #save-invoice-button {
  display: none !important;
}

.invoice-preview {
  overflow-x: auto;
  padding-bottom: 8px;
}

.invoice-page {
  width: min(100%, 210mm);
  min-height: 297mm;
  margin: 0 auto;
  padding: 14mm;
  color: #1b1b1b;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.invoice-document-header {
  align-items: flex-start;
  padding-bottom: 28px;
  border-bottom: 2px solid #1b1b1b;
}

.invoice-business {
  margin: 0 0 4px;
  font-size: 28px;
  font-weight: 850;
}

.invoice-title-block {
  text-align: right;
}

.invoice-title-block h3 {
  margin: 0 0 4px;
  font-size: 28px;
  letter-spacing: 0;
}

.invoice-title-block p {
  margin: 0;
  font-weight: 800;
}

.invoice-party-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 24px;
  padding: 24px 0;
}

.invoice-party-block {
  display: grid;
  gap: 5px;
  align-content: start;
}

.invoice-party-block p,
.invoice-work-details p,
.account-detail p {
  margin: 0;
}

.invoice-work-details {
  display: grid;
  gap: 6px;
  margin: 0 0 18px;
}

.invoice-party-block span,
.invoice-meta-list dt {
  color: #5d665f;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.invoice-meta-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.invoice-meta-list div {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 12px;
  align-items: baseline;
}

.invoice-meta-list dt,
.invoice-meta-list dd {
  margin: 0;
}

.invoice-meta-list dd {
  text-align: right;
  font-weight: 800;
}

.invoice-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.invoice-table th,
.invoice-table td {
  padding: 10px 8px;
  border-bottom: 1px solid #d8d8d8;
  text-align: right;
  vertical-align: top;
}

.invoice-table th:first-child,
.invoice-table td:first-child {
  text-align: left;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.invoice-table th:not(:first-child),
.invoice-table td:not(:first-child) {
  width: 18%;
  white-space: nowrap;
}

.work-detail-table th:nth-child(2),
.work-detail-table td:nth-child(2) {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.work-detail-table th,
.work-detail-table td {
  padding: 9px 5px;
}

.work-detail-table th:first-child,
.work-detail-table td:first-child {
  white-space: nowrap;
}

.work-detail-table th:not(:first-child),
.work-detail-table td:not(:first-child) {
  width: auto;
}

.work-date-column {
  width: 17%;
}

.work-description-column {
  width: 40%;
}

.work-unit-column {
  width: 7%;
}

.work-quantity-column {
  width: 12%;
}

.work-price-column,
.work-subtotal-column {
  width: 12%;
}

.work-tax-column {
  width: 10%;
}

.work-detail-table-tax-breakdown .work-description-column {
  width: 31%;
}

.work-detail-table-no-unit .work-date-column {
  width: 17%;
}

.work-detail-table-no-unit .work-description-column {
  width: 45%;
}

.work-detail-table-no-unit .work-quantity-column,
.work-detail-table-no-unit .work-price-column,
.work-detail-table-no-unit .work-subtotal-column {
  width: 12.666%;
}

.invoice-table th {
  color: #fff;
  background: #000;
  font-size: 12px;
  text-transform: uppercase;
}

.invoice-table.work-detail-table th {
  font-size: 8px;
}

.line-group-row th {
  color: #000;
  background: #edf3ed;
  text-align: left;
  font-size: 10px;
}

.invoice-total-block {
  display: grid;
  gap: 8px;
  width: min(100%, 280px);
  margin: 24px 0 0 auto;
}

.invoice-total-block div {
  padding: 4px 0;
}

.grand-total {
  border-top: 2px solid #1b1b1b;
  font-size: 20px;
}

.invoice-footer {
  margin-top: 42px;
  padding-top: 16px;
  border-top: 1px solid #d8d8d8;
}

.account-detail {
  display: grid;
  gap: 4px;
  margin-bottom: 16px;
}

.invoice-footer p {
  margin: 0 0 8px;
}

@media (max-width: 520px) {
  .app-shell {
    padding: 12px;
  }

  .tab-bar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    overflow: visible;
    padding: 6px;
  }

  .tab-button,
  .segment-button {
    font-size: 12px;
  }

  .tab-button {
    min-width: 0;
    padding: 0 6px;
  }

  .header-actions .icon-button {
    min-height: 40px;
    padding: 0 14px;
    font-size: 13px;
  }

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

  .app-brand {
    justify-content: center;
  }

  .header-actions {
    justify-content: center;
    justify-self: stretch;
  }

  .signed-in-email {
    order: -1;
    flex: 1 1 100%;
    max-width: 100%;
    text-align: center;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 13px;
  }

  .app-header h1 {
    font-size: 23px;
  }

  .panel {
    padding: 12px;
  }

  .section-heading {
    gap: 10px;
    margin-bottom: 14px;
  }

  .section-heading {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .section-actions {
    width: 100%;
  }

  .section-actions .secondary-button {
    flex: 1;
    min-width: 128px;
  }

  .section-actions .primary-button {
    flex: 1.2;
    min-width: 148px;
  }

  .settings-row {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-row .secondary-button {
    width: 100%;
  }

  .field-row-heading {
    align-items: stretch;
  }

  .field-row-heading > span {
    flex: 1 1 100%;
  }

  .field-row-heading .compact-button {
    width: 100%;
  }

  .invoice-row {
    display: grid;
    gap: 12px;
  }

  .invoice-row-actions {
    justify-items: stretch;
    width: 100%;
  }

  .invoice-row-meta {
    justify-content: flex-start;
  }

  .invoice-row-buttons {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: center;
    gap: 8px;
  }

  .invoice-row-buttons .compact-button {
    width: 100%;
    min-height: 40px;
    min-width: 0;
    padding: 0 8px;
  }

  .danger-link-button {
    grid-column: 1 / -1;
    justify-self: start;
    min-height: 36px;
    margin-left: 0;
  }

  .admin-user-grid {
    grid-template-columns: 1fr;
  }

  .admin-stats-summary,
  .admin-tenant-summary,
  .admin-stats-detail,
  .admin-readonly-list {
    grid-template-columns: 1fr;
  }

  .admin-create-user-form {
    grid-template-columns: 1fr;
  }

  .admin-user-summary,
  .admin-user-meta,
  .business-setup-panel,
  .follow-up-panel > div:first-child {
    align-items: flex-start;
    flex-direction: column;
  }

  .help-guide-grid,
  .help-example-grid {
    grid-template-columns: 1fr;
  }

  .help-card,
  .help-examples {
    padding: 14px;
  }

  .help-example-button {
    min-height: 82px;
  }

  .change-summary-list li {
    grid-template-columns: 1fr;
  }

  .business-setup-actions {
    width: 100%;
    justify-content: stretch;
  }

  .business-setup-actions button {
    flex: 1 1 150px;
  }

  .invoice-page {
    min-width: 640px;
    padding: 28px;
  }
}

@page {
  size: A4;
  margin: 0;
}

@media print {
  html,
  body {
    background: #fff;
  }

  .app-header,
  .tab-bar,
  .section-heading,
  .action-row,
  #unlock-view,
  #recent-panel,
  #new-panel,
  #companies-panel,
  #business-panel {
    display: none !important;
  }

  .app-shell,
  .panel,
  .invoice-preview {
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .invoice-page {
    width: 210mm;
    min-height: 297mm;
    padding: 14mm;
    border: 0;
    box-shadow: none;
    break-after: page;
  }

  .invoice-document-header,
  .invoice-party-grid,
  .invoice-total-block,
  .invoice-footer,
  .account-detail {
    break-inside: avoid;
  }

  .invoice-table {
    break-inside: auto;
  }

  .invoice-table thead {
    display: table-header-group;
  }

  .invoice-table tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
