:root {
  color-scheme: dark;
  --bg: #050711;
  --panel: rgba(13, 18, 36, .72);
  --panel-2: rgba(255, 255, 255, .08);
  --line: rgba(255, 255, 255, .16);
  --text: #f7fbff;
  --muted: #a8b3c7;
  --cyan: #00f5ff;
  --pink: #ff2bd6;
  --lime: #a6ff00;
  --violet: #8b5cf6;
  --danger: #ff4672;
  --shadow: 0 24px 80px rgba(0, 0, 0, .38);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 10%, rgba(255, 43, 214, .28), transparent 28%),
    radial-gradient(circle at 85% 20%, rgba(0, 245, 255, .24), transparent 30%),
    radial-gradient(circle at 70% 85%, rgba(166, 255, 0, .18), transparent 32%),
    linear-gradient(140deg, #04050d 0%, #07111e 48%, #120719 100%);
  overflow-x: hidden;
}

body > main {
  position: relative;
  z-index: 1;
}

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

button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text);
  font-weight: 750;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}

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

.primary {
  background: linear-gradient(135deg, var(--pink), var(--violet) 45%, var(--cyan));
  box-shadow: 0 0 24px rgba(255, 43, 214, .26);
}

.secondary {
  background: rgba(255, 255, 255, .1);
  border-color: rgba(255, 255, 255, .18);
}

.ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, .22);
}

.danger { color: #ffd7e1; border-color: rgba(255, 70, 114, .55); }

.icon {
  width: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .1);
}

.hidden { display: none !important; }

.glass {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.aurora {
  position: fixed;
  inset: -20%;
  z-index: 0;
  pointer-events: none;
  opacity: .55;
  background:
    conic-gradient(from 90deg at 40% 45%, transparent, rgba(0, 245, 255, .2), transparent, rgba(255, 43, 214, .22), transparent);
  filter: blur(50px);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(560px, 100%);
  border-radius: 28px;
  padding: clamp(24px, 5vw, 44px);
}

.brand-mark {
  width: 60px;
  height: 60px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: #041017;
  font-weight: 950;
  background: linear-gradient(135deg, var(--cyan), var(--lime));
  box-shadow: 0 0 34px rgba(0, 245, 255, .38);
}

.brand-mark.small {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  font-size: 14px;
}

/* Vrai logo (image) : fond blanc pour lisibilité sur le thème sombre. */
img.brand-mark {
  object-fit: contain;
  background: #fff;
  padding: 6px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1, h2, h3 { margin: 0; letter-spacing: 0; }
h1 { font-size: clamp(34px, 6vw, 58px); line-height: .98; }
h2 { font-size: clamp(24px, 3vw, 38px); }
h3 { font-size: 20px; }

.lede {
  color: var(--muted);
  line-height: 1.6;
}

.form-grid {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input, select, textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  background: rgba(3, 8, 18, .58);
  outline: none;
}

textarea {
  min-height: 140px;
  resize: vertical;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0, 245, 255, .12);
}

.button-row, .top-actions, .card-actions, .line-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.status {
  min-height: 38px;
  margin-top: 16px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #dffcff;
  background: rgba(0, 245, 255, .09);
  border: 1px solid rgba(0, 245, 255, .22);
  white-space: pre-wrap;
}

.status.compact {
  font-size: 13px;
  margin-top: 12px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
  position: relative;
  z-index: 1;
}

.sidebar {
  border-radius: 24px;
  padding: 18px;
  position: sticky;
  top: 18px;
  z-index: 2;
  height: calc(100vh - 36px);
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow: hidden;
}

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

.brand-block span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 8px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  align-content: start;
  padding-right: 4px;
}

.nav button {
  justify-content: flex-start;
  text-align: left;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.nav button.active {
  color: var(--text);
  border-color: rgba(0, 245, 255, .28);
  background: linear-gradient(90deg, rgba(0, 245, 255, .16), rgba(255, 43, 214, .12));
}

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

.workspace {
  min-width: 0;
  display: grid;
  gap: 18px;
  align-content: start;
}

.topbar {
  border-radius: 24px;
  padding: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.content-grid {
  display: grid;
  gap: 16px;
}

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

.stat, .panel, .data-card {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .07);
  border-radius: 18px;
  padding: 16px;
}

.stat span, .muted { color: var(--muted); }
.stat strong { display: block; margin-top: 8px; font-size: 30px; }

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

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}

.search {
  max-width: 360px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 13px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

td { color: #eef5ff; }

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
  color: #061016;
  background: var(--lime);
}

.pill.invoice { background: var(--cyan); }
.pill.quote { background: #ffd166; }
.pill.creditNote { background: #ff8fab; }
.pill.deliveryNote { background: #c4b5fd; }

.empty {
  padding: 28px;
  border: 1px dashed rgba(255, 255, 255, .18);
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
}

.modal {
  width: min(980px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  border: 1px solid var(--line);
  border-radius: 22px;
  color: var(--text);
  padding: 0;
}

.modal::backdrop {
  background: rgba(0, 0, 0, .62);
  backdrop-filter: blur(8px);
}

.modal-card {
  padding: 18px;
}

.modal-card header, .modal-card footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.modal-card footer {
  margin-top: 16px;
  justify-content: flex-end;
}

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

.editor-grid .full { grid-column: 1 / -1; }

.lines {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.line-row {
  display: grid;
  grid-template-columns: 1.25fr 1.45fr .55fr .75fr .65fr .85fr auto;
  gap: 8px;
  align-items: end;
}

.compact-note {
  min-height: 76px;
}

.line-discount {
  min-height: 20px;
  font-size: 12px;
  color: var(--muted);
  align-self: center;
}

.line-discount.good { color: var(--lime); }
.line-discount.warn { color: #ffd166; }

.switch-line {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 10px;
  background: rgba(3, 8, 18, .38);
}

.switch-line input {
  width: 18px;
  min-height: 18px;
}

.switch-line span {
  margin: 0;
  color: var(--text);
}

.invoice-preview {
  position: fixed;
  left: -10000px;
  top: 0;
  width: 820px;
  background: #fff;
  color: #172033;
}

.invoice-paper {
  width: 820px;
  min-height: 1060px;
  padding: 54px;
  color: #172033;
  background: #fff;
  font-family: Arial, Helvetica, sans-serif;
}

.invoice-head, .invoice-meta, .invoice-total {
  display: flex;
  justify-content: space-between;
  gap: 24px;
}

.invoice-head h1 {
  color: #172033;
  font-size: 34px;
}

.invoice-badge {
  min-width: 180px;
  text-align: right;
}

.invoice-badge span {
  display: block;
  color: #7a1238;
  font-weight: 900;
}

.invoice-badge strong {
  font-size: 26px;
}

.invoice-meta {
  margin: 40px 0 26px;
  padding: 18px;
  border: 1px solid #d8deea;
}

.invoice-meta small {
  display: block;
  color: #667085;
  margin-bottom: 4px;
}

.invoice-lines th, .invoice-lines td {
  color: #172033;
  border-bottom: 1px solid #d8deea;
}

.invoice-total {
  margin-top: 28px;
  align-items: flex-start;
}

.invoice-total div {
  min-width: 260px;
  display: grid;
  gap: 8px;
}

.invoice-total span {
  display: flex;
  justify-content: space-between;
}

.invoice-total .grand {
  padding-top: 10px;
  border-top: 2px solid #172033;
  font-size: 20px;
  font-weight: 900;
}

@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area {
    position: absolute;
    left: 0;
    top: 0;
  }
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
  }
  .stats, .grid-2, .editor-grid {
    grid-template-columns: 1fr;
  }
  .line-row {
    grid-template-columns: 1fr;
  }
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }
}

/* ===================== Console d'administration ===================== */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  margin-top: 12px;
}
.admin-card {
  border: 1px solid rgba(255, 255, 255, .10);
  border-radius: 16px;
  background: rgba(255, 255, 255, .03);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ac-head { display: flex; align-items: center; gap: 10px; }
.ac-logo {
  width: 46px; height: 46px; flex: 0 0 46px;
  border-radius: 12px; overflow: hidden;
  background: #fff; display: grid; place-items: center;
  color: #7A0C3E; font-weight: 800;
}
.ac-logo img { width: 100%; height: 100%; object-fit: contain; }
.ac-title { flex: 1 1 auto; min-width: 0; }
.ac-company { font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-contact { color: var(--muted); font-size: 12.5px; }
.ac-body { display: grid; gap: 4px; }
.ac-row { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; }
.ac-row span { color: var(--muted); flex: 0 0 auto; }
.ac-row b { text-align: right; overflow: hidden; text-overflow: ellipsis; }
.ac-warn { color: #d97706; font-size: 12px; margin-top: 2px; }
.ac-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.ac-actions button { padding: 6px 10px; font-size: 12.5px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.stat-card {
  border: 1px solid rgba(255, 255, 255, .10);
  border-radius: 14px;
  background: rgba(255, 255, 255, .03);
  padding: 16px;
  text-align: center;
}
.stat-value { font-size: 30px; font-weight: 900; line-height: 1; }
.stat-label { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.stat-note { margin-top: 14px; color: var(--muted); font-size: 13px; }

.switch-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; font-weight: 600; }
.field-row { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.field-row span { color: var(--muted); font-size: 13px; }
