/* ── Quintessence Cockpit — Design System ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --violet-deep:    #3D1A6E;
  --violet-brand:   #7B2FBE;
  --violet-light:   #F3EEFF;
  --violet-border:  #C4A0F0;
  --gold:           #C9A84C;
  --green:          #2D8A5E;
  --red:            #C0392B;
  --orange:         #E67E22;
  --text:           #4A4A5A;
  --bg:             #FAF9FE;
  --white:          #FFFFFF;
}

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

body {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: 220px;
  background: var(--violet-light);
  border-right: 1px solid var(--violet-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-brand {
  background: var(--violet-deep);
  color: var(--white);
  padding: 20px 16px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  line-height: 1.4;
}

.sidebar-brand span {
  display: block;
  color: var(--gold);
  font-size: 11px;
  font-weight: 400;
  margin-top: 2px;
}

.sidebar nav {
  flex: 1;
  padding: 12px 0;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--violet-deep);
  text-decoration: none;
  font-weight: 500;
  font-size: 13px;
  border-radius: 0;
  transition: background 0.15s, color 0.15s;
}

.sidebar nav a:hover {
  background: rgba(123, 47, 190, 0.1);
}

.sidebar nav a.active {
  background: var(--violet-brand);
  color: var(--white);
}

.sidebar nav a .nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--violet-border);
  font-size: 12px;
  color: var(--violet-brand);
}

.sidebar-footer a { color: var(--violet-brand); text-decoration: none; }

/* ── Main layout ── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  background: var(--violet-deep);
  color: var(--white);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.topbar h1 {
  font-size: 16px;
  font-weight: 600;
}

.topbar .period-selector {
  display: flex;
  gap: 8px;
  align-items: center;
}

.topbar select {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: var(--white);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

.topbar select option { background: var(--violet-deep); }

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

/* ── KPI Cards ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--white);
  border: 1px solid var(--violet-border);
  border-radius: 8px;
  padding: 16px;
}

.kpi-card .kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--violet-brand);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.kpi-card .kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--violet-brand);
  line-height: 1;
}

.kpi-card .kpi-sub {
  font-size: 11px;
  color: #888;
  margin-top: 4px;
}

/* ── Alerts ── */
.alerts { margin-bottom: 20px; display: flex; flex-direction: column; gap: 8px; }

.alert {
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  border-left: 4px solid;
}

.alert-orange { background: #FFF3E0; border-color: var(--orange); color: #7B4A00; }
.alert-red    { background: #FDECEA; border-color: var(--red); color: #7B1A14; }

/* ── Tables ── */
.table-wrapper {
  background: var(--white);
  border: 1px solid var(--violet-border);
  border-radius: 8px;
  overflow-x: auto;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--violet-border);
  gap: 12px;
  flex-wrap: wrap;
}

.table-toolbar h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--violet-deep);
}

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.filters select,
.filters input[type="date"] {
  border: 1px solid var(--violet-border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--text);
  background: var(--white);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: var(--violet-deep);
  color: var(--white);
  padding: 10px 10px;
  text-align: right;
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
}

thead th:first-child { text-align: left; }

tbody tr:nth-child(even) { background: var(--violet-light); }
tbody tr:hover { background: rgba(123,47,190,0.07); }

tbody td {
  padding: 8px 10px;
  text-align: right;
  border-bottom: 1px solid var(--violet-border);
  white-space: nowrap;
}

tbody td:first-child { text-align: left; font-weight: 500; }

tfoot tr { background: var(--violet-deep) !important; color: var(--white); font-weight: 700; }
tfoot td { padding: 9px 10px; border: none; }

/* Coloring conditionnel */
.positive { color: var(--green); font-weight: 600; }
.negative { color: var(--red); font-weight: 600; }

/* Editable cells */
.editable {
  cursor: pointer;
  border-bottom: 1px dashed var(--violet-brand);
  min-width: 60px;
  display: inline-block;
}

.editable:focus {
  outline: 2px solid var(--violet-brand);
  border-radius: 3px;
  background: var(--white);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background 0.15s;
}

.btn-primary { background: var(--violet-brand); color: var(--white); }
.btn-primary:hover { background: var(--violet-deep); }
.btn-outline {
  background: var(--white);
  color: var(--violet-brand);
  border: 1px solid var(--violet-brand);
}
.btn-outline:hover { background: var(--violet-light); }
.btn-copy { background: var(--violet-light); color: var(--violet-deep); border: 1px solid var(--violet-border); }

/* ── Charts ── */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--white);
  border: 1px solid var(--violet-border);
  border-radius: 8px;
  padding: 16px;
}

.chart-card h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--violet-deep);
  margin-bottom: 12px;
}

/* ── Funnel ── */
.funnel-container { max-width: 600px; margin: 0 auto; }

.funnel-stage {
  margin-bottom: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.funnel-bar {
  background: var(--violet-brand);
  height: 48px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  color: var(--white);
  font-weight: 600;
  font-size: 13px;
  transition: width 0.5s ease;
}

.funnel-label { font-size: 12px; color: var(--text); margin-top: 4px; }
.funnel-arrow { color: var(--violet-border); font-size: 20px; margin: 2px 0; }

/* ── Login ── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--violet-deep);
}

.login-card {
  background: var(--white);
  border-radius: 12px;
  padding: 40px;
  width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-card .brand {
  text-align: center;
  margin-bottom: 28px;
}

.login-card .brand h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--violet-deep);
}

.login-card .brand p {
  font-size: 12px;
  color: var(--violet-brand);
  margin-top: 4px;
}

.login-card .gold-line {
  width: 40px;
  height: 3px;
  background: var(--gold);
  margin: 8px auto 0;
  border-radius: 2px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--violet-deep);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--violet-border);
  border-radius: 6px;
  font-size: 14px;
  color: var(--text);
  transition: border-color 0.15s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--violet-brand);
}

.login-error {
  background: #FDECEA;
  border: 1px solid var(--red);
  color: var(--red);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ── Form inline ── */
.form-card {
  background: var(--white);
  border: 1px solid var(--violet-border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.form-card h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--violet-deep);
  margin-bottom: 16px;
}

.form-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 150px;
}

.form-field label { font-size: 12px; font-weight: 600; color: var(--violet-deep); }

.form-field input,
.form-field select {
  padding: 8px 10px;
  border: 1px solid var(--violet-border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
}

/* ── Source badge ── */
.source-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: var(--violet-light);
  color: var(--violet-brand);
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }

  thead th:not(:first-child):not(:nth-child(2)):not(:nth-child(3)):not(:nth-child(8)):not(:nth-child(9)) {
    display: none;
  }
  tbody td:not(:first-child):not(:nth-child(2)):not(:nth-child(3)):not(:nth-child(8)):not(:nth-child(9)) {
    display: none;
  }
}
