* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f5;
  color: #333;
}

/* Loading */
#loading-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  font-size: 1.1rem;
  color: #666;
}

/* Login */
#login-section {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: linear-gradient(135deg, #60763e 0%, #3e4d27 100%);
}

.login-box {
  background: white;
  padding: 2.5rem;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  width: 360px;
  text-align: center;
}

.login-box h1 { color: #60763e; margin-bottom: 0.25rem; }
.login-box .subtitle { color: #888; margin-bottom: 1.5rem; }

.login-box input {
  display: block;
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.95rem;
}

.login-box button {
  width: 100%;
  padding: 0.75rem;
  background: #60763e;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
}

.login-box button:hover { background: #4a5c30; }
.error { color: #d32f2f; margin-top: 0.5rem; font-size: 0.9rem; }

/* Header */
header {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0.75rem 1.5rem;
  background: white;
  border-bottom: 2px solid #60763e;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

header h1 { color: #60763e; font-size: 1.3rem; white-space: nowrap; }

header nav { display: flex; gap: 0.25rem; flex: 1; }

.nav-btn {
  padding: 0.5rem 1rem;
  border: none;
  background: transparent;
  color: #666;
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
}

.nav-btn:hover { background: #f0f0f0; color: #333; }
.nav-btn.active { background: #60763e; color: white; }

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  white-space: nowrap;
}

.user-info span { color: #666; font-size: 0.85rem; }

#logout-btn {
  padding: 0.35rem 0.75rem;
  border: 1px solid #ddd;
  background: white;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
}

#logout-btn:hover { border-color: #60763e; color: #60763e; }

/* Tabs */
.tab-content { padding: 1.5rem; }

.tab-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.tab-header h2 { font-size: 1.25rem; color: #333; }

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

th {
  background: #fafafa;
  padding: 0.65rem 0.75rem;
  text-align: left;
  font-size: 0.8rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #eee;
}

td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid #f0f0f0;
  font-size: 0.9rem;
}

tr:hover td { background: #fafafa; }
.empty { text-align: center; color: #999; padding: 2rem !important; }

/* Badges */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-brouillon { background: #e0e0e0; color: #666; }
.badge-confirme { background: #fff3e0; color: #e65100; }
.badge-fabrication { background: #e3f2fd; color: #1565c0; }
.badge-expedie { background: #e8f5e9; color: #2e7d32; }

/* Buttons */
.btn-primary {
  padding: 0.5rem 1rem;
  background: #60763e;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-primary:hover { background: #4a5c30; }

.btn-small {
  padding: 0.25rem 0.6rem;
  border: 1px solid #ddd;
  background: white;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
}

.btn-small:hover { border-color: #60763e; color: #60763e; }

/* Filters */
.filters select {
  padding: 0.4rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.85rem;
}

/* Config */
.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.config-section h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: #555;
}

.webhook-url {
  font-size: 0.75rem;
  background: #f5f5f5;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: #666;
}

/* Main content */
#content { padding: 1.5rem; }

/* Rows / navigation */
.clickable { cursor: pointer; }
.back { color: #60763e; text-decoration: none; }
.back:hover { text-decoration: underline; }
.muted { color: #999; font-size: 0.85rem; }
.section-title { margin: 1.5rem 0 0.75rem; font-size: 1.05rem; color: #444; }

/* Cards */
.card {
  background: white;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 1rem;
}
.card h3 { font-size: 0.95rem; color: #555; margin-bottom: 0.75rem; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.card dl { display: grid; grid-template-columns: auto 1fr; gap: 0.35rem 1rem; font-size: 0.9rem; }
.card dt { color: #999; }
.card label { display: block; margin-bottom: 0.6rem; font-size: 0.85rem; color: #666; }
.card input, .card select, .card textarea {
  display: block; width: 100%; padding: 0.45rem 0.6rem; margin-top: 0.2rem;
  border: 1px solid #ddd; border-radius: 5px; font-size: 0.9rem;
}

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.5rem 0; }
.chips-block { margin-bottom: 0.5rem; }
.chip {
  background: #f0f0f0; border-radius: 12px; padding: 0.2rem 0.6rem;
  font-size: 0.78rem; color: #555; white-space: nowrap;
}
.chip-custom { background: #eef2e4; color: #4a5c30; }
.chip-sm { font-size: 0.7rem; padding: 0.1rem 0.45rem; }
.chips-cell { max-width: 320px; }
.chips-cell .chip { margin: 1px; display: inline-block; }

/* Book cards (commande) */
.book-card { margin-bottom: 0.75rem; }
.book-card-head { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.actions { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.6rem; flex-wrap: wrap; }
.btn-danger { border-color: #d32f2f; color: #d32f2f; }
.btn-danger:hover { background: #d32f2f; color: white; }

/* Pages grid */
.pages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}
.page-card {
  background: white; border-radius: 8px; overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08); text-align: center;
  transition: transform 0.1s, box-shadow 0.1s;
}
.page-card:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,0.12); }
.page-card img { width: 100%; aspect-ratio: 1; object-fit: contain; background: #fafafa; }
.page-card-label { padding: 0.4rem; font-size: 0.8rem; }

/* Layer editor */
.page-layers { display: grid; grid-template-columns: 1.2fr 1fr; gap: 1rem; align-items: start; }
.layers-list table { font-size: 0.85rem; }
.layer-thumb { width: 42px; height: 42px; object-fit: contain; background: #f5f5f5; border-radius: 4px; }
.layer-name { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-editor {
  background: white; border-radius: 8px; padding: 1rem 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08); position: sticky; top: 1rem;
  max-height: calc(100vh - 8rem); overflow-y: auto;
}
.layer-preview { max-width: 100%; max-height: 180px; object-fit: contain; background: #f5f5f5; border-radius: 6px; margin-bottom: 0.75rem; }
.layer-editor label { display: block; margin-bottom: 0.55rem; font-size: 0.8rem; color: #666; }
.layer-editor input, .layer-editor select, .layer-editor textarea {
  display: block; width: 100%; padding: 0.4rem 0.5rem; margin-top: 0.15rem;
  border: 1px solid #ddd; border-radius: 5px; font-size: 0.85rem;
}
.form-row { display: flex; gap: 0.6rem; }
.form-row label { flex: 1; }
.layer-editor h4 { margin: 0.8rem 0 0.4rem; font-size: 0.85rem; color: #555; }
.cond-group { margin-bottom: 0.5rem; font-size: 0.8rem; }
.cond-group strong { display: block; color: #777; margin-bottom: 0.2rem; }
.cond-check { display: inline-flex !important; align-items: center; gap: 0.25rem; margin: 0 0.6rem 0.25rem 0 !important; }
.cond-check input { width: auto !important; display: inline !important; margin: 0 !important; }

/* Toasts */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 1000;
  background: #2e7d32; color: white; padding: 0.7rem 1.2rem;
  border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  font-size: 0.9rem; animation: toast-in 0.25s ease;
}
.toast-error { background: #d32f2f; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

@media (max-width: 900px) {
  .detail-grid, .page-layers, .config-grid { grid-template-columns: 1fr; }
}

/* Formulaires mot de passe oublie / reinitialisation */
.forgot-link {
  display: block;
  margin-top: 0.75rem;
  font-size: 0.82rem;
  color: #60763e;
  text-decoration: none;
}
.forgot-link:hover { text-decoration: underline; }
.form-info { font-size: 0.85rem; color: #666; margin-bottom: 0.75rem; }
