/* ═══════════════════════════════════════════════ TRVFlex — styles */
@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Syne:wght@400;600;700;800&display=swap');

:root {
  --bg:          #0f0f0f;
  --surface:     #1a1a1a;
  --surface2:    #222222;
  --surface3:    #272727;
  --border:      #2e2e2e;
  --accent:      #c8a96e;
  --accent2:     #e0c88a;
  --text:        #e8e4dc;
  --text-muted:  #7a7570;
  --text-dim:    #4a4540;
  --green:       #4caf82;
  --red:         #e05555;
  --orange:      #e09555;
  --radius:      4px;
  --sidebar-w:   260px;
  --header-h:    50px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  min-height: 100vh;
  overflow: hidden;
}

/* ── Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ══════════════════════════════════════════════ AUTH */
#auth-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.auth-screen { width: 100%; max-width: 360px; padding: 24px; text-align: center; }

.auth-logo {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 32px;
  color: var(--accent);
  letter-spacing: .08em;
  margin-bottom: 4px;
}

.auth-sub {
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  margin-bottom: 32px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px;
  text-align: left;
}

/* ══════════════════════════════════════════════ LAYOUT */
#app-view { display: flex; flex-direction: column; height: 100vh; }

.app-header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  gap: 12px;
}

.hd-logo {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: .06em;
  color: var(--accent);
  flex-shrink: 0;
}
.hd-logo span { color: var(--text-muted); font-weight: 400; }

.hd-center {
  flex: 1;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: .04em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hd-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ══════════════════════════════════════════════ SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 10px;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--accent);
}

.chantier-list { flex: 1; overflow-y: auto; padding: 6px; }

.chantier-item {
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 3px;
  transition: all .15s;
}

.chantier-item:hover { background: var(--surface2); }
.chantier-item.active { background: var(--surface2); border-color: var(--accent); }

.chantier-item-name {
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chantier-item-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ══════════════════════════════════════════════ MAIN */
.main-area {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  padding: 40px;
  text-align: center;
}

.empty-icon { font-size: 48px; }
.empty-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 16px; color: var(--text); }
.empty-sub { font-size: 12px; max-width: 280px; line-height: 1.6; }

/* ══════════════════════════════════════════════ TABS */
.tabs {
  display: flex;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  flex-shrink: 0;
}

.tab {
  padding: 10px 14px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all .15s;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-panel { flex: 1; overflow-y: auto; padding: 16px; display: none; }
.tab-panel.active { display: block; }

#chantier-editor {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

/* ══════════════════════════════════════════════ FORMS */
.panel-section { margin-bottom: 20px; }

.section-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 10px;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--accent2);
  margin-bottom: 10px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.form-grid .span2 { grid-column: span 2; }

.field { display: flex; flex-direction: column; gap: 4px; }

.field label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: .02em;
  display: flex;
  align-items: center;
  gap: 4px;
}

.unit { color: var(--text-dim); font-size: 10px; }
.hint-inline { color: var(--text-dim); font-size: 10px; }

.field input,
.field select,
.field textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  padding: 6px 9px;
  outline: none;
  transition: border-color .15s;
  width: 100%;
}

.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--accent); }

.field input.error { border-color: var(--red); }
.field select option { background: var(--surface2); }
.field textarea { resize: vertical; }

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ══════════════════════════════════════════════ BUTTONS */
.btn {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  padding: 7px 14px;
  transition: all .15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #0f0f0f;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.btn-primary:hover { background: var(--accent2); }

.btn-secondary {
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-danger {
  background: var(--red);
  color: #fff;
}
.btn-danger:hover { opacity: .85; }

.btn-sm { padding: 5px 10px; font-size: 10px; }

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}
.icon-btn:hover { background: var(--surface2); color: var(--text); }

/* ══════════════════════════════════════════════ MESURES */
.pos-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 8px 0 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

#pos-indicator {
  font-family: 'Syne', sans-serif;
  font-size: 12px;
  color: var(--text-muted);
}

#pos-indicator strong { color: var(--accent); }

.mesures-grid { display: flex; flex-direction: column; gap: 14px; }

.mesure-section {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.banane-alert {
  margin-top: 8px;
  padding: 6px 10px;
  background: rgba(224, 149, 85, .12);
  border: 1px solid var(--orange);
  border-radius: var(--radius);
  color: var(--orange);
  font-size: 11px;
}

/* ══════════════════════════════════════════════ RESULTATS */
.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.result-table th {
  text-align: left;
  padding: 6px 10px;
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}

.result-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}

.result-table tr:hover td { background: var(--surface2); }
.result-val { color: var(--accent2); font-weight: 500; }
.result-ok { color: var(--green); }
.result-warn { color: var(--red); }

.result-section-header {
  padding: 8px 0 4px;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 10px;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--accent);
}

.bw-check-ok { color: var(--green); }
.bw-check-warn { color: var(--red); font-weight: 600; }

/* ══════════════════════════════════════════════ EXPORT */
.export-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 10px;
}

.export-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.export-icon { font-size: 32px; }
.export-label { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 14px; }
.export-desc { font-size: 11px; color: var(--text-muted); line-height: 1.5; }

/* ══════════════════════════════════════════════ HINTS */
.hint {
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  margin-bottom: 10px;
  border: 1px solid;
}

.hint-warning {
  background: rgba(224, 149, 85, .08);
  border-color: var(--orange);
  color: var(--orange);
}

.errmsg {
  color: var(--red);
  font-size: 11px;
  margin-top: 8px;
  text-align: center;
}

/* ══════════════════════════════════════════════ MODAL */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px;
  width: 100%;
  max-width: 360px;
}

.modal-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 10px;
}

.modal-body { color: var(--text-muted); font-size: 12px; line-height: 1.6; margin-bottom: 16px; }

.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ══════════════════════════════════════════════ UTILS */
[hidden] { display: none !important; }

@media (max-width: 680px) {
  .sidebar { width: 200px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: span 1; }
  .export-grid { grid-template-columns: 1fr; }
}
