:root {
  color-scheme: dark;
  --facture-bg: #040914;
  --facture-bg-soft: #0b1223;
  --facture-panel: rgba(8, 16, 34, 0.88);
  --facture-panel-strong: rgba(12, 20, 42, 0.96);
  --facture-line: rgba(120, 147, 255, 0.18);
  --facture-line-strong: rgba(120, 147, 255, 0.34);
  --facture-text: #f7f8ff;
  --facture-text-soft: rgba(233, 238, 255, 0.76);
  --facture-text-muted: rgba(181, 193, 229, 0.64);
  --facture-blue: #4f7dff;
  --facture-cyan: #2bc5ff;
  --facture-violet: #8f45ff;
  --facture-orange: #f68f37;
  --facture-success: #3ce0a4;
  --facture-danger: #ff6b85;
  --facture-shadow: 0 30px 90px rgba(0, 0, 0, 0.46);
  --facture-radius: 28px;
  --facture-radius-sm: 18px;
  --facture-font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
}

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

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background:
    radial-gradient(circle at 12% 0%, rgba(79, 125, 255, 0.22), transparent 34%),
    radial-gradient(circle at 88% 10%, rgba(143, 69, 255, 0.22), transparent 36%),
    radial-gradient(circle at 50% 110%, rgba(246, 143, 55, 0.1), transparent 28%),
    var(--facture-bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--facture-text);
  font-family: var(--facture-font);
  background: transparent;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.2;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 74px 74px;
  mask-image: radial-gradient(circle at center, black 54%, transparent 88%);
}

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

button {
  cursor: pointer;
}

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

.facture-body.is-locked {
  overflow: hidden;
}

.facture-auth-screen,
.facture-shell {
  position: relative;
  z-index: 1;
}

.facture-auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.facture-auth-card {
  width: min(100%, 520px);
  padding: 32px;
  border-radius: 32px;
  border: 1px solid var(--facture-line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03)),
    rgba(4, 10, 24, 0.82);
  box-shadow: var(--facture-shadow);
  backdrop-filter: blur(22px);
}

.facture-shell {
  padding: 22px;
}

.facture-hero,
.facture-panel,
.facture-modal-card {
  border-radius: var(--facture-radius);
  border: 1px solid var(--facture-line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
    var(--facture-panel);
  box-shadow: var(--facture-shadow);
  backdrop-filter: blur(24px);
}

.facture-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 28px;
  overflow: hidden;
}

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

.facture-brand-mark {
  width: 96px;
  height: 96px;
  flex: 0 0 96px;
  display: grid;
  place-items: center;
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(79, 125, 255, 0.2), rgba(143, 69, 255, 0.22)),
    rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.facture-brand-mark img {
  width: 74px;
  height: 74px;
  object-fit: cover;
  border-radius: 50%;
}

.facture-kicker,
.facture-panel-kicker {
  display: inline-block;
  margin-bottom: 10px;
  color: #6d8dff;
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.facture-brand-copy h1,
.facture-panel-head h2,
.facture-modal-head h2 {
  margin: 0;
  line-height: 0.96;
  letter-spacing: -0.05em;
}

.facture-brand-copy h1 {
  font-size: clamp(2.5rem, 5vw, 4.5rem);
}

.facture-brand-copy p,
.facture-panel-copy,
.facture-empty-text,
.facture-auth-caption,
.facture-sync-summary,
.facture-sync-note,
.facture-company-note,
.facture-line-note {
  margin: 0;
  color: var(--facture-text-soft);
  line-height: 1.64;
}

.facture-hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
  max-width: 560px;
}

.facture-sync-summary {
  width: 100%;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--facture-text-muted);
}

.facture-primary-button,
.facture-secondary-button,
.facture-danger-button,
.facture-link-button,
.facture-view-chip,
.facture-filter-chip,
.facture-mini-button {
  border: 0;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, opacity 0.18s ease;
}

.facture-primary-button:hover,
.facture-secondary-button:hover,
.facture-danger-button:hover,
.facture-link-button:hover,
.facture-view-chip:hover,
.facture-filter-chip:hover,
.facture-mini-button:hover {
  transform: translateY(-1px);
}

.facture-primary-button,
.facture-secondary-button,
.facture-danger-button {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 16px;
  font-weight: 800;
}

.facture-primary-button {
  color: white;
  background: linear-gradient(135deg, var(--facture-blue), var(--facture-violet));
  box-shadow: 0 18px 40px rgba(79, 125, 255, 0.28);
}

.facture-secondary-button {
  color: var(--facture-text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

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

.facture-danger-button {
  color: white;
  background: linear-gradient(135deg, #ff4d67, #ff7990);
}

.facture-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 18px 0;
}

.facture-stat-card {
  padding: 22px;
  border-radius: 22px;
  border: 1px solid var(--facture-line);
  background:
    radial-gradient(circle at top right, rgba(79, 125, 255, 0.16), transparent 44%),
    rgba(7, 13, 30, 0.84);
}

.facture-stat-label {
  display: inline-block;
  color: var(--facture-text-muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.facture-stat-value {
  margin: 8px 0 6px;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  font-weight: 900;
  letter-spacing: -0.05em;
}

.facture-stat-meta {
  margin: 0;
  color: var(--facture-text-soft);
  line-height: 1.55;
}

.facture-main {
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  gap: 18px;
}

.facture-panel {
  min-width: 0;
  padding: 22px;
}

.facture-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.facture-panel-head-stack {
  display: grid;
  gap: 16px;
}

.facture-count-pill,
.facture-chip,
.facture-status-chip,
.facture-alert-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 800;
}

.facture-count-pill {
  color: var(--facture-text);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
}

.facture-view-switch,
.facture-filter-group,
.facture-inline-actions,
.facture-sync-actions,
.facture-row-actions,
.facture-pdf-actions,
.facture-catalog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.facture-view-switch {
  margin-bottom: 18px;
}

.facture-view-chip,
.facture-filter-chip,
.facture-mini-button {
  min-height: 42px;
  padding: 0 15px;
  border-radius: 14px;
  color: var(--facture-text-soft);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-weight: 700;
}

.facture-view-chip.is-active,
.facture-filter-chip.is-active,
.facture-mini-button.is-active {
  color: white;
  background: linear-gradient(135deg, rgba(79, 125, 255, 0.28), rgba(143, 69, 255, 0.22));
  border-color: rgba(126, 148, 255, 0.36);
}

.facture-toolbar {
  display: grid;
  gap: 14px;
  margin: 18px 0;
}

.facture-list,
.facture-detail-stack,
.facture-form-grid,
.facture-details-grid,
.facture-catalog-list,
.facture-warning-list,
.facture-summary-list {
  display: grid;
  gap: 14px;
}

.facture-list {
  max-height: calc(100vh - 330px);
  overflow: auto;
  padding-right: 4px;
}

.facture-list::-webkit-scrollbar {
  width: 10px;
}

.facture-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.facture-card,
.facture-empty-card,
.facture-note-card,
.facture-summary-card,
.facture-warning-card,
.facture-catalog-card,
.facture-line-card {
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.facture-card {
  width: 100%;
  padding: 18px;
  color: inherit;
  text-align: left;
}

.facture-card.is-selected {
  border-color: rgba(122, 144, 255, 0.46);
  background:
    linear-gradient(135deg, rgba(79, 125, 255, 0.14), rgba(143, 69, 255, 0.1)),
    rgba(255, 255, 255, 0.04);
}

.facture-card-top,
.facture-card-bottom,
.facture-line-top,
.facture-catalog-top,
.facture-note-top,
.facture-summary-row,
.facture-detail-head,
.facture-company-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.facture-card-top,
.facture-line-top,
.facture-catalog-top,
.facture-note-top,
.facture-detail-head,
.facture-company-head {
  align-items: flex-start;
}

.facture-card-bottom,
.facture-summary-row {
  align-items: center;
}

.facture-card-main,
.facture-summary-main {
  display: grid;
  gap: 6px;
}

.facture-card-code,
.facture-small-code {
  display: inline-block;
  color: #8aa5ff;
  font-size: 0.84rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.facture-card-title,
.facture-detail-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.facture-detail-title {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
}

.facture-card-meta,
.facture-detail-subtitle,
.facture-note-caption,
.facture-company-note,
.facture-inline-text,
.facture-summary-meta {
  color: var(--facture-text-soft);
}

.facture-detail-panel {
  min-height: 640px;
}

.facture-detail-stack {
  min-width: 0;
}

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

.facture-detail-box {
  padding: 18px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.facture-meta-label {
  display: block;
  margin-bottom: 8px;
  color: var(--facture-text-muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.facture-field {
  display: grid;
  gap: 8px;
}

.facture-field span {
  color: var(--facture-text-soft);
  font-size: 0.92rem;
  font-weight: 700;
}

.facture-field input,
.facture-field select,
.facture-field textarea {
  width: 100%;
  min-height: 48px;
  padding: 14px 16px;
  color: var(--facture-text);
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.facture-field textarea {
  min-height: 110px;
  resize: vertical;
}

.facture-help-text {
  color: var(--facture-text-muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.facture-terms-editor {
  min-height: 420px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.88rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.facture-field input:focus,
.facture-field select:focus,
.facture-field textarea:focus {
  border-color: rgba(95, 136, 255, 0.48);
  box-shadow: 0 0 0 4px rgba(79, 125, 255, 0.16);
  background: rgba(0, 0, 0, 0.28);
}

.facture-form,
.facture-detail-form,
.facture-settings-form {
  display: grid;
  gap: 18px;
}

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

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

.facture-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.facture-modal-card .facture-form-actions {
  position: sticky;
  bottom: -28px;
  z-index: 2;
  margin: 6px -28px -28px;
  padding: 18px 28px 24px;
  background:
    linear-gradient(0deg, rgba(12, 20, 42, 0.98), rgba(12, 20, 42, 0.9) 78%, rgba(12, 20, 42, 0));
}

.facture-empty-card,
.facture-summary-card,
.facture-warning-card {
  padding: 22px;
}

.facture-empty-card h3,
.facture-summary-card h3,
.facture-warning-card h3,
.facture-section-title {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.facture-chip[data-type="quote"],
.facture-status-chip[data-type="quote"] {
  color: #8cd3ff;
  background: rgba(43, 197, 255, 0.12);
}

.facture-chip[data-type="order"],
.facture-status-chip[data-type="order"] {
  color: #ffcb86;
  background: rgba(246, 143, 55, 0.13);
}

.facture-chip[data-type="invoice"],
.facture-status-chip[data-type="invoice"] {
  color: #cfa6ff;
  background: rgba(143, 69, 255, 0.16);
}

.facture-status-chip[data-status="draft"] {
  color: var(--facture-text-soft);
  background: rgba(255, 255, 255, 0.08);
}

.facture-status-chip[data-status="sent"] {
  color: #8ed6ff;
  background: rgba(43, 197, 255, 0.12);
}

.facture-status-chip[data-status="approved"] {
  color: #ffe18a;
  background: rgba(246, 143, 55, 0.15);
}

.facture-status-chip[data-status="paid"] {
  color: #8ff2c3;
  background: rgba(60, 224, 164, 0.13);
}

.facture-status-chip[data-status="cancelled"] {
  color: #ff98ab;
  background: rgba(255, 107, 133, 0.12);
}

.facture-alert-chip {
  color: #d9e3ff;
  background: rgba(255, 255, 255, 0.07);
}

.facture-line-card,
.facture-catalog-card {
  padding: 16px;
}

.facture-line-body,
.facture-catalog-body {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.facture-line-body .facture-field:first-child,
.facture-catalog-body .facture-field:first-child {
  grid-column: span 2;
}

.facture-line-totals,
.facture-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.facture-line-total-box,
.facture-summary-box {
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.facture-line-total-box strong,
.facture-summary-box strong {
  display: block;
  margin-top: 6px;
  font-size: 1.08rem;
}

.facture-company-grid,
.facture-pdf-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.facture-pdf-grid .facture-summary-card,
.facture-pdf-grid .facture-warning-card {
  height: 100%;
}

.facture-warning-list {
  margin: 0;
  padding-left: 18px;
  color: #ffd4dd;
  line-height: 1.65;
}

.facture-summary-list {
  gap: 10px;
}

.facture-summary-row strong {
  font-size: 1rem;
}

.facture-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: start center;
  padding: 24px;
  overflow: auto;
  overscroll-behavior: contain;
}

.facture-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.54);
  backdrop-filter: blur(10px);
}

.facture-modal-card {
  position: relative;
  width: min(100%, 920px);
  max-height: calc(100dvh - 48px);
  padding: 28px;
  overflow: auto;
  margin: auto 0;
  scrollbar-gutter: stable;
}

.facture-modal-card-compact {
  width: min(100%, 560px);
}

.facture-modal-head {
  position: sticky;
  top: -28px;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  padding: 0 0 18px;
  background:
    linear-gradient(180deg, rgba(12, 20, 42, 0.98), rgba(12, 20, 42, 0.9) 78%, rgba(12, 20, 42, 0));
}

.facture-icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--facture-text);
  font-size: 1.4rem;
}

.facture-auth-error,
.facture-sync-status {
  margin: 0;
  color: #9bc8ff;
  line-height: 1.6;
}

.facture-auth-error,
.facture-sync-status.is-error {
  color: #ff97ab;
}

.facture-sync-sheet {
  display: grid;
  gap: 16px;
}

.facture-sync-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.32);
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.03);
}

.facture-sync-dot.is-ready {
  background: var(--facture-success);
  box-shadow: 0 0 18px rgba(60, 224, 164, 0.64);
}

.facture-sync-button {
  position: relative;
  min-width: 48px;
  width: 48px;
  padding: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
}

.facture-sync-orbit {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  display: grid;
  place-items: center;
}

.facture-link-button {
  min-height: 42px;
  padding: 0 15px;
  color: white;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(79, 125, 255, 0.28), rgba(143, 69, 255, 0.2));
}

.facture-inline-text {
  margin: 0;
  line-height: 1.55;
}

.facture-auth-caption {
  text-align: center;
}

.facture-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  min-width: 220px;
  max-width: min(420px, calc(100vw - 40px));
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(8, 16, 34, 0.96);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.46);
}

.facture-company-logo {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.facture-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
}

.facture-subpanel {
  padding: 18px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.facture-atelier-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  color: #8fcaff;
  background: rgba(43, 197, 255, 0.12);
  font-weight: 800;
}

@media (max-width: 1240px) {
  .facture-main {
    grid-template-columns: 360px minmax(0, 1fr);
  }

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

@media (max-width: 980px) {
  .facture-shell {
    padding: 16px;
  }

  .facture-hero {
    flex-direction: column;
  }

  .facture-hero-actions {
    justify-content: flex-start;
  }

  .facture-main {
    grid-template-columns: 1fr;
  }

  .facture-list {
    max-height: none;
  }

  .facture-details-grid,
  .facture-line-totals,
  .facture-summary-grid,
  .facture-company-grid,
  .facture-pdf-grid {
    grid-template-columns: 1fr;
  }

  .facture-line-body,
  .facture-catalog-body {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .facture-line-body .facture-field:first-child,
  .facture-catalog-body .facture-field:first-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .facture-auth-screen,
  .facture-modal {
    padding: 14px;
  }

  .facture-auth-card,
  .facture-modal-card,
  .facture-hero,
  .facture-panel {
    padding: 20px;
    border-radius: 24px;
  }

  .facture-brand {
    align-items: flex-start;
  }

  .facture-brand-mark {
    width: 78px;
    height: 78px;
    flex-basis: 78px;
    border-radius: 24px;
  }

  .facture-brand-mark img {
    width: 62px;
    height: 62px;
  }

  .facture-brand-copy h1 {
    font-size: 2.4rem;
  }

  .facture-stats,
  .facture-form-grid,
  .facture-line-body,
  .facture-catalog-body {
    grid-template-columns: 1fr;
  }

  .facture-field-wide {
    grid-column: auto;
  }

  .facture-toolbar {
    gap: 12px;
  }
}
