:root {
  --primary: #1a5f7a;
  --primary-light: #e8f4f8;
  --border: #d0d7de;
  --text: #24292f;
  --muted: #57606a;
  --danger: #cf222e;
  --success: #1a7f37;
  --warning: #9a6700;
  --group1: #e8f4f8;
  --group2: #f0f7fa;
  --group3: #f8fbfd;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: #f6f8fa;
  color: var(--text);
  padding: 16px;
}
.container { max-width: 1900px; margin: 0 auto; }
.app-heading { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.user-actions { display: flex; align-items: center; gap: 8px; }
.user-email {
  align-self: center;
  max-width: min(32vw, 360px);
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.85rem;
}
h1 { font-size: 1.25rem; color: var(--primary); margin-bottom: 4px; }
.subtitle { color: var(--muted); font-size: 0.85rem; margin-bottom: 14px; }

.auth-panel {
  max-width: 620px;
  margin: 12vh auto 0;
  padding: 28px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 18px rgba(36, 41, 47, 0.08);
}
.auth-panel h2 { color: var(--primary); font-size: 1.15rem; margin-bottom: 10px; }
.auth-panel p { color: var(--muted); line-height: 1.5; margin-bottom: 18px; }

.collapsible {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
  overflow: hidden;
}
.collapsible-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #f8fafc;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  font-size: 0.9rem;
}
.collapsible-header:hover { background: #f0f4f8; }
.collapsible-body { padding: 12px 14px; display: none; }
.collapsible.open .collapsible-body { display: block; }
.toggle-icon { font-size: 0.9rem; color: var(--muted); }

textarea {
  width: 100%;
  height: 130px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: monospace;
  font-size: 0.78rem;
  resize: vertical;
}
.actions {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
button {
  padding: 7px 14px;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: #154e63; }
.btn-secondary { background: #eaeef2; }
.btn-secondary:hover { background: #d0d7de; }
.btn-eva { background: #0f766e; color: white; }
.btn-eva:hover { background: #0d9488; }
.btn-eva:disabled { background: #94a3b8; cursor: not-allowed; }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-danger:hover { background: #fecaca; }
.saved-info { font-size: 0.8rem; color: var(--muted); }

.controls {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  align-items: flex-start;
}
.controls-group { display: flex; flex-direction: column; gap: 5px; }
.controls-group label { font-weight: 500; font-size: 0.82rem; }
select[multiple] {
  min-width: 160px;
  min-height: 70px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.82rem;
}
.search-box, .date-input {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
}
.search-box { min-width: 200px; }
.date-row { display: flex; gap: 6px; align-items: center; font-size: 0.82rem; }
.eva-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.row-count { font-size: 0.9rem; color: var(--muted); }

.progress-bar-container {
  display: none;
  margin-top: 10px;
  background: #e2e8f0;
  border-radius: 6px;
  height: 22px;
  overflow: hidden;
  position: relative;
}
.progress-bar {
  height: 100%;
  background: #0f766e;
  width: 0%;
  transition: width 0.2s;
}
.progress-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: #1e293b;
}

.alert-cors {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  color: #92400e;
  padding: 10px 14px;
  border-radius: 6px;
  margin-top: 10px;
  font-size: 0.85rem;
  display: none;
}

.table-wrapper {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: auto;
  display: none;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  min-width: 1800px;
}
thead {
  background: var(--primary);
  color: white;
  position: sticky;
  top: 0;
  z-index: 10;
}
th {
  padding: 8px 9px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  border-right: 1px solid rgba(255,255,255,0.12);
}
th:hover { background: #154e63; }
th .sort-icon { margin-left: 3px; font-size: 0.7rem; opacity: 0.8; }

td {
  padding: 6px 9px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tbody tr:hover { background: var(--primary-light); }

.group-header td {
  font-weight: 600;
  color: var(--primary);
  border-bottom: 2px solid var(--primary);
}
.group-level-0 td { background: var(--group1); }
.group-level-1 td { background: var(--group2); padding-left: 22px; }
.group-level-2 td { background: var(--group3); padding-left: 38px; }

.group-toggle {
  display: inline-block;
  width: 18px;
  height: 18px;
  line-height: 16px;
  text-align: center;
  border: 1px solid var(--primary);
  border-radius: 3px;
  margin-right: 8px;
  cursor: pointer;
  font-size: 0.75rem;
  background: white;
  color: var(--primary);
  user-select: none;
}
.group-toggle:hover { background: var(--primary-light); }

.num { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.76rem; }
.num-opco {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.76rem;
  white-space: nowrap !important;
  word-break: keep-all;
}
.montant { font-weight: 600; text-align: right; white-space: nowrap; }
.montant.negatif { color: var(--danger); }
.row-num { color: var(--muted); font-size: 0.76rem; text-align: center; width: 36px; }

.eva-ok { color: var(--success); font-weight: 600; }
.eva-ko { color: var(--danger); font-weight: 600; }
.eva-warn { color: var(--warning); font-weight: 600; }
.eva-link { color: var(--primary); text-decoration: none; }
.eva-link:hover { text-decoration: underline; }
.eva-info { font-size: 0.75rem; color: var(--muted); }

.hidden-row { display: none; }
