:root {
  --bg: #f3f6fa;
  --panel: #ffffff;
  --ink: #17212b;
  --muted: #667085;
  --line: #dfe7ef;
  --brand: #0f6b55;
  --brand-dark: #0a3f34;
  --soft: #e8f6f1;
  --warn: #fff2df;
  --blue: #eef3ff;
  --shadow: 0 12px 32px rgba(15, 31, 46, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: var(--brand); font-weight: 700; text-decoration: none; }

button, input, select { font: inherit; }

.layout {
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, #0b3f34, #10251f);
  bottom: 0;
  color: white;
  display: flex;
  flex-direction: column;
  left: 0;
  padding: 22px 14px;
  position: fixed;
  top: 0;
  width: 260px;
  z-index: 10;
}

.brand {
  display: grid;
  gap: 4px;
  padding: 0 10px 26px;
}

.brand strong { font-size: 22px; letter-spacing: 0.02em; }
.brand span, .sidebar-foot { color: #b8d4cc; font-size: 13px; }

.side-nav {
  display: grid;
  gap: 8px;
}

.side-nav button {
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: #e9f4f1;
  cursor: pointer;
  font-weight: 750;
  padding: 12px 14px;
  text-align: left;
}

.side-nav button:hover,
.side-nav button.active {
  background: rgba(255, 255, 255, 0.13);
}

.sidebar-foot {
  display: grid;
  gap: 5px;
  margin-top: auto;
  padding: 0 10px;
}

.content {
  margin-left: 260px;
  max-width: 1540px;
  padding: 26px;
}

.topbar {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 22px;
}

.topbar h1 { font-size: 28px; margin: 0; }
.topbar p { color: var(--muted); margin: 4px 0 0; }

.burger {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  display: none;
  height: 42px;
  width: 44px;
}

.burger span {
  background: var(--ink);
  border-radius: 999px;
  display: block;
  height: 2px;
  margin: 4px auto;
  width: 19px;
}

.actions { display: flex; gap: 10px; }

.btn {
  align-items: center;
  background: var(--brand);
  border: 0;
  border-radius: 10px;
  color: white;
  cursor: pointer;
  display: inline-flex;
  font-weight: 750;
  padding: 10px 14px;
}

.btn.ghost {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
}

.btn:disabled { opacity: 0.45; cursor: default; }

.kpis {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  margin-bottom: 18px;
}

.kpi, .panel, .company-profile, .filters, .tender {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.kpi {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.kpi span { color: var(--muted); font-size: 13px; font-weight: 700; }
.kpi strong { font-size: 30px; letter-spacing: -0.03em; }

.dashboard-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(420px, 1.4fr) minmax(280px, 0.8fr);
}

.panel { overflow: hidden; }
.panel.wide { grid-column: 1 / -1; }
.panel > header {
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  padding: 13px 16px;
}
.panel h2 { font-size: 15px; margin: 0; }

.filters {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(170px, 1fr));
  margin-bottom: 16px;
  padding: 16px;
}

.filters label {
  display: grid;
  gap: 6px;
}

.filters label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

input, select {
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  min-height: 40px;
  padding: 9px 11px;
}

input:focus, select:focus {
  border-color: var(--brand);
  outline: 3px solid #cfe8df;
}

.bidder-search {
  grid-template-columns: minmax(320px, 1fr);
}

.results-bar {
  color: var(--muted);
  margin: 6px 2px 14px;
}

.tender-list {
  display: grid;
  gap: 12px;
}

.tender {
  overflow: hidden;
}

.tender summary {
  align-items: center;
  cursor: pointer;
  display: grid;
  gap: 14px;
  grid-template-columns: 115px 1fr 150px 120px 70px;
  list-style: none;
  padding: 14px 16px;
}

.tender summary::-webkit-details-marker { display: none; }
.tender summary:hover { background: #fbfcfe; }

.tender-title {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.tender-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tender-title small, td small {
  color: var(--muted);
  display: block;
  font-size: 12px;
}

.tender summary b {
  color: var(--brand);
  display: grid;
  font-size: 22px;
  line-height: 1;
  text-align: center;
}

.tender summary b small {
  color: var(--muted);
  font-size: 11px;
}

.tender-detail {
  background: #fcfdff;
  border-top: 1px solid var(--line);
}

.detail-meta {
  color: var(--muted);
  display: flex;
  gap: 18px;
  padding: 10px 16px;
}

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; min-width: 820px; width: 100%; }
th, td {
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}
th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sort-head {
  align-items: center;
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  gap: 7px;
  letter-spacing: inherit;
  padding: 0;
  text-align: left;
  text-transform: inherit;
  width: 100%;
}

.sort-head:hover,
.sort-head.active {
  color: var(--brand);
}

.sort-arrows {
  display: inline-grid;
  font-size: 8px;
  gap: 0;
  line-height: 0.9;
  opacity: 0.45;
}

.sort-arrows .on {
  color: var(--brand);
  opacity: 1;
}

.sort-head.active .sort-arrows {
  opacity: 1;
}

tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #f8fafc; }

.metric-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.metric-list li {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 11px 14px;
}
.metric-list li:last-child { border-bottom: 0; }
.metric-list span { font-size: 13px; }
.metric-list strong {
  background: var(--soft);
  border-radius: 999px;
  color: var(--brand-dark);
  min-width: 30px;
  padding: 3px 8px;
  text-align: center;
}

.badge {
  background: #eef2f7;
  border-radius: 999px;
  color: #475569;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  justify-content: center;
  padding: 5px 10px;
}
.badge-ouvert { background: var(--soft); color: var(--brand-dark); }
.badge-cloture, .badge-resultat-publie { background: var(--warn); color: #8a541d; }
.badge-delibere { background: var(--blue); color: #3446a3; }

.rank-one {
  background: var(--soft);
  border-radius: 7px;
  color: var(--brand-dark);
  display: inline-flex;
  font-weight: 900;
  justify-content: center;
  min-width: 24px;
  padding: 2px 7px;
}

.company-profile {
  margin-bottom: 16px;
  padding: 16px;
}
.profile-head {
  align-items: flex-start;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.profile-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.profile-head h2 { margin: 4px 0 0; }
.profile-head em {
  background: var(--soft);
  border-radius: 999px;
  color: var(--brand-dark);
  font-style: normal;
  font-weight: 800;
  padding: 6px 12px;
}
.profile-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 14px;
}
.profile-card {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  gap: 5px;
  padding: 13px;
}
.profile-card span, .profile-card small { color: var(--muted); font-size: 12px; font-weight: 800; }
.profile-card strong { font-size: 22px; }
.profile-columns {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(280px, 0.8fr) minmax(540px, 2fr);
}

.clamp {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.clamp.small { color: var(--muted); font-size: 12px; margin-top: 3px; }

.pagination {
  align-items: center;
  display: flex;
  gap: 14px;
  justify-content: center;
  margin: 18px 0;
}

.alert, .empty, .skeleton {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--muted);
  padding: 18px;
}
.alert { color: #9b1c1c; }

@media (max-width: 1100px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.18s ease; }
  .layout.menu-open .sidebar { transform: translateX(0); }
  .content { margin-left: 0; padding: 18px; }
  .burger { display: block; }
  .kpis, .dashboard-grid, .filters, .profile-grid, .profile-columns { grid-template-columns: 1fr; }
  .tender summary { grid-template-columns: 95px 1fr 55px; }
  .tender summary > span:nth-of-type(3),
  .tender summary > span:nth-of-type(4) { display: none; }
  .topbar { align-items: flex-start; }
}

/* ---- Pourcentages (Prédiction) ---- */
.pct {
  font-size: 14px;
  font-weight: 700;
}
.pct-part { color: #0f6b55; }
.pct-win { color: #c2710f; }
.justif {
  display: block;
  max-width: 360px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  white-space: normal;
}

/* ---- Certitude prédiction ---- */
.confidence {
  margin: 4px 0 14px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  background: var(--soft);
  border: 1px solid var(--line);
}
.confidence.conf-elevee { background: #e7f5ef; border-color: #b6e0d0; }
.confidence.conf-moyenne { background: #fff7e6; border-color: #f0dca8; }
.confidence.conf-faible, .confidence.conf-tres { background: #fdecec; border-color: #f3c2c2; }

/* ============ Écran de connexion ============ */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #0b3f34, #10251f);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 13px;
}
.login-brand { display: grid; gap: 2px; }
.login-brand strong { font-size: 22px; color: var(--brand); letter-spacing: 0.02em; }
.login-brand span { font-size: 13px; color: var(--muted); }
.login-card h1 { margin: 8px 0 0; font-size: 24px; }
.login-sub { margin: 0 0 6px; color: var(--muted); font-size: 14px; }
.login-card label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink); }
.login-card input[type="text"],
.login-card input[type="password"],
.login-card input:not([type]) {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 15px;
}
.login-card input:focus { outline: 2px solid var(--soft); border-color: var(--brand); }
.login-remember {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  color: var(--muted);
}
.login-remember input { width: auto; }
.login-btn { justify-content: center; padding: 12px; font-size: 15px; margin-top: 4px; }
.login-note { margin: 4px 0 0; font-size: 12px; color: var(--muted); text-align: center; }

/* ============ Responsive ============ */
.backdrop { display: none; }

@media (max-width: 1100px) {
  .backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(10, 20, 16, 0.45);
    z-index: 9;
  }
}

@media (max-width: 640px) {
  .content { padding: 14px; }
  .topbar { flex-wrap: wrap; }
  .topbar h1 { font-size: 20px; }
  .topbar p { display: none; }
  .actions { flex-wrap: wrap; }
  .actions .btn { flex: 1; justify-content: center; }
  .kpi strong { font-size: 24px; }
  .login-card { padding: 24px 18px; }
  .justif { max-width: 240px; }
}

.login-error {
  background: #fdecec;
  border: 1px solid #f3c2c2;
  color: #9b1c1c;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
}
