:root{
  --bg:#0b0f14;
  --panel:#131a22;
  --panel-2:#0f151c;
  --border:#1f2a35;
  --text:#e6edf3;
  --muted:#9db0c3;
  --accent:#4dd1a1;
  --accent-2:#3aa8ff;
  --danger:#ff6b6b;
}

body{
  font-family:"Trebuchet MS","Segoe UI",sans-serif;
  margin:0;
  background:radial-gradient(900px 500px at 10% 0%, #15212c 0%, #0b0f14 55%, #090c10 100%);
  color:var(--text);
}

header{
  background:linear-gradient(180deg, #111821 0%, #0f141b 100%);
  border-bottom:1px solid var(--border);
  padding:12px 16px;
  display:flex;
  justify-content:space-between;
  align-items:center;
  position:sticky;
  top:0;
  z-index:200;
  gap:10px;
  flex-wrap:wrap;
}
header strong{flex:1;font-size:18px;letter-spacing:0.3px;}
header .header-actions{display:flex;gap:8px;align-items:center;flex-wrap:nowrap;}
.icon-button{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:36px;
  height:34px;
  padding:6px;
  min-width:34px;
  background:var(--panel);
  color:var(--text);
  border:1px solid var(--border);
  border-radius:12px;
  cursor:pointer;
  transition:transform .15s ease,border-color .15s ease;
}
.icon-button:hover{transform:translateY(-1px);border-color:#38506a;}
.icon-button svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.icon-button.small{width:34px;height:30px;padding:4px;}

@media (max-width: 640px){
  header{flex-direction:column;align-items:stretch;padding:10px 12px;}
  header strong{width:100%}
  header .header-actions{
    justify-content:space-between;
    width:100%;
    flex-wrap:nowrap;
    gap:6px;
  }
  header .header-actions button{
    flex:1 1 0;
    min-width:0;
    padding:6px 8px;
    max-height:42px;
  }
}

main{
  padding:16px;
  max-width:1100px;
  margin:0 auto;
}
.card{
  background:linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border:1px solid var(--border);
  border-radius:14px;
  padding:14px;
  margin:10px 0;
  box-shadow:0 12px 24px rgba(0,0,0,0.25);
}
.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:10px}

button{
  padding:8px 10px;
  border:1px solid #263241;
  background:linear-gradient(180deg, #1a2430 0%, #111820 100%);
  color:var(--text);
  border-radius:12px;
  cursor:pointer;
  transition:transform .15s ease,border-color .15s ease;
}
button:hover{transform:translateY(-1px);border-color:#38506a;}
.btn{
  background:linear-gradient(180deg, #1a2430 0%, #111820 100%);
  color:var(--text);
  border:1px solid #263241;
  border-radius:12px;
  padding:8px 12px;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  gap:6px;
  justify-content:center;
  transition:all .2s ease;
  min-height:42px;
}
.btn:hover{transform:translateY(-1px);border-color:#38506a;}
.btn.small{padding:6px 10px;font-size:13px;border-radius:10px;min-height:38px;}
.btn.primary{background:var(--accent);color:#0d1218;border:1px solid var(--accent);}
.btn.danger{background:var(--danger);color:#fff;border:0;}
.btn.pill{border-radius:999px;}
.btn.full{width:100%;}

input,select,textarea{
  width:100%;
  padding:10px;
  border:1px solid var(--border);
  border-radius:10px;
  box-sizing:border-box;
  margin:6px 0;
  background:#0f151c;
  color:var(--text);
}
.small{font-size:12px;color:var(--muted)}

/* =========================
   ACTION TYPE BUTTONS
   (Diagnostic / Réparation / Dossier)
========================= */

.btnActionType {
  padding: 8px 14px;
  border: 1px solid #32465a;
  background: #1a2430;
  color: var(--text);
  cursor: pointer;
  border-radius: 6px;
  font-size: 0.95rem;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

/* Uniformise la couleur de l'icône calendrier (inputs date/datetime) sur fond sombre */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
}
input[type="date"]::-moz-focus-inner,
input[type="datetime-local"]::-moz-focus-inner {
  filter: invert(1);
}

/* Réparations : outillage rapide */
.rep-tools {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin-top: 6px;
}
.rep-box {
  background: linear-gradient(180deg, #111821 0%, #0f141b 100%);
  border: 1px solid #222c36;
  border-radius: 12px;
  padding: 12px;
}
.rep-head h3 { margin: 0; }
.rep-head .muted { color: #9bb0c6; }
.rep-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}
.rep-sheet {
  display: none;
  background: #0f151c;
  border: 1px solid #253241;
  border-radius: 10px;
  padding: 6px;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.rep-progress {
  margin-top: 8px;
}
.rep-phase {
  margin-top: 10px;
}
.btn.primary {
  background: var(--accent);
  color: #0d1218;
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn.pill {
  background: #192431;
  color: #fff;
  border: 1px solid #2b3a4d;
  border-radius: 999px;
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn.full { width: 100%; }

@media (max-width: 640px) {
  .rep-actions { gap: 6px; }
  .rep-box { padding: 10px; }
}

/* Mode intervention : vue épurée */
.intervention-mode .logSection,
.intervention-mode .detailsGrid,
.intervention-mode .statusSection,
.intervention-mode .pieces-block,
.intervention-mode .filesSection,
.intervention-mode .timeline,
.intervention-mode .followupCard,
.intervention-mode .rdvSection,
.intervention-mode .qualiSection,
.intervention-mode .app-info {
  display: none !important;
}
.intervention-mode #cycleSection > .rep-box:not(#interventionPane),
.intervention-mode #cycleSection > .card {
  display: none !important;
}
.intervention-mode #cycleSection > *:not(#interventionPane) {
  display: none !important;
}
.intervention-mode #cycleSection {
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}
.intervention-mode #appareilInfo,
.intervention-mode #followupCard {
  display: none !important;
}
.intervention-mode #interventionPane {
  display: block !important;
}
.intervention-mode .rep-tools > .rep-box:first-child {
  display: block !important;
}
.intervention-mode .rep-tools > .rep-box:first-child .rep-head,
.intervention-mode .rep-tools > .rep-box:first-child .rep-actions {
  display: none !important;
}
.intervention-mode #historyCard {
  display: none !important;
}
.intervention-pane {
  display: none;
  margin-top: 12px;
}
.intervention-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 14px;
  margin-top: 10px;
}
.intervention-actions .action {
  background: linear-gradient(180deg, #17212d 0%, #111821 100%);
  border: 1px solid #2b3a4d;
  border-radius: 14px;
  padding: 16px;
  text-align: center;
  color: #e6edf3;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 600;
  cursor: pointer;
}
.intervention-actions .action svg {
  width: 32px;
  height: 32px;
  stroke: currentColor;
  stroke-width: 1.7;
  fill: none;
}
.intervention-actions .action:active {
  transform: translateY(1px);
}
.intervention-mode .rep-sheet { display: flex !important; }

/* Modal générique pour notes intervention */
.modal-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
  overflow: auto;
}
.modal-card {
  background: #101820;
  color: #e6edf3;
  border: 1px solid #233140;
  border-radius: 12px;
  padding: 14px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 12px 24px rgba(0,0,0,0.35);
}
@media (max-width: 640px) {
  .modal-overlay {
    align-items: flex-start;
    padding: 20px 12px;
  }
  .modal-card {
    margin-top: 20px;
    width: 100%;
  }
}

.btnActionType:not(.active) {
  opacity: 0.7;
}

.btnActionType.active {
  background: #2c7be5;
  color: #ffffff;
  border-color: #2c7be5;
  opacity: 1;
}

/* Optionnel : effet hover pour lisibilité */
.btnActionType:hover {
  opacity: 1;
}

.timeline {
  list-style: none;
  padding-left: 0;
}

.timelineItem {
  display: block;
  padding: 10px 12px;
  cursor: pointer;
  border-left: 3px solid #2a3a48;
  margin-bottom: 6px;
  background: #0f151c;
  border-radius: 10px;
  color: var(--text);
}

.timelineItem .date {
  margin-left: auto;
  color: #9bb0c6;
  font-size: 0.85rem;
  font-weight: 400;
}

.timelineActions {
  display: flex;
  gap: 4px;
  margin-left: 4px;
}

.timelineItem .editDateBtn {
  padding: 4px;
}

.timelineItem.active {
  border-color: var(--accent-2);
  background: #13202b;
}

.timelineHead {
  display: flex;
  gap: 10px;
  align-items: center;
}
.timelineHead .btn.icon-only {
  min-width: 32px;
  min-height: 32px;
  padding: 6px;
}
.timelineHead .btn.icon-only svg {
  width: 18px;
  height: 18px;
}

.timelineQuickActions {
  position: relative;
  margin-top: 6px;
  display: flex;
  gap: 8px;
}
.timelineQuickMenu {
  position: absolute;
  top: 36px;
  right: 0;
  min-width: 120px;
  display: none;
  flex-direction: column;
  gap: 6px;
  background: #0f151c;
  border: 1px solid var(--app-border);
  border-radius: 10px;
  padding: 8px;
  z-index: 5;
  box-shadow: 0 8px 18px rgba(0,0,0,0.25);
}
.timelineQuickMenu .btn {
  width: 100%;
}

.timelineContent {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--app-border);
}
.timelineContent .tl-block-title {
  font-size: 12px;
  color: var(--app-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.2px;
}
.timelineContent .tl-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px dashed var(--app-border);
}
.timelineContent .tl-row:last-child {
  border-bottom: none;
}
.timelineContent .tl-main {
  font-size: 13px;
}
.timelineContent .tl-meta {
  font-size: 11px;
  color: var(--app-muted);
  text-align: right;
  white-space: nowrap;
}
.timelineContent .tl-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.timelineContent .tl-photo-wrap {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--app-border);
  background: #0f151c;
}
.timelineContent .tl-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
}
.timelineContent .photoStatus {
  position: absolute;
  bottom: 4px;
  right: 4px;
}

.photoGrid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.photoItem {
  position: relative;
  width: 90px;
  height: 90px;
  display: inline-block;
}
.photoItem.uploading img {
  opacity: 0.55;
}
.photoItem.uploading::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid #ccc;
  border-top-color: #333;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.photoStatus {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #fff;
  background: rgba(0,0,0,0.65);
  pointer-events: none;
}
.photoStatus.ok { background: #2e7d32; }
.photoStatus.error { background: #b23b3b; }
.photoStatus.pending { background: rgba(0,0,0,0.55); }
.photoStatus .photoSpinner {
  width: 14px;
  height: 14px;
  border: 2px solid #ffffff33;
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  box-sizing: border-box;
}
.photoRetry {
  position: absolute;
  bottom: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 4px;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  line-height: 20px;
}
.photoDelete {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border: none;
  background: rgba(0,0,0,0.65);
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  line-height: 20px;
  padding: 0;
}

.photoThumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
}

.btnAdd {
  margin-left: 8px;
  font-size: 0.8rem;
  cursor: pointer;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.inlineInput {
  width: 100%;
  padding: 6px;
  margin-top: 6px;
}
.noteBadge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  border-radius: 8px;
  font-size: 11px;
  margin-right: 6px;
  color: #fff;
}
.noteBadge.tech { background: #5262ff; }
.noteBadge.client { background: #2e7d32; }
.noteDate {
  color: #777;
  font-size: 11px;
  margin-left: 6px;
}

.progressContainer {
  width: 100%;
  height: 10px;
  background: #1b2530;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progressBar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-2), #74f0c0);
  transition: width 0.3s ease;
}

.progressLabel {
  font-size: 0.85rem;
  color: var(--muted);
}
