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

:root {
  --indigo: #4338ca;
  --indigo-dark: #3730a3;
  --amber: #b45309;
  --bg: #f1f5f9;
  --border: #d8dee9;
  --row-hover: #eef2ff;
  --text: #1f2933;
  --muted: #64748b;
  --green: #059669;
  --red: #dc2626;
}

body {
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
}

.hidden { display: none !important; }

/* ---------------- LOGIN ---------------- */
.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #4338ca 0%, #6d28d9 100%);
}
.login-box {
  background: #fff; padding: 34px 30px; border-radius: 14px;
  width: 320px; box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  text-align: center;
}
.login-box h1 { color: var(--indigo); font-size: 22px; }
.login-sub { color: var(--muted); margin-bottom: 20px; font-size: 12px; }
.login-box input {
  width: 100%; padding: 10px 12px; margin-bottom: 12px;
  border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
}
.login-box button {
  width: 100%; padding: 11px; background: var(--indigo); color: #fff;
  border: none; border-radius: 8px; font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.login-box button:hover { background: var(--indigo-dark); }
.login-error { color: var(--red); font-size: 12px; margin-top: 10px; min-height: 16px; }

/* ---------------- LAYOUT ---------------- */
.app { display: flex; height: 100vh; }

.sidebar {
  width: 230px; background: #1e293b; color: #cbd5e1;
  display: flex; flex-direction: column; overflow-y: auto; flex-shrink: 0;
}
.sidebar-title {
  font-size: 16px; font-weight: 700; color: #fff;
  padding: 16px 18px; border-bottom: 1px solid #334155;
}
.sidebar-group {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px;
  color: #64748b; padding: 14px 18px 6px;
}
.sidebar nav a {
  display: block; padding: 8px 18px; color: #cbd5e1;
  text-decoration: none; font-size: 12.5px; cursor: pointer;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: #334155; color: #fff; }
.sidebar nav a.active {
  background: #334155; color: #fff; border-left-color: var(--indigo);
}
.logout-btn {
  margin: auto 14px 16px; padding: 9px; background: #334155; color: #fff;
  border: none; border-radius: 8px; cursor: pointer; font-size: 12px;
}
.logout-btn:hover { background: #475569; }

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

.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; background: #fff; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.toolbar h2 { font-size: 15px; color: var(--indigo); }
.toolbar-actions { display: flex; align-items: center; gap: 10px; }
#search-box {
  padding: 7px 11px; border: 1px solid var(--border); border-radius: 7px;
  font-size: 12.5px; width: 240px;
}
#refresh-btn {
  padding: 7px 12px; background: var(--indigo); color: #fff; border: none;
  border-radius: 7px; cursor: pointer; font-size: 12px;
}
#refresh-btn:hover { background: var(--indigo-dark); }
.row-count { color: var(--muted); font-size: 12px; }

/* ---------------- TABLEAU ---------------- */
.table-wrap { flex: 1; overflow: auto; position: relative; }
table { border-collapse: collapse; width: 100%; background: #fff; }
thead th {
  position: sticky; top: 0; background: var(--indigo); color: #fff;
  text-align: left; padding: 9px 12px; font-size: 12px; font-weight: 600;
  cursor: pointer; user-select: none; white-space: nowrap;
}
thead th:hover { background: var(--indigo-dark); }
thead th .arrow { margin-left: 5px; opacity: 0.6; font-size: 10px; }
tbody td {
  padding: 7px 12px; border-bottom: 1px solid #eef1f5; font-size: 12.5px;
  white-space: nowrap; max-width: 340px; overflow: hidden; text-overflow: ellipsis;
}
tbody tr:nth-child(even) { background: #f8fafc; }
tbody tr:hover { background: var(--row-hover); }
tbody tr { cursor: context-menu; }

.status-ok { color: var(--green); font-weight: 600; }
.status-fail { color: var(--red); font-weight: 600; }
.mono { font-family: "SF Mono", Consolas, monospace; font-size: 11.5px; }

.empty-msg, .loading-msg {
  padding: 40px; text-align: center; color: var(--muted); font-size: 13px;
}

/* ---------------- MENU CONTEXTUEL ---------------- */
.context-menu {
  position: fixed; background: #fff; border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  z-index: 1000; min-width: 210px; overflow: hidden; padding: 4px 0;
}
.context-menu div {
  padding: 9px 14px; font-size: 12.5px; cursor: pointer;
}
.context-menu div:hover { background: var(--row-hover); color: var(--indigo); }
.context-menu .ctx-sep { height: 1px; background: var(--border); padding: 0; margin: 4px 0; cursor: default; }
.context-menu .ctx-danger:hover { background: #fef2f2; color: var(--red); }

/* ---------------- MODALE ---------------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.55);
  display: flex; align-items: center; justify-content: center; z-index: 2000;
}
.modal {
  background: #fff; border-radius: 12px; width: 440px; max-width: 92vw;
  max-height: 88vh; overflow: auto; box-shadow: 0 24px 60px rgba(0,0,0,0.3);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 15px 18px; border-bottom: 1px solid var(--border);
  font-size: 15px; font-weight: 600; color: var(--indigo);
}
#modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 18px; }
.modal-body label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.modal-body input, .modal-body select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: 7px; font-size: 13px;
}
.modal-body .modal-info {
  background: #eff6ff; border-left: 3px solid var(--indigo);
  padding: 8px 11px; border-radius: 6px; font-size: 12px; margin-bottom: 8px;
}
.modal-body .modal-warn {
  background: #fef2f2; border-left: 3px solid var(--red);
  padding: 8px 11px; border-radius: 6px; font-size: 12px;
  margin: 10px 0; color: #991b1b;
}
.modal-btn {
  width: 100%; margin-top: 16px; padding: 11px; border: none;
  border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer;
  color: #fff; background: var(--indigo);
}
.modal-btn:hover { background: var(--indigo-dark); }
.modal-btn.danger { background: var(--amber); }
.modal-btn.danger:hover { background: #92400e; }
.modal-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.modal-result { padding: 0 18px 18px; }
.modal-result .ok-box {
  background: #ecfdf5; border-left: 3px solid var(--green);
  padding: 10px 12px; border-radius: 6px; font-size: 12px; color: #065f46;
  word-break: break-all;
}
.modal-result .err-box {
  background: #fef2f2; border-left: 3px solid var(--red);
  padding: 10px 12px; border-radius: 6px; font-size: 12px; color: #991b1b;
  word-break: break-all;
}
