/* ─── THÈME & VARIABLES ─── */
:root {
  --bg:       #f5f7fa;
  --surface:  #ffffff;
  --surface2: #f0f2f5;
  --border:   #e2e8f0;
  --border2:  #cbd5e1;
  --accent:   #059669;
  --accent2:  #10b981;
  --danger:   #ef4444;
  --warn:     #f59e0b;
  --text:     #0f172a;
  --text2:    #475569;
  --text3:    #94a3b8;
  --mono: 'Inter', monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow: 0 4px 12px rgba(0,0,0,0.06);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: calc(100vh / 1.2);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, rgba(15,23,42,0.04) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
  z-index: 0;
}

/* ─── LAYOUT ─── */
.app { display: flex; min-height: calc(100vh / 1.2); position: relative; z-index: 1; }

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

.view { display: none; }
.view.active { display: block; }

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(5,150,105,0.25);
}
.btn-primary:hover { background: #047857; transform: translateY(-1px); }

.btn-ghost {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--border2); color: var(--text); }

.btn--xs { font-size: 11px; padding: 5px 10px; }
.btn--danger-text { color: var(--danger); border-color: rgba(255,59,92,0.3); }

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ─── ANIMATIONS ─── */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes slideIn {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.fade-in { animation: fadeIn 0.4s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeDown { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

.stagger > * { animation: fadeIn 0.4s ease both; }
.stagger > *:nth-child(1) { animation-delay: 0.05s; }
.stagger > *:nth-child(2) { animation-delay: 0.1s; }
.stagger > *:nth-child(3) { animation-delay: 0.15s; }
.stagger > *:nth-child(4) { animation-delay: 0.2s; }

/* ─── EMPTY STATE ─── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
  color: var(--text2);
}

.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.4; }
.empty-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.empty-sub { font-size: 14px; color: var(--text2); }
.empty-placeholder { color: var(--text3); font-size: 13px; padding: 32px; text-align: center; }
.empty-state-inline { color: var(--text3); font-size: 13px; padding: 20px; text-align: center; }
.empty-state-text { color: var(--text3); font-size: 13px; padding: 32px; text-align: center; }

/* ─── TOAST ─── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  animation: slideIn 0.3s ease;
  max-width: 320px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.toast.success { border-left: 3px solid var(--accent2); }
.toast.error { border-left: 3px solid var(--danger); position: relative; padding-right: 32px; max-width: 480px; }
.toast-close {
  position: absolute; top: 6px; right: 10px;
  cursor: pointer; font-size: 18px; font-weight: bold;
  color: var(--text3); line-height: 1;
}
.toast-close:hover { color: var(--danger); }

/* ─── MODAL ─── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(15,23,42,0.4);
  backdrop-filter: blur(8px);
  display: none; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 480px;
  max-width: 90vw;
  box-shadow: 0 24px 48px rgba(0,0,0,0.12);
}
.modal--wide { width: 680px; }
.modal--narrow { width: 400px; }
.modal h3 { font-size: 16px; font-weight: 800; margin-bottom: 4px; }
.modal-desc {
  color: var(--text3);
  font-size: 13px;
  line-height: 1.4;
  margin: 0 0 20px 0;
}
.modal h3 + .form-grid,
.modal h3 + .form-grid--single { margin-top: 16px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.form-error-msg {
  color: var(--danger);
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255,59,92,0.06);
  border: 1px solid rgba(255,59,92,0.15);
}
.form-error-msg.hidden { display: none; }

/* ─── VERSION / RELEASE NOTES ─── */
.version-link {
  color: var(--accent2); text-decoration: none; cursor: pointer;
  border-bottom: 1px dashed var(--accent2); transition: opacity .2s;
}
.version-link:hover { opacity: .7; }

.release-notes-list { max-height: 60vh; overflow-y: auto; }
.rn-version { margin-bottom: 18px; }
.rn-version:last-child { margin-bottom: 0; }
.rn-header { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.rn-tag {
  background: var(--accent2); color: var(--bg); font-weight: 800;
  font-size: 12px; padding: 2px 8px; border-radius: 4px;
}
.rn-date { color: var(--text3); font-size: 12px; }
.rn-changes {
  margin: 0; padding-left: 20px; color: var(--text2);
  font-size: 13px; line-height: 1.7;
}
.rn-changes li::marker { color: var(--accent2); }

/* ─── INFO BOXES ─── */
.info-box { border-radius: 8px; padding: 12px; }
.info-box--warn { background: rgba(255,170,0,0.04); border: 1px solid rgba(255,170,0,0.2); }
.info-box--accent { background: rgba(5,150,105,0.04); border: 1px solid rgba(5,150,105,0.15); }
.info-box-label { font-size: 11px; font-family: var(--mono); }
.info-box-label--warn { color: var(--warn); }
.info-box-label--accent { color: var(--accent); }
.info-box-text { font-size: 12px; color: var(--text2); margin-top: 6px; }

/* ─── ALERT SETTINGS MODAL ─── */
.alert-cfg-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 0;
  font-size: 13px; border-bottom: 1px solid var(--border);
}
.alert-cfg-row input[type="checkbox"] {
  width: 16px; height: 16px; accent-color: var(--accent);
}
.alert-cfg-row input[type="number"] {
  font-family: var(--mono);
}

/* ─── LANGUAGE TOGGLE ─── */
.lang-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.15s;
}
.lang-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(5,150,105,0.06);
}

/* ─── FLAG ICONS (SVG, Chrome-safe) ─── */
.flag-icon {
  display: inline-block; width: 1.25em; height: 0.95em;
  vertical-align: -0.15em; background-size: contain;
  background-repeat: no-repeat; background-position: center;
  border-radius: 2px; flex-shrink: 0;
}
.flag-fr { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 3 2'%3E%3Crect fill='%23002395' width='1' height='2'/%3E%3Crect fill='%23fff' x='1' width='1' height='2'/%3E%3Crect fill='%23ED2939' x='2' width='1' height='2'/%3E%3C/svg%3E"); }
.flag-gb { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 30'%3E%3Crect fill='%23012169' width='60' height='30'/%3E%3Cpath d='M0 0l60 30M60 0L0 30' stroke='%23fff' stroke-width='6'/%3E%3Cpath d='M0 0l60 30M60 0L0 30' stroke='%23C8102E' stroke-width='4' clip-path='polygon(30 15,60 30,60 0)' /%3E%3Cpath d='M0 0l60 30' stroke='%23C8102E' stroke-width='4' clip-path='polygon(0 0,30 15,0 30)' /%3E%3Cpath d='M60 0L0 30' stroke='%23C8102E' stroke-width='4' clip-path='polygon(30 15,60 0,60 30)' /%3E%3Cpath d='M60 0L0 30' stroke='%23C8102E' stroke-width='4' clip-path='polygon(0 0,30 15,0 30)' /%3E%3Cpath d='M30 0v30M0 15h60' stroke='%23fff' stroke-width='10'/%3E%3Cpath d='M30 0v30M0 15h60' stroke='%23C8102E' stroke-width='6'/%3E%3C/svg%3E"); }
.flag-us { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 190 100'%3E%3Crect fill='%23B22234' width='190' height='100'/%3E%3Cg fill='%23fff'%3E%3Crect y='7.69' width='190' height='7.69'/%3E%3Crect y='23.08' width='190' height='7.69'/%3E%3Crect y='38.46' width='190' height='7.69'/%3E%3Crect y='53.85' width='190' height='7.69'/%3E%3Crect y='69.23' width='190' height='7.69'/%3E%3Crect y='84.62' width='190' height='7.69'/%3E%3C/g%3E%3Crect fill='%233C3B6E' width='76' height='53.85'/%3E%3C/svg%3E"); }

/* ─── UTILITY CLASSES ─── */
.hidden { display: none !important; }
.text-muted { color: var(--text2); }
.text-muted-sm { color: var(--text3); font-size: 13px; }
.mono-text { font-family: var(--mono); font-size: 12px; }
.date-text { font-size: 12px; color: var(--text2); }
.text-right { text-align: right; }
.text-ellipsis { overflow: hidden; text-overflow: ellipsis; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-10 { margin-top: 10px; }
.status-message { padding: 40px; text-align: center; color: var(--text2); }
.status-message--error { color: var(--danger); }
.code-accent { color: var(--accent); }
.panel--mb { margin-bottom: 20px; }
.panel-body--padded { padding: 16px; }
.panel-body--compact { padding: 12px; }
.section-label-mono { font-family: var(--mono); font-size: 10px; color: var(--text3); letter-spacing: 1.5px; margin-bottom: 14px; }
.section-label-sm { font-size: 10px; font-family: var(--mono); color: var(--text3); letter-spacing: 0.6px; margin-bottom: 8px; }
.infinity-badge { font-family: var(--mono); font-weight: 700; color: var(--accent2); }
.sub-id-text { font-size: 9px; color: var(--text3); font-family: var(--mono); margin-top: 2px; }
.cell-text { font-size: 13px; }
.cell-email { font-size: 12px; color: var(--text2); }

/* ─── RESPONSIVE ─── */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .panels-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .content { padding: 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .provider-grid { grid-template-columns: repeat(3, 1fr); }
  .audit-topbar { flex-direction: column; align-items: stretch; }
}
