:root {
  --navy: #33435C;
  --coral: #FF8552;
  --aqua: #7FD6DB;
  --navy-soft: #41526e;
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #2a3445;
  --muted: #7b8494;
  --line: #e3e6ea;
  --ok: #2faa6a;
  --warn: #e8a13a;
  --error: #d6483b;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* --- Login ------------------------------------------------------------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  padding: 24px;
}
.login-card {
  background: var(--card);
  border-radius: 16px;
  padding: 40px 34px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.brand {
  font-size: 26px;
  font-weight: 800;
  color: var(--navy);
  letter-spacing: -.5px;
}
.brand .k { color: var(--coral); }
.login-card .brand { margin-bottom: 4px; }
.login-sub { color: var(--muted); font-size: 13px; margin-bottom: 26px; }

label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
input, textarea, select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--aqua);
  box-shadow: 0 0 0 3px rgba(127,214,219,.3);
}
.field { margin-bottom: 16px; }

button.primary {
  width: 100%;
  padding: 12px;
  background: var(--coral);
  color: #fff;
  border: none;
  border-radius: 9px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
button.primary:hover { background: #ef7642; }
button.primary:disabled { opacity: .55; cursor: default; }

.error-msg {
  color: var(--error);
  font-size: 13px;
  margin-top: 12px;
  min-height: 16px;
}

/* --- App shell --------------------------------------------------------- */
.topbar {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
}
.topbar .brand { color: #fff; font-size: 19px; }
.topbar .brand .k { color: var(--coral); }
.topbar .user { font-size: 13px; color: #c9cfda; display: flex; gap: 12px; align-items: center; }
.topbar .user a { color: var(--aqua); cursor: pointer; text-decoration: none; }

.alerts { padding: 0 20px; }
.alert {
  margin-top: 10px;
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}
.alert.error { background: #fbe5e3; color: var(--error); }
.alert.warn  { background: #fdf2dd; color: #9a6a17; }
.alert.ok    { background: #e3f4ea; color: var(--ok); }

.tabs {
  display: flex;
  gap: 4px;
  padding: 14px 20px 0;
  overflow-x: auto;
}
.tab {
  padding: 9px 16px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.tab.active { color: var(--navy); border-bottom-color: var(--coral); }

.content { padding: 20px; max-width: 1000px; margin: 0 auto; }
.page { display: none; }
.page.active { display: block; }

h2.section { font-size: 17px; color: var(--navy); margin-bottom: 4px; }
p.hint { color: var(--muted); font-size: 13px; margin-bottom: 16px; }

/* --- Cards / agents ---------------------------------------------------- */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}
.card h3 { font-size: 15px; color: var(--navy); margin-bottom: 6px; }
.card .cat {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--coral);
  margin-bottom: 8px;
}
.card p { font-size: 13px; color: var(--muted); line-height: 1.5; margin-bottom: 12px; }
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
}
.badge.actif { background: #e3f4ea; color: var(--ok); }
.badge.a-cabler { background: #fdf2dd; color: #9a6a17; }
.badge.info { background: #eef0f3; color: var(--muted); }

button.action {
  padding: 9px 14px;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
button.action:hover { background: var(--navy-soft); }
button.action:disabled { background: #c4c9d1; cursor: default; }
button.ghost {
  background: none;
  border: 1px solid var(--line);
  color: var(--navy);
}

/* --- Tables / monitoring ---------------------------------------------- */
table { width: 100%; border-collapse: collapse; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
th, td { text-align: left; padding: 10px 14px; font-size: 13px; }
th { background: #eef0f3; color: var(--navy); font-weight: 700; }
tr + tr td { border-top: 1px solid var(--line); }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.dot.up { background: var(--ok); }
.dot.down { background: var(--error); }

.metric-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.metric {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 18px; flex: 1; min-width: 150px;
}
.metric .label { font-size: 12px; color: var(--muted); font-weight: 600; }
.metric .value { font-size: 22px; font-weight: 800; color: var(--navy); margin-top: 4px; }
.bar { height: 6px; background: var(--line); border-radius: 4px; margin-top: 8px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--aqua); }
.bar > span.hot { background: var(--coral); }
.bar > span.crit { background: var(--error); }

.links { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); }
.links a {
  display: block; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 14px; text-decoration: none; color: var(--navy);
  font-weight: 600; font-size: 14px;
}
.links a:hover { border-color: var(--aqua); }
.links a span { display: block; font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 3px; }

/* --- Modal ------------------------------------------------------------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(20,26,38,.55);
  display: none; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal-bg.open { display: flex; }
.modal {
  background: var(--card); border-radius: 14px; padding: 24px;
  width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto;
}
.modal h3 { color: var(--navy); margin-bottom: 4px; }
.modal .desc { font-size: 13px; color: var(--muted); margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions button { flex: 1; }
.drop {
  border: 2px dashed var(--line); border-radius: 10px; padding: 22px;
  text-align: center; color: var(--muted); font-size: 13px; cursor: pointer;
}
.drop.over { border-color: var(--aqua); background: #f0fbfc; }
.result-box {
  margin-top: 14px; padding: 12px; border-radius: 8px; font-size: 13px;
  white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow-y: auto;
}
.result-box.ok { background: #e3f4ea; color: #1e6b42; }
.result-box.ko { background: #fbe5e3; color: var(--error); }

.muted-block { color: var(--muted); font-size: 13px; padding: 20px; text-align: center; }
