:root {
  --ink: #172329;
  --muted: #5b6a70;
  --line: #d6e2e6;
  --bg: #f5f9fa;
  --panel: #ffffff;
  --accent: #1e93c6;
  --accent-dark: #146a94;
  --accent-ink: #ffffff;
  --danger: #b3261e;
  --radius: 10px;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

header.top {
  margin-bottom: 24px;
}

header.top .logo {
  display: block;
  height: 40px;
  width: auto;
  margin-bottom: 12px;
}

header.top .tag {
  display: inline-block;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 6px;
}

header.top h1 {
  font-size: 1.6rem;
  margin: 0 0 6px;
}

header.top p {
  color: var(--muted);
  margin: 0;
}

#app-content {
  display: none;
}

.user-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 16px;
}

.user-bar strong {
  color: var(--ink);
}

#logout-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.nav-switch {
  display: flex;
  gap: 8px;
  margin-bottom: 28px;
}

.nav-switch button {
  flex: 1;
  text-align: center;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  background: var(--panel);
  cursor: pointer;
}

.nav-switch button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}

fieldset {
  border: none;
  padding: 0;
  margin: 0 0 20px;
}

label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.hint {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.8rem;
  margin: -10px 0 16px;
}

input[type="file"] {
  padding: 8px;
  background: var(--bg);
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  margin-bottom: 16px;
}

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

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
}

.item-row {
  display: grid;
  grid-template-columns: 1fr 70px 100px auto;
  gap: 8px;
  align-items: start;
}

.total-row {
  text-align: right;
  font-size: 0.95rem;
  color: var(--muted);
  margin: -8px 0 20px;
}

.total-row strong {
  color: var(--ink);
  font-size: 1.1rem;
}

.item-row button {
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--danger);
  cursor: pointer;
  height: 42px;
  margin-top: 0;
}

#supply-add-item, #report-add-piece {
  background: none;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 10px;
  width: 100%;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 20px;
}

button[type="submit"] {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

button[type="submit"]:hover:not(:disabled) {
  background: var(--accent-dark);
}

button[type="submit"]:disabled {
  opacity: 0.6;
  cursor: progress;
}

.msg {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  display: none;
}

.msg.show { display: block; }
.msg.ok { background: #e6f4ea; color: #1e4620; border: 1px solid #b7ddc0; }
.msg.error { background: #fbeaea; color: var(--danger); border: 1px solid #f0c4c1; }

.required::after {
  content: " *";
  color: var(--danger);
}

/* --- Sous-onglets (ex: Maintenance > Nouvelle demande / Historique) --- */
.sub-nav {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}

.sub-nav button {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.sub-nav button.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.subpanel {
  display: none;
}

.subpanel.active {
  display: block;
}

/* --- Historique des demandes --- */
.history-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}

.history-item-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.history-item-top strong {
  font-size: 0.95rem;
}

.history-item .meta {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 4px 0 10px;
}

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge.pending { background: #fdf1d6; color: #8a5b00; }
.badge.done { background: #e6f4ea; color: #1e4620; }

.history-item .actions {
  display: flex;
  gap: 8px;
}

.history-item .actions button {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.history-item .actions button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* --- Modal (rapport d'intervention) --- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(23, 35, 41, 0.55);
  padding: 20px;
  overflow-y: auto;
  z-index: 100;
}

.modal-overlay.show {
  display: block;
}

.modal-box {
  max-width: 640px;
  margin: 0 auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal-header h2 {
  color: #fff;
  font-size: 1.15rem;
  margin: 0;
}

#report-modal-close {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  color: #fff;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 1rem;
}

#report-organisme-wrap {
  display: none;
}
