*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root { --navy: #1e2d5a; --green: #7ec242; --red: #e53e3e; --amber: #dd8b0f; --bg: #f0f4f8; --white: #fff; }
body { font-family: 'Nunito', -apple-system, sans-serif; background: var(--bg); color: #2d3748; min-height: 100vh; }

/* ---- TOPBAR ---- */
.topbar {
  background: var(--navy); color: #fff; padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.topbar .brand { font-weight: 800; font-size: 1.1rem; }
.topbar span { font-size: .85rem; color: rgba(255,255,255,.6); }
#btn-logout {
  background: transparent; border: 1px solid rgba(255,255,255,.3); color: #fff;
  padding: 6px 14px; border-radius: 8px; cursor: pointer; font-family: inherit; font-size: .85rem;
}
#btn-logout:hover { background: rgba(255,255,255,.1); }

/* ---- LOGIN (index.html) ---- */
#login-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
}
.login-card {
  background: var(--white); border-radius: 16px; padding: 40px;
  width: 100%; max-width: 380px; box-shadow: 0 8px 32px rgba(0,0,0,.1);
  text-align: center;
}
.login-card h1 { font-size: 1.3rem; color: var(--navy); margin-bottom: 6px; }
.login-card p { font-size: .9rem; color: #718096; margin-bottom: 24px; }
.btn-ms {
  width: 100%; padding: 13px; background: var(--navy); color: #fff;
  border: none; border-radius: 10px; font-family: inherit; font-size: 1rem;
  font-weight: 700; cursor: pointer; text-decoration: none; display: inline-block;
}
.btn-ms:hover { background: #2a3d7a; }

/* ---- APP ---- */
#app-screen { max-width: 1100px; margin: 0 auto; padding: 28px 20px; }

.tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 2px solid #e2e8f0; flex-wrap: wrap; }
.tab-btn {
  padding: 10px 20px; border: none; background: transparent; cursor: pointer;
  font-family: inherit; font-size: .95rem; font-weight: 700; color: #718096;
  border-bottom: 3px solid transparent; margin-bottom: -2px; border-radius: 6px 6px 0 0;
}
.tab-btn.active { color: var(--navy); border-bottom-color: var(--green); }
.tab-content { display: none; }
.tab-content.active { display: block; }

.section-card {
  background: var(--white); border-radius: 14px; padding: 24px;
  box-shadow: 0 2px 12px rgba(0,0,0,.06); margin-bottom: 20px;
}
.section-card h2 { font-size: 1.05rem; color: var(--navy); margin-bottom: 16px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-header h2 { margin-bottom: 0; }

/* Buttons */
.btn { padding: 9px 18px; border: none; border-radius: 8px; font-family: inherit; font-weight: 700; font-size: .9rem; cursor: pointer; }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: #6db035; }
.btn-secondary { background: #e2e8f0; color: var(--navy); }
.btn-secondary:hover { background: #cbd5e0; }
.btn-danger { background: transparent; border: 1px solid #fed7d7; color: var(--red); }
.btn-danger:hover { background: #fff5f5; }
.btn-small { padding: 5px 12px; font-size: .8rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-add {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  background: transparent; border: 2px dashed #cbd5e0; color: #718096;
  padding: 12px 20px; border-radius: 10px; cursor: pointer;
  font-family: inherit; font-size: .9rem; font-weight: 700; width: 100%; margin-top: 4px;
}
.btn-add:hover { border-color: var(--green); color: var(--green); }

.dropzone {
  display: flex; align-items: center; justify-content: center; text-align: center;
  background: transparent; border: 2px dashed #cbd5e0; color: #718096;
  padding: 28px 20px; border-radius: 10px; cursor: pointer;
  font-family: inherit; font-size: .9rem; font-weight: 700; width: 100%; margin-bottom: 16px;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--green); color: var(--green); }

/* Tables / lists */
table.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data-table th { text-align: left; font-size: .75rem; text-transform: uppercase; color: #a0aec0; padding: 8px 6px; border-bottom: 2px solid #e2e8f0; }
table.data-table td { padding: 10px 6px; border-bottom: 1px solid #edf2f7; vertical-align: middle; }
table.data-table tr:hover td { background: #fafbfc; }
table.data-table .num { text-align: right; }
table.data-table .actions { display: flex; gap: 6px; flex-wrap: wrap; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 800; }
.badge-attente { background: #fef3c7; color: #92400e; }
.badge-accepte { background: #d1fae5; color: #065f46; }
.badge-refuse { background: #fee2e2; color: #991b1b; }
.badge-transforme { background: #e0e7ff; color: #3730a3; }
.badge-brouillon { background: #e2e8f0; color: #4a5568; }
.badge-validee { background: #d1fae5; color: #065f46; }
.badge-annulee { background: #fee2e2; color: #991b1b; }
.badge-impayee { background: #fef3c7; color: #92400e; }
.badge-payee { background: #d1fae5; color: #065f46; }

/* Forms */
.field-group { margin-bottom: 14px; }
.field-group label { display: block; font-size: .82rem; font-weight: 700; color: #718096; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
.field-group input, .field-group select, .field-group textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #e2e8f0; border-radius: 8px;
  font-family: inherit; font-size: .95rem;
}
.field-group textarea { resize: vertical; min-height: 70px; }
.field-group input:focus, .field-group select:focus, .field-group textarea:focus { outline: none; border-color: var(--navy); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

/* Lignes editor */
.lignes-table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.lignes-table th { text-align: left; font-size: .72rem; text-transform: uppercase; color: #a0aec0; padding: 4px 6px; }
.lignes-table td { padding: 4px 6px; }
.lignes-table input { width: 100%; padding: 7px 8px; border: 1px solid #e2e8f0; border-radius: 6px; font-family: inherit; font-size: .88rem; }
.lignes-table .col-qte, .lignes-table .col-prix { width: 90px; }
.lignes-table .col-unite { width: 90px; }
.lignes-table .col-montant { width: 100px; text-align: right; font-weight: 700; }
.totals-row { display: flex; justify-content: flex-end; gap: 24px; padding: 10px 0; font-weight: 800; font-size: 1.05rem; color: var(--navy); }

.overlay {
  position: fixed; inset: 0; background: rgba(30,45,90,.4);
  display: none; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 10;
}
.overlay.active { display: flex; }
.modal { background: #fff; border-radius: 14px; padding: 28px; width: 100%; max-width: 640px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-header h2 { color: var(--navy); }
.btn-close { background: transparent; border: none; font-size: 1.4rem; cursor: pointer; color: #a0aec0; line-height: 1; }

#toast { position: fixed; bottom: 20px; right: 20px; padding: 12px 20px; border-radius: 10px; font-weight: 700; color: #fff; display: none; z-index: 20; }
#toast.ok { background: var(--green); }
#toast.err { background: var(--red); }

@media (max-width: 640px) {
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  table.data-table { font-size: .82rem; }
}
