:root {
  --space-xs: 4px;
  --space-sm: 8px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;
  --space-3xl: 48px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --height-button-xs: 30px;
  --height-button-s: 36px;
  --height-button-m: 40px;
  --height-button-l: 48px;

  --font-h1: 32px;
  --font-h2: 24px;
  --font-h3: 20px;
  --font-h4: 16px;
  --font-body: 14px;
  --font-small: 12px;

  --color-canvas: #0b0f14;
  --color-surface: #151c24;
  --color-surface-raised: #1d2630;
  --color-surface-sunken: #101720;
  --color-border: #2a3542;
  --color-border-strong: #5f7488;

  --color-text: #eaf0f6;
  --color-text-muted: #9aa8b8;
  --color-text-inverse: #0b0f14;

  --color-accent: #ff7a1a;
  --color-accent-hover: #ff9147;
  --color-accent-soft: rgba(255, 122, 26, 0.14);

  --color-info: #60a5fa;
  --color-info-soft: rgba(96, 165, 250, 0.16);
  --color-success: #34d399;
  --color-success-soft: rgba(52, 211, 153, 0.16);
  --color-warning: #fbbf24;
  --color-warning-soft: rgba(251, 191, 36, 0.16);
  --color-danger: #fb7185;
  --color-danger-soft: rgba(251, 113, 133, 0.16);

  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.32);
  --shadow-sheet: 0 -8px 32px rgba(0, 0, 0, 0.48);

  --layout-max-width: 520px;
  --tab-bar-height: 64px;
}

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

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--color-canvas);
  color: var(--color-text);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.25;
}

h1 {
  font-size: var(--font-h1);
  letter-spacing: -0.02em;
}

h2 {
  font-size: var(--font-h2);
  letter-spacing: -0.01em;
}

h3 {
  font-size: var(--font-h3);
}

h4 {
  font-size: var(--font-h4);
  font-weight: 600;
}

p {
  margin: 0;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

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

button {
  font: inherit;
  cursor: pointer;
}

img,
svg {
  display: block;
}

:focus-visible {
  outline: 2px solid var(--color-info);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.icon {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

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

.app-shell {
  max-width: var(--layout-max-width);
  margin: 0 auto;
  padding-bottom: calc(var(--tab-bar-height) + var(--space-3xl));
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  padding: var(--space-lg);
  background: rgba(11, 15, 20, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--color-text);
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--color-accent);
  color: var(--color-text-inverse);
}

.brand__name {
  font-size: var(--font-h4);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand__meta {
  font-size: var(--font-small);
  color: var(--color-text-muted);
}

.screen {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
  padding: var(--space-xl) var(--space-lg) 0;
}

.screen__head {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.section {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.section__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.stack-sm {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.stack-lg {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

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

.row--between > strong {
  white-space: nowrap;
}

.row--wrap {
  flex-wrap: wrap;
}

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

.text-small {
  font-size: var(--font-small);
}

.text-accent {
  color: var(--color-accent);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-lg);
}

.tab-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  width: 100%;
  max-width: var(--layout-max-width);
  height: var(--tab-bar-height);
  padding: 0 var(--space-sm);
  background: rgba(21, 28, 36, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--color-border);
}

.tab-bar__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  min-height: 48px;
  padding: var(--space-sm);
  border: 0;
  background: none;
  color: var(--color-text-muted);
  font-size: var(--font-small);
}

.tab-bar__item[aria-current='page'] {
  color: var(--color-accent);
}

.tab-bar__item[aria-current='page'] .icon {
  stroke-width: 2.25;
}

@font-face {
  font-family: 'Archivo Brand';
  src: url('../assets/fonts/archivo-brand.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-brand: 'Archivo Brand', 'Archivo', 'Helvetica Neue', system-ui, sans-serif;
}

h1,
h2,
h3,
h4,
.brand__name,
.price-headline__amount,
.stat__value,
.invoice-document__total strong {
  font-family: var(--font-brand);
  font-variation-settings: 'wdth' 108;
}

.brand__name {
  font-family: var(--font-brand);
  font-size: 19px;
  font-weight: 800;
  font-variation-settings: 'wdth' 118;
  letter-spacing: 0.01em;
  line-height: 1.1;
  text-transform: uppercase;
}

.brand__name em {
  font-style: normal;
  color: var(--color-accent);
}

.brand__meta {
  font-family: var(--font-brand);
  font-variation-settings: 'wdth' 88;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
}

h1 {
  font-weight: 800;
  font-variation-settings: 'wdth' 112;
}

h2 {
  font-weight: 700;
}

.price-headline__amount,
.stat__value {
  font-variation-settings: 'wdth' 100;
  font-feature-settings: 'tnum' 1;
}

.wordmark {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.card-title,
h2.card-title {
  font-size: var(--font-h4);
  font-weight: 600;
  font-variation-settings: 'wdth' 104;
  letter-spacing: 0;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  height: var(--height-button-m);
  padding: 0 var(--space-lg);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  color: var(--color-text);
  font-size: var(--font-body);
  font-weight: 600;
  white-space: nowrap;
  transition: background 120ms ease, border-color 120ms ease;
}

.button--l {
  height: var(--height-button-l);
  padding: 0 var(--space-xl);
}

.button--s {
  height: var(--height-button-s);
  padding: 0 var(--space-lg);
}

.button--xs {
  height: var(--height-button-xs);
  padding: 0 var(--space-sm);
  font-size: var(--font-small);
}

.button--primary {
  background: var(--color-accent);
  color: var(--color-text-inverse);
}

.button--primary:hover {
  background: var(--color-accent-hover);
}

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

.button--stroke {
  background: transparent;
  border-color: var(--color-border-strong);
}

.button--link {
  height: auto;
  min-height: 24px;
  padding: 0;
  background: none;
  border: 0;
  color: var(--color-accent);
  font-weight: 600;
}

.button--danger {
  background: transparent;
  border-color: var(--color-danger);
  color: var(--color-danger);
}

.button--full {
  width: 100%;
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.button-icon {
  display: grid;
  place-items: center;
  width: var(--height-button-s);
  height: var(--height-button-s);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  color: var(--color-text);
}

.card {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  padding: var(--space-lg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.card--accent {
  border-color: var(--color-accent);
  background: linear-gradient(160deg, var(--color-accent-soft), var(--color-surface) 60%);
}

.card--flat {
  background: var(--color-surface-sunken);
}

.card__row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-lg);
}

.chip {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  gap: var(--space-xs);
  height: 28px;
  padding: 0 var(--space-sm);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--color-text-muted);
  font-size: var(--font-small);
  font-weight: 600;
}

.chip--filter[aria-pressed='true'] {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.chip--status {
  height: 24px;
  white-space: nowrap;
}

.chip--neutral {
  border-color: var(--color-border-strong);
  color: var(--color-text-muted);
}

.chip--info {
  border-color: var(--color-info);
  background: var(--color-info-soft);
  color: var(--color-info);
}

.chip--progress {
  border-color: var(--color-warning);
  background: var(--color-warning-soft);
  color: var(--color-warning);
}

.chip--success {
  border-color: var(--color-success);
  background: var(--color-success-soft);
  color: var(--color-success);
}

.chip--danger {
  border-color: var(--color-danger);
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.field__label {
  font-size: var(--font-small);
  font-weight: 600;
  color: var(--color-text-muted);
}

.field__hint {
  font-size: var(--font-small);
  color: var(--color-text-muted);
}

.field__error {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--font-small);
  color: var(--color-danger);
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: var(--height-button-m);
  padding: var(--space-sm);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface-sunken);
  color: var(--color-text);
  font-family: inherit;
  font-size: var(--font-body);
}

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

.input::placeholder,
.textarea::placeholder {
  color: var(--color-text-muted);
}

.input[aria-invalid='true'] {
  border-color: var(--color-danger);
}

.autocomplete {
  position: relative;
}

.autocomplete__list {
  position: absolute;
  top: calc(100% + var(--space-xs));
  left: 0;
  right: 0;
  z-index: 10;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  box-shadow: var(--shadow-card);
}

.autocomplete__option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  width: 100%;
  min-height: var(--height-button-m);
  padding: var(--space-sm);
  border: 0;
  background: none;
  color: var(--color-text);
  text-align: left;
}

.autocomplete__option:hover {
  background: var(--color-accent-soft);
}

.option-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.option {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-height: 48px;
  padding: var(--space-sm);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface-sunken);
  cursor: pointer;
}

.option--selected {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
}

.option input {
  flex: none;
  width: 20px;
  height: 20px;
  accent-color: var(--color-accent);
}

.option__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.option__label {
  font-weight: 600;
}

.option__price {
  margin-left: auto;
  font-weight: 700;
  color: var(--color-accent);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-lg);
}

.stat {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-lg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.stat__label {
  font-size: var(--font-small);
  color: var(--color-text-muted);
}

.stat__value {
  font-size: var(--font-h3);
  font-weight: 700;
}

.price-summary {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.price-summary__line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-lg);
  font-size: var(--font-body);
}

.price-summary__line--total {
  padding-top: var(--space-sm);
  border-top: 1px solid var(--color-border);
  font-size: var(--font-h4);
  font-weight: 700;
}

.price-headline {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.price-headline__amount {
  font-size: var(--font-h1);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.timeline__step {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: var(--space-sm);
  align-items: start;
}

.timeline__bullet {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 2px solid var(--color-border-strong);
  border-radius: var(--radius-pill);
  color: var(--color-text-muted);
}

.timeline__step--done .timeline__bullet {
  border-color: var(--color-success);
  background: var(--color-success-soft);
  color: var(--color-success);
}

.timeline__step--current .timeline__bullet {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.empty-state,
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
  padding: var(--space-xl) var(--space-lg);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  text-align: center;
}

.error-state {
  border-style: solid;
  border-color: var(--color-danger);
  background: var(--color-danger-soft);
}

.skeleton {
  height: 16px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--color-surface) 25%, var(--color-surface-raised) 50%, var(--color-surface) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1200ms linear infinite;
}

@keyframes skeleton-shimmer {
  to {
    background-position: -200% 0;
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-bar-height) + var(--space-lg));
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: calc(100% - var(--space-2xl));
  max-width: 480px;
  padding: var(--space-lg);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface-raised);
  box-shadow: var(--shadow-card);
}

.toast--success {
  border-color: var(--color-success);
  color: var(--color-success);
}

.toast--danger {
  border-color: var(--color-danger);
  color: var(--color-danger);
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(4, 7, 10, 0.72);
}

.sheet {
  width: 100%;
  max-width: var(--layout-max-width);
  max-height: 88vh;
  overflow-y: auto;
  padding: var(--space-lg);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-sheet);
}

.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.divider {
  height: 1px;
  border: 0;
  margin: 0;
  background: var(--color-border);
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-sm);
}

.photo-grid__item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.photo-grid__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-grid__remove {
  position: absolute;
  top: var(--space-xs);
  right: var(--space-xs);
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: var(--radius-pill);
  background: rgba(4, 7, 10, 0.8);
  color: var(--color-text);
}

.signature-pad {
  width: 100%;
  height: 160px;
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface-sunken);
  touch-action: none;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-body);
}

.table th,
.table td {
  padding: var(--space-sm);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.table th {
  font-size: var(--font-small);
  color: var(--color-text-muted);
  font-weight: 600;
}

.steps {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin: 0;
  padding-left: var(--space-xl);
  list-style: decimal;
}

.steps li::marker {
  color: var(--color-accent);
  font-weight: 700;
}

.chip--accent {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.invoice-document {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
  padding: var(--space-lg);
  border-radius: var(--radius-md);
  background: var(--color-surface-sunken);
  color: var(--color-text);
}

.invoice-document__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-lg);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--color-border-strong);
}

.invoice-document__head h2 {
  margin-bottom: var(--space-xs);
}

.invoice-document__head p {
  font-size: var(--font-small);
  color: var(--color-text-muted);
}

.invoice-document__total {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-xs);
  white-space: nowrap;
}

.invoice-document__total span {
  font-size: var(--font-small);
  color: var(--color-text-muted);
}

.invoice-document__total strong {
  font-size: var(--font-h3);
}

.invoice-document__parties {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-lg);
}

.invoice-document__parties h3 {
  margin-bottom: var(--space-sm);
  font-size: var(--font-h4);
}

.invoice-document__parties p {
  font-size: var(--font-small);
  color: var(--color-text-muted);
}

.invoice-document__parties p strong {
  color: var(--color-text);
}

.invoice-document__meta {
  display: grid;
  gap: var(--space-sm);
  margin: 0;
}

.invoice-document__meta div {
  display: flex;
  justify-content: space-between;
  gap: var(--space-lg);
  font-size: var(--font-small);
}

.invoice-document__meta dt {
  color: var(--color-text-muted);
}

.invoice-document__meta dd {
  margin: 0;
  text-align: right;
}

.invoice-document__lines {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-small);
}

.invoice-document__lines th,
.invoice-document__lines td {
  padding: var(--space-sm);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}

.invoice-document__lines thead th {
  color: var(--color-text-muted);
  font-weight: 600;
}

.invoice-document__lines .numeric {
  text-align: right;
  white-space: nowrap;
}

.invoice-document__lines tfoot th {
  text-align: right;
  color: var(--color-text-muted);
}

.invoice-document__grand th,
.invoice-document__grand td {
  font-size: var(--font-h4);
  font-weight: 700;
  color: var(--color-text);
  border-bottom: 0;
}

.invoice-document__notes {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--color-border-strong);
  font-size: var(--font-small);
  color: var(--color-text-muted);
}

@media print {
  @page {
    size: A4;
    margin: 16mm;
  }

  body.print-body {
    background: #ffffff;
    color: #111111;
  }

  .app-header,
  .tab-bar,
  .toast,
  .sheet__head,
  .button,
  .button-icon {
    display: none;
  }

  .invoice-document {
    padding: 0;
    background: #ffffff;
    color: #111111;
    gap: 8mm;
  }

  .invoice-document__head,
  .invoice-document__notes {
    border-color: #111111;
  }

  .invoice-document__head p,
  .invoice-document__parties p,
  .invoice-document__meta dt,
  .invoice-document__lines thead th,
  .invoice-document__lines tfoot th,
  .invoice-document__notes {
    color: #333333;
  }

  .invoice-document__parties p strong,
  .invoice-document__grand th,
  .invoice-document__grand td {
    color: #111111;
  }

  .invoice-document__lines th,
  .invoice-document__lines td {
    border-color: #cccccc;
  }
}
